setContextNodeIdToSelectedElement

How to get setContextNodeIdToSelectedElement

Depend on fontoxml-base-flow to make this transform available.

Set the contextNodeId step data to the closest ancestor element that contains the entire cursor selection. If no ancestor is found, then the contextNodeId will be set to null.

This transform differs from transform/setContextNodeIdToSelectionAncestor in that it will not seek upward until a matching element is found, but instead always returns the element closest to the selection.

If an element is selected using the breadcrumbs at the bottom of the application, setContextNodeIdToSelectedElement will return that element. Even if the element technically doesn't contain the selection, this is the behaviour most users would expect.

Example:

"do-something": {
  "label": "Do Something(r)",
   "steps": [
     {
       "type": "transform/setContextNodeIdToSelectedElement"
     }
   ]
}

This makes the operation 'do-something' set stepData.contextNodeId to the first element in the ancestry of the selectionRange

Exported operation data

Name Type Description
contextNodeId NodeId
Was this page helpful?