From 56c56e81fe89fee3b879ff31083cdf8fccb6c25b Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 10 Aug 2016 12:46:56 -0700 Subject: [PATCH] Move image-paste blocking to transfer handler match function By not matching, we allow other types of paste to happen, e.g. HTML/plain text. Bug: T142622 Change-Id: I3a2224ab23b5073eb7b031134ecc3170ccc782c0 --- .../ve.ui.MWMediaTransferHandler.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js index ff369a6427..a3ba5e05ec 100644 --- a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js +++ b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js @@ -36,6 +36,13 @@ ve.ui.MWMediaTransferHandler.static.types = [ 'image/jpeg', 'image/png', 'image/ ve.ui.MWMediaTransferHandler.static.extensions = [ 'jpg', 'jpeg', 'png', 'gif', 'svg' ]; +ve.ui.MWMediaTransferHandler.static.matchFunction = function ( item ) { + var file = item.getAsFile(); + // If file is null, return true as the data is not available yet from the browser. + // If file is a non-File (pasted Blob), return false as this is not yet supported. + return !file || file instanceof File; +}; + /* Methods */ /** @@ -45,11 +52,9 @@ ve.ui.MWMediaTransferHandler.prototype.process = function () { var action, file = this.item.getAsFile(); - // File upload doesn't support pasted Blobs yet - if ( file instanceof File ) { - action = ve.ui.actionFactory.create( 'window', this.surface ); - action.open( 'media', { file: file } ); - } + action = ve.ui.actionFactory.create( 'window', this.surface ); + action.open( 'media', { file: file } ); + this.insertableDataDeferred.reject(); };