A tool to load InDesign menus.
npm install @extendscript/ind.util.menuloader
> InDesign Utility
A tool to load InDesign menus.
``
npm install @extendscript/ind.util.menuloader
`
`
#include 'node_modules/@extendscript/ind.util.menuloader/menuloader.js'
`
`javascript
// Load the module by creating a reference.
var Menuloader = Sky.getUtil("menuloader")
`
Options
* __path__ (Array, Optional)undefined
- Path to main menu, leave for InDesign's main menuArray
* __sub__ (, Optional)menuItem
- The template's submenu. (s)LocationOptions
* __loc__ (, Optional)path
- Location option for or ref below.menuItem
* __ref__ (, Optional)lastItem()
- A reference menu item (Defaults to )Function
* __fun__ (, Optional)path
- The action for main menu (). Used when sub is undefined
`javascript
// 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)sub
- Add element to menucaption
* __createItem__ (Param , fun, subName)elementTemplate
- Creates an for type menuItemsubName
* __createSeparator__ (Param , Optional)elementTemplate
- Creates an for type menuSeparator
`javascript
myMenu.addElement( myMenu.createSeparator() )
`
`javascript
// Load the menu into InDesign's Main menu
myMenu.load();
`
#### Unloading
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:
`javascript
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:
`javascript
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