mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -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,9 +641,11 @@
|
|||
}
|
||||
|
||||
if ( mutates ) {
|
||||
setSelection( range );
|
||||
|
||||
// Path may have changed
|
||||
updatePath( 0, true );
|
||||
|
||||
|
||||
// We're not still in an undo state
|
||||
docWasChanged();
|
||||
}
|
||||
|
@ -898,6 +900,15 @@
|
|||
parent.replaceChild( el, node );
|
||||
el.appendChild( node.empty() );
|
||||
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 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 ) {
|
||||
child = children[i];
|
||||
nodeName = child.nodeName;
|
||||
nodeType = child.nodeType;
|
||||
rewriter = stylesRewriters[ nodeName ];
|
||||
if ( rewriter ) {
|
||||
child = rewriter( child, node );
|
||||
} else if (
|
||||
( !allowedBlock.test( nodeName ) && !child.isInline() ) ||
|
||||
( nodeType === TEXT_NODE && !( /\S/.test( child.data ) ) ) ) {
|
||||
node.removeChild( child );
|
||||
i -= 1;
|
||||
l -= 1;
|
||||
continue;
|
||||
}
|
||||
if ( nodeType === ELEMENT_NODE ) {
|
||||
childLength = child.childNodes.length;
|
||||
if ( rewriter ) {
|
||||
child = rewriter( child, node );
|
||||
} else if ( !allowedBlock.test( nodeName ) &&
|
||||
!child.isInline() ) {
|
||||
i -= 1;
|
||||
l += childLength - 1;
|
||||
node.replaceChild( child.empty(), child );
|
||||
continue;
|
||||
}
|
||||
if ( !allowStyles && child.style.cssText ) {
|
||||
child.removeAttribute( 'style' );
|
||||
}
|
||||
if ( child.childNodes.length ) {
|
||||
if ( childLength ) {
|
||||
cleanTree( child, allowStyles );
|
||||
}
|
||||
} else {
|
||||
if ( ( nodeType !== TEXT_NODE ) ||
|
||||
!( /\S/.test( child.data ) ) ) {
|
||||
node.removeChild( child );
|
||||
i -= 1;
|
||||
l -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
@ -1575,4 +1593,9 @@
|
|||
body.setAttribute( 'contenteditable', 'true' );
|
||||
win.editor.setHTML( '' );
|
||||
|
||||
if ( win.onEditorLoad ) {
|
||||
win.onEditorLoad( win.editor );
|
||||
delete win.onEditorLoad;
|
||||
}
|
||||
|
||||
}( document ) );
|
Loading…
Reference in a new issue