mediawiki-extensions-Visual.../modules/ve-mw/ui/elements/ve.ui.MWPreviewElement.js
Thiemo Kreuz aa556e3ef8 Update and fix all @param config and @cfg documentation
I tried to review all of them. Some of the changes I did:
* Make sure the `config` parameter is not marked as optional
  when it is not.
* Make sure default values are mentioned.
* List individual `@cfg` options when it makes sense.

Note I don't list all options a class could accept (e.g. via all
its parent classes and mixins). That's too much. Instead I checked
how a class is actually used and list only these options.

Even then I don't list everything, e.g. unspecific options
like "classes" that can be used pretty much everywhere.

Change-Id: Idf4fbe1dc3608ace277df9e385f2f140df3a2f50
2021-09-12 12:35:27 +00:00

60 lines
1.5 KiB
JavaScript

/*!
* VisualEditor UserInterface MWPreviewElement class.
*
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
* @license The MIT License (MIT); see LICENSE.txt
*/
/**
* Creates an ve.ui.MWPreviewElement object.
*
* @class
* @extends ve.ui.PreviewElement
*
* @constructor
* @param {ve.dm.Node} [model]
* @param {Object} [config]
* @cfg {boolean} [useView=false] Use the view HTML, and don't bother generating model HTML, which
* is a bit slower
*/
ve.ui.MWPreviewElement = function VeUiMwPreviewElement() {
// Parent constructor
ve.ui.MWPreviewElement.super.apply( this, arguments );
// Initialize
this.$element.addClass( 've-ui-mwPreviewElement mw-body-content mw-parser-output' );
};
/* Inheritance */
OO.inheritClass( ve.ui.MWPreviewElement, ve.ui.PreviewElement );
/* Method */
/**
* @inheritdoc
*/
ve.ui.MWPreviewElement.prototype.setModel = function ( model ) {
// Parent method
ve.ui.MWPreviewElement.super.prototype.setModel.call( this, model );
// The following classes are used here:
// * mw-content-ltr
// * mw-content-rtl
this.$element.addClass( 'mw-content-' + this.model.getDocument().getDir() );
};
/**
* @inheritdoc
*/
ve.ui.MWPreviewElement.prototype.replaceWithModelDom = function () {
// Parent method
ve.ui.MWPreviewElement.super.prototype.replaceWithModelDom.apply( this, arguments );
ve.init.platform.linkCache.styleParsoidElements(
this.$element,
// The DM node should be attached, but check just in case.
this.model.getDocument() && this.model.getDocument().getHtmlDocument()
);
};