mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Merge "Use .static.isMeta to communicate meta-ness"
This commit is contained in:
commit
a1bd1db241
|
@ -29,6 +29,8 @@ ve.inheritClass( ve.dm.MetaNode, ve.dm.LeafNode );
|
|||
|
||||
ve.dm.MetaNode.static.name = 'meta';
|
||||
|
||||
ve.dm.MetaNode.static.isMeta = true;
|
||||
|
||||
ve.dm.MetaNode.static.matchTagNames = [ 'meta', 'link' ];
|
||||
|
||||
ve.dm.MetaNode.static.toDataElement = function ( domElement, context ) {
|
||||
|
|
|
@ -68,7 +68,10 @@ ve.dm.Document = function VeDmDocument( data, parentDocument ) {
|
|||
// Track the length
|
||||
textLength++;
|
||||
} else {
|
||||
if ( this.data[i].type === 'metaInline' || this.data[i].type === 'metaBlock' ) {
|
||||
if (
|
||||
this.data[i].type.charAt( 0 ) !== '/' &&
|
||||
ve.dm.nodeFactory.isNodeMeta( this.data[i].type )
|
||||
) {
|
||||
// Metadata
|
||||
// Splice the meta element and its closing out of the linmod
|
||||
meta = this.data[i];
|
||||
|
|
|
@ -139,6 +139,17 @@ ve.dm.Node.static.toDomElement = function ( /*dataElement*/ ) {
|
|||
throw new Error( 've.dm.Node subclass must implement toDomElement' );
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether this node type represents metadata.
|
||||
*
|
||||
* Linear model elements with this type will be moved out of the linear model into the metadata.
|
||||
*
|
||||
* @static
|
||||
* @property {Boolean} static.isMeta
|
||||
* @inheritable
|
||||
*/
|
||||
ve.dm.Node.static.isMeta = false;
|
||||
|
||||
/**
|
||||
* Whether this node type has a wrapping element in the linear model. Most node types are wrapped,
|
||||
* only special node types are not wrapped.
|
||||
|
|
|
@ -109,6 +109,21 @@ ve.dm.NodeFactory.prototype.canNodeHaveGrandchildren = function ( type ) {
|
|||
throw new Error( 'Unknown node type: ' + type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a node represents metadata.
|
||||
*
|
||||
* @method
|
||||
* @param {string} type Node type
|
||||
* @returns {boolean} The node is meta
|
||||
* @throws {Error} Unknown node type
|
||||
*/
|
||||
ve.dm.NodeFactory.prototype.isNodeMeta = function ( type ) {
|
||||
if ( type in this.registry ) {
|
||||
return this.registry[type].static.isMeta;
|
||||
}
|
||||
throw new Error( 'Unknown node type: ' + type );
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a node has a wrapped element in the document data.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue