mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-18 12:42:37 -05:00
Allow contents of unknown tags in.
Clean functions were removing contents of any unknown tag. This was, it turned out, a bit too strict.
This commit is contained in:
parent
143eea15cb
commit
3068c496c9
1 changed files with 36 additions and 13 deletions
|
@ -641,6 +641,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( mutates ) {
|
if ( mutates ) {
|
||||||
|
setSelection( range );
|
||||||
|
|
||||||
// Path may have changed
|
// Path may have changed
|
||||||
updatePath( 0, true );
|
updatePath( 0, true );
|
||||||
|
|
||||||
|
@ -898,6 +900,15 @@
|
||||||
parent.replaceChild( el, node );
|
parent.replaceChild( el, node );
|
||||||
el.appendChild( node.empty() );
|
el.appendChild( node.empty() );
|
||||||
return el;
|
return el;
|
||||||
|
},
|
||||||
|
TT: function ( node, parent ) {
|
||||||
|
var el = createElement( 'SPAN', {
|
||||||
|
'class': 'font',
|
||||||
|
style: 'font-family:menlo,consolas,"courier new",monospace'
|
||||||
|
});
|
||||||
|
parent.replaceChild( el, node );
|
||||||
|
el.appendChild( node.empty() );
|
||||||
|
return el;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -910,29 +921,36 @@
|
||||||
*/
|
*/
|
||||||
var cleanTree = function ( node, allowStyles ) {
|
var cleanTree = function ( node, allowStyles ) {
|
||||||
var children = node.childNodes,
|
var children = node.childNodes,
|
||||||
i, l, child, nodeName, nodeType, rewriter, parent;
|
i, l, child, nodeName, nodeType, rewriter, childLength;
|
||||||
for ( i = 0, l = children.length; i < l; i += 1 ) {
|
for ( i = 0, l = children.length; i < l; i += 1 ) {
|
||||||
child = children[i];
|
child = children[i];
|
||||||
nodeName = child.nodeName;
|
nodeName = child.nodeName;
|
||||||
nodeType = child.nodeType;
|
nodeType = child.nodeType;
|
||||||
rewriter = stylesRewriters[ nodeName ];
|
rewriter = stylesRewriters[ nodeName ];
|
||||||
|
if ( nodeType === ELEMENT_NODE ) {
|
||||||
|
childLength = child.childNodes.length;
|
||||||
if ( rewriter ) {
|
if ( rewriter ) {
|
||||||
child = rewriter( child, node );
|
child = rewriter( child, node );
|
||||||
} else if (
|
} else if ( !allowedBlock.test( nodeName ) &&
|
||||||
( !allowedBlock.test( nodeName ) && !child.isInline() ) ||
|
!child.isInline() ) {
|
||||||
( nodeType === TEXT_NODE && !( /\S/.test( child.data ) ) ) ) {
|
|
||||||
node.removeChild( child );
|
|
||||||
i -= 1;
|
i -= 1;
|
||||||
l -= 1;
|
l += childLength - 1;
|
||||||
|
node.replaceChild( child.empty(), child );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( nodeType === ELEMENT_NODE ) {
|
|
||||||
if ( !allowStyles && child.style.cssText ) {
|
if ( !allowStyles && child.style.cssText ) {
|
||||||
child.removeAttribute( 'style' );
|
child.removeAttribute( 'style' );
|
||||||
}
|
}
|
||||||
if ( child.childNodes.length ) {
|
if ( childLength ) {
|
||||||
cleanTree( child, allowStyles );
|
cleanTree( child, allowStyles );
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if ( ( nodeType !== TEXT_NODE ) ||
|
||||||
|
!( /\S/.test( child.data ) ) ) {
|
||||||
|
node.removeChild( child );
|
||||||
|
i -= 1;
|
||||||
|
l -= 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return node;
|
return node;
|
||||||
|
@ -1575,4 +1593,9 @@
|
||||||
body.setAttribute( 'contenteditable', 'true' );
|
body.setAttribute( 'contenteditable', 'true' );
|
||||||
win.editor.setHTML( '' );
|
win.editor.setHTML( '' );
|
||||||
|
|
||||||
|
if ( win.onEditorLoad ) {
|
||||||
|
win.onEditorLoad( win.editor );
|
||||||
|
delete win.onEditorLoad;
|
||||||
|
}
|
||||||
|
|
||||||
}( document ) );
|
}( document ) );
|
Loading…
Add table
Reference in a new issue