OO-PG0011
Plug-In: Grid Lines
This plug-in displays a form for controlling the display and color of the outline’s vertical and horizontal grid lines.
Return to: OmniOutliner Plug-In Collection
Grid Lines
/*{
"type": "action",
"targets": ["omnioutliner"],
"author": "Otto Automator",
"identifier": "com.omni-automation.oo.grid-lines",
"version": "1.0",
"description": "Control the display and color of the outline’s vertical and horizontal grid lines.",
"label": "Grid Lines",
"shortLabel": "Grid Lines",
"paletteLabel": "Grid Lines",
"image": "grid"
}*/
(() => {
const action = new PlugIn.Action(async function(selection, sender){
// action code
// selection options: columns, document, editor, items, nodes, outline, styles
try {
var lineColorOptions = ["None", "Black", "Gray", "White", "Red", "Green", "Blue"]
var lineColorValues = [null, Color.black, Color.gray, Color.white, Color.red, Color.green, Color.blue]
verticalLinesMenu = new Form.Field.Option(
"verticalLines",
"Vertical",
[0, 1, 2, 3, 4, 5, 6],
lineColorOptions,
0
)
horizontalLinesMenu = new Form.Field.Option(
"horizontalLines",
"Horizontal",
[0, 1, 2, 3, 4, 5, 6],
lineColorOptions,
0
)
// CREATE NEW FORM AND ADD FIELD
inputForm = new Form()
inputForm.addField(verticalLinesMenu)
inputForm.addField(horizontalLinesMenu)
// VALIDATE USER INPUT
inputForm.validate = function(formObject){
return true
}
// DISPLAY THE FORM
formPrompt = "Select grid line options:"
buttonTitle = "Continue"
formObject = await inputForm.show(formPrompt, buttonTitle)
// RETRIVE FORM INPUT
verticalIndex = formObject.values["verticalLines"]
horizontalIndex = formObject.values["horizontalLines"]
verticalGridColor = lineColorValues[verticalIndex]
horizontalGridColor = lineColorValues[horizontalIndex]
}
catch(err){
if(!err.causedByUserCancelling){
new Alert(err.name, err.message).show()
}
}
});
action.validate = function(selection, sender){
// validation code
// selection options: columns, document, editor, items, nodes, outline, styles
return true
};
return action;
})();