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

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

      • Overview
      • Global Object

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

        • BooleanOperationNode
        • ComponentNode
        • ComponentSetNode
        • DocumentNode
        • EllipseNode
        • FolderNode
        • 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

pixso.codegen

pixso.codegen provides APIs related to code generation. These APIs are only effective in the Dev mode, Historical Dev mode, and single artboard mode. For how the plugin runs in these modes, please refer to the manifest.editorType configuration.

unit

  • type: unit: "px" | "pt" | "dp" | "rem" | "sp"

Gets or modifies the dimension unit of the generated code. The default value is px.

language

  • type: language: "CSS" | "swiftUI" | "UIKit" | "XML" | "Compose"

Gets or modifies the language type of the generated code. The default value is CSS.

conversionRate

  • type: number

Gets or modifies the dimension ratio of the generated code. The default value is 1.

on

on(type: "generatewithcfg", callback: (event: CodegenResultWithConfig) => void): void;

The on method allows you to register a handler function for the code generation event. The callback function will be executed when the event occurs. The event types are as follows:

  • generatewithcfg: This event will be triggered when the selected nodes in the canvas change, or when the configurations of codegen (such as unit, language, conversionRate) change.

once

once(type: "generatewithcfg", callback: (event: CodegenResultWithConfig) => void): void;

The once method allows you to register a handler function for the code generation event. The callback function will be executed when the event occurs. The difference between the once method and the on method is that the event handler function registered through the once method will only be executed once.

off

off(type: "generatewithcfg", callback: (event: CodegenResultWithConfig) => void): void;

Removes the event handler function bound through pixso.codegen.on or pixso.codegen.once.

Prev
pixso.editor
Next
pixso.keyboard