Tutorial: How to Remove a Toolbar Button

How to Remove a Toolbar Button

When oXygen XML Web Author is used for a group of users that are not supposed to perform some action, you can enforce this by removing it completely from the user interface.

For example, when used as a review tool, the reviewers should change tracking support should be turned on by default, and the reviewers should not be able to turn it off. To achieve this, you can enable change tracking from the Administration Page and remove the "Toggle Change Tracking" action from the toolbar.

In order to remove an action from the toolbar and to prevent it from being performed using any other method (e.g. context menu, shortcut key) you can the code snippet below:

var actionId = 'Author/TrackChanges';
goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function(e) {
  var editor = e.editor;
  goog.events.listen(editor, sync.api.Editor.EventTypes.ACTIONS_LOADED, function(e) {
    editor.getActionsManager().unregisterAction(actionId);
  });
});

In order to find the action ID, follow one of the approaches below:

  1. Inspect the corresponding toolbar button using your browser Dev Tools and look for the "name" attribute of the corresponding div. The HTML will look something like:
`<div class="goog-inline-block goog-toolbar-button" title="Toggle Change Tracking" role="button" name="Author/TrackChanges">`
  1. Open an XML document in Web Author, go to the Console tab of the browser Dev Tools and use the following command to list the IDs of all the available actions:
`workspace.currentEditor.getActionsManager().actionsById.keys_`