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
This commit is contained in:
Ed Sanders 2016-08-10 12:46:56 -07:00 committed by Jforrester
parent f071b0380d
commit 56c56e81fe

View file

@ -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();
};