Pixso Open Documentation
guide
  • 中文
  • English
guide
  • 中文
  • English
  • Plugin API

    • Brief Introduction
    • Prerequisites
    • manifest
    • Development Guide
    • Change Log
    • Plugin API Documentation

      • Overview
      • Global Object

        • pixso
        • pixso.ui
        • pixso.host
        • pixso.mouse
        • pixso.editor
        • pixso.keyboard
        • pixso.fieldset
        • pixso.viewport
        • pixso.vectorEditor
        • pixso.clientStorage
        • pixso.serverStorage
      • Node Types

        • BooleanOperationNode
        • ComponentNode
        • ComponentSetNode
        • DocumentNode
        • EllipseNode
        • FrameNode
        • GroupNode
        • InstanceNode
        • LineNode
        • PageNode
        • PolygonNode
        • RectangleNode
        • SectionNode
        • SliceNode
        • StarNode
        • TextNode
        • VectorNode
      • Data Types

        • Action
        • ArcData
        • BlendMode
        • CommandItem
        • ComponentProperties-Related
        • Constraints
        • DialogType
        • DocumentationLink
        • Effect
        • EmbedData
        • ExportSettings
        • FontName
        • Guide
        • HandleMirroring
        • HyperlinkTarget
        • Image
        • LayoutGrid
        • LetterSpacing
        • Library
        • LineHeight
        • NodeChangeProperty
        • OverflowDirection
        • Overlay
        • Paint
        • PublishStatus
        • Reaction
        • Rect-related
        • RGB & RGBA
        • StrokeCap
        • StrokeJoin
        • StyleChangeProperty
        • TextCase
        • TextDecoration
        • TextListOptions
        • ThemeType
        • ToolType
        • Transition
        • Trigger
        • Vector
    • Host API Documentation

      • Overview
      • Host API
  • Open API

    • OpenAPI Doc

SectionNode

SectionNode is often used to combine related layers.

Section node properties

type

  • Readonly: true
  • Type: SECTION

The type of this node, represented by the string literal SECTION

clone

  • Type: clone(): SectionNode

Duplicates the section node.

resizeWithoutConstraints

  • Type: resizeWithoutConstraints(width: number, height: number): void

Resize nodes. If the parent is not automatically laid out, the children of the node will never resize, even if those children are constrained. If the parent has automatic layout, the parent child nodes and nodes of the node are resized (this constraint cannot be ignored).

Base node properties

id

  • Readonly: true
  • Type: string

The ID of current node.

parent

  • Readonly: true
  • Type: (BaseNode & ChildrenMixin) | null

Get the parent node of the current node.

index

  • Readonly: true
  • Type: number

Get the sequential index of the current node at the same level.

name

  • Type: string

The name of the layer that appears in the layers panel.

removed

  • Readonly: true
  • Type: boolean

Returns true if the node was removed. if the plugin stays open for a while and stores references to the node, you should defensively write code and check that the node has not been removed by the user.

toString

  • Type: string

Returns a string representation of the node.

remove

  • Type: remove():void

Removes this node and all of its children from the document.

setRelaunchData

  • Type: data: {[command: string]: string}): void

Sets state on the node to show a button and description when the node is selected.

getRelaunchData

  • Type: getRelaunchData(): { [command: string]: string }

Retreives the reluanch data stored on this node using setRelaunchData

getPluginData

  • Type: getPluginData(key: string): string

Retrieves custom information that was stored on this node or style. To get a value type other than a string, decode it first via JSON.parse.

setPluginData

  • Type: setPluginData(key: string, value: string): void

Lets you store custom information on any node or style, private to your plugin. If you want to store a value type other than a string, please encode it first via JSON.stringify.

getPluginDataKeys

  • Type: getPluginDataKeys(): string[]

Retrieves a list of all keys stored on this node or style.

getSharedPluginData

  • Type: getSharedPluginData(namespace: string, key: string): string

Get the shared data stored on a specific namespace.

setSharedPluginData

  • Type: setSharedPluginData(namespace: string, key: string, value: string): void

This allows you to store custom information on any node. You can retrieve it later by calling getSharedPluginData with the same namespace and key. To find all the data on a node stored in a specific namespace, use getSharpedPluginDataKeys.

Any data you write using this API can be read by any plug-in. The purpose is to allow plugins to interoperate with each other. If you do not want other plugins to be able to read your data, use setPluginData instead.

You must also provide the namespace parameter to avoid key conflicts with other plugins. This parameter is mandatory to prevent multiple plugins from using common key names (such as data) and overwriting each other. We recommend passing a value that identifies your plugin. This namespace can be provided to the authors of other plugins so that they can read data from your plugin.

namespace is a unique string used to identify your plugin and avoid key conflicts with other plugins. The namespace must contain at least 3 alphanumeric characters.

getSharedPluginDataKeys

  • Type: getSharedPluginDataKeys(namespace: string): string[]

Retrieves a list of all keys stored on this node or style using setSharedPluginData. This enables iterating through all data stored in a given namespace.

Scene node properties

visible

  • Type: boolean

Whether the node is visible or not. This property does not affect the ability of the plugin to access the node.

locked

  • Type: boolean

Whether the node is locked to prevent certain user interactions on the canvas, such as selection and dragging. This property does not affect the ability of the plugin to write these properties.

componentPropertyReferences

  • Type: { [nodeProperty in 'visible' | 'characters' | 'mainComponent']?: string} | null

All component properties that are attached on this node. The value in the key-value pair refers to the component property name as returned by componentPropertyDefinitions on the containing component, component set or main component (for instances).

A node can only have componentPropertyReferences if it is a component sublayer or an instance sublayer。

Children-related

children

  • Readonly: true
  • Type: ReadonlyArray<SceneNode>
  • Type Declaration: SceneNode

The direct child of the current node.

childrenCount

  • Readonly: true
  • Type: number

Gets the number of direct children of the current node.

appendChild

  • Type: appendChild(child: SceneNode, preserveAbsolutePostion?: boolean): void

Adds the given node child as a direct child of the current node.

After appendChild, the relativeTransform of the child node is maintained by default. Due to changes in the parent layer of child, the position of the child node on the canvas may change; if you want to maintain the position of the child node, you can Set preserveAbsolutePostion to true.

insertChild

  • Type: insertChild(index: number, child: SceneNode, preserveAbsolutePostion?: boolean): void

Suppose a group has three children, A, B, and C. Now call the insertChild method to insert layer node D.

  • insertChild(0, D), the order of child nodes is: D, A, B, C.
  • insertChild(1, D), the order of child nodes is: A, D, B, C.
  • insertChild(2, D), the order of child nodes is: A, B, D, C.
  • insertChild(3, D), the order of child nodes is: A, B, C, D.

findChildren

  • Type: findChildren(callback?: (node: SceneNode) => boolean): SceneNode[]

Similar to findAll, except that findChildren will only look in the direct children of the current node (not the children of the children).

findChild

  • Type: findChild(callback: (node: SceneNode) => boolean): SceneNode | null

Similar to findOne, except that findChild will only look in the direct children of the current node (excluding children of children).

findAll

  • Type: findAll(callback?: (node: SceneNode) => boolean): SceneNode[]

Finds the entire subtree starting from the current node, calls the callback function for each node, and returns all nodes whose return value is true for the callback function.

findOne

  • Type: findOne(callback: (node: SceneNode) => boolean): SceneNode | null

Find the entire node tree starting from the current node, call the callback function for each node, and return the first node whose return value is true for the callback function.

findAllWithCriteria

  • Type: findAllWithCriteria<T extends NodeType[]>(criteria: {types: T;}): Array<{ type: T[number] } & SceneNode>
  • Type Declaration: NodeType

Searches the entire subtree (children of this node, children of its children, etc.). Returns all nodes that satisfy any of the types defined in the condition.

Layout-related

x

  • Type: number

The position of the layer node, equivalent to relativeTransform[0][2].

y

  • Type: number

The position of the layer node, equivalent to relativeTransform[1][2].

width

  • Readonly: true
  • Type: number

The width of the layer node.

height

  • Readonly: true
  • Type: number

The height of the layer node.

relativeTransform

  • Type: Transform
  • Type Declaration: Transform

The position of the layer node relative to its parent is represented as a transformation matrix. Note: relativeTransform does not work for auto layout normal sublayers. Relativetransform still works for sublayers with absolute positioning.

absoluteTransform

  • Readonly: true
  • Type: Transform
  • Type Declaration: Transform

The position of a layer node relative to the page containing it is presented as a transformation matrix.

absoluteBoundingBox

  • Readonly: true
  • Type: Rect | null
  • Type Declaration: Rect

Node boundaries that do not include rendering attributes such as shadows or strokes.

getNestedBoundaryBox

  • Type:getNestedBoundaryBox(): NestedBoundaryBox
  • Type Declaration: NestedBoundaryBox

Get the boundaryBox information of the current layer and all its sublayers

Geometry-related

fills

  • Type: ReadonlyArray<Paint> | pixso.mixed
  • Type Declaration: Paint

The fill of the layer.

// set fills
node.fills = newFills;

fillStyleId

  • Type: string | pixso.mixed

The id of the fill style linked to the current node, i.e. the id of the PaintStyle object linked to the fills property of the current node.

strokes

  • Type: ReadonlyArray<Paint>
  • Type Declaration: Paint

Stroke of the layer.

strokeStyleId

  • Type: string

The id of the stroke style linked to the current node, i.e. the id of the PaintStyle object linked to the strokes property of the current node.

strokeWeight

  • Type: number

The thickness of the stroke in all four directions, in pixels. It must be non-negative and can be a decimal number. Note that if a single-edge stroke is set such as strokeTopWeight, the single-edge stroke will prevail; if strokeWeight is set, a single-edge stroke in all four directions will be set at the same time.

strokeJoin

  • Type: StrokeJoin | pixso.mixed
  • Type Declaration: StrokeJoin

Edge decoration.

  • 'MITER'
  • 'BEVEL'
  • 'ROUND'

strokeAlign

  • Type: "CENTER" | "INSIDE" | "OUTSIDE"

The alignment of the stroke relative to the layer boundary.

  • 'CENTER'
  • 'INSIDE'
  • 'OUTSIDE'

dashPattern

  • Type: ReadonlyArray<number>

Specifies a list of numbers in pixels for the length of alternate strokes and gaps.

strokeCap

  • Type: StrokeCap | pixso.mixed
  • Type Declaration: StrokeCap

The endpoints are decorated.

strokeMiterLimit

  • Type: number

The miter limit on the stroke. This is the same as the SVG miter limit.

Export-related

exportSettings

  • Type: exportSettings: ReadonlyArray<ExportSettings>
  • Type Declaration: ExportSettings

The export settings for the node.

exportAsync

  • Type: exportAsync(settings?: ExportSettings): Promise<Uint8Array>
  • Type Declaration: ExportSettings

Export the node as a encoded image.

HWDC

exportJsonAsync

  • Type: exportJsonAsync(): Promise<string>

Export the JSON data of the node, which includes all the information of the node.

exportHexAsync

  • Type: exportHexAsync(hex: string): Promise<string>

Export the Hex data of the node, which includes all the information of the node.


Prev
RectangleNode
Next
SliceNode