Debian Codegraph @

extensions/VisualEditor/lib/ve/src/ce/ve.ce.TableCellableNode.js

raw symbols SCIP
1 /*!
2 * VisualEditor ContentEditable TableCellableNode class.
3 *
4 * @copyright See AUTHORS.txt
5 */
6
7 /**
8 * ContentEditable node which can behave as a table cell
9 *
10 * @class
11 *
12 * @abstract
13 * @constructor
14 */
15 ve.ce.TableCellableNode = function VeCeTableCellableNode() {
16 if ( this.isCellable() && !this.isCellEditable() ) {
17 this.$element.attr( 'title', ve.msg( 'visualeditor-aliennode-tooltip' ) );
18 }
19
20 this.$element.addClass( 've-ce-tableCellableNode' );
21 };
22
23 /* Inheritance */
24
25 OO.initClass( ve.ce.TableCellableNode );
26
27 /* Static Methods */
28
29 /* Methods */
30
31 /**
32 * Set the editing mode of a table cell node
33 *
34 * @param {boolean} enable Enable editing
35 */
36 ve.ce.TableCellableNode.prototype.setEditing = function () {
37 };
38
39 /**
40 * Get the HTML tag name.
41 *
42 * Tag name is selected based on the model's style attribute.
43 *
44 * @return {string} HTML tag name
45 * @throws {Error} Invalid style
46 */
47 ve.ce.TableCellableNode.prototype.getTagName = function () {
48 const style = this.model.getAttribute( 'style' ),
49 types = { data: 'td', header: 'th' };
50
51 if ( !Object.prototype.hasOwnProperty.call( types, style ) ) {
52 throw new Error( 'Invalid style' );
53 }
54 return types[ style ];
55 };