Class: ExpressContext
Contains The Express specific APIs related to the current selection state.
Extends
Constructors
Constructor
new ExpressContext(): ExpressContext;
Returns
ExpressContext
Inherited from
Accessors
selection
Get Signature
get selection(): readonly Node[];
Returns
readonly Node[]
the current selection. Nodes that are locked or otherwise non-editable are never included in the regular selection (see selectionIncludingNonEditable to get any locked nodes the user may have clicked).
Set Signature
set selection(nodes): void;
Sets the current selection to an array of Node. Accepts a single node as a shortcut for a length-1 array [node] or undefined as a shortcut for [], which clears the selection.
Only node(s) that meet the following criteria can be selected:
- Nodes must be within the current artboard (nodes outside the active artboard are filtered out).
- A node cannot be selected if its ancestor is also selected (descendants are filtered out).
- Locked nodes are filtered out (but will still be included in selectionIncludingNonEditable).
Parameters
Returns
void
Inherited from
selectionIncludingNonEditable
Get Signature
get selectionIncludingNonEditable(): readonly Node[];
Returns
readonly Node[]
the current selection and any locked nodes the user has attempted to select at the same time. This can happen for example if the user clicks on a locked node or if the user drags a selection marquee that overlaps locked nodes in addition to regular unlocked nodes.
Inherited from
Context.selectionIncludingNonEditable
hasSelection
Get Signature
get hasSelection(): boolean;
Returns
boolean
false if the current editable selection does not contain any nodes, otherwise true.
Inherited from
insertionParent
Get Signature
get insertionParent(): ContainerNode;
Returns
the preferred parent to insert newly added content into (i.e., the location content would get inserted if a user were to Paste or use the Shapes panel in the UI). This will vary depending on the user's current selection and other UI state.
Inherited from
currentPage
Get Signature
get currentPage(): PageNode;
Returns
The currently viewed page. To change the current page, call ExpressViewport.bringIntoView with an artboard or other content on that page.
Methods
on()
on(eventName, callback): string;
Registers a handler for editor events such as selection change. The registered callback will be invoked when the specified event occurs. Note: Do not attempt to make changes to the document in response to a selection change callback because it may destabilize the application.
Parameters
Returns
string
a unique ID for the registered event handler.
Inherited from
off()
off(eventName, handlerId): void;
Unregisters handlers for editor events like selection change.
Parameters
handlerIdstringeditor.context.on API. Callback that was previously registered will be removed and will no more be invoked when the event occurs.Returns
void