Debian Codegraph @

extensions/VisualEditor/lib/ve/src/dm/nodes/ve.dm.SectionNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor DataModel SectionNode class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * DataModel section node.
9 *
10 * @class
11 * @extends ve.dm.BranchNode
12 *
13 * @constructor
14 * @param {Object} [element] Reference to element in linear model
15 * @param {ve.dm.Node[]} [children]
16 */
17 ve.dm.SectionNode = function VeDmSectionNode() {
18 // Parent constructor
19 ve.dm.SectionNode.super.apply( this, arguments );
20 };
21
22 /* Inheritance */
23
24 OO.inheritClass( ve.dm.SectionNode, ve.dm.BranchNode );
25
26 /* Static Properties */
27
28 ve.dm.SectionNode.static.name = 'section';
29
30 ve.dm.SectionNode.static.isUnwrappable = false;
31
32 ve.dm.SectionNode.static.defaultAttributes = {
33 style: 'section'
34 };
35
36 ve.dm.SectionNode.static.matchTagNames = [ 'header', 'section', 'footer' ];
37
38 ve.dm.SectionNode.static.toDataElement = function ( domElements ) {
39 return { type: this.name, attributes: { style: domElements[ 0 ].nodeName.toLowerCase() } };
40 };
41
42 ve.dm.SectionNode.static.toDomElements = function ( dataElement, doc ) {
43 const style = dataElement.attributes && dataElement.attributes.style || 'section';
44 return [ doc.createElement( style ) ];
45 };
46
47 /* Methods */
48
49 ve.dm.SectionNode.prototype.canHaveSlugBefore = function () {
50 return false;
51 };
52
53 ve.dm.SectionNode.prototype.canHaveSlugAfter = function () {
54 return false;
55 };
56
57 /* Registration */
58
59 ve.dm.modelRegistry.register( ve.dm.SectionNode );