mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Rewrite <s> to <strike> in cleanTree fn.
This commit is contained in:
parent
db82ba1217
commit
a875d20f12
3 changed files with 56 additions and 33 deletions
|
@ -1058,7 +1058,7 @@ var expandRangeToBlockBoundaries = function ( range ) {
|
||||||
isIOS,
|
isIOS,
|
||||||
isMac,
|
isMac,
|
||||||
isGecko,
|
isGecko,
|
||||||
isIE,
|
isIE8or9or10,
|
||||||
isIE8,
|
isIE8,
|
||||||
isOpera,
|
isOpera,
|
||||||
ctrlKey,
|
ctrlKey,
|
||||||
|
@ -1106,7 +1106,6 @@ var expandRangeToBlockBoundaries = function ( range ) {
|
||||||
rangeDoesEndAtBlockBoundary,
|
rangeDoesEndAtBlockBoundary,
|
||||||
expandRangeToBlockBoundaries,
|
expandRangeToBlockBoundaries,
|
||||||
|
|
||||||
Range,
|
|
||||||
top,
|
top,
|
||||||
console,
|
console,
|
||||||
setTimeout
|
setTimeout
|
||||||
|
@ -2210,6 +2209,15 @@ var spanToSemantic = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var replaceWithTag = function ( tag ) {
|
||||||
|
return function ( node, parent ) {
|
||||||
|
var el = createElement( node.ownerDocument, tag );
|
||||||
|
parent.replaceChild( el, node );
|
||||||
|
el.appendChild( empty( node ) );
|
||||||
|
return el;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var stylesRewriters = {
|
var stylesRewriters = {
|
||||||
SPAN: function ( span, parent ) {
|
SPAN: function ( span, parent ) {
|
||||||
var style = span.style,
|
var style = span.style,
|
||||||
|
@ -2238,41 +2246,56 @@ var stylesRewriters = {
|
||||||
|
|
||||||
return newTreeBottom || span;
|
return newTreeBottom || span;
|
||||||
},
|
},
|
||||||
STRONG: function ( node, parent ) {
|
STRONG: replaceWithTag( 'B' ),
|
||||||
var el = createElement( node.ownerDocument, 'B' );
|
EM: replaceWithTag( 'I' ),
|
||||||
parent.replaceChild( el, node );
|
S: replaceWithTag( 'STRIKE' ),
|
||||||
el.appendChild( empty( node ) );
|
|
||||||
return el;
|
|
||||||
},
|
|
||||||
EM: function ( node, parent ) {
|
|
||||||
var el = createElement( node.ownerDocument, 'I' );
|
|
||||||
parent.replaceChild( el, node );
|
|
||||||
el.appendChild( empty( node ) );
|
|
||||||
return el;
|
|
||||||
},
|
|
||||||
FONT: function ( node, parent ) {
|
FONT: function ( node, parent ) {
|
||||||
var face = node.face,
|
var face = node.face,
|
||||||
size = node.size,
|
size = node.size,
|
||||||
|
colour = node.color,
|
||||||
doc = node.ownerDocument,
|
doc = node.ownerDocument,
|
||||||
fontSpan, sizeSpan,
|
fontSpan, sizeSpan, colourSpan,
|
||||||
newTreeBottom, newTreeTop;
|
newTreeBottom, newTreeTop;
|
||||||
if ( face ) {
|
if ( face ) {
|
||||||
fontSpan = createElement( doc, 'SPAN', {
|
fontSpan = createElement( doc, 'SPAN', {
|
||||||
'class': 'font',
|
'class': 'font',
|
||||||
style: 'font-family:' + face
|
style: 'font-family:' + face
|
||||||
});
|
});
|
||||||
|
newTreeTop = fontSpan;
|
||||||
|
newTreeBottom = fontSpan;
|
||||||
}
|
}
|
||||||
if ( size ) {
|
if ( size ) {
|
||||||
sizeSpan = createElement( doc, 'SPAN', {
|
sizeSpan = createElement( doc, 'SPAN', {
|
||||||
'class': 'size',
|
'class': 'size',
|
||||||
style: 'font-size:' + fontSizes[ size ] + 'px'
|
style: 'font-size:' + fontSizes[ size ] + 'px'
|
||||||
});
|
});
|
||||||
if ( fontSpan ) {
|
if ( !newTreeTop ) {
|
||||||
fontSpan.appendChild( sizeSpan );
|
newTreeTop = sizeSpan;
|
||||||
}
|
}
|
||||||
|
if ( newTreeBottom ) {
|
||||||
|
newTreeBottom.appendChild( sizeSpan );
|
||||||
|
}
|
||||||
|
newTreeBottom = sizeSpan;
|
||||||
|
}
|
||||||
|
if ( colour && /^#?([\dA-F]{3}){1,2}$/i.test( colour ) ) {
|
||||||
|
if ( colour.charAt( 0 ) !== '#' ) {
|
||||||
|
colour = '#' + colour;
|
||||||
|
}
|
||||||
|
colourSpan = createElement( doc, 'SPAN', {
|
||||||
|
'class': 'colour',
|
||||||
|
style: 'color:' + colour
|
||||||
|
});
|
||||||
|
if ( !newTreeTop ) {
|
||||||
|
newTreeTop = colourSpan;
|
||||||
|
}
|
||||||
|
if ( newTreeBottom ) {
|
||||||
|
newTreeBottom.appendChild( colourSpan );
|
||||||
|
}
|
||||||
|
newTreeBottom = colourSpan;
|
||||||
|
}
|
||||||
|
if ( !newTreeTop ) {
|
||||||
|
newTreeTop = newTreeBottom = createElement( doc, 'SPAN' );
|
||||||
}
|
}
|
||||||
newTreeTop = fontSpan || sizeSpan || createElement( doc, 'SPAN' );
|
|
||||||
newTreeBottom = sizeSpan || fontSpan || newTreeTop;
|
|
||||||
parent.replaceChild( newTreeTop, node );
|
parent.replaceChild( newTreeTop, node );
|
||||||
newTreeBottom.appendChild( empty( node ) );
|
newTreeBottom.appendChild( empty( node ) );
|
||||||
return newTreeBottom;
|
return newTreeBottom;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1161,6 +1161,15 @@ var spanToSemantic = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var replaceWithTag = function ( tag ) {
|
||||||
|
return function ( node, parent ) {
|
||||||
|
var el = createElement( node.ownerDocument, tag );
|
||||||
|
parent.replaceChild( el, node );
|
||||||
|
el.appendChild( empty( node ) );
|
||||||
|
return el;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
var stylesRewriters = {
|
var stylesRewriters = {
|
||||||
SPAN: function ( span, parent ) {
|
SPAN: function ( span, parent ) {
|
||||||
var style = span.style,
|
var style = span.style,
|
||||||
|
@ -1189,18 +1198,9 @@ var stylesRewriters = {
|
||||||
|
|
||||||
return newTreeBottom || span;
|
return newTreeBottom || span;
|
||||||
},
|
},
|
||||||
STRONG: function ( node, parent ) {
|
STRONG: replaceWithTag( 'B' ),
|
||||||
var el = createElement( node.ownerDocument, 'B' );
|
EM: replaceWithTag( 'I' ),
|
||||||
parent.replaceChild( el, node );
|
S: replaceWithTag( 'STRIKE' ),
|
||||||
el.appendChild( empty( node ) );
|
|
||||||
return el;
|
|
||||||
},
|
|
||||||
EM: function ( node, parent ) {
|
|
||||||
var el = createElement( node.ownerDocument, 'I' );
|
|
||||||
parent.replaceChild( el, node );
|
|
||||||
el.appendChild( empty( node ) );
|
|
||||||
return el;
|
|
||||||
},
|
|
||||||
FONT: function ( node, parent ) {
|
FONT: function ( node, parent ) {
|
||||||
var face = node.face,
|
var face = node.face,
|
||||||
size = node.size,
|
size = node.size,
|
||||||
|
|
Loading…
Reference in a new issue