Skip to content

Latest commit

 

History

History

menuloader

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

menuloader

version

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
  • sub (Array, Optional)
    • The template's submenu. (menuItems)
  • loc (LocationOptions, Optional)
    • Location option for path or ref below.
  • ref (menuItem, Optional)
    • A reference menu item (Defaults to lastItem())
  • fun (Function, Optional)
    • The action for main menu (path). Used when sub is undefined
    // 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
  • createItem (Param caption, fun, subName)
    • Creates an elementTemplate for type menuItem
  • createSeparator (Param subName, Optional)
    • Creates an elementTemplate for type menuSeparator
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