mediawiki-extensions-Visual.../modules/ve-mw/ui/datatransferhandlers/ve.ui.MWMediaTransferHandler.js
Ed Sanders dbc696124f ESLint: Enforce no-var and autofix
Temporarily disable prefer-const as this requires
manual fixing.

Change-Id: I477b69a57e8d33535c6fc71dba196a8605780725
2024-05-21 17:40:52 +01:00

54 lines
1.3 KiB
JavaScript

/*!
* VisualEditor MediaWiki UserInterface media transfer handler class.
*
* @copyright See AUTHORS.txt
*/
/**
* 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 () {
const file = this.item.getAsFile();
const action = ve.ui.actionFactory.create( 'window', this.surface );
action.open( 'media', { file: file } );
this.insertableDataDeferred.reject();
};
/* Registration */
ve.ui.dataTransferHandlerFactory.register( ve.ui.MWMediaTransferHandler );