mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 07:40:48 +00:00
3a9dcf7ec5
Previous the media upload panel didn't support this. This makes Chrome behave in the same way as Firefox when pasting images into a document. Bug: T39932 Change-Id: I12f190a48ae9b62d4ad2f33b2a4ee546fdf7b354
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
/*!
|
|
* VisualEditor MediaWiki UserInterface media transfer handler class.
|
|
*
|
|
* @copyright 2011-2017 VisualEditor Team and others; see http://ve.mit-license.org
|
|
*/
|
|
|
|
/* global File */
|
|
|
|
/**
|
|
* Media transfer handler.
|
|
*
|
|
* @class
|
|
* @extends ve.ui.DataTransferHandler
|
|
*
|
|
* @constructor
|
|
* @param {ve.ui.Surface} surface
|
|
* @param {ve.ui.DataTransferItem} item
|
|
*/
|
|
ve.ui.MWMediaTransferHandler = function VeUiMWMediaTransferHandler() {
|
|
// Parent constructor
|
|
ve.ui.MWMediaTransferHandler.super.apply( this, arguments );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWMediaTransferHandler, ve.ui.DataTransferHandler );
|
|
|
|
/* Static properties */
|
|
|
|
ve.ui.MWMediaTransferHandler.static.name = 'media';
|
|
|
|
ve.ui.MWMediaTransferHandler.static.kinds = [ 'file' ];
|
|
|
|
// TODO: Pull available types and extensions from MW config
|
|
ve.ui.MWMediaTransferHandler.static.types = [ 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml' ];
|
|
|
|
ve.ui.MWMediaTransferHandler.static.extensions = [ 'jpg', 'jpeg', 'png', 'gif', 'svg' ];
|
|
|
|
/* Methods */
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWMediaTransferHandler.prototype.process = function () {
|
|
var action,
|
|
file = this.item.getAsFile();
|
|
|
|
action = ve.ui.actionFactory.create( 'window', this.surface );
|
|
action.open( 'media', { file: file } );
|
|
|
|
this.insertableDataDeferred.reject();
|
|
};
|
|
|
|
/* Registration */
|
|
|
|
ve.ui.dataTransferHandlerFactory.register( ve.ui.MWMediaTransferHandler );
|