0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Update to latest release

This commit is contained in:
Neil Jenkins 2016-11-02 15:33:44 +11:00
parent bfbec71507
commit 5d0731836c
2 changed files with 19 additions and 10 deletions

View file

@ -1770,7 +1770,7 @@ var styleToSemantic = {
} }
}, },
fontWeight: { fontWeight: {
regexp: /^bold/i, regexp: /^bold|^700/i,
replace: function ( doc ) { replace: function ( doc ) {
return createElement( doc, 'B' ); return createElement( doc, 'B' );
} }
@ -1918,7 +1918,7 @@ var stylesRewriters = {
} }
}; };
var allowedBlock = /^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|UL)$/; var allowedBlock = /^(?:A(?:DDRESS|RTICLE|SIDE|UDIO)|BLOCKQUOTE|CAPTION|D(?:[DLT]|IV)|F(?:IGURE|IGCAPTION|OOTER)|H[1-6]|HEADER|L(?:ABEL|EGEND|I)|O(?:L|UTPUT)|P(?:RE)?|SECTION|T(?:ABLE|BODY|D|FOOT|H|HEAD|R)|COL(?:GROUP)?|UL)$/;
var blacklist = /^(?:HEAD|META|STYLE)/; var blacklist = /^(?:HEAD|META|STYLE)/;
@ -2096,6 +2096,19 @@ var cleanupBRs = function ( node, root ) {
} }
}; };
// The (non-standard but supported enough) innerText property is based on the
// render tree in Firefox and possibly other browsers, so we must insert the
// DOM node into the document to ensure the text part is correct.
var setClipboardData = function ( clipboardData, node ) {
var body = node.ownerDocument.body;
node.setAttribute( 'style',
'position:fixed;overflow:hidden;bottom:100%;right:100%;' );
body.appendChild( node );
clipboardData.setData( 'text/html', node.innerHTML );
clipboardData.setData( 'text/plain', node.innerText || node.textContent );
body.removeChild( node );
};
var onCut = function ( event ) { var onCut = function ( event ) {
var clipboardData = event.clipboardData; var clipboardData = event.clipboardData;
var range = this.getSelection(); var range = this.getSelection();
@ -2112,9 +2125,7 @@ var onCut = function ( event ) {
if ( !isEdge && !isIOS && clipboardData ) { if ( !isEdge && !isIOS && clipboardData ) {
moveRangeBoundariesUpTree( range, root ); moveRangeBoundariesUpTree( range, root );
node.appendChild( deleteContentsOfRange( range, root ) ); node.appendChild( deleteContentsOfRange( range, root ) );
clipboardData.setData( 'text/html', node.innerHTML ); setClipboardData( clipboardData, node );
clipboardData.setData( 'text/plain',
node.innerText || node.textContent );
event.preventDefault(); event.preventDefault();
} else { } else {
setTimeout( function () { setTimeout( function () {
@ -2160,9 +2171,7 @@ var onCopy = function ( event ) {
} }
node.appendChild( contents ); node.appendChild( contents );
clipboardData.setData( 'text/html', node.innerHTML ); setClipboardData( clipboardData, node );
clipboardData.setData( 'text/plain',
node.innerText || node.textContent );
event.preventDefault(); event.preventDefault();
} }
}; };

File diff suppressed because one or more lines are too long