User:Yaron Koren/VEHighlight.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
* Add a "Highlight" option to the menu of formatting options in VisualEditor,
* which adds (or removes) a <mark> tag around the relevant text.
* This is somehow already half-supported (!), since (a) this code does not
* need to specify that <mark> is the tag for highlighting, and (b) a
* "highlight" icon is already present in OOUI. So our job here is easier than
* it would have been otherwise.
*
* @author Yaron Koren
*/
mw.libs.ve.targetLoader.addPlugin( function() {
/**
* UserInterface highlight tool.
*
* @class
* @extends ve.ui.AnnotationTool
* @constructor
* @param {OO.ui.ToolGroup} toolGroup
* @param {Object} [config] Configuration options
*/
ve.ui.HighlightAnnotationTool = function VeUiHighlightAnnotationTool() {
ve.ui.HighlightAnnotationTool.super.apply( this, arguments );
};
OO.inheritClass( ve.ui.HighlightAnnotationTool, ve.ui.AnnotationTool );
ve.ui.HighlightAnnotationTool.static.name = 'highlight';
ve.ui.HighlightAnnotationTool.static.group = 'textStyle';
ve.ui.HighlightAnnotationTool.static.icon = 'highlight';
ve.ui.HighlightAnnotationTool.static.title = "Highlight";
ve.ui.HighlightAnnotationTool.static.annotation = { name: 'textStyle/highlight' };
ve.ui.HighlightAnnotationTool.static.commandName = 'highlight';
ve.ui.toolFactory.register( ve.ui.HighlightAnnotationTool );
ve.ui.commandRegistry.register(
new ve.ui.Command(
'highlight', 'annotation', 'toggle',
{ args: [ 'textStyle/highlight' ], supportedSelections: [ 'linear', 'table' ] }
)
);
} );