2015-10-07 20:12:15 +00:00
|
|
|
/*!
|
2015-10-14 10:56:41 +00:00
|
|
|
* VisualEditor MediaWiki UserInterface media transfer handler class.
|
2015-10-07 20:12:15 +00:00
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright See AUTHORS.txt
|
2015-10-07 20:12:15 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2015-10-14 10:56:41 +00:00
|
|
|
* Media transfer handler.
|
2015-10-07 20:12:15 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.DataTransferHandler
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.ui.Surface} surface
|
|
|
|
* @param {ve.ui.DataTransferItem} item
|
|
|
|
*/
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler = function VeUiMWMediaTransferHandler() {
|
2015-10-07 20:12:15 +00:00
|
|
|
// Parent constructor
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.super.apply( this, arguments );
|
2015-10-07 20:12:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
OO.inheritClass( ve.ui.MWMediaTransferHandler, ve.ui.DataTransferHandler );
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
/* Static properties */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.name = 'media';
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.kinds = [ 'file' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
// TODO: Pull available types and extensions from MW config
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.types = [ 'image/jpeg', 'image/png', 'image/gif', 'image/svg+xml' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.static.extensions = [ 'jpg', 'jpeg', 'png', 'gif', 'svg' ];
|
2015-10-07 20:12:15 +00:00
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.MWMediaTransferHandler.prototype.process = function () {
|
2024-05-21 14:22:56 +00:00
|
|
|
const file = this.item.getAsFile();
|
2015-10-07 20:12:15 +00:00
|
|
|
|
2024-05-21 14:22:56 +00:00
|
|
|
const action = ve.ui.actionFactory.create( 'window', this.surface );
|
2016-08-10 19:46:56 +00:00
|
|
|
action.open( 'media', { file: file } );
|
|
|
|
|
2015-10-07 20:12:15 +00:00
|
|
|
this.insertableDataDeferred.reject();
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Registration */
|
|
|
|
|
2015-10-14 10:56:41 +00:00
|
|
|
ve.ui.dataTransferHandlerFactory.register( ve.ui.MWMediaTransferHandler );
|