mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Don't try to rewrite style of <p>
This was the only block-level element being rewritten, and could result in some strange effects. For example, when you move a background colour from the <p> to a <span>, it renders very differently. It was already inconsistent to do this for <p> but not for <div>, and better just to drop it.
This commit is contained in:
parent
af93577405
commit
f8a5b1ee19
3 changed files with 10 additions and 9 deletions
|
@ -390,7 +390,7 @@ function createElement ( doc, tag, props, children ) {
|
||||||
for ( attr in props ) {
|
for ( attr in props ) {
|
||||||
value = props[ attr ];
|
value = props[ attr ];
|
||||||
if ( value !== undefined ) {
|
if ( value !== undefined ) {
|
||||||
el.setAttribute( attr, props[ attr ] );
|
el.setAttribute( attr, value );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -500,16 +500,14 @@ function fixContainer ( container, root ) {
|
||||||
isBR = child.nodeName === 'BR';
|
isBR = child.nodeName === 'BR';
|
||||||
if ( !isBR && isInline( child ) ) {
|
if ( !isBR && isInline( child ) ) {
|
||||||
if ( !wrapper ) {
|
if ( !wrapper ) {
|
||||||
wrapper = createElement( doc,
|
wrapper = createElement( doc, 'div' );
|
||||||
config.blockTag, config.blockAttributes );
|
|
||||||
}
|
}
|
||||||
wrapper.appendChild( child );
|
wrapper.appendChild( child );
|
||||||
i -= 1;
|
i -= 1;
|
||||||
l -= 1;
|
l -= 1;
|
||||||
} else if ( isBR || wrapper ) {
|
} else if ( isBR || wrapper ) {
|
||||||
if ( !wrapper ) {
|
if ( !wrapper ) {
|
||||||
wrapper = createElement( doc,
|
wrapper = createElement( doc, 'div' );
|
||||||
config.blockTag, config.blockAttributes );
|
|
||||||
}
|
}
|
||||||
fixCursor( wrapper, root );
|
fixCursor( wrapper, root );
|
||||||
if ( isBR ) {
|
if ( isBR ) {
|
||||||
|
@ -1941,6 +1939,12 @@ var styleToSemantic = {
|
||||||
var replaceWithTag = function ( tag ) {
|
var replaceWithTag = function ( tag ) {
|
||||||
return function ( node, parent ) {
|
return function ( node, parent ) {
|
||||||
var el = createElement( node.ownerDocument, tag );
|
var el = createElement( node.ownerDocument, tag );
|
||||||
|
var attributes = node.attributes;
|
||||||
|
var i, l, attribute;
|
||||||
|
for ( i = 0, l = attributes.length; i < l; i += 1 ) {
|
||||||
|
attribute = attributes[i];
|
||||||
|
el.setAttribute( attribute.name, attribute.value );
|
||||||
|
}
|
||||||
parent.replaceChild( el, node );
|
parent.replaceChild( el, node );
|
||||||
el.appendChild( empty( node ) );
|
el.appendChild( empty( node ) );
|
||||||
return el;
|
return el;
|
||||||
|
@ -1981,7 +1985,6 @@ var replaceStyles = function ( node, parent, config ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var stylesRewriters = {
|
var stylesRewriters = {
|
||||||
P: replaceStyles,
|
|
||||||
SPAN: replaceStyles,
|
SPAN: replaceStyles,
|
||||||
STRONG: replaceWithTag( 'B' ),
|
STRONG: replaceWithTag( 'B' ),
|
||||||
EM: replaceWithTag( 'I' ),
|
EM: replaceWithTag( 'I' ),
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -116,7 +116,6 @@ var replaceStyles = function ( node, parent, config ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var stylesRewriters = {
|
var stylesRewriters = {
|
||||||
P: replaceStyles,
|
|
||||||
SPAN: replaceStyles,
|
SPAN: replaceStyles,
|
||||||
STRONG: replaceWithTag( 'B' ),
|
STRONG: replaceWithTag( 'B' ),
|
||||||
EM: replaceWithTag( 'I' ),
|
EM: replaceWithTag( 'I' ),
|
||||||
|
|
Loading…
Reference in a new issue