Plug-In: Reset Character Attributes
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:
- Font Family (String) • The name of the font family to be applied to the note. The cross-platform typeface options are; "Default", "Avenir Next", "Baskerville", "Bodoni 72", "Bradley Hand", "Chalkboard SE", "Cochin", "Courier New", "Damascus", "Georgia", "Gill Sans", "Helvetica Neue", "Hoefler Text", "Menlo", "Noteworthy", "Optima", "Palatino", "Rockwell", "Savoye LET", "Snell Roundhand", "Times New Roman", "Trebuchet MS", and "Verdana"
- Font Weight (Number) • This value, from 1 through 9, indicates the thickness of the typeface. Light-thin variations are usually 1-2, book or regular variations are usually 3-5, and the higher settings are for bold. Use the System Font Panel (⌘T) to confirm.
- Font Size (Number) • The size (in points) to be used. Options include: "Default", "9", "10", "11", "12", "13", "14", "15", "16", "18", "24"
- Kerning Adjustment (Number) • Controls the space between characters. For example, some of the lighter typeface when used at a larger type size, require slight positive (increased) kerning to display well. Options include: "Default", "+3", "+2", "+1", " 0", "-1", "-2", and "-3"
- Color Shade (Percent) • Whe used, this setting will cause the note text to display as a shade of black (or white for Dark Mode). Options are (%): "Default", "100", "95", "90", "85", "80", "75", "70"
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;
})();