2013-06-11 19:16:04 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWTransclusionContentModel class.
|
|
|
|
*
|
2023-12-01 16:06:11 +00:00
|
|
|
* @copyright 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
|
2021-06-04 10:16:58 +00:00
|
|
|
* @param {ve.dm.MWTransclusionModel} transclusion
|
|
|
|
* @param {string} [wikitext='']
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
2021-06-04 10:16:58 +00:00
|
|
|
ve.dm.MWTransclusionContentModel = function VeDmMWTransclusionContentModel( transclusion, wikitext ) {
|
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
|
2021-06-04 10:16:58 +00:00
|
|
|
this.wikitext = wikitext || '';
|
2013-06-11 19:16:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* 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 */
|
|
|
|
|
|
|
|
/**
|
2021-07-15 15:07:21 +00:00
|
|
|
* Emitted when the wikitext changed.
|
|
|
|
*
|
2013-12-09 19:05:57 +00:00
|
|
|
* @event change
|
|
|
|
*/
|
|
|
|
|
2013-06-11 19:16:04 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
2021-06-04 10:16:58 +00:00
|
|
|
* @param {string} wikitext
|
2021-09-30 11:04:30 +00:00
|
|
|
* @fires change
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
2021-06-04 10:16:58 +00:00
|
|
|
ve.dm.MWTransclusionContentModel.prototype.setWikitext = function ( wikitext ) {
|
2021-07-15 15:07:21 +00:00
|
|
|
if ( this.wikitext !== wikitext ) {
|
|
|
|
this.wikitext = wikitext;
|
|
|
|
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 () {
|
2021-06-04 10:16:58 +00:00
|
|
|
return this.wikitext;
|
2013-12-09 19:05:57 +00:00
|
|
|
};
|
|
|
|
|
2021-05-17 11:26:11 +00:00
|
|
|
/**
|
2021-06-18 13:51:25 +00:00
|
|
|
* @inheritdoc
|
2021-05-17 11:26:11 +00:00
|
|
|
*/
|
2021-08-03 13:24:36 +00:00
|
|
|
ve.dm.MWTransclusionContentModel.prototype.containsValuableData = function () {
|
|
|
|
return this.wikitext !== '';
|
2021-05-17 11:26:11 +00:00
|
|
|
};
|