mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Insert table rather than image on paste from Excel
This commit is contained in:
parent
2059c5a4ae
commit
43b2c6b0e1
3 changed files with 21 additions and 7 deletions
|
@ -2346,6 +2346,7 @@ var onPaste = function ( event ) {
|
|||
var items = clipboardData && clipboardData.items;
|
||||
var choosePlain = this.isShiftDown;
|
||||
var fireDrop = false;
|
||||
var hasRTF = false;
|
||||
var hasImage = false;
|
||||
var plainItem = null;
|
||||
var htmlItem = null;
|
||||
|
@ -2364,6 +2365,8 @@ var onPaste = function ( event ) {
|
|||
htmlItem = item;
|
||||
} else if ( type === 'text/plain' ) {
|
||||
plainItem = item;
|
||||
} else if ( type === 'text/rtf' ) {
|
||||
hasRTF = true;
|
||||
} else if ( /^image\/.*/.test( type ) ) {
|
||||
hasImage = true;
|
||||
}
|
||||
|
@ -2372,9 +2375,13 @@ var onPaste = function ( event ) {
|
|||
// Treat image paste as a drop of an image file. When you copy
|
||||
// an image in Chrome/Firefox (at least), it copies the image data
|
||||
// but also an HTML version (referencing the original URL of the image)
|
||||
// and a plain text version. So we check for image data first, only if
|
||||
// none look for text/html.
|
||||
if ( hasImage ) {
|
||||
// and a plain text version.
|
||||
//
|
||||
// However, when you copy in Excel, you get html, rtf, text, image;
|
||||
// in this instance you want the html version! So let's try using
|
||||
// the presence of text/rtf as an indicator to choose the html version
|
||||
// over the image.
|
||||
if ( hasImage && !( hasRTF && htmlItem ) ) {
|
||||
event.preventDefault();
|
||||
this.fireEvent( 'dragover', {
|
||||
dataTransfer: clipboardData,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -145,6 +145,7 @@ var onPaste = function ( event ) {
|
|||
var items = clipboardData && clipboardData.items;
|
||||
var choosePlain = this.isShiftDown;
|
||||
var fireDrop = false;
|
||||
var hasRTF = false;
|
||||
var hasImage = false;
|
||||
var plainItem = null;
|
||||
var htmlItem = null;
|
||||
|
@ -163,6 +164,8 @@ var onPaste = function ( event ) {
|
|||
htmlItem = item;
|
||||
} else if ( type === 'text/plain' ) {
|
||||
plainItem = item;
|
||||
} else if ( type === 'text/rtf' ) {
|
||||
hasRTF = true;
|
||||
} else if ( /^image\/.*/.test( type ) ) {
|
||||
hasImage = true;
|
||||
}
|
||||
|
@ -171,9 +174,13 @@ var onPaste = function ( event ) {
|
|||
// Treat image paste as a drop of an image file. When you copy
|
||||
// an image in Chrome/Firefox (at least), it copies the image data
|
||||
// but also an HTML version (referencing the original URL of the image)
|
||||
// and a plain text version. So we check for image data first, only if
|
||||
// none look for text/html.
|
||||
if ( hasImage ) {
|
||||
// and a plain text version.
|
||||
//
|
||||
// However, when you copy in Excel, you get html, rtf, text, image;
|
||||
// in this instance you want the html version! So let's try using
|
||||
// the presence of text/rtf as an indicator to choose the html version
|
||||
// over the image.
|
||||
if ( hasImage && !( hasRTF && htmlItem ) ) {
|
||||
event.preventDefault();
|
||||
this.fireEvent( 'dragover', {
|
||||
dataTransfer: clipboardData,
|
||||
|
|
Loading…
Reference in a new issue