mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Always run html through willCutCopy fn
The plain text may be calculated from the HTML, so we should convert the HTML first, then convert it to text.
This commit is contained in:
parent
d5b320bd7d
commit
a91c3f3042
3 changed files with 16 additions and 16 deletions
|
@ -2237,22 +2237,22 @@ var setClipboardData =
|
||||||
// calculating innerText, even though they don't actually affect display.
|
// calculating innerText, even though they don't actually affect display.
|
||||||
// So we need to remove them first.
|
// So we need to remove them first.
|
||||||
cleanupBRs( node, root, true );
|
cleanupBRs( node, root, true );
|
||||||
node.setAttribute( 'style',
|
|
||||||
'position:fixed;overflow:hidden;bottom:100%;right:100%;' );
|
html = node.innerHTML;
|
||||||
html = plainTextOnly ? '' : node.innerHTML;
|
if ( willCutCopy ) {
|
||||||
|
html = willCutCopy( html );
|
||||||
|
}
|
||||||
|
|
||||||
if ( toPlainText ) {
|
if ( toPlainText ) {
|
||||||
text = toPlainText( html );
|
text = toPlainText( html );
|
||||||
} else {
|
} else {
|
||||||
|
node.setAttribute( 'style',
|
||||||
|
'position:fixed;overflow:hidden;bottom:100%;right:100%;' );
|
||||||
body.appendChild( node );
|
body.appendChild( node );
|
||||||
text = node.innerText || node.textContent;
|
text = node.innerText || node.textContent;
|
||||||
text = text.replace( / /g, ' ' ); // Replace nbsp with regular space
|
text = text.replace( / /g, ' ' ); // Replace nbsp with regular space
|
||||||
body.removeChild( node );
|
body.removeChild( node );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !plainTextOnly && willCutCopy ) {
|
|
||||||
html = willCutCopy( html );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Firefox (and others?) returns unix line endings (\n) even on Windows.
|
// Firefox (and others?) returns unix line endings (\n) even on Windows.
|
||||||
// If on Windows, normalise to \r\n, since Notepad and some other crappy
|
// If on Windows, normalise to \r\n, since Notepad and some other crappy
|
||||||
// apps do not understand just \n.
|
// apps do not understand just \n.
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -16,22 +16,22 @@ var setClipboardData =
|
||||||
// calculating innerText, even though they don't actually affect display.
|
// calculating innerText, even though they don't actually affect display.
|
||||||
// So we need to remove them first.
|
// So we need to remove them first.
|
||||||
cleanupBRs( node, root, true );
|
cleanupBRs( node, root, true );
|
||||||
node.setAttribute( 'style',
|
|
||||||
'position:fixed;overflow:hidden;bottom:100%;right:100%;' );
|
|
||||||
html = node.innerHTML;
|
html = node.innerHTML;
|
||||||
|
if ( willCutCopy ) {
|
||||||
|
html = willCutCopy( html );
|
||||||
|
}
|
||||||
|
|
||||||
if ( toPlainText ) {
|
if ( toPlainText ) {
|
||||||
text = toPlainText( html );
|
text = toPlainText( html );
|
||||||
} else {
|
} else {
|
||||||
|
node.setAttribute( 'style',
|
||||||
|
'position:fixed;overflow:hidden;bottom:100%;right:100%;' );
|
||||||
body.appendChild( node );
|
body.appendChild( node );
|
||||||
text = node.innerText || node.textContent;
|
text = node.innerText || node.textContent;
|
||||||
text = text.replace( / /g, ' ' ); // Replace nbsp with regular space
|
text = text.replace( / /g, ' ' ); // Replace nbsp with regular space
|
||||||
body.removeChild( node );
|
body.removeChild( node );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !plainTextOnly && willCutCopy ) {
|
|
||||||
html = willCutCopy( html );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Firefox (and others?) returns unix line endings (\n) even on Windows.
|
// Firefox (and others?) returns unix line endings (\n) even on Windows.
|
||||||
// If on Windows, normalise to \r\n, since Notepad and some other crappy
|
// If on Windows, normalise to \r\n, since Notepad and some other crappy
|
||||||
// apps do not understand just \n.
|
// apps do not understand just \n.
|
||||||
|
|
Loading…
Reference in a new issue