Class: AbstractAction

sync.actions.AbstractAction

new AbstractAction(keystrokeStr)

The base class for the editor actions. Besides the action behavior, this class also specifies how the buttons that trigger the action should be rendered. This rendering is represented by an action display name, a description (usually presented on a tooltip), and some icons to be rendered depending on the button size.
Parameters:
Name Type Description
keystrokeStr string the string representation of the shortcut of the action.
Source:

Methods

actionPerformed(callback)

Abstract method that executes the action.
Parameters:
Name Type Description
callback function A function to call after the action was performed to notify the editor that the action was finished. It must be called even when the action finished with an error.
Source:

getDescription() → {string}

Returns the description for the action - usually displayed on a tooltip.
Source:
Returns:
The description.
Type
string

getDisplayName() → {string}

Returns the display name for the action.
Source:
Returns:
The display name.
Type
string

(protected) getLargeIcon(devicePixelRationopt) → {string}

One should override this method to provide the absolute URL of the action's large icon.

When the action is defined in a framework, one can use the sync.ext.Registry.extensionURL to refer images inside the framework's web folder folder. When used inside a plugin, one may also want to expose a directory with static resources using a WebappStaticResourcesFolder extension.

The large icon should have a minimum size of 24 by 24 px for non-hidpi displays and can vary depending on the device pixel ration, the icon being used as the background of a 24 by 24 px DIV.

Parameters:
Name Type Attributes Description
devicePixelRation number <optional>
the device pixel ratio.
Source:
Returns:
The icon.
Type
string

getShortcut() → {string}

Returns the shortcut, represented as a string. E.g. "Ctrl B", "Alt Shift T". The shortcut may use platform-independent modifiers M1 to M4.
Source:
Returns:
the string representation of the shortcut. If there is no shortcut, returns an empty string.
Type
string

(protected) getSmallIcon(devicePixelRationopt) → {string}

One should override this method to provide the absolute URL of the action's small icon.

When the action is defined in a framework, one can use the sync.ext.Registry.extensionURL to refer images inside the framework's web folder folder. When used inside a plugin, one may also want to expose a directory with static resources using a WebappStaticResourcesFolder extension.

The small icon should have a minimum size of 16 by 16 px for non-hidpi displays and can vary depending on the device pixel ration, the small icon being used as the background of a 16px by 16px div.

Parameters:
Name Type Attributes Description
devicePixelRation number <optional>
the device pixel ratio.
Source:
Returns:
The icon.
Type
string

isEnabled() → {boolean}

Tells whether the action is enabled. Note: The action is not permanently polled for its "enabled-ness". If you want the GUI to reflect the current status you will have to call sync.api.ActionsManager#refreshActionsStatus.
Source:
Returns:
Whether the action is enabled.
Type
boolean

renderLargeIcon() → {Element}

This method renders the large icon of the action in a 24px by 24px div with the action's large icon as its background. This allows the getLargeIcon() method to return different sized icons depending on the device pixel ration, the size constraints being imposed by the enclosing DIV. It should be overridden only for custom rendering strategies, otherwise consider using the getLargeIcon method.
Source:
Returns:
the rendering of the large icon image.
Type
Element

renderSmallIcon() → {HTMLElement}

This method renders the small icon of the action in a 16px by 16px DIV with the action's small icon as its background. This allows the getSmallIcon() method to return different sized icons depending on the device pixel ration, the size constraints being imposed by the enclosing DIV. It should be overridden only for custom rendering strategies, otherwise consider using the getSmallIcon method.
Source:
Returns:
the rendering of the small icon image.
Type
HTMLElement