2012-07-19 00:11:26 +00:00
|
|
|
/**
|
|
|
|
* VisualEditor data model TableNode 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-02-06 23:50:56 +00:00
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* DataModel node for a table.
|
|
|
|
*
|
2012-02-06 23:50:56 +00:00
|
|
|
* @class
|
|
|
|
* @constructor
|
|
|
|
* @extends {ve.dm.BranchNode}
|
2012-06-20 01:20:28 +00:00
|
|
|
* @param {ve.dm.BranchNode[]} [children] Child nodes to attach
|
|
|
|
* @param {Object} [attributes] Reference to map of attribute key/value pairs
|
2012-08-16 17:53:33 +00:00
|
|
|
* @param {Object} [internal] Reference to internal data object
|
2012-02-06 23:50:56 +00:00
|
|
|
*/
|
2012-08-16 17:53:33 +00:00
|
|
|
ve.dm.TableNode = function ( children, attributes, internal ) {
|
2012-02-06 23:50:56 +00:00
|
|
|
// Inheritance
|
2012-08-16 17:53:33 +00:00
|
|
|
ve.dm.BranchNode.call( this, 'table', children, attributes, internal );
|
2012-02-06 23:50:56 +00:00
|
|
|
};
|
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/* Static Members */
|
2012-02-06 23:50:56 +00:00
|
|
|
|
|
|
|
/**
|
2012-06-20 01:20:28 +00:00
|
|
|
* Node rules.
|
|
|
|
*
|
|
|
|
* @see ve.dm.NodeFactory
|
|
|
|
* @static
|
|
|
|
* @member
|
2012-02-06 23:50:56 +00:00
|
|
|
*/
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.TableNode.rules = {
|
|
|
|
'isWrapped': true,
|
|
|
|
'isContent': false,
|
|
|
|
'canContainContent': false,
|
2012-07-24 00:10:03 +00:00
|
|
|
'childNodeTypes': ['tableSection'],
|
2012-06-20 01:20:28 +00:00
|
|
|
'parentNodeTypes': null
|
2012-02-06 23:50:56 +00:00
|
|
|
};
|
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/**
|
|
|
|
* Node converters.
|
|
|
|
*
|
|
|
|
* @see {ve.dm.Converter}
|
|
|
|
* @static
|
|
|
|
* @member
|
|
|
|
*/
|
|
|
|
ve.dm.TableNode.converters = {
|
|
|
|
'domElementTypes': ['table'],
|
2012-08-07 01:50:44 +00:00
|
|
|
'toDomElement': function ( type, element ) {
|
2012-06-20 01:20:28 +00:00
|
|
|
return document.createElement( 'table' );
|
|
|
|
},
|
2012-08-07 01:50:44 +00:00
|
|
|
'toDataElement': function ( tag, element ) {
|
2012-06-20 01:20:28 +00:00
|
|
|
return { 'type': 'table' };
|
|
|
|
}
|
|
|
|
};
|
2012-02-06 23:50:56 +00:00
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
/* Registration */
|
2012-02-06 23:50:56 +00:00
|
|
|
|
2012-06-20 01:20:28 +00:00
|
|
|
ve.dm.nodeFactory.register( 'table', ve.dm.TableNode );
|
2012-02-06 23:50:56 +00:00
|
|
|
|
|
|
|
/* Inheritance */
|
|
|
|
|
|
|
|
ve.extendClass( ve.dm.TableNode, ve.dm.BranchNode );
|