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

SliceNode

A slice is an invisible object with a bounding box, represented as dashed lines in the editor. Its purpose is to allow you to export a specific part of a document.

Slice node properties

type

  • Readonly: true
  • Type: SLICE

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

clone

  • Type: clone(): SliceNode

Duplicates the slice node.

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。

absoluteRenderBounds

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

The actual boundaries of the node, including shadows, bold strokes, and anything else that might fall outside the node's regular bounding box, which is defined in x, y, width, and in height. x and y inside this property represents the absolute position of the node on the page. If the node is not visible, this value will be null.

constrainProportions

  • Type: boolean

After the switch, when the user resizes the layer via the Properties panel, it makes the layer maintain its scale.

rotation

  • Type: number

The rotation angle of the layer node. The value range is [-180, 180]. The values are equivalent to.

Math.atan2(-relativeTransform[1][0], relativeTransform[0][0]);

layoutAlign

  • Type: "STRETCH" | "INHERIT"

Applies only to direct child levels of the auto layout frame, otherwise ignore. Determines if the layer should be stretched along the inverse axis of the parent. The default is INHERIT.

layoutGrow

  • Type: number

This property applies only to direct child levels of the auto layout frame, otherwise it is ignored. Determines whether the layer should be stretched along the main axis of its parent. 0 corresponds to fixed size, 1 to stretched.

resize

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

Resizes the node. If the node contains child nodes with constraints, it applies those constraints during resizing. If the parent has an automatic layout, it causes the parent to resize.

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).

rescale

  • Type: rescale(scale: number): void

Rescales the node. This API function is the equivalent of using the Scale Tool from the toolbar.

constraints

  • Type: Constraints
  • Type Declaration: Constraints

Constraints of this node relative to its containing FrameNode, if any.

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
SectionNode
Next
StarNode