mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
parent
7291fe0000
commit
aae328e226
3 changed files with 40 additions and 4 deletions
|
@ -2117,12 +2117,30 @@ var onCopy = function ( event ) {
|
||||||
var clipboardData = event.clipboardData;
|
var clipboardData = event.clipboardData;
|
||||||
var range = this.getSelection();
|
var range = this.getSelection();
|
||||||
var node = this.createElement( 'div' );
|
var node = this.createElement( 'div' );
|
||||||
|
var root = this._root;
|
||||||
|
var contents, parent, newContents;
|
||||||
|
|
||||||
// Edge only seems to support setting plain text as of 2016-03-11.
|
// Edge only seems to support setting plain text as of 2016-03-11.
|
||||||
// Mobile Safari flat out doesn't work:
|
// Mobile Safari flat out doesn't work:
|
||||||
// https://bugs.webkit.org/show_bug.cgi?id=143776
|
// https://bugs.webkit.org/show_bug.cgi?id=143776
|
||||||
if ( !isEdge && !isIOS && clipboardData ) {
|
if ( !isEdge && !isIOS && clipboardData ) {
|
||||||
node.appendChild( range.cloneContents() );
|
range = range.cloneRange();
|
||||||
|
if ( getStartBlockOfRange( range, root ) ===
|
||||||
|
getEndBlockOfRange( range, root ) ) {
|
||||||
|
moveRangeBoundariesDownTree( range );
|
||||||
|
contents = range.cloneContents();
|
||||||
|
} else {
|
||||||
|
moveRangeBoundariesUpTree( range, root );
|
||||||
|
contents = range.cloneContents();
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
|
while ( parent && parent !== root ) {
|
||||||
|
newContents = parent.cloneNode( false );
|
||||||
|
newContents.appendChild( contents );
|
||||||
|
contents = newContents;
|
||||||
|
parent = parent.parentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.appendChild( contents );
|
||||||
clipboardData.setData( 'text/html', node.innerHTML );
|
clipboardData.setData( 'text/html', node.innerHTML );
|
||||||
clipboardData.setData( 'text/plain',
|
clipboardData.setData( 'text/plain',
|
||||||
node.innerText || node.textContent );
|
node.innerText || node.textContent );
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -38,12 +38,30 @@ var onCopy = function ( event ) {
|
||||||
var clipboardData = event.clipboardData;
|
var clipboardData = event.clipboardData;
|
||||||
var range = this.getSelection();
|
var range = this.getSelection();
|
||||||
var node = this.createElement( 'div' );
|
var node = this.createElement( 'div' );
|
||||||
|
var root = this._root;
|
||||||
|
var contents, parent, newContents;
|
||||||
|
|
||||||
// Edge only seems to support setting plain text as of 2016-03-11.
|
// Edge only seems to support setting plain text as of 2016-03-11.
|
||||||
// Mobile Safari flat out doesn't work:
|
// Mobile Safari flat out doesn't work:
|
||||||
// https://bugs.webkit.org/show_bug.cgi?id=143776
|
// https://bugs.webkit.org/show_bug.cgi?id=143776
|
||||||
if ( !isEdge && !isIOS && clipboardData ) {
|
if ( !isEdge && !isIOS && clipboardData ) {
|
||||||
node.appendChild( range.cloneContents() );
|
range = range.cloneRange();
|
||||||
|
if ( getStartBlockOfRange( range, root ) ===
|
||||||
|
getEndBlockOfRange( range, root ) ) {
|
||||||
|
moveRangeBoundariesDownTree( range );
|
||||||
|
contents = range.cloneContents();
|
||||||
|
} else {
|
||||||
|
moveRangeBoundariesUpTree( range, root );
|
||||||
|
contents = range.cloneContents();
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
|
while ( parent && parent !== root ) {
|
||||||
|
newContents = parent.cloneNode( false );
|
||||||
|
newContents.appendChild( contents );
|
||||||
|
contents = newContents;
|
||||||
|
parent = parent.parentNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node.appendChild( contents );
|
||||||
clipboardData.setData( 'text/html', node.innerHTML );
|
clipboardData.setData( 'text/html', node.innerHTML );
|
||||||
clipboardData.setData( 'text/plain',
|
clipboardData.setData( 'text/plain',
|
||||||
node.innerText || node.textContent );
|
node.innerText || node.textContent );
|
||||||
|
|
Loading…
Reference in a new issue