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 73 74 75 | 1x 2x 1x 1x 2x 2x 1x 1x 1x 2x 1x 1x 1x 7328x 7328x 4x 7328x 1x | /*! * VisualEditor ContentEditable NodeFactory class. * * @copyright See AUTHORS.txt */ /** * ContentEditable node factory. * * @class * @extends OO.Factory * @constructor */ ve.ce.NodeFactory = function VeCeNodeFactory() { // Parent constructor OO.Factory.call( this ); }; /* Inheritance */ OO.inheritClass( ve.ce.NodeFactory, OO.Factory ); /* Methods */ /** * Get a plain text description of a node model. * * @param {ve.dm.Node} node Node to describe * @return {string} Description of the node * @throws {Error} Unknown node type */ ve.ce.NodeFactory.prototype.getDescription = function ( node ) { const type = node.constructor.static.name; if ( Object.prototype.hasOwnProperty.call( this.registry, type ) ) { return this.registry[ type ].static.getDescription( node ); } throw new Error( 'Unknown node type: ' + type ); }; /** * Check if a node type splits on Enter * * @param {string} type Node type * @return {boolean} The node can have grandchildren * @throws {Error} Unknown node type */ ve.ce.NodeFactory.prototype.splitNodeOnEnter = function ( type ) { if ( Object.prototype.hasOwnProperty.call( this.registry, type ) ) { return this.registry[ type ].static.splitOnEnter; } throw new Error( 'Unknown node type: ' + type ); }; /** * Create a view node from a model node. * * @param {ve.dm.Node} model Mode node * @return {ve.ce.Node} View node * @throws {Error} Unknown object name */ ve.ce.NodeFactory.prototype.createFromModel = function ( model ) { let type = model.getType(); if ( ve.dm.nodeFactory.isMetaData( type ) ) { // Metadata never has an explicit view representation, so a generic // ve.ce.MetaItem should be fine type = 'meta'; } return this.create( type, model ); }; /* Initialization */ // TODO: Move instantiation to a different file ve.ce.nodeFactory = new ve.ce.NodeFactory(); |