InDesign Utility
A tool to load InDesign menus.
npm install @extendscript/ind.util.menuloader
#include 'node_modules/@extendscript/ind.util.menuloader/menuloader.js'
// Load the module by creating a reference.
var Menuloader = Sky.getUtil("menuloader")
Options
- path (
Array
, Optional)- Path to main menu, leave
undefined
for InDesign's main menu
- Path to main menu, leave
- sub (
Array
, Optional)- The template's submenu. (
menuItem
s)
- The template's submenu. (
- loc (
LocationOptions
, Optional)- Location option for
path
orref
below.
- Location option for
- ref (
menuItem
, Optional)- A reference menu item (Defaults to
lastItem()
)
- A reference menu item (Defaults to
- fun (
Function
, Optional)- The action for main menu (
path
). Used whensub
isundefined
- The action for main menu (
// Load the template with the options defined
var myMenu = new Menuloader.template( menuName, Options );
If you can define the sub
menu in your options or use the templates build in functions.
- addElement (Param
elementTemplate
)- Add element to
sub
menu
- Add element to
- createItem (Param
caption
,fun
,subName
)- Creates an
elementTemplate
for typemenuItem
- Creates an
- createSeparator (Param
subName
, Optional)- Creates an
elementTemplate
for typemenuSeparator
- Creates an
myMenu.addElement( myMenu.createSeparator() )
// Load the menu into InDesign's Main menu
myMenu.load();
To remove your menu call `myMenu.unload()`
If you lost the reference to your original template you can unload the menu by creating a new template (You don't need to define the sub menu's) just the name and path to menu:
var unloadMenu = new MenuLoader.template("My Menu", {path: "File"});
MenuLoader.unload(unloadMenu);
Note that if you have the reference to the loaded menu you can also call unloadElement which will unload any menuElement it is given:
Menuloader.unloadElement(menuElement)
We can test the code against a range of targets:
npm run test myTarget
We keep a log of test results
Read the docs