0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Always preserve inline formatting on copy

Fixes #219.
This commit is contained in:
Neil Jenkins 2016-09-04 20:44:36 -04:00
parent 25ff83455e
commit cbde7a9198
3 changed files with 11 additions and 7 deletions

View file

@ -2118,16 +2118,18 @@ var onCopy = function ( event ) {
var range = this.getSelection();
var node = this.createElement( 'div' );
var root = this._root;
var contents, parent, newContents;
var startBlock, contents, parent, newContents;
// Edge only seems to support setting plain text as of 2016-03-11.
// Mobile Safari flat out doesn't work:
// https://bugs.webkit.org/show_bug.cgi?id=143776
if ( !isEdge && !isIOS && clipboardData ) {
range = range.cloneRange();
if ( getStartBlockOfRange( range, root ) ===
getEndBlockOfRange( range, root ) ) {
startBlock = getStartBlockOfRange( range, root );
if ( startBlock === getEndBlockOfRange( range, root ) ) {
// Copy all inline formatting, but that's it.
moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, startBlock );
contents = range.cloneContents();
} else {
moveRangeBoundariesUpTree( range, root );

File diff suppressed because one or more lines are too long

View file

@ -39,16 +39,18 @@ var onCopy = function ( event ) {
var range = this.getSelection();
var node = this.createElement( 'div' );
var root = this._root;
var contents, parent, newContents;
var startBlock, contents, parent, newContents;
// Edge only seems to support setting plain text as of 2016-03-11.
// Mobile Safari flat out doesn't work:
// https://bugs.webkit.org/show_bug.cgi?id=143776
if ( !isEdge && !isIOS && clipboardData ) {
range = range.cloneRange();
if ( getStartBlockOfRange( range, root ) ===
getEndBlockOfRange( range, root ) ) {
startBlock = getStartBlockOfRange( range, root );
if ( startBlock === getEndBlockOfRange( range, root ) ) {
// Copy all inline formatting, but that's it.
moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, startBlock );
contents = range.cloneContents();
} else {
moveRangeBoundariesUpTree( range, root );