mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Allow extension nodes to convert to a specified type of dataElement"
This commit is contained in:
commit
ed2a6b873e
|
@ -59,13 +59,19 @@ ve.dm.MWExtensionNode.static.getMatchRdfaTypes = function () {
|
||||||
return [ 'mw:Extension/' + this.extensionName ];
|
return [ 'mw:Extension/' + this.extensionName ];
|
||||||
};
|
};
|
||||||
|
|
||||||
ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter ) {
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
* @param {Node[]} domElements
|
||||||
|
* @param {ve.dm.Converter} converter
|
||||||
|
* @param {string} [type] Type to give dataElement, defaults to static.name
|
||||||
|
*/
|
||||||
|
ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter, type ) {
|
||||||
var dataElement,
|
var dataElement,
|
||||||
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' ),
|
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' ),
|
||||||
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
|
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
|
||||||
|
|
||||||
dataElement = {
|
dataElement = {
|
||||||
type: this.name,
|
type: type || this.name,
|
||||||
attributes: {
|
attributes: {
|
||||||
mw: mwData,
|
mw: mwData,
|
||||||
originalMw: mwDataJSON
|
originalMw: mwDataJSON
|
||||||
|
@ -73,6 +79,7 @@ ve.dm.MWExtensionNode.static.toDataElement = function ( domElements, converter )
|
||||||
};
|
};
|
||||||
|
|
||||||
this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
this.storeGeneratedContents( dataElement, domElements, converter.getStore() );
|
||||||
|
// Sub-classes should not modify dataElement beyond this point as it will invalidate the cache
|
||||||
|
|
||||||
return dataElement;
|
return dataElement;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue