2013-06-11 19:16:04 +00:00
|
|
|
/*!
|
|
|
|
* VisualEditor DataModel MWTransclusionPartModel 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
|
|
|
* Abstract base class for items in a {@see ve.dm.MWTransclusionModel}. Holds a back-reference to
|
|
|
|
* it's parent. Currently used for:
|
|
|
|
* - {@see ve.dm.MWTemplateModel} for a single template invocation.
|
|
|
|
* - {@see ve.dm.MWTemplatePlaceholderModel} while searching for a template name to be added.
|
|
|
|
* - {@see ve.dm.MWTransclusionContentModel} for a raw wikitext snippet.
|
2013-06-11 19:16:04 +00:00
|
|
|
*
|
2021-08-24 09:31:14 +00:00
|
|
|
* @abstract
|
2013-06-11 19:16:04 +00:00
|
|
|
* @class
|
2013-10-15 11:58:04 +00:00
|
|
|
* @mixins OO.EventEmitter
|
2013-06-11 19:16:04 +00:00
|
|
|
*
|
|
|
|
* @constructor
|
2021-06-04 11:58:18 +00:00
|
|
|
* @param {ve.dm.MWTransclusionModel} transclusion
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
2013-07-12 00:23:33 +00:00
|
|
|
ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion ) {
|
2013-06-11 19:16:04 +00:00
|
|
|
// Mixin constructors
|
2013-10-15 11:58:04 +00:00
|
|
|
OO.EventEmitter.call( this );
|
2013-06-11 19:16:04 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
this.transclusion = transclusion;
|
2022-04-19 11:46:34 +00:00
|
|
|
this.id = this.transclusion.nextUniquePartId();
|
2013-06-11 19:16:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2013-10-15 11:58:04 +00:00
|
|
|
OO.mixinClass( ve.dm.MWTransclusionPartModel, OO.EventEmitter );
|
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 anything changed in the content the part represents, e.g. a parameter was added to a
|
|
|
|
* template, or a value edited.
|
|
|
|
*
|
2013-12-09 19:05:57 +00:00
|
|
|
* @event change
|
|
|
|
*/
|
|
|
|
|
2013-06-11 19:16:04 +00:00
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get transclusion part is in.
|
|
|
|
*
|
2015-08-19 18:09:34 +00:00
|
|
|
* @return {ve.dm.MWTransclusionModel} Transclusion
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
|
|
|
|
return this.transclusion;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a unique part ID within the transclusion.
|
|
|
|
*
|
2015-08-19 18:09:34 +00:00
|
|
|
* @return {string} Unique ID
|
2013-06-11 19:16:04 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.getId = function () {
|
|
|
|
return this.id;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove part from transclusion.
|
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.remove = function () {
|
|
|
|
this.transclusion.removePart( this );
|
|
|
|
};
|
2013-07-12 00:23:33 +00:00
|
|
|
|
|
|
|
/**
|
2021-06-17 15:54:14 +00:00
|
|
|
* Create a serialized representation of this part. Contains all information needed to recreate the
|
|
|
|
* original wikitext, including extra whitespace. Used in
|
|
|
|
* {@see ve.dm.MWTransclusionModel.getPlainObject}. The corresponding deserializer is in
|
|
|
|
* {@see ve.dm.MWTransclusionNode.static.getWikitext}.
|
2013-07-12 00:23:33 +00:00
|
|
|
*
|
2021-06-17 15:54:14 +00:00
|
|
|
* @return {Object|string|undefined} Serialized representation, raw wikitext, or undefined if empty
|
2013-07-12 00:23:33 +00:00
|
|
|
*/
|
|
|
|
ve.dm.MWTransclusionPartModel.prototype.serialize = function () {
|
|
|
|
return undefined;
|
|
|
|
};
|
2013-12-09 19:05:57 +00:00
|
|
|
|
2021-05-17 11:26:11 +00:00
|
|
|
/**
|
2021-08-03 13:24:36 +00:00
|
|
|
* @return {boolean} True if there is meaningful user input that was not e.g. auto-generated
|
2021-05-17 11:26:11 +00:00
|
|
|
*/
|
2021-08-03 13:24:36 +00:00
|
|
|
ve.dm.MWTransclusionPartModel.prototype.containsValuableData = function () {
|
|
|
|
return false;
|
2021-05-17 11:26:11 +00:00
|
|
|
};
|