1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

When pasting both image data and text into Chrome, use only the text

Summary: Fixes T5437. This actual behavior is debateable but this is the one that seems simplest and most sensible.

Test Plan: Copied some cells from Numbers, pasted them into a remarkup box in Chrome, got just the text.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5437

Differential Revision: https://secure.phabricator.com/D9647
This commit is contained in:
epriestley 2014-06-21 10:04:46 -07:00
parent b20884a842
commit a496d4aa42
2 changed files with 29 additions and 16 deletions

View file

@ -11,7 +11,7 @@ return array(
'core.pkg.js' => '07b01d4f', 'core.pkg.js' => '07b01d4f',
'darkconsole.pkg.js' => 'ca8671ce', 'darkconsole.pkg.js' => 'ca8671ce',
'differential.pkg.css' => '4a93db37', 'differential.pkg.css' => '4a93db37',
'differential.pkg.js' => '2b128f3a', 'differential.pkg.js' => '5b252007',
'diffusion.pkg.css' => '471bc9eb', 'diffusion.pkg.css' => '471bc9eb',
'diffusion.pkg.js' => '077e3ad0', 'diffusion.pkg.js' => '077e3ad0',
'maniphest.pkg.css' => 'f88a8402', 'maniphest.pkg.css' => 'f88a8402',
@ -434,7 +434,7 @@ return array(
'rsrc/js/application/uiexample/gesture-example.js' => 'f42bb8c6', 'rsrc/js/application/uiexample/gesture-example.js' => 'f42bb8c6',
'rsrc/js/application/uiexample/notification-example.js' => 'c51a6616', 'rsrc/js/application/uiexample/notification-example.js' => 'c51a6616',
'rsrc/js/core/Busy.js' => '6453c869', 'rsrc/js/core/Busy.js' => '6453c869',
'rsrc/js/core/DragAndDropFileUpload.js' => 'ae6abfba', 'rsrc/js/core/DragAndDropFileUpload.js' => '1d8ad5c3',
'rsrc/js/core/DraggableList.js' => '109e2a87', 'rsrc/js/core/DraggableList.js' => '109e2a87',
'rsrc/js/core/FileUpload.js' => 'a4ae61bf', 'rsrc/js/core/FileUpload.js' => 'a4ae61bf',
'rsrc/js/core/Hovercard.js' => '4f344388', 'rsrc/js/core/Hovercard.js' => '4f344388',
@ -708,7 +708,7 @@ return array(
'phabricator-countdown-css' => '86b7b0a0', 'phabricator-countdown-css' => '86b7b0a0',
'phabricator-crumbs-view-css' => '7fbf25b8', 'phabricator-crumbs-view-css' => '7fbf25b8',
'phabricator-dashboard-css' => '22dfc441', 'phabricator-dashboard-css' => '22dfc441',
'phabricator-drag-and-drop-file-upload' => 'ae6abfba', 'phabricator-drag-and-drop-file-upload' => '1d8ad5c3',
'phabricator-draggable-list' => '109e2a87', 'phabricator-draggable-list' => '109e2a87',
'phabricator-fatal-config-template-css' => '25d446d6', 'phabricator-fatal-config-template-css' => '25d446d6',
'phabricator-feed-css' => '5cbec787', 'phabricator-feed-css' => '5cbec787',
@ -970,6 +970,15 @@ return array(
1 => 'javelin-util', 1 => 'javelin-util',
2 => 'phabricator-keyboard-shortcut-manager', 2 => 'phabricator-keyboard-shortcut-manager',
), ),
'1d8ad5c3' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-request',
3 => 'javelin-dom',
4 => 'javelin-uri',
5 => 'phabricator-file-upload',
),
'1da67f34' => '1da67f34' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1656,15 +1665,6 @@ return array(
3 => 'javelin-dom', 3 => 'javelin-dom',
4 => 'javelin-vector', 4 => 'javelin-vector',
), ),
'ae6abfba' =>
array(
0 => 'javelin-install',
1 => 'javelin-util',
2 => 'javelin-request',
3 => 'javelin-dom',
4 => 'javelin-uri',
5 => 'phabricator-file-upload',
),
'b3a4b884' => 'b3a4b884' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',

View file

@ -121,13 +121,26 @@ JX.install('PhabricatorDragAndDropFileUpload', {
'paste', 'paste',
null, null,
JX.bind(this, function(e) { JX.bind(this, function(e) {
var clipboardData = e.getRawEvent().clipboardData; var clipboard = e.getRawEvent().clipboardData;
if (!clipboardData) { if (!clipboard) {
return; return;
} }
for (var ii = 0; ii < clipboardData.items.length; ii++) { // If there's any text on the clipboard, just let the event fire
var item = clipboardData.items[ii]; // normally, choosing the text over any images. See T5437 / D9647.
var text = clipboard.getData('text/plain').toString();
if (text.length) {
return;
}
// Safari and Firefox have clipboardData, but no items. They
// don't seem to provide a way to get image data directly yet.
if (!clipboard.items) {
return;
}
for (var ii = 0; ii < clipboard.items.length; ii++) {
var item = clipboard.items[ii];
if (!/^image\//.test(item.type)) { if (!/^image\//.test(item.type)) {
continue; continue;
} }