2013-06-11 19:16:04 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWTransclusionContentModel class.
|
|
|
|
*
|
2020-01-08 17:13:04 +00:00
|
|
|
* @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt
|
2013-06-11 19:16:04 +00:00
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-06-03 16:25:15 +00:00
|
|
|
* Represents a raw wikitext snippet that is part of an unbalanced sequence of template invocations.
|
|
|
|
* Meant to be an item in a {@see ve.dm.MWTransclusionModel}. Holds a back-reference to it's parent.
|
2013-06-11 19:16:04 +00:00
|
|
|
*
|
|
|
|
* @class
|
|
|
|
* @extends ve.dm.MWTransclusionPartModel
|
|
|
|
*
|
|
|
|
* @constructor
|
|
|
|
* @param {ve.dm.MWTransclusionModel} transclusion Transclusion
|
|
|
|
* @param {string} [value] Content value
|
|
|
|
*/
|
2013-07-12 00:23:33 +00:00
|
|
|
ve.dm.MWTransclusionContentModel = function VeDmMWTransclusionContentModel( transclusion, value ) {
|
2013-06-11 19:16:04 +00:00
|
|
|
// Parent constructor
|
2016-08-22 21:44:59 +00:00
|
|
|
ve.dm.MWTransclusionContentModel.super.call( this, transclusion );
|
2013-06-11 19:16:04 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.value = value || '';
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-11 21:44:09 +00:00
|
|
|
OO.inheritClass( ve.dm.MWTransclusionContentModel, ve.dm.MWTransclusionPartModel );
|
2013-06-11 19:16:04 +00:00
|
|
|
|
2013-12-09 19:05:57 +00:00
|
|
|
/* Events */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @event change
|
|
|
|
*/
|
|
|
|
|
2013-06-11 19:16:04 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get content value.
|
|
|
|
*
|
2015-08-19 18:09:34 +00:00
|
|
|
* @return {string} Content value
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionContentModel.prototype.getValue = function () {
|
|
|
|
return this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set content value.
|
|
|
|
*
|
|
|
|
* @param {string} value Content value
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionContentModel.prototype.setValue = function ( value ) {
|
|
|
|
this.value = value;
|
2013-12-09 19:05:57 +00:00
|
|
|
this.emit( 'change' );
|
2013-06-11 19:16:04 +00:00
|
|
|
};
|
2013-07-12 00:23:33 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionContentModel.prototype.serialize = function () {
|
2013-12-09 19:05:57 +00:00
|
|
|
return this.value;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2020-09-09 08:31:27 +00:00
|
|
|
ve.dm.MWTransclusionContentModel.prototype.getWikitext = function () {
|
2013-12-09 19:05:57 +00:00
|
|
|
return this.value;
|
2013-07-12 00:23:33 +00:00
|
|
|
};
|
2021-05-17 11:26:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionContentModel.prototype.isEmpty = function () {
|
|
|
|
return this.value === '';
|
|
|
|
};
|