mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
9aa22ca0e2
* Source-based round-tripping now uses typeof="mw:Placeholder" instead of data-gen. * mw:Image is supported for round-tripping, but not yet for modifications as it is still source-based Change-Id: Ie5cf4e54de0163168c25c2b5c09380657a15970f
30 lines
710 B
JavaScript
30 lines
710 B
JavaScript
/**
|
|
*/
|
|
|
|
function BehaviorSwitchHandler( manager, isInclude ) {
|
|
this.manager = manager;
|
|
this.manager.addTransform( this.onBehaviorSwitch.bind( this ), "BehaviorSwitchHandler:onBehaviorSwitch", this.rank, 'tag', 'behavior-switch' );
|
|
}
|
|
|
|
BehaviorSwitchHandler.prototype.rank = 2.14;
|
|
|
|
BehaviorSwitchHandler.prototype.onBehaviorSwitch = function ( token, manager, cb ) {
|
|
var env = this.manager.env,
|
|
magic_word = token.attribs[0].v;
|
|
|
|
env.setVariable(magic_word, true);
|
|
|
|
return { tokens:
|
|
[
|
|
new SelfclosingTagTk( 'meta',
|
|
[ new KV( 'typeof', 'mw:Placeholder' ) ],
|
|
token.dataAttribs )
|
|
]
|
|
};
|
|
};
|
|
|
|
|
|
if (typeof module == "object") {
|
|
module.exports.BehaviorSwitchHandler = BehaviorSwitchHandler;
|
|
}
|