Requiring Objects

You can use the require function to get various objects from Content Studio:

notifier

You can use this object to display notification messages in Content Studio (see Hello World).

actions

You can use this object to create your own menu items and shortcuts, which you can then add to Content Studio menus.

content-studio

This object represents the whole Content Studio application and you can use it to:

  • Open and close content editors.

  • Create and display your own side panels (which appear in the same area as the Sections, Search and Clipboard panels).

  • Open browser windows.

  • Listen for various events and do something when they occur.

Using the actions object

Try this:

actions = require('actions');
myaction = actions.createAction('My Action', 'shortcut M');
actions.addAction(myaction, 'file');

Now look at the File menu. Your action should appear at the bottom of the menu:

graphics/my-action.png

The Action object you have created also has methods - you can, for example, enable and disable the menu option using its enabled method:

myaction.enabled(false);

The menu entry should now be disabled. To re-enable it, enter:

myaction.enabled(true);
Using the content-studio object

You can get access to the content-studio object and use its methods in just the same way. This code, for example, opens your default browser and displays a web page:

cs = require('content-studio');
cs.browse('http://www.escenic.com');