Type: Object

Operations are the building blocks for all interaction with the application state of Fonto and the XML Fonto has loaded. Operations range from inserting text to opening sidebars or saving the document.

More information can be found in our Operations concept page. Also refer to our guide on creating operations.


Name Type Description
alternatives Array<String>

If set to a list of operation names, this operation will adopt the behavior of the first of these operations which is enabled. If alternatives is set, steps can not be used. Make sure to use either one.

[description] String

The description is used as tooltip text by UI elements using the operation.

[errorsAreFatal] Boolean

Determines whether failure of the operation should redirect to the error route. If false (the default value), a modal will be shown if the operation fails.

[getStateSteps] OperationStep | Array<OperationStep>

For operations with side-effects, it may be necessary to provide separate steps used to compute the state of the operation. Defaults to the steps of the operation, but using the getState callbacks for transforms and actions as appropriate.

[icon] String

The icon displayed by UI elements using the operation. This should be one of the FontAwesome (v5 Pro) icon names with an optional style prefix ('far ' is the default prefix). For more info, see the Font Awesome concept page.

[initialData] StepData

The data with which to start the steps and getStateSteps pipelines. This data is extended during the run of this operation.

[keyBinding] KeyBinding

Sets a keyboard listener that executes this operation when a particular combination is pressed. While it is possible to use a ctrl+b/cmd+b keybinding here, it would cause the shortcut win+b on Windows or super+b on Linux to also bind to the operation. Use osxKeyBinding if this should not happen. Please note that browser keybindings and OS keybindings are reserved and will take precedence over any keybinding you will configure for Fonto.

[keyBindingDisabled] Boolean

Prevents Fonto from actually listening for the keyboard combination, causing it to only be shown in the UI.

[keyBindingIsGlobal] Boolean

Allows the keyBinding to work in any part of Fonto, except when focusing the editor is not allowed (eg. when a Modal is opened). Normally a keyBinding for an operation only works when the content view is focussed. Warning: we only recommend using this for operations that do not modify the document. Changing the document is almost always done contextually to your cursor position or selection. If your operation keyBinding is global, your cursor or selection might not even be visible to the user (because they scrolled their viewport), which might result in a change to the document that the user is unaware of because they (accidentally) triggered a global keyBinding.

[label] String

The label used when the operation is used in a UI element such as a button or menu item. Defaults to the name of the operation (eg. insert-text).

[osxKeyBinding] String

Keybindings for Mac OSX keyboards. This can be used to redefine shortcuts using the cmd key instead of the ctrl key.

[steps] OperationStep | Array<OperationStep>

The steps executed when the operation is invoked. Steps form a pipeline, passing step data from each step to the next. If steps is set, alternatives can not be used. Make sure to use either one.

Was this page helpful?