Plug-In: Style “Syllabus”

(NOTE: This plug-in requires OmniFocus 4.x)

This plug-in will apply a set of style attributes to the note of the selected project or task.

Here are the available attribute settings of this style:

Return to: OmniFocus Plug-In Collection

Note Style: Syllabus
  

/*{ "type": "action", "targets": ["omnifocus"], "author": "Otto Automator", "identifier": "com.omni-automation.of.note-template-syllabus", "version": "1.7", "description": "This plug-in will format the rich text of the note of the selected project or task. To fully apply all parameters, use the reset plug-ins to reset existing settings to defaults.", "label": "Note Style “Syllabus”", "shortLabel": "Syllabus Style", "paletteLabel": "Syllabus Style", "image": "wand.and.stars" }*/ (() => { const action = new PlugIn.Action(function(selection, sender){ // ACTION CODE var deviceIsPhone = (Device.current.type === DeviceType.iPhone) ? true:false // SELECTION OPTIONS: TASKS, PROJECTS, FOLDERS, TAGS, ALLOBJECTS, DATABASEOBJECTS var item = selection.databaseObjects[0] // CREATE VIRTUAL TEXT OBJECT CONTAING CURRENT NOTE var noteObj = new Text("", baseStyle) noteObj.replace(noteObj.range, item.noteText) var nStyle = noteObj.style // GET ATTRIBUTES RANGES var runRanges = noteObj.ranges(TextComponent.AttributeRuns) // PROCESS THE ATTRIBUTE RANGES runRanges.forEach(range => { runStyle = noteObj.styleForRange(range) runStyle.set(Style.Attribute.FontFamily, 'Avenir Next') typeSize = (deviceIsPhone) ? 13:14 runStyle.set(Style.Attribute.FontSize, typeSize) runStyle.set(Style.Attribute.FontStrokeColor, Color.RGB(0, 0, 0, 1)) runStyle.set(Style.Attribute.FontFillColor, Color.RGB(0.15, 0.15, 0.15, 1)) runStyle.set(Style.Attribute.UnderlineColor, Color.RGB(0, 0, 0, 1)) runStyle.set(Style.Attribute.StrikethroughColor, Color.RGB(0, 0, 0, 1)) runStyle.set(Style.Attribute.ParagraphAlignment, TextAlignment.Left) runStyle.set(Style.Attribute.ParagraphMinimumLineHeight, 19.5) runStyle.set(Style.Attribute.ParagraphSpacingBefore, 8) runStyle.set(Style.Attribute.ParagraphLineSpacing, 3.5) // TURN OFF BACKGROUND COLOR, ALPHA = 0 runStyle.set(Style.Attribute.BackgroundColor, Color.RGB(1, 1, 1, 0)) }) // REPLACE NOTE WITH VIRTUAL OBJECT item.noteText.replace(item.noteText.range, noteObj) // REVEAL NOTE tree = document.windows[0].content tree.nodeForObject(item).expandNote(false) }); action.validate = function(selection, sender){ // validation code // selection options: tasks, projects, folders, tags, databaseObjects, allObjects return (selection.tasks.length === 1 || selection.projects.length === 1 ) }; return action; })();