mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Don't use old clipboard API.
Safari very rarely has a text/html version (even if you copy from within Safari!) so you end up always pasting plain text. Better to use the fallback method to grab the data.
This commit is contained in:
parent
bc523f83e8
commit
680c0fbbb7
3 changed files with 40 additions and 20 deletions
|
@ -1927,7 +1927,9 @@ var onPaste = function ( event ) {
|
||||||
l, item, type;
|
l, item, type;
|
||||||
|
|
||||||
// Current HTML5 Clipboard interface
|
// Current HTML5 Clipboard interface
|
||||||
|
// ---------------------------------
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html
|
// https://html.spec.whatwg.org/multipage/interaction.html
|
||||||
|
|
||||||
if ( items ) {
|
if ( items ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
l = items.length;
|
l = items.length;
|
||||||
|
@ -1973,17 +1975,25 @@ var onPaste = function ( event ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Old interface
|
// Old interface
|
||||||
if ( clipboardData ) {
|
// -------------
|
||||||
event.preventDefault();
|
// Currently supported by FF & Safari. *However*, Safari flat out refuses
|
||||||
if ( indexOf.call( clipboardData.types, 'text/html' ) > -1 ) {
|
// to copy stuff as text/html when copying from *within Safari*. There is
|
||||||
this.insertHTML( clipboardData.getData( 'text/html' ), true );
|
// no way to get an HTML version of the clipboard other than to use the
|
||||||
} else {
|
// fallback method.
|
||||||
this.insertPlainText( clipboardData.getData( 'text/plain' ), true );
|
|
||||||
}
|
// if ( clipboardData ) {
|
||||||
return;
|
// event.preventDefault();
|
||||||
}
|
// if ( indexOf.call( clipboardData.types, 'text/html' ) > -1 ) {
|
||||||
|
// this.insertHTML( clipboardData.getData( 'text/html' ), true );
|
||||||
|
// } else {
|
||||||
|
// this.insertPlainText( clipboardData.getData( 'text/plain' ), true );
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
// No interface :(
|
// No interface :(
|
||||||
|
// ---------------
|
||||||
|
|
||||||
this._awaitingPaste = true;
|
this._awaitingPaste = true;
|
||||||
|
|
||||||
var body = this._body,
|
var body = this._body,
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -27,7 +27,9 @@ var onPaste = function ( event ) {
|
||||||
l, item, type;
|
l, item, type;
|
||||||
|
|
||||||
// Current HTML5 Clipboard interface
|
// Current HTML5 Clipboard interface
|
||||||
|
// ---------------------------------
|
||||||
// https://html.spec.whatwg.org/multipage/interaction.html
|
// https://html.spec.whatwg.org/multipage/interaction.html
|
||||||
|
|
||||||
if ( items ) {
|
if ( items ) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
l = items.length;
|
l = items.length;
|
||||||
|
@ -73,17 +75,25 @@ var onPaste = function ( event ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Old interface
|
// Old interface
|
||||||
if ( clipboardData ) {
|
// -------------
|
||||||
event.preventDefault();
|
// Currently supported by FF & Safari. *However*, Safari flat out refuses
|
||||||
if ( indexOf.call( clipboardData.types, 'text/html' ) > -1 ) {
|
// to copy stuff as text/html when copying from *within Safari*. There is
|
||||||
this.insertHTML( clipboardData.getData( 'text/html' ), true );
|
// no way to get an HTML version of the clipboard other than to use the
|
||||||
} else {
|
// fallback method.
|
||||||
this.insertPlainText( clipboardData.getData( 'text/plain' ), true );
|
|
||||||
}
|
// if ( clipboardData ) {
|
||||||
return;
|
// event.preventDefault();
|
||||||
}
|
// if ( indexOf.call( clipboardData.types, 'text/html' ) > -1 ) {
|
||||||
|
// this.insertHTML( clipboardData.getData( 'text/html' ), true );
|
||||||
|
// } else {
|
||||||
|
// this.insertPlainText( clipboardData.getData( 'text/plain' ), true );
|
||||||
|
// }
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
// No interface :(
|
// No interface :(
|
||||||
|
// ---------------
|
||||||
|
|
||||||
this._awaitingPaste = true;
|
this._awaitingPaste = true;
|
||||||
|
|
||||||
var body = this._body,
|
var body = this._body,
|
||||||
|
|
Loading…
Reference in a new issue