Type: Function

How to get addTransform?


import addTransform from 'fontoxml-operations/src/addTransform.js'

Register a transform to the set of globally usable transforms. Transforms do not change application state, but do change the step data of the operation.

Examples of transforms include setting contextNodeId to various values, or encoding information in a URL.

A transform does not automatically cause the state of operations using it to be recomputed when the data it uses changes. While Fonto does automatically refresh some operation states in some cases, this behavior is subject to change. Therefore, we recommend not relying on this behavior to also recompute the state of custom transforms. Instead, developers should make sure to call OperationsManager#invalidateOperationStatesByStepType whenever the result of the transform may have changed. For example, a transform that uses the selection may invalidate corresponding operation states when the selection changes by subscribing to the selection change notifier. This is usually done in the same install.js that registers the transform:


addTransform('setSomethingBasedOnSelection', stepData => {
    const selectedNode = selectionManager.getSelectedElement();
    if (selectedNode) {
        stepData.selectedNodeName = selectedNode.nodeName;
    return stepData;
selectionManager.selectionChangeNotifier.addCallback(() => {


  1. name


    Type: String

    The name of the transform. Operations can invoke transform action using a step of type "transform/name".

  2. run


    Type: addTransform~runTransformCallback

    Asynchronous callback function which defines the actual behavior of the transform.

  3. getState


    Type: addTransform~getTransformStateCallback

    Optional asynchronous callback function which can be implemented to calculate the current state of operations using this transform.