Debian Codegraph @

extensions/VisualEditor/modules/ve-mw/dm/models/ve.dm.MWTransclusionPartModel.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel MWTransclusionPartModel class.
3 *
4 * @copyright See AUTHORS.txt
5 * @license The MIT License (MIT); see LICENSE.txt
6 */
7
8 /**
9 * Abstract base class for items in a {@see ve.dm.MWTransclusionModel}. Holds a back-reference to
10 * it's parent. Currently used for:
11 * - {@see ve.dm.MWTemplateModel} for a single template invocation.
12 * - {@see ve.dm.MWTemplatePlaceholderModel} while searching for a template name to be added.
13 * - {@see ve.dm.MWTransclusionContentModel} for a raw wikitext snippet.
14 *
15 * @abstract
16 * @class
17 * @mixes OO.EventEmitter
18 *
19 * @constructor
20 * @param {ve.dm.MWTransclusionModel} transclusion
21 */
22 ve.dm.MWTransclusionPartModel = function VeDmMWTransclusionPartModel( transclusion ) {
23 // Mixin constructors
24 OO.EventEmitter.call( this );
25
26 // Properties
27 this.transclusion = transclusion;
28 this.id = this.transclusion.nextUniquePartId();
29 };
30
31 /* Inheritance */
32
33 OO.mixinClass( ve.dm.MWTransclusionPartModel, OO.EventEmitter );
34
35 /* Events */
36
37 /**
38 * Emitted when anything changed in the content the part represents, e.g. a parameter was added to a
39 * template, or a value edited.
40 *
41 * @event ve.dm.MWTransclusionPartModel#change
42 */
43
44 /* Methods */
45
46 /**
47 * Get transclusion part is in.
48 *
49 * @return {ve.dm.MWTransclusionModel} Transclusion
50 */
51 ve.dm.MWTransclusionPartModel.prototype.getTransclusion = function () {
52 return this.transclusion;
53 };
54
55 /**
56 * Get a unique part ID within the transclusion.
57 *
58 * @return {string} Unique ID
59 */
60 ve.dm.MWTransclusionPartModel.prototype.getId = function () {
61 return this.id;
62 };
63
64 /**
65 * Remove part from transclusion.
66 */
67 ve.dm.MWTransclusionPartModel.prototype.remove = function () {
68 this.transclusion.removePart( this );
69 };
70
71 /**
72 * Create a serialized representation of this part. Contains all information needed to recreate the
73 * original wikitext, including extra whitespace. Used in
74 * {@see ve.dm.MWTransclusionModel.getPlainObject}. The corresponding deserializer is in
75 * {@see ve.dm.MWTransclusionNode.static.getWikitext}.
76 *
77 * @return {Object|string|undefined} Serialized representation, raw wikitext, or undefined if empty
78 */
79 ve.dm.MWTransclusionPartModel.prototype.serialize = function () {
80 return undefined;
81 };
82
83 /**
84 * @return {boolean} True if there is meaningful user input that was not e.g. auto-generated
85 */
86 ve.dm.MWTransclusionPartModel.prototype.containsValuableData = function () {
87 return false;
88 };