2018-05-05 15:42:34 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor UserInterface MWSurface class.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see http://ve.mit-license.org
|
2018-05-05 15:42:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @class
|
|
|
|
* @extends ve.ui.Surface
|
|
|
|
*
|
|
|
|
* @constructor
|
2023-01-28 14:05:05 +00:00
|
|
|
* @param {ve.init.Target} target
|
2018-05-05 15:42:34 +00:00
|
|
|
* @param {HTMLDocument|Array|ve.dm.LinearData|ve.dm.Document} dataOrDoc Document data to edit
|
|
|
|
* @param {Object} [config] Configuration options
|
|
|
|
*/
|
|
|
|
ve.ui.MWSurface = function VeUiMWSurface() {
|
|
|
|
// Parent constructor
|
|
|
|
ve.ui.MWSurface.super.apply( this, arguments );
|
|
|
|
|
|
|
|
// Events
|
|
|
|
this.getView().getDocument().connect( this, { langChange: 'onDocumentViewLangChange' } );
|
|
|
|
|
|
|
|
// DOM changes
|
|
|
|
this.onDocumentViewLangChange();
|
|
|
|
this.$element.addClass( 've-ui-mwSurface' );
|
|
|
|
// T164790
|
2021-11-18 14:09:04 +00:00
|
|
|
this.getView().$attachedRootNode.addClass( 'mw-parser-output mw-show-empty-elt' );
|
2018-05-05 15:42:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
OO.inheritClass( ve.ui.MWSurface, ve.ui.Surface );
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle document view langChange events
|
|
|
|
*/
|
|
|
|
ve.ui.MWSurface.prototype.onDocumentViewLangChange = function () {
|
|
|
|
// Add appropriately mw-content-ltr or mw-content-rtl class
|
2019-02-13 13:20:46 +00:00
|
|
|
this.getView().$attachedRootNode
|
2018-05-05 15:42:34 +00:00
|
|
|
.removeClass( 'mw-content-ltr mw-content-rtl' )
|
2020-04-09 13:33:54 +00:00
|
|
|
// The following classes are used here:
|
|
|
|
// * mw-content-ltr
|
|
|
|
// * mw-content-rtl
|
2018-05-05 15:42:34 +00:00
|
|
|
.addClass( 'mw-content-' + this.getView().getDocument().getDir() );
|
|
|
|
};
|