Plug-In: Reset Character Attributes Apple Vision Pro

A plug-in for restoring the haracter attributes of the note of the selected project or task to their default values.

IMPORTANT: Attribute changes are applied to all of the note text, not just a selection.

Here is a description of each of the character attributes:

Return to: OmniFocus Plug-In Collection

Reset Character Attributes
   

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.note-character-defaults", "version": "1.1", "description": "This plug-in will set the value of the style Character-related attributes to their default values.", "label": "Note Character Defaults", "shortLabel": "Character Defaults", "paletteLabel": "Character Defaults", "image": "textformat.abc" }*/ (() => { var action = new PlugIn.Action(function(selection, sender){ // action code // selection options: tasks, projects, folders, tags, allObjects, databaseObjects var item = selection.databaseObjects[0] // reveal note tree = document.windows[0].content tree.nodeForObject(item).expandNote(false) // formatting var fAtts = [ Style.Attribute.FontCondensed, Style.Attribute.FontFamily, Style.Attribute.FontFillColor, Style.Attribute.FontFixedPitch, Style.Attribute.FontItalic, Style.Attribute.FontName, Style.Attribute.FontNarrow, Style.Attribute.FontSize, Style.Attribute.FontStrokeColor, Style.Attribute.FontStrokeWidth, Style.Attribute.FontWeight, Style.Attribute.KerningAdjustment, Style.Attribute.Obliqueness, Style.Attribute.BaselineOffset, Style.Attribute.BaselineSuperscript, Style.Attribute.Expansion ] // CREATE VIRTUAL TEXT OBJECT CONTAING CURRENT NOTE var noteObj = new Text("", baseStyle) noteObj.replace(noteObj.range, item.noteText) // GET ATTRIBUTE RUNS runRanges = noteObj.ranges(TextComponent.AttributeRuns) // PROCESS ATTRIBUTE RUNS runRanges.forEach(range => { runStyle = noteObj.styleForRange(range) fAtts.forEach(att => { runStyle.set(att, att.defaultValue) }) }) // REPLACE NOTE WITH VIRTUAL OBJECT item.noteText.replace(item.noteText.range, noteObj) }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, allObjects return (selection.tasks.length === 1 || selection.projects.length === 1 ) }; return action; })();