Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | 1x 118x 118x 1x 1x 1x 118x 118x 1x 143x 143x 143x 143x 1x 25x 1x | /*!
* VisualEditor ContentEditable HeadingNode class.
*
* @copyright See AUTHORS.txt
*/
/**
* ContentEditable heading node.
*
* @class
* @extends ve.ce.ContentBranchNode
* @constructor
* @param {ve.dm.HeadingNode} model Model to observe
* @param {Object} [config] Configuration options
*/
ve.ce.HeadingNode = function VeCeHeadingNode() {
// Parent constructor
ve.ce.HeadingNode.super.apply( this, arguments );
// Events
this.model.connect( this, { update: 'onUpdate' } );
};
/* Inheritance */
OO.inheritClass( ve.ce.HeadingNode, ve.ce.ContentBranchNode );
/* Static Properties */
ve.ce.HeadingNode.static.name = 'heading';
/* Methods */
/**
* @inheritdoc
*/
ve.ce.HeadingNode.prototype.initialize = function () {
ve.ce.HeadingNode.super.prototype.initialize.call( this );
this.$element.addClass( 've-ce-headingNode' );
};
/**
* Get the HTML tag name.
*
* Tag name is selected based on the model's level attribute.
*
* @return {string} HTML tag name
* @throws {Error} If level is invalid
*/
ve.ce.HeadingNode.prototype.getTagName = function () {
const level = this.model.getAttribute( 'level' ),
types = { 1: 'h1', 2: 'h2', 3: 'h3', 4: 'h4', 5: 'h5', 6: 'h6' };
Iif ( !Object.prototype.hasOwnProperty.call( types, level ) ) {
throw new Error( 'Invalid level' );
}
return types[ level ];
};
/**
* Handle model update events.
*
* If the level changed since last update the DOM wrapper will be replaced with an appropriate one.
*/
ve.ce.HeadingNode.prototype.onUpdate = function () {
this.updateTagName();
};
/* Registration */
ve.ce.nodeFactory.register( ve.ce.HeadingNode );
|