OO-PG0003

Plug-In: Strikethrough

A plug-in for applying or removing strikethrough to the selected text or row.

By default, when the plug-n is activated it will present an alert with options to select whether to apply or remove strikethrough.

Holding down the Shift (⇧) key when launching the plug-in will bypass the alert and apply strikethrough to the text.

Holding down the Option (⌥) key when launching the plug-in will bypass the alert and remove strikethrough from the text.

Return to: OmniOutliner Plug-In Collection

Video: Apply and Remove Strikethrough
Demonstrates the use of a plug-in for applying or removing strikethrough to the selected text or row.
Strikethrough: Apply|Remove
 

/*{ "type": "action", "targets": ["omnioutliner"], "author": "Otto Automator", "identifier": "com.omni-automation.oo.apply-remove-strikethrough", "version": "1.0", "description": "This plug-in will apply or remove strikethrough to the selected text or the topic text of the selected row. If shift key is pressed, strikethrough will be applied. If option key is pressed, strikethrough will be removed. Otherwise, an alert will be displayed with options.", "label": "Strike: Apply|Remove", "shortLabel": "Strikethrough", "paletteLabel": "Strikethrough", "image":"strikethrough" }*/ (() => { const action = new PlugIn.Action(async function(selection, sender){ // action code var style = selection.styles[0] if(app.shiftKeyDown){ // APPLY STRIKETHROUGH style.set(Style.Attribute.StrikethroughStyle, UnderlineStyle.Single) } else if (app.optionKeyDown){ // REMOVE STRIKETHROUGH style.set(Style.Attribute.StrikethroughStyle, UnderlineStyle.None) } else { var alert = new Alert("Strikethrough", "Apply or remove?") alert.addOption("Apply") alert.addOption("Remove") alert.addOption("Cancel") alert.show(function(result){ if (result == 0){ style.set(Style.Attribute.StrikethroughStyle, UnderlineStyle.Single) } else if (result == 1){ style.set(Style.Attribute.StrikethroughStyle, UnderlineStyle.None) } }) } }); action.validate = function(selection, sender){ // validation code if (selection.items.length === 1){ if (sender instanceof MenuItem || sender instanceof ToolbarItem){ if(app.shiftKeyDown){ var menuText = "Strike: Apply" } else if (app.optionKeyDown){ var menuText = "Strike: Remove" } else { var menuText = "Strike: Apply|Remove" } sender.label = menuText } return true } else { if (sender instanceof MenuItem || sender instanceof ToolbarItem){sender.label = 'Strike: Apply|Remove'} return false } }; return action; })();