@express-document-sdk

Class: StandaloneTextNode

A StandaloneTextNode represents text that is displayed entirely within one single frame in the scenegraph (in contrast to ThreadedTextNode, where text may flow across several separate display "frames"). The StandaloneTextNode does not directly hold the text content and styles – instead it refers to a TextNodeContentModel.

To create a new StandaloneTextNode, see Editor.createText.

Extends

Constructors

Constructor

new StandaloneTextNode(): StandaloneTextNode;

Returns

StandaloneTextNode

Inherited from

TextNode.constructor

Accessors

addOnData

Get Signature

get addOnData(): AddOnData;

Get AddOnData reference for managing the private metadata on this node for this add-on.

Returns

AddOnData

Inherited from

TextNode.addOnData

id

Get Signature

get id(): string;

A unique identifier for this node that stays the same when the file is closed & reopened, or if the node is moved to a different part of the document.

Returns

string

Inherited from

TextNode.id

allChildren

Get Signature

get allChildren(): Readonly<Iterable<Node>>;

Returns a read-only list of all children of the node. General-purpose content containers such as ArtboardNode or GroupNode also provide a mutable ContainerNode.children list. Other nodes with a more specific structure can hold children in various discrete "slots"; this allChildren list includes all such children and reflects their overall display z-order.

The children of a Node are always other Node classes (never the more minimal BaseNode).

Returns

Readonly<Iterable<Node>>

Inherited from

TextNode.allChildren

allDescendants

Get Signature

get allDescendants(): Readonly<Iterable<Node>>;

Experimental

data-slots=text
data-variant=warning
IMPORTANT: This is currently experimental only and should not be used in any add-ons you will be distributing until it has been declared stable. To use it, you will first need to set the experimentalApis flag to true in the requirements section of the manifest.json.

Helper to recursively traverse all the exposed scenegraph content within the subtree of this node. Every container node and every leaf node will be visited via a pre-order tree traversal. Although once called the list of direct descendants is static, changes to further descendants may appear while iterating depending on when the operation occurs relative to the parent being yielded. Note that the root node (i.e. what this API was called on) is not visited.

The descendants of a Node are always other Node classes (never the more minimal BaseNode).

Warning: Processing text content via this API can be error-prone. Use VisualNode.allTextContent

Returns

Readonly<Iterable<Node>>

Inherited from

TextNode.allDescendants

type

Get Signature

get type(): SceneNodeType;

The node's type.

Returns

SceneNodeType

Inherited from

TextNode.type

parent

Get Signature

get parent(): BaseNode | undefined;

The node's parent. The parent chain will eventually reach ExpressRootNode for all nodes that are part of the document content.

Nodes that have been deleted are "orphaned," with a parent chain that terminates in undefined without reaching the root node. Such nodes cannot be selected, so it is unlikely to encounter one unless you retain a reference to a node that was part of the document content earlier. Deleted nodes can be reattached to the scenegraph, e.g. via Undo.

Returns

BaseNode | undefined

Inherited from

TextNode.parent

translation

Get Signature

get translation(): Readonly<Point>;

The translation of the node along its parent's axes. This is identical to the translation component of transformMatrix. It is often simpler to set a node's position using setPositionInParent than by setting translation directly.

Returns

Readonly<Point>

Set Signature

set translation(value): void;

The translation of the node along its parent's axes. This is identical to the translation component of transformMatrix. It is often simpler to set a node's position using setPositionInParent than by setting translation directly.

Parameters
Parameter
Type
value
Point
Returns

void

Inherited from

TextNode.translation

rotation

Get Signature

get rotation(): number;

The node's local rotation angle in degrees, relative to its parent's axes. Use setRotationInParent to change rotation by rotating around a defined centerpoint.

Returns

number

Inherited from

TextNode.rotation

rotationInScreen

Get Signature

get rotationInScreen(): number;

The node's total rotation angle in degrees, relative to the overall global view of the document – including any cumulative rotation from the node's parent containers.

Returns

number

Inherited from

TextNode.rotationInScreen

opacity

Get Signature

get opacity(): number;

The node's opacity, from 0.0 to 1.0

Returns

number

Set Signature

set opacity(opacity): void;
Parameters
Parameter
Type
opacity
number
Returns

void

Inherited from

TextNode.opacity

transformMatrix

Get Signature

get transformMatrix(): mat2d;

The node's transform matrix relative to its parent.

Returns

mat2d

Inherited from

TextNode.transformMatrix

locked

Get Signature

get locked(): boolean;

The node's lock/unlock state. Locked nodes are excluded from the selection (see Context.selection), and cannot be edited by the user in the UI unless they are unlocked first. It is still possible to mutate locked nodes at the model level using these APIs. However, please consider if modifying a locked node would align with user expectations before doing so.

Returns

boolean

Set Signature

set locked(locked): void;
Parameters
Parameter
Type
locked
boolean
Returns

void

Inherited from

TextNode.locked

blendMode

Get Signature

get blendMode(): BlendMode;

Blend mode determines how a node is composited onto the content below it. The default value is BlendMode.normal for most nodes, and BlendMode.passThrough for GroupNodes.

Returns

BlendMode

Set Signature

set blendMode(value): void;
Parameters
Parameter
Type
value
BlendMode
Returns

void

Inherited from

TextNode.blendMode

fullContent

Get Signature

get fullContent(): StandaloneTextContentModel;

The model containing the complete text string and its styles, all which will be visible within the bounds of this specific StandaloneTextNode.

Returns

StandaloneTextContentModel

Overrides

TextNode.fullContent

nextTextNode

Get Signature

get nextTextNode(): undefined;

The next TextNode that text overflowing this node will spill into, if any. If undefined and this TextNode is fixed size (AreaTextLayout), any text content that does not fit within this node's area will be clipped.

To get all TextNodes that the text content may be split across, use TextNode.fullContent.allTextNodes.

Returns

undefined

Overrides

TextNode.nextTextNode

layout

Get Signature

get layout(): Readonly<
  | AutoWidthTextLayout
  | AutoHeightTextLayout
| UnsupportedTextLayout>;
Returns

Readonly< | AutoWidthTextLayout | AutoHeightTextLayout | UnsupportedTextLayout>

The layout mode of the TextNode "frame."

Set Signature

set layout(layout): void;

Sets the layout mode of this TextNode "frame" which the text content is displayed within. AreaTextLayout is not supported by standalone text.

Throws

if changing text layout to/from TextLayout.magicFit or TextLayout.circular layout when the text contains fonts that are unavailable to the current user, because these layouts change capitalization and thus alter which glyphs are displayed.

Parameters
Parameter
Type
layout
| AutoWidthTextLayout | AutoHeightTextLayout
Returns

void

Overrides

TextNode.layout

boundsLocal

Get Signature

get boundsLocal(): Readonly<Rect>;

The bounding box of the node, expressed in the node's local coordinate space (which may be shifted or rotated relative to its parent). Generally matches the selection outline seen in the UI, encompassing the vector path "spine" of the shape as well as its stroke, but excluding effects such as shadows.

The top-left corner of the bounding box corresponds to the visual top-left corner of the node, but this value is not necessarily (0,0) – this is especially true for Text and Path nodes.

Returns

Readonly<Rect>

Inherited from

TextNode.boundsLocal

centerPointLocal

Get Signature

get centerPointLocal(): Readonly<Point>;

Position of the node's centerpoint in its own local coordinate space, i.e. the center of the boundsLocal box.

Returns

Readonly<Point>

Inherited from

TextNode.centerPointLocal

topLeftLocal

Get Signature

get topLeftLocal(): Readonly<Point>;

Position of the node's top-left corner in its own local coordinate space, equal to (boundsLocal.x, boundsLocal.y). If the node is rotated, this is not the same as the top-left corner of boundsInParent.

Returns

Readonly<Point>

Inherited from

TextNode.topLeftLocal

boundsInParent

Get Signature

get boundsInParent(): Readonly<Rect>;

An axis-aligned box in the parent’s coordinate space encompassing the node’s layout bounds (its boundsLocal, as transformed by its position and rotation relative to the parent). If the node has rotation, the top-left of its boundsLocal box (aligned to its own axes) is not necessarily located at the top-left of the boundsInParent box (since it's aligned to the parent's axes). This value is well-defined even for an orphan node with no parent.

Returns

Readonly<Rect>

Inherited from

TextNode.boundsInParent

text

Get Signature

get text(): string;

The text string content which is partially or fully displayed in this TextNode "frame." WARNING: If a piece of text content flows across several TextNodes, each TextNode's text getter will return the entire text content string.

Deprecated
Returns

string

Set Signature

set text(textContent): void;

Sets the text content of the TextNode. WARNING: If a piece of text content flows across several TextNodes, each TextNode's text setter will sets the entire text content string.

Deprecated
Parameters
Parameter
Type
textContent
string
Returns

void

Inherited from

TextNode.text

textAlignment

Get Signature

get textAlignment(): TextAlignment;

The horizontal text alignment of the TextNode. Alignment is always the same across this node's entire text content.

Returns

TextAlignment

Set Signature

set textAlignment(alignment): void;
Parameters
Parameter
Type
alignment
TextAlignment
Returns

void

Inherited from

TextNode.textAlignment

visualEffects

Get Signature

get visualEffects(): readonly VisualEffectType[];
Returns

readonly VisualEffectType[]

The list of visual effects applied to the TextNode.

Inherited from

TextNode.visualEffects

visualRoot

Get Signature

get visualRoot(): VisualNode;

The highest ancestor that still has visual presence in the document. Typically an Artboard, but for orphaned content, it will be the root of the deleted content (which might be this node itself).

Nodes that are both in the same visualRoot subtree lie within the same "visual space" of the document's structure. Nodes that are in different visual roots have no spatial relation to one another; there is no meaningful comparison or conversion between the bounds or coordinate spaces of such nodes.

Returns

VisualNode

Inherited from

TextNode.visualRoot

allTextContent

Get Signature

get allTextContent(): Readonly<Iterable<TextContent>>;

Experimental

data-slots=text
data-variant=warning
IMPORTANT: This is currently experimental only and should not be used in any add-ons you will be distributing until it has been declared stable. To use it, you will first need to set the experimentalApis flag to true in the requirements section of the manifest.json.

Helper to process all text content that is found as part of or within this node. This can be hard to do correctly via manual tree traversal since multiple ThreadedTextNode can share a single TextContentModel.

This iterator returns a single result per TextContentModel that is at least partially displayed within this node, even if that content is split across several separate TextNode "frames". If this node is or contains some but not all of the display frames of an overall TextContentModel, that model is still included as a result.

Note that visibleRanges and visibleText may not be sorted as TextNode "frames" can appear in any order in the scenegraph.

Returns

Readonly<Iterable<TextContent>>

Inherited from

TextNode.allTextContent

Methods

removeFromParent()

removeFromParent(): void;

Removes the node from its parent - effectively deleting it, if the node is not re-added to another parent before the document is closed.

If parent is a basic ContainerNode, this is equivalent to node.parent.children.remove(node). For nodes with other child "slots," removes the child from whichever slot it resides in, if possible. Throws if the slot does not permit removal. No-op if node is already an orphan.

Returns

void

Inherited from

TextNode.removeFromParent

setPositionInParent()

setPositionInParent(parentPoint, localRegistrationPoint): void;

Move the node so the given localRegistrationPoint in its local coordinates is placed at the given parentPoint in its parent's coordinates (taking into account any rotation on this node, etc.).

Parameters

Parameter
Type
Description
parentPoint
Point
Point in this node's parent's coordinate space to move localRegistrationPoint to
localRegistrationPoint
Point
Point in this node's local coordinate space to align with parentPoint

Returns

void

Example

Center a rectangle within its parent artboard:

rectangle.setPositionInParent(
    { x: artboard.width / 2, y: artboard.height / 2 },
    { x: rectangle.width / 2, y: rectangle.height / 2 }
);

Inherited from

TextNode.setPositionInParent

setRotationInParent()

setRotationInParent(angleInDegrees, localRotationPoint): void;

Set the node’s rotation angle relative to its parent to exactly the given value, keeping the given point in the node’s local coordinate space at a fixed location within the parent. Disregards any rotation the node may already have had. The angle set here may not be the absolute rotation angle seen on screen, if the parent or other ancestors also have rotation of their own.

Parameters

Parameter
Type
Description
angleInDegrees
number
Angle in degrees.
localRotationPoint
Point
Point to rotate around, in node's local coordinates.

Returns

void

Example

Rotate the rectangle 45 degrees clockwise around its centerpoint:

rectangle.setRotationInParent(45, rectangle.centerPointLocal);

Inherited from

TextNode.setRotationInParent

resize()

resize(options): void;

Resizes this node based on the given ResizeOptions.

Parameters

Parameter
Type
options
ResizeOptions

Returns

void

Inherited from

TextNode.resize

cloneInPlace()

cloneInPlace(): StandaloneTextNode;

Creates a copy of this node and its entire subtree of descendants.

The node must be attached to a page as the copy will be added as a sibling.

Returns

StandaloneTextNode

Inherited from

TextNode.cloneInPlace

isStandaloneText()

isStandaloneText(): this is StandaloneTextNode;

Always returns true for this StandaloneTextNode, indicating that it is not part of a multi-frame text flow.

Returns

this is StandaloneTextNode

Overrides

TextNode.isStandaloneText

boundsInNode()

boundsInNode(targetNode): Readonly<Rect>;

Convert the node's boundsLocal to an axis-aligned bounding box in the coordinate space of the target node. Both nodes must share the same visualRoot, but can lie anywhere within that subtree relative to one another (the target node need not be an ancestor of this node, nor vice versa).

Parameters

Parameter
Type
Description
targetNode
VisualNode

Returns

Readonly<Rect>

Inherited from

TextNode.boundsInNode

isThreadedText()

isThreadedText(): this is ThreadedTextNode;

Helper method to determine if the text is in a flow.

Returns

this is ThreadedTextNode

Inherited from

TextNode.isThreadedText

localPointInNode()

localPointInNode(localPoint, targetNode): Readonly<Point>;

Convert a point given in the node’s local coordinate space to a point in the coordinate space of the target node. Both nodes must share the same visualRoot, but can lie anywhere within that subtree relative to one another (the target node need not be an ancestor of this node, nor vice versa).

Parameters

Parameter
Type
localPoint
Point
targetNode
VisualNode

Returns

Readonly<Point>

Inherited from

TextNode.localPointInNode

createRendition()

createRendition(options?): Promise<CreateRenditionResult>;

Experimental

data-slots=text
data-variant=warning
IMPORTANT: This is currently experimental only and should not be used in any add-ons you will be distributing until it has been declared stable. To use it, you will first need to set the experimentalApis flag to true in the requirements section of the manifest.json.

Generates a rendition of this node and its descendants.

If this node contains images, it will wait for the best quality to be available before capturing. As such, there is a 20s timeout before an error is thrown to prevent indefinite waiting.

Parameters

Parameter
Type
options?
CreateRenditionOptions

Returns

Promise<CreateRenditionResult>

Inherited from

TextNode.createRendition