Debian Codegraph @

extensions/VisualEditor/lib/ve/src/dm/annotations/ve.dm.TextStyleAnnotation.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel TextStyleAnnotation class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * DataModel text style annotation.
9 *
10 * @class
11 * @abstract
12 * @extends ve.dm.Annotation
13 * @constructor
14 * @param {Object} element
15 */
16 ve.dm.TextStyleAnnotation = function VeDmTextStyleAnnotation() {
17 // Parent constructor
18 ve.dm.TextStyleAnnotation.super.apply( this, arguments );
19 };
20
21 /* Inheritance */
22
23 OO.inheritClass( ve.dm.TextStyleAnnotation, ve.dm.Annotation );
24
25 /* Static Properties */
26
27 ve.dm.TextStyleAnnotation.static.name = 'textStyle';
28
29 ve.dm.TextStyleAnnotation.static.matchTagNames = [];
30
31 ve.dm.TextStyleAnnotation.static.toDataElement = function ( domElements, converter ) {
32 const nodeName = converter.isFromClipboard() ? this.matchTagNames[ 0 ] : domElements[ 0 ].nodeName.toLowerCase();
33 return {
34 type: this.name,
35 attributes: {
36 nodeName: nodeName
37 }
38 };
39 };
40
41 ve.dm.TextStyleAnnotation.static.toDomElements = function ( dataElement, doc ) {
42 const nodeName = ve.getProp( dataElement, 'attributes', 'nodeName' );
43
44 return [ doc.createElement( nodeName || this.matchTagNames[ 0 ] ) ];
45 };
46
47 ve.dm.TextStyleAnnotation.static.description = null;
48
49 /* Methods */
50
51 /**
52 * @return {Object}
53 */
54 ve.dm.TextStyleAnnotation.prototype.getComparableObject = function () {
55 return { type: this.getType() };
56 };
57
58 ve.dm.TextStyleAnnotation.prototype.describeAdded = function () {
59 if ( this.constructor.static.description ) {
60 return [ ve.msg( 'visualeditor-changedesc-textstyle-added', OO.ui.resolveMsg( this.constructor.static.description ) ) ];
61 }
62 return [];
63 };
64
65 ve.dm.TextStyleAnnotation.prototype.describeRemoved = function () {
66 if ( this.constructor.static.description ) {
67 return [ ve.msg( 'visualeditor-changedesc-textstyle-removed', OO.ui.resolveMsg( this.constructor.static.description ) ) ];
68 }
69 return [];
70 };
71
72 /* Registration */
73
74 ve.dm.modelRegistry.register( ve.dm.TextStyleAnnotation );