mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
33546466eb
Bug: T313221 Change-Id: I06366d4601342435b70d311742ee985e01b0477b
52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/*!
|
|
* VisualEditor UserInterface MWTargetWidget class.
|
|
*
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
*/
|
|
|
|
/**
|
|
* Creates an ve.ui.MWTargetWidget object.
|
|
*
|
|
* @class
|
|
* @abstract
|
|
* @extends ve.ui.TargetWidget
|
|
*
|
|
* @constructor
|
|
* @param {Object} config
|
|
* @cfg {string[]} [surfaceClasses] Surface classes to apply
|
|
*/
|
|
ve.ui.MWTargetWidget = function VeUiMWTargetWidget( config ) {
|
|
this.surfaceClasses = ve.copy( config.surfaceClasses ) || [];
|
|
|
|
// HACK: T287733
|
|
// This assumes the target widget is being shown outside of vector-body, otherwise this
|
|
// will apply the class a second time and cause problems.
|
|
if ( mw.config.get( 'skin' ) === 'vector' || mw.config.get( 'skin' ) === 'vector-2022' ) {
|
|
this.surfaceClasses.push( 'vector-body' );
|
|
}
|
|
|
|
// Parent constructor
|
|
ve.ui.MWTargetWidget.super.apply( this, arguments );
|
|
|
|
// Initialization
|
|
this.$element.addClass( 've-ui-mwTargetWidget' );
|
|
};
|
|
|
|
/* Inheritance */
|
|
|
|
OO.inheritClass( ve.ui.MWTargetWidget, ve.ui.TargetWidget );
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
ve.ui.MWTargetWidget.prototype.createTarget = function () {
|
|
return new ve.init.mw.Target( {
|
|
register: false,
|
|
toolbarGroups: this.toolbarGroups,
|
|
modes: this.modes,
|
|
defaultMode: this.defaultMode,
|
|
surfaceClasses: this.surfaceClasses
|
|
} );
|
|
};
|