2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor content editable NodeFactory class.
|
2012-07-19 21:25:16 +00:00
|
|
|
*
|
2012-07-19 00:11:26 +00:00
|
|
|
* @copyright 2011-2012 VisualEditor Team and others; see AUTHORS.txt
|
|
|
|
* @license The MIT License (MIT); see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2012-04-30 23:36:02 +00:00
|
|
|
/**
|
|
|
|
* ContentEditable node factory.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-30 23:36:02 +00:00
|
|
|
* @class
|
2012-05-31 23:50:16 +00:00
|
|
|
* @extends {ve.Factory}
|
2012-04-30 23:36:02 +00:00
|
|
|
* @constructor
|
|
|
|
*/
|
2012-08-07 01:50:44 +00:00
|
|
|
ve.ce.NodeFactory = function () {
|
2012-04-30 23:36:02 +00:00
|
|
|
// Inheritance
|
2012-05-31 23:50:16 +00:00
|
|
|
ve.Factory.call( this );
|
2012-04-30 23:36:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Methods */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks if a given node type can be split.
|
2012-05-14 22:05:09 +00:00
|
|
|
*
|
2012-04-30 23:36:02 +00:00
|
|
|
* @param {String} type Node type
|
|
|
|
* @returns {Boolean} The node can have grandchildren
|
|
|
|
* @throws 'Unknown node type'
|
|
|
|
*/
|
2012-08-07 01:50:44 +00:00
|
|
|
ve.ce.NodeFactory.prototype.canNodeBeSplit = function ( type ) {
|
2012-04-30 23:36:02 +00:00
|
|
|
if ( type in this.registry ) {
|
|
|
|
return this.registry[type].rules.canBeSplit;
|
|
|
|
}
|
2012-08-06 20:38:00 +00:00
|
|
|
throw new ve.Error( 'Unknown node type: ' + type );
|
2012-04-30 23:36:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
2012-05-31 23:50:16 +00:00
|
|
|
ve.extendClass( ve.ce.NodeFactory, ve.Factory );
|
2012-04-30 23:36:02 +00:00
|
|
|
|
|
|
|
/* Initialization */
|
|
|
|
|
2012-05-31 22:20:58 +00:00
|
|
|
ve.ce.nodeFactory = new ve.ce.NodeFactory();
|