mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-29 08:34:54 +00:00
a85ed36efa
behavior switches are converted to tokens which set parser.environment flags during the async transformation stage. The next step would be for handlers in the sync23 stage to generate the TOC, section edit links, and so on according to these directives. No tests written, because the switches are consumed and don't appear in rendered html. We can test the magic word layout controls individually, once they're implemented. Another small change was to store option flags directly in the environment object, not that it makes much difference. Change-Id: I863fbf4be1a17d2f6c31158298dd301f19ae1137
24 lines
544 B
JavaScript
24 lines
544 B
JavaScript
/**
|
|
*/
|
|
|
|
function BehaviorSwitchHandler( manager, isInclude ) {
|
|
this.manager = manager;
|
|
this.manager.addTransform( this.onBehaviorSwitch.bind( this ), this.rank, 'tag', 'behavior-switch' );
|
|
}
|
|
|
|
BehaviorSwitchHandler.prototype.rank = 1.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 { };
|
|
};
|
|
|
|
|
|
if (typeof module == "object") {
|
|
module.exports.BehaviorSwitchHandler = BehaviorSwitchHandler;
|
|
}
|