| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
ve.ce.NodeFactory = function VeCeNodeFactory() { |
| 15 |
|
| 16 |
OO.Factory.call( this ); |
| 17 |
}; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
OO.inheritClass( ve.ce.NodeFactory, OO.Factory ); |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
ve.ce.NodeFactory.prototype.getDescription = function ( node ) { |
| 33 |
const type = node.constructor.static.name; |
| 34 |
if ( Object.prototype.hasOwnProperty.call( this.registry, type ) ) { |
| 35 |
return this.registry[ type ].static.getDescription( node ); |
| 36 |
} |
| 37 |
throw new Error( 'Unknown node type: ' + type ); |
| 38 |
}; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
ve.ce.NodeFactory.prototype.splitNodeOnEnter = function ( type ) { |
| 48 |
if ( Object.prototype.hasOwnProperty.call( this.registry, type ) ) { |
| 49 |
return this.registry[ type ].static.splitOnEnter; |
| 50 |
} |
| 51 |
throw new Error( 'Unknown node type: ' + type ); |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
ve.ce.NodeFactory.prototype.createFromModel = function ( model ) { |
| 62 |
let type = model.getType(); |
| 63 |
if ( ve.dm.nodeFactory.isMetaData( type ) ) { |
| 64 |
|
| 65 |
|
| 66 |
type = 'meta'; |
| 67 |
} |
| 68 |
return this.create( type, model ); |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
ve.ce.nodeFactory = new ve.ce.NodeFactory(); |