0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Let browser handle paste of images in FF/Safari.

This commit is contained in:
Neil Jenkins 2015-07-16 10:46:29 -07:00
parent fdcef5fc8e
commit 715166b95d
3 changed files with 16 additions and 16 deletions

View file

@ -2033,19 +2033,19 @@ var onPaste = function ( event ) {
// Safari (and indeed many other OS X apps) copies stuff as text/rtf // Safari (and indeed many other OS X apps) copies stuff as text/rtf
// rather than text/html; even from a webpage in Safari. The only way // rather than text/html; even from a webpage in Safari. The only way
// to get an HTML version is to fallback to letting the browser insert // to get an HTML version is to fallback to letting the browser insert
// the content. *Sigh*. // the content. Same for getting image data. *Sigh*.
if ( clipboardData && ( if ( clipboardData && (
indexOf.call( clipboardData.types, 'text/html' ) > -1 || indexOf.call( clipboardData.types, 'text/html' ) > -1 || (
indexOf.call( clipboardData.types, 'text/rtf' ) === -1 ) ) { indexOf.call( clipboardData.types, 'text/plain' ) > -1 &&
indexOf.call( clipboardData.types, 'text/rtf' ) < 0 ) ) ) {
event.preventDefault(); event.preventDefault();
// Abiword on Linux copies a plain text and html version, but the HTML // Abiword on Linux copies a plain text and html version, but the HTML
// version is the empty string! So always try to get HTML, but if none, // version is the empty string! So always try to get HTML, but if none,
// insert plain text instead. // insert plain text instead.
data = clipboardData.getData( 'text/html' ); if (( data = clipboardData.getData( 'text/html' ) )) {
if ( data ) {
this.insertHTML( data, true ); this.insertHTML( data, true );
} else { } else if (( data = clipboardData.getData( 'text/plain' ) )) {
this.insertPlainText( clipboardData.getData( 'text/plain' ), true ); this.insertPlainText( data, true );
} }
return; return;
} }

File diff suppressed because one or more lines are too long

View file

@ -80,19 +80,19 @@ var onPaste = function ( event ) {
// Safari (and indeed many other OS X apps) copies stuff as text/rtf // Safari (and indeed many other OS X apps) copies stuff as text/rtf
// rather than text/html; even from a webpage in Safari. The only way // rather than text/html; even from a webpage in Safari. The only way
// to get an HTML version is to fallback to letting the browser insert // to get an HTML version is to fallback to letting the browser insert
// the content. *Sigh*. // the content. Same for getting image data. *Sigh*.
if ( clipboardData && ( if ( clipboardData && (
indexOf.call( clipboardData.types, 'text/html' ) > -1 || indexOf.call( clipboardData.types, 'text/html' ) > -1 || (
indexOf.call( clipboardData.types, 'text/rtf' ) === -1 ) ) { indexOf.call( clipboardData.types, 'text/plain' ) > -1 &&
indexOf.call( clipboardData.types, 'text/rtf' ) < 0 ) ) ) {
event.preventDefault(); event.preventDefault();
// Abiword on Linux copies a plain text and html version, but the HTML // Abiword on Linux copies a plain text and html version, but the HTML
// version is the empty string! So always try to get HTML, but if none, // version is the empty string! So always try to get HTML, but if none,
// insert plain text instead. // insert plain text instead.
data = clipboardData.getData( 'text/html' ); if (( data = clipboardData.getData( 'text/html' ) )) {
if ( data ) {
this.insertHTML( data, true ); this.insertHTML( data, true );
} else { } else if (( data = clipboardData.getData( 'text/plain' ) )) {
this.insertPlainText( clipboardData.getData( 'text/plain' ), true ); this.insertPlainText( data, true );
} }
return; return;
} }