1.0.1 • Published 7 years ago
@extendscript/ind.util.menuloader v1.0.1
menuloader
InDesign Utility
A tool to load InDesign menus.
Install
npm install @extendscript/ind.util.menuloaderUse
1. Include
#include 'node_modules/@extendscript/ind.util.menuloader/menuloader.js'2. Load
// Load the module by creating a reference.
var Menuloader = Sky.getUtil("menuloader")3. Define menu
Options
- path (
Array, Optional)- Path to main menu, leave
undefinedfor InDesign's main menu
- Path to main menu, leave
- sub (
Array, Optional)- The template's submenu. (
menuItems)
- The template's submenu. (
- loc (
LocationOptions, Optional)- Location option for
pathorrefbelow.
- 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 whensubisundefined
- 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
submenu
- Add element to
- createItem (Param
caption,fun,subName)- Creates an
elementTemplatefor typemenuItem
- Creates an
- createSeparator (Param
subName, Optional)- Creates an
elementTemplatefor typemenuSeparator
- Creates an
myMenu.addElement( myMenu.createSeparator() )3. Load
// 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:
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)Test
We can test the code against a range of targets:
npm run test myTargetWe keep a log of test results
More info
Read the docs