@extendscript/ind.util.menuloader
v1.0.1
Published
A tool to load InDesign menus.
Downloads
5
Readme
menuloader
InDesign Utility
A tool to load InDesign menus.
Install
npm install @extendscript/ind.util.menuloader
Use
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
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() )
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 myTarget
We keep a log of test results
More info
Read the docs