Plug-In: Reset Paragraph Attributes Apple Vision Pro

A plug-in for restoring the paragraph 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 paragraph attributes:

Return to: OmniFocus Plug-In Collection

Reset Paragraph Attributes
   

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.note-paragraph-defaults", "version": "1.2", "description": "This plug-in will format the rich text of the note of the selected project or task.", "label": "Note Paragraph Defaults", "shortLabel": "Paragraph Defaults", "paletteLabel": "Paragraph Defaults", "image": "parkingsign.circle" }*/ (() => { 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) // PARAGRAPH ATTRIBUTES var pAtts = [ Style.Attribute.ParagraphBaseWritingDirection, Style.Attribute.ParagraphAlignment, Style.Attribute.ParagraphFirstLineHeadIndent, Style.Attribute.ParagraphHeadIndent, Style.Attribute.ParagraphLineHeightMultiple, Style.Attribute.ParagraphLineSpacing, Style.Attribute.ParagraphMaximumLineHeight, Style.Attribute.ParagraphMinimumLineHeight, Style.Attribute.ParagraphSpacing, Style.Attribute.ParagraphSpacingBefore, Style.Attribute.ParagraphDefaultTabInterval, Style.Attribute.ParagraphTabStops, Style.Attribute.ParagraphTailIndent ] // 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) pAtts.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; })();