0
Fork 0
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:
Neil Jenkins 2015-06-19 12:35:18 +07:00
parent bc523f83e8
commit 680c0fbbb7
3 changed files with 40 additions and 20 deletions

View file

@ -1927,7 +1927,9 @@ var onPaste = function ( event ) {
l, item, type;
// Current HTML5 Clipboard interface
// ---------------------------------
// https://html.spec.whatwg.org/multipage/interaction.html
if ( items ) {
event.preventDefault();
l = items.length;
@ -1973,17 +1975,25 @@ var onPaste = function ( event ) {
}
// Old interface
if ( clipboardData ) {
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;
}
// -------------
// Currently supported by FF & Safari. *However*, Safari flat out refuses
// to copy stuff as text/html when copying from *within Safari*. There is
// no way to get an HTML version of the clipboard other than to use the
// fallback method.
// if ( clipboardData ) {
// 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 :(
// ---------------
this._awaitingPaste = true;
var body = this._body,

File diff suppressed because one or more lines are too long

View file

@ -27,7 +27,9 @@ var onPaste = function ( event ) {
l, item, type;
// Current HTML5 Clipboard interface
// ---------------------------------
// https://html.spec.whatwg.org/multipage/interaction.html
if ( items ) {
event.preventDefault();
l = items.length;
@ -73,17 +75,25 @@ var onPaste = function ( event ) {
}
// Old interface
if ( clipboardData ) {
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;
}
// -------------
// Currently supported by FF & Safari. *However*, Safari flat out refuses
// to copy stuff as text/html when copying from *within Safari*. There is
// no way to get an HTML version of the clipboard other than to use the
// fallback method.
// if ( clipboardData ) {
// 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 :(
// ---------------
this._awaitingPaste = true;
var body = this._body,