OO-PG0013
Plug-In: Column Title Alignment
Presents a form for selecting the alignment to use for column titles. Options are: Left, Center, Right, and Clear All Alignments
Return to: OmniOutliner Plug-In Collection
Column Title Alignment
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Otto Automator",
"identifier": "com.omni-automation.oo.column-title-alignment",
"version": "1.0",
"description": "Presents a form for selecting the alignment to use for column titles. Options are: Left, Center, Right, and Clear All Alignments",
"label": "Title Alignment",
"shortLabel": "Titles",
"paletteLabel": "Titles",
"image": "align.horizontal.center"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
try {
try {document.name} catch(err){
throw {
name:"Missing Resource",
message:"No outline document is open."
}
}
inputForm = new Form()
alignmentOptions = ["Left", "Center", "Right", "Clear"]
alignmentMenu = new Form.Field.Option(
"alignmentValue",
"Align",
[0, 1, 2, 3],
alignmentOptions,
1
)
inputForm.addField(alignmentMenu)
inputForm.validate = function(formObject){
return true
}
formPrompt = "Title Alignment:"
formButtom = "Apply"
formObject = await inputForm.show(formPrompt, formButtom)
alignmentIndex = formObject.values["alignmentValue"]
switch(alignmentIndex) {
case 0:
var alignmentValue = TextAlignment.Left
break;
case 1:
var alignmentValue = TextAlignment.Center
break;
case 2:
var alignmentValue = TextAlignment.Right
break;
case 3:
var alignmentValue = null
}
columnTitleStyle.set(Style.Attribute.ParagraphAlignment, alignmentValue)
}
catch(err){
if(!err.causedByUserCancelling){
console.error(err.name, err.message)
new Alert(err.name, err.message).show()
}
}
});
action.validate = function(selection, sender){
return true
};
return action;
})();