FBoard
The facade class for a board unit.
This facade is the recommended entry point for agents and integrations that create or edit board content. Prefer element ids for later references and batch APIs when creating or updating multiple elements. Facade mutations go through the board command layer, so collaboration, undo/redo, validation, and container invariants follow the same path as UI operations.
Persist returned element ids in the caller's own state when later edits need to address the same elements. The facade
does not provide semantic-key indexes or implicit idempotent creation.
Avoid chaining many single-element mutations when generating diagrams. Prefer insertShapes(),
insertConnectors(), and other batch helpers so related edits travel as compact batch mutations with compact
undo/redo history.
Access
Access through:
Setup
Register @univerjs-pro/boards or a preset that includes it. In plugin mode, import @univerjs-pro/boards/facade. Additional methods below require their listed plugin packages. See Facade setup.
@univerjs-pro/boards
FBoard.addElement
Adds one fully constructed board element through the command layer.
This is a low-level escape hatch for code that already has an IBoardPageElement. Agent scripts should prefer
insertShapes(), insertConnector(), createContainer(), or createSwimlane() because those APIs are more
higher-level and harder to misuse.
addElement(element: IBoardPageElement, options?: IBoardFacadeAddElementOptions): booleanParameters
element— Required. Fully constructed board element.options— Optional. Default:{}. Insert options such asinsertIndex.
Returns
true when the element passes local invariants and the command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const seed = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 }, name: 'Seed',})if (!seed) throw new Error('Cannot create seed shape')const source = board.getElement(seed.getId())if (!source) throw new Error('Cannot read seed shape')const rawId = `${source.id}-copy`const added = board.addElement({ ...source, id: rawId, transform: { ...source.transform, left: 320 },})if (!added) throw new Error('Cannot add raw shape')console.log(rawId)Types: IBoardPageElement · IBoardFacadeAddElementOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.addElements
Adds multiple fully constructed board elements in one command.
This keeps collaboration traffic and undo history compact when callers already own valid element models. Agent
scripts that are creating new shapes or connectors should prefer insertShapes() and insertConnectors().
addElements(elements: IBoardPageElement[], options?: IBoardFacadeAddElementsOptions): booleanParameters
elements— Required. Fully constructed board elements.options— Optional. Default:{}. Batch insert options such asinsertIndex,fitContainerId.
Returns
true when all elements pass local invariants and the command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])const elements = shapes ?.map((shape) => board.getElement(shape.getId())) .filter((element) => element !== null)if ( !shapes || !elements || elements.length !== shapes.length || !board.removeElements(shapes.map((shape) => shape.getId()))) { throw new Error('Cannot prepare elements')}if (!board.addElements(elements)) throw new Error('Cannot add elements')Types: IBoardPageElement · IBoardFacadeAddElementsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.addSwimlaneLane
Adds a lane to a swimlane container.
The lane is inserted at options.insertIndex or appended when omitted. Lane order is normalized after insertion.
addSwimlaneLane(containerId: string, lane: IBoardFacadeSwimlaneLane, options?: IBoardFacadeAddSwimlaneLaneOptions): booleanParameters
containerId— Required. Swimlane container id.lane— Required. Lane model to add.options— Optional. Default:{}. Optional insert index.
Returns
true when the lane is added.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [{ id: 'todo', title: 'Todo' }], }) || !board.addSwimlaneLane(swimlaneId, { id: 'done', title: 'Done', size: 200, order: 1 })) { throw new Error('Cannot add lane')}Types: IBoardFacadeSwimlaneLane · IBoardFacadeAddSwimlaneLaneOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.alignElements
Aligns at least two elements against their combined resolved bounds.
alignElements(elementIds: string[], alignment: BoardFacadeElementAlignment): booleanParameters
elementIds— Required. Existing element ids.alignment— Required. Edge or center alignment mode.
Returns
true when at least one element moves and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const nodes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 160 } },])if ( !nodes || !board.alignElements( nodes.map((node) => node.getId()), 'left', )) { throw new Error('Cannot align nodes')}Types: BoardFacadeElementAlignment
Package: @univerjs-pro/boards · Type definitions
FBoard.analyzeModelLayout
Detects model-visible Board layout conflicts on the active page.
Model analysis can inspect persisted manual connector paths. Auto-routed connectors without persisted route points are reported as unresolved; a UI host can use rendered analysis for their final paths.
analyzeModelLayout(focusPadding?: number): AnalyzeBoardModelLayoutResultParameters
focusPadding— Optional. Padding added to each issue's suggested screenshot bounds.
Returns
Structured layout issues, or false when the command cannot run.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const analysis = board.analyzeModelLayout(48)if (!analysis) throw new Error('Cannot analyze the active board')const blockingIssues = analysis.issues.filter((issue) => issue.severity === 'error')console.log({ blockingIssues, unresolved: analysis.summary.unresolvedConnectorCount })Types: AnalyzeBoardModelLayoutResult
Package: @univerjs-pro/boards · Type definitions
FBoard.arrangeElements
Arranges elements in their supplied order, preserving their current sizes.
arrangeElements(elementIds: string[], options: IBoardFacadeArrangeElementsOptions): booleanParameters
elementIds— Required. Existing element ids in visual order.options— Required. Direction, gap, and optional starting point.
Returns
true when at least one element moves and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 180 } },])if ( !shapes || !board.arrangeElements( shapes.map((shape) => shape.getId()), { direction: 'horizontal', gap: 60 }, )) { throw new Error('Cannot arrange shapes')}Types: IBoardFacadeArrangeElementsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.arrangeElementsInCircle
Arranges elements around a circle in their supplied order.
arrangeElementsInCircle(elementIds: string[], options: IBoardFacadeArrangeElementsInCircleOptions): booleanParameters
elementIds— Required. Existing element ids in circular order.options— Required. Circle center, radius, start angle, and direction.
Returns
true when the geometry is valid and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Ellipse, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Ellipse, transform: { left: 280, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Ellipse, transform: { left: 480, top: 80 } },])if ( !shapes || !board.arrangeElementsInCircle( shapes.map((shape) => shape.getId()), { center: { x: 400, y: 300 }, radius: 180, }, )) throw new Error('Cannot arrange circle')Types: IBoardFacadeArrangeElementsInCircleOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.arrangeElementsInGrid
Arranges elements in their supplied order into a row-major grid.
arrangeElementsInGrid(elementIds: string[], options: IBoardFacadeArrangeElementsInGridOptions): booleanParameters
elementIds— Required. Existing element ids in row-major order.options— Required. Column count, gaps, and optional starting point.
Returns
true when at least one element moves and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 180 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 480, top: 280 } },])if ( !shapes || !board.arrangeElementsInGrid( shapes.map((shape) => shape.getId()), { columns: 2 }, )) { throw new Error('Cannot arrange grid')}Types: IBoardFacadeArrangeElementsInGridOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.arrangeElementsInLayers
Arranges explicitly supplied element layers for flowcharts and dependency diagrams.
Each inner array is rendered in its supplied visual order. Layers flow top-to-bottom by default, or left-to-right
when direction is horizontal.
arrangeElementsInLayers(layers: string[][], options?: IBoardFacadeArrangeElementsInLayersOptions): booleanParameters
layers— Required. Element ids grouped into ordered visual layers.options— Optional. Default:{}. Flow direction, layer/item gaps, alignments, and optional starting point.
Returns
true when all ids are unique and valid and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const nodes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Diamond, transform: { left: 280, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 480, top: 40 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 480, top: 180 } },])if (!nodes) throw new Error('Cannot insert flowchart nodes')const [start, decision, approved, rejected] = nodesconst arranged = board.arrangeElementsInLayers( [[start.id], [decision.id], [approved.id, rejected.id]], { direction: 'horizontal', layerGap: 140, itemGap: 100 },)if (!arranged) throw new Error('Cannot arrange flowchart')Types: IBoardFacadeArrangeElementsInLayersOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.beginExport
Starts the host-configured Board export flow for this board.
Export rendering and file delivery are owned by the registered export adapter. This facade method only supplies stable board context and an optional target hint, so UI, service, and SDK callers share the same operation.
beginExport(targetType?: 'image' | 'pdf' | string): booleanParameters
targetType— Optional. Optional adapter target such asimage,pdf, or a host-supported format.
Returns
true when a registered adapter accepts the request.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const opened = board.beginExport('image')console.log(opened)Package: @univerjs-pro/boards · Type definitions
FBoard.beginImport
Starts the host-configured Board import flow for this board.
This method delegates to the registered import adapter; it does not parse files in the model package. Hosts may open a picker, display an import dialog, or route to an exchange service. Agents that already own structured Board content should use the element insertion APIs instead of this interactive adapter entry point.
beginImport(sourceType?: string): booleanParameters
sourceType— Optional. Optional adapter hint such asmermaid,pptx, or another host-supported source type.
Returns
true when a registered adapter accepts the request.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const opened = board.beginImport('mermaid')console.log(opened)Package: @univerjs-pro/boards · Type definitions
FBoard.bringElementsForward
Moves elements one z-order step forward.
bringElementsForward(elementIds: string[]): booleanParameters
elementIds— Required. Existing element ids.
Returns
true when the order changes successfully.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 } },])if (!shapes || !board.bringElementsForward([shapes[0].getId()])) throw new Error('Cannot move shape forward')Package: @univerjs-pro/boards · Type definitions
FBoard.bringElementsToFront
Brings elements to the front.
bringElementsToFront(elementIds: string[]): booleanParameters
elementIds— Required. Existing element ids.
Returns
true when the order changes successfully.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 } },])if (!shapes || !board.bringElementsToFront([shapes[0].getId()])) throw new Error('Cannot bring shape to front')Package: @univerjs-pro/boards · Type definitions
FBoard.checkElementIds
Checks a list of generated board element ids and returns a structured preflight result.
Use this when an integration starts from UI selection ids or event payload ids and wants to verify all referenced elements still exist before mapping them back to generated ids or running low-level commands.
checkElementIds(elementIds: string[]): IBoardFacadeElementIdCheckResultParameters
elementIds— Required. Generated board element ids.
Returns
Requested ids, existing ids, missing ids, and an allExist boolean.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.checkElementIds([shape.getId(), 'missing-element']))Types: IBoardFacadeElementIdCheckResult
Package: @univerjs-pro/boards · Type definitions
FBoard.checkElementIdTypes
Checks generated board element ids against expected board element types.
Use this before type-specific low-level integrations that start from UI selection ids. It separates missing ids from ids that still exist but point to the wrong element type.
checkElementIdTypes(elementIds: string[], expectedTypes: BoardElementType | BoardElementType[]): IBoardFacadeElementIdTypeCheckResultParameters
elementIds— Required. Generated board element ids.expectedTypes— Required. Allowed board element type or types.
Returns
Requested ids, matching ids, missing ids, mismatched ids, and an allMatch boolean.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.checkElementIdTypes([shape.getId()], univerAPI.Enum.BoardElementType.Shape))Types: IBoardFacadeElementIdTypeCheckResult · BoardElementType
Package: @univerjs-pro/boards · Type definitions
FBoard.clearBackground
Clears the active Board page background and restores the theme-aware canvas fill.
clearBackground(): thisReturns
This board, for chaining.
Package: @univerjs-pro/boards · Type definitions
FBoard.createContainer
Creates a generic, UML package, or system-boundary container.
Containers can group elements and optionally auto-capture/membership-lock children depending on the provided container options. Give agent-created containers generated ids so later scripts can move children into them.
createContainer(options: IBoardFacadeCreateContainerOptions): booleanParameters
options— Required. Container creation options.
Returns
true when the container is created through the command layer.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if ( !board.createContainer({ id: containerId, kind: univerAPI.Enum.BoardContainerKind.SystemBoundary, left: 80, top: 80, title: 'Planning', })) { throw new Error('Cannot create container')}Types: IBoardFacadeCreateContainerOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.createSwimlane
Creates a swimlane container.
Use this for process maps, responsibility diagrams, or timelines. Provide lane ids that are meaningful to the
agent, such as todo, doing, and done, so later lane operations are readable.
createSwimlane(options: IBoardFacadeCreateSwimlaneOptions): booleanParameters
options— Required. Swimlane creation options.
Returns
true when the swimlane is created through the command layer.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, title: 'Workflow', lanes: [ { id: 'todo', title: 'Todo' }, { id: 'done', title: 'Done' }, ], })) throw new Error('Cannot create swimlane')Types: IBoardFacadeCreateSwimlaneOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.describeElement
Describes one board element as a compact agent-friendly summary.
Use this when an agent needs to inspect an element without depending on the full internal model. The descriptor
includes generated element id, resolved metadata, parent id, local transform, and world bounds,
but it does not include heavy payloads such as shapeData or connectorData.
Agent scripts should prefer describeElement() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
describeElement(elementId: string): IBoardFacadeElementDescriptor | nullParameters
elementId— Required. Generated board element id.
Returns
Compact element descriptor, or null when the element is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.describeElement(shape.getId()))Types: IBoardFacadeElementDescriptor
Package: @univerjs-pro/boards · Type definitions
FBoard.describeElements
Describes matching board elements as compact agent-friendly summaries.
This is the recommended discovery API for agents before they modify a board. It returns descriptors in board
z-order, supports the same filters as findElements(), and avoids exposing large internal element payloads in
prompts or tool results.
describeElements(query?: IBoardFacadeElementQuery): IBoardFacadeElementDescriptor[]Parameters
query— Optional. Default:{}. Optional type and visibility filters.
Returns
Compact descriptors in board z-order.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.describeElements({ elementType: univerAPI.Enum.BoardElementType.Shape }))Types: IBoardFacadeElementDescriptor · IBoardFacadeElementQuery
Package: @univerjs-pro/boards · Type definitions
FBoard.describeElementsByIds
Describes multiple board elements addressed by generated ids.
Use this when an integration starts from UI selection ids or event payload ids and the agent needs compact
descriptors before deciding which id-based mutation APIs to call. The returned object preserves every normalized
requested id and uses null when an element is missing.
describeElementsByIds(elementIds: string[]): Record<string, IBoardFacadeElementDescriptor | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-descriptor map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.describeElementsByIds([shape.getId()]))Types: IBoardFacadeElementDescriptor · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.disbandContainer
Disbands a container while preserving its children.
This is useful when an agent decides a grouping container is no longer semantically meaningful. The method refuses blocked containers and containers whose parent membership rules prevent disbanding.
disbandContainer(containerId: string): booleanParameters
containerId— Required. Container id to disband.
Returns
true when the disband command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if ( !board.createContainer({ id: containerId, left: 80, top: 80 }) || !board.disbandContainer(containerId)) { throw new Error('Cannot disband container')}Package: @univerjs-pro/boards · Type definitions
FBoard.distributeElements
Distributes at least three elements with equal horizontal or vertical gaps.
distributeElements(elementIds: string[], distribution: BoardFacadeElementDistribution): booleanParameters
elementIds— Required. Existing element ids.distribution— Required. Distribution axis.
Returns
true when at least one element moves and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 260, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 560, top: 80 } },])if ( !shapes || !board.distributeElements( shapes.map((shape) => shape.getId()), 'horizontal', )) { throw new Error('Cannot distribute shapes')}Types: BoardFacadeElementDistribution
Package: @univerjs-pro/boards · Type definitions
FBoard.findElements
Finds board elements by type and visibility.
Agent examples should use univerAPI.Enum.BoardElementType constants for type filters so scripts remain discoverable
and typo-resistant.
findElements(query?: IBoardFacadeElementQuery): IBoardPageElement[]Parameters
query— Optional. Default:{}. Query options. Omit it to list all visible elements on the active page.
Returns
Matching elements in board z-order.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.findElements({ elementType: univerAPI.Enum.BoardElementType.Shape })console.log(shapes.map((shape) => shape.id))Types: IBoardPageElement · IBoardFacadeElementQuery
Package: @univerjs-pro/boards · Type definitions
FBoard.fitContainerToContent
Fits a container bounds to its current content.
Use this after an agent moves elements into a container or changes child geometry. The operation goes through the same command path as the UI action.
fitContainerToContent(containerId: string): booleanParameters
containerId— Required. Container id.
Returns
true when the fit command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 },})if (!shape || !board.reparentElements([shape.getId()], containerId)) throw new Error('Cannot insert shape')if (!board.fitContainerToContent(containerId)) throw new Error('Cannot fit container')Package: @univerjs-pro/boards · Type definitions
FBoard.fitElementsIntoBounds
Fits an element group into a rectangle while optionally preserving its aspect ratio.
fitElementsIntoBounds(elementIds: string[], bounds: IBoardRect, options?: IBoardFacadeFitElementsIntoBoundsOptions): booleanParameters
elementIds— Required. Existing element ids.bounds— Required. Target board-coordinate rectangle.options— Optional. Default:{}. Aspect-ratio behavior.
Returns
true when source and target bounds are valid and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 180 } },])if ( !shapes || !board.fitElementsIntoBounds( shapes.map((shape) => shape.getId()), { left: 100, top: 100, width: 640, height: 360, }, )) throw new Error('Cannot fit shapes')Types: IBoardRect · IBoardFacadeFitElementsIntoBoundsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.getBackground
Gets the active Board page background as detached data.
getBackground(): IBoardBackgroundData | undefinedReturns
The explicit background, or undefined when the page uses the default canvas background.
Types: IBoardBackgroundData
Package: @univerjs-pro/boards · Type definitions
FBoard.getConnectorConnection
Returns detached endpoint and routing data for one connector.
getConnectorConnection(elementId: string): IBoardFacadeConnectorConnection | nullParameters
elementId— Required. Existing connector id.
Returns
Detached connection data, or null when the id is missing or not a connector.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(),})if (!connector) throw new Error('Cannot insert connector')console.log(board.getConnectorConnection(connector.id))Types: IBoardFacadeConnectorConnection
Package: @univerjs-pro/boards · Type definitions
FBoard.getConnectorLabels
Returns a detached copy of connector labels in rendering order, including rich document content.
Mutating the result does not change the Board; use setConnectorLabels or updateConnectorLabel to write.
getConnectorLabels(elementId: string): IBoardConnectorLabel[]Parameters
elementId— Required. Connector id on the active page.
Returns
Labels synchronously, or an empty array if there are none or the id is not a connector.
Examples
const labels = board.getConnectorLabels(connectorId)const labelIds = labels.map((label) => label.id)Types: IBoardConnectorLabel
Package: @univerjs-pro/boards · Type definitions
FBoard.getConnectorLabelStyle
Gets the detached visual style of one connector label.
Label appearance is separate from rich-text formatting. fill and stroke style the label box, while
interruptLine controls whether the connector route is visually interrupted behind the label. Missing fill means
transparent, missing stroke means no border, and missing interruptLine means the route is interrupted.
getConnectorLabelStyle(elementId: string): IBoardConnectorLabelStyle | nullParameters
elementId— Required. Existing connector id.
Returns
Detached label style, or null when the connector or label is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const style = board.getConnectorLabelStyle('connector-id')if (style) console.log(style.fill?.color, style.stroke?.color, style.interruptLine ?? true)Types: IBoardConnectorLabelStyle
Package: @univerjs-pro/boards · Type definitions
FBoard.getConnectorLabelText
Gets one connector label as a detached rich-text value.
The returned value never mutates the Board directly. Call copy() to obtain the shared Univer
RichTextBuilder, update the builder, and pass it to setConnectorLabelText() to commit the change through the
Board command layer. This is the same value/builder flow used by other Univer rich-text facade APIs.
getConnectorLabelText(elementId: string): RichTextValue | nullParameters
elementId— Required. Existing connector id.
Returns
Detached label text, or null when the connector or label is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(), labelText: 'Next',})if (!connector) throw new Error('Cannot insert connector')const value = board.getConnectorLabelText(connector.id)const builder = value?.copy()if (!builder) throw new Error('Connector label is missing')builder.setStyle(0, builder.toPlainText().length, { fs: 16, bl: univerAPI.Enum.BooleanNumber.TRUE, cl: { rgb: '#2563eb' },})if (!board.setConnectorLabelText(connector.id, builder)) throw new Error('Cannot style label')Types: RichTextValue
Package: @univerjs-pro/boards · Type definitions
FBoard.getConnectorStyle
Returns a detached connector style snapshot.
getConnectorStyle(elementId: string): IBoardFacadeConnectorStylePatch | nullParameters
elementId— Required. Existing connector id.
Returns
Editable connector style, or null when the id is missing or not a connector.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(),})if (!connector) throw new Error('Cannot insert connector')console.log(board.getConnectorStyle(connector.id))Types: IBoardFacadeConnectorStylePatch
Package: @univerjs-pro/boards · Type definitions
FBoard.getContainerChildren
Gets direct children of a container in board z-order.
This only returns direct members whose parentId equals containerId. Use getContainerDescendants() when an
agent needs nested container content.
Agent scripts should prefer getContainerChildren() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getContainerChildren(containerId: string): IBoardPageElement[]Parameters
containerId— Required. Container element id.
Returns
Direct child elements. Returns an empty array for missing or non-container elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const child = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 },})if (!child || !board.reparentElements([child.getId()], containerId)) throw new Error('Cannot insert child')console.log(board.getContainerChildren(containerId))Types: IBoardPageElement
Package: @univerjs-pro/boards · Type definitions
FBoard.getContainerDescendants
Gets all nested descendants of a container in traversal order.
The traversal follows direct children in board z-order and then walks nested containers. It guards against cycles so agent scripts can inspect imperfect imported content without hanging.
Agent scripts should prefer getContainerDescendants() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getContainerDescendants(containerId: string): IBoardPageElement[]Parameters
containerId— Required. Container element id.
Returns
Nested child elements. Returns an empty array for missing or empty containers.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const child = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 },})if (!child || !board.reparentElements([child.getId()], containerId)) throw new Error('Cannot insert child')console.log(board.getContainerDescendants(containerId))Types: IBoardPageElement
Package: @univerjs-pro/boards · Type definitions
FBoard.getContainerStyle
Returns a detached container-style snapshot.
getContainerStyle(elementId: string): IBoardFacadeContainerStyle | nullParameters
elementId— Required. Existing container id.
Returns
Editable frame/title style, or null when the id is missing or not a container.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')console.log(board.getContainerStyle(containerId))Types: IBoardFacadeContainerStyle
Package: @univerjs-pro/boards · Type definitions
FBoard.getData
Gets the current in-memory board snapshot.
This does not force resource serialization. Use save() when you need a persisted snapshot with resource data.
The returned serialization snapshot is detached: changing it cannot mutate the live board. For ordinary board
inspection, prefer describeElements() or other id-based reads.
getData(): IBoardDataReturns
The current board data.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const data = board.getData()console.log(data.name, Object.keys(data.pages ?? {}).length)Types: IBoardData
Package: @univerjs-pro/boards · Type definitions
FBoard.getElement
Gets one element by generated id.
This low-level read returns a detached model snapshot. Changing it cannot mutate the live board; use
updateElement() or an intent-specific mutation method to apply changes.
getElement(elementId: string): IBoardPageElement | nullParameters
elementId— Required. Generated board element id.
Returns
The element, or null when it is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape || !board.getElement(shape.getId())) throw new Error('Cannot read inserted shape')Types: IBoardPageElement
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementBounds
Reads one board element's resolved bounds by generated id.
Use this when code starts from a UI selection id and only needs board-coordinate bounds for layout, collision,
or viewport calculations. This is lighter than describeElement() because it returns only the resolved bounds.
Agent scripts should prefer getElementBounds() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getElementBounds(elementId: string): IBoardRect | nullParameters
elementId— Required. Generated board element id.
Returns
Resolved board-coordinate bounds, or null when the element is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementBounds(shape.getId()))Types: IBoardRect
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementCenter
Reads one board element's center point by generated id.
Use this when code starts from a UI selection id and needs a stable board-coordinate point for connector endpoints, relative placement, or distance calculations. The center is derived from resolved world bounds, so it accounts for parent container transforms.
Agent scripts should prefer getElementCenter() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getElementCenter(elementId: string): IBoardFacadePoint | nullParameters
elementId— Required. Generated board element id.
Returns
Center point in board coordinates, or null when the element is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementCenter(shape.getId()))Types: IBoardFacadePoint
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementGeometry
Reads one board element's lightweight geometry by generated id.
Use this when code starts from a UI selection id and needs both resolved bounds and center point. It is lighter
than describeElement() and avoids making agents call separate bounds and center APIs.
Agent scripts should prefer getElementGeometry() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getElementGeometry(elementId: string): IBoardFacadeElementGeometry | nullParameters
elementId— Required. Generated board element id.
Returns
Geometry snapshot, or null when the element is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementGeometry(shape.getId()))Types: IBoardFacadeElementGeometry
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementIdsInOrder
Gets generated board element ids in board z-order with optional facade filters.
Use this narrow helper when an id-based integration needs ordered ids but the script still wants the same type,
visibility filters supported by findElements(). Prefer getElementIdsInOrder() for prompts
and saved agent plans.
getElementIdsInOrder(query?: IBoardFacadeElementQuery): string[]Parameters
query— Optional. Default:{}. Optional type and visibility filters.
Returns
Generated element ids in board z-order.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const visibleShapeIds = board.getElementIdsInOrder({ elementTypes: [univerAPI.Enum.BoardElementType.Shape],})console.log(visibleShapeIds)Types: IBoardFacadeElementQuery
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementLayout
Returns the active Board page's element layout in Board model coordinates.
This is a model-only query. It does not depend on a Scene, viewport, scroll position, zoom, Canvas, DOM, or a UI plugin. Because Board is an infinite canvas, the result intentionally has no finite container bounds.
getElementLayout(): IBoardFacadeElementLayoutResultReturns
Ordered element bounds and their union.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const layout = board.getElementLayout()console.log(layout.subUnitId, layout.contentBounds)Types: IBoardFacadeElementLayoutResult
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementMetadata
Gets resolved top-level metadata for an element.
The returned booleans use board defaults: visible and selectable default to true, while locked defaults to
false. This is easier for agents than reading raw optional model fields.
Agent scripts should prefer getElementMetadata() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getElementMetadata(elementId: string): IBoardFacadeElementMetadata | nullParameters
elementId— Required. Generated board element id.
Returns
Resolved metadata, or null when the element is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementMetadata(shape.getId()))Types: IBoardFacadeElementMetadata
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementOrder
Gets generated element ids in the current board z-order.
This is a low-level order API. Use it when a UI integration or import/export pipeline must preserve the raw page
order. Agent scripts should prefer getElementIdsInOrder() for generated element ids or describeElements() for
type, metadata, and z-order in one descriptor list.
getElementOrder(): string[]Returns
Ordered generated element ids. Returns an empty array when the page does not exist.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getElementOrder())Package: @univerjs-pro/boards · Type definitions
FBoard.getElementParentChain
Gets the parent container chain for an element.
The first id is the direct parent, followed by ancestors. This is useful when an agent needs to understand whether an element is inside a group, generic container, or swimlane before moving or deleting it.
Agent scripts should prefer getElementParentChain() when element ids are known; use this id-based
method only for UI selection ids, event payload ids, or low-level integrations.
getElementParentChain(elementId: string): string[]Parameters
elementId— Required. Element id to inspect.
Returns
Parent container ids from nearest to farthest.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const child = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 },})if (!child || !board.reparentElements([child.getId()], containerId)) throw new Error('Cannot insert child')console.log(board.getElementParentChain(child.getId()))Package: @univerjs-pro/boards · Type definitions
FBoard.getElementPermission
Returns the permission facade for one stable Board element id.
The Board's single page id remains an internal address component and is resolved automatically.
getElementPermission(elementId: string): FBoardElementPermissionParameters
elementId— Required. Stable Board element id.
Returns
Permission facade combining the Board and Element Edit points.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active Board.')const element = Object.values(board.getElements())[0]if (!element) throw new Error('Board element not found.')await board.getElementPermission(element.id).setReadOnly()Types: FBoardElementPermission
Package: @univerjs-pro/boards · Type definitions
FBoard.getElements
Gets all elements on the Board as an id-to-element map.
Use getElementOrder() when iteration order matters.
This low-level read returns detached model snapshots. For agent reasoning over board content, prefer
describeElements() or id-based descriptor APIs so scripts do not depend on internal element payloads.
getElements(): Record<string, IBoardPageElement>Returns
Element map in Board z-order, or an empty object when the Board is empty.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(Object.keys(board.getElements()))Types: IBoardPageElement · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsBoundingRect
Reads the union bounds for all board elements matching a facade query.
Use this when an agent needs the overall occupied board rectangle for visible content, a group, a type
subset, or another query without first collecting ids. It uses the same filters as describeElements(),
including default hidden-element filtering.
getElementsBoundingRect(query?: IBoardFacadeElementQuery): IBoardRect | nullParameters
query— Optional. Default:{}. Optional type and visibility filters.
Returns
Union bounds for matching elements, or null when the query matches no bounded elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getElementsBoundingRect({ elementType: univerAPI.Enum.BoardElementType.Shape }))Types: IBoardRect · IBoardFacadeElementQuery
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsBoundingRectByIds
Reads the union bounds for multiple board elements addressed by generated ids.
Use this after a UI selection when an agent needs the group's overall board-coordinate rectangle for centering,
spacing, collision checks, or viewport fitting. Missing ids are ignored; null means none of the requested ids
resolved to elements with bounds.
getElementsBoundingRectByIds(elementIds: string[]): IBoardRect | nullParameters
elementIds— Required. Generated board element ids.
Returns
Union bounds for existing elements, or null when no requested id resolves.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 160 } },])if (!shapes) throw new Error('Cannot insert shapes')console.log(board.getElementsBoundingRectByIds(shapes.map((shape) => shape.getId())))Types: IBoardRect
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsBoundsByIds
Reads resolved bounds for multiple board elements addressed by generated ids.
The returned object preserves every normalized requested id and uses null for missing elements. Use this after
a UI multi-selection when an agent wants to compute spacing or alignment without pulling full descriptors.
getElementsBoundsByIds(elementIds: string[]): Record<string, IBoardRect | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-bounds map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementsBoundsByIds([shape.getId()]))Types: IBoardRect · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsByIds
Gets multiple elements by generated ids.
This is a low-level escape hatch for framework integrations that already have generated ids. Agent scripts should
usually prefer describeElementsByIds() or id-based APIs because raw elements include internal board model
payloads.
getElementsByIds(elementIds: string[]): Record<string, IBoardPageElement | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-element map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementsByIds([shape.getId(), 'missing-element']))Types: IBoardPageElement · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsCentersByIds
Reads center points for multiple board elements addressed by generated ids.
The returned object preserves every normalized requested id and uses null for missing elements. Use this after
UI multi-selection when an agent wants anchor points without pulling full descriptors.
getElementsCentersByIds(elementIds: string[]): Record<string, IBoardFacadePoint | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-center map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementsCentersByIds([shape.getId()]))Types: IBoardFacadePoint · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsGeometry
Reads lightweight geometry descriptors for all board elements matching a facade query.
Use this when an agent needs identity, type, z-order, bounds, and center point for matching elements without the
heavier text and metadata payload in describeElements(). Results preserve board z-order and use the
same filters as describeElements().
getElementsGeometry(query?: IBoardFacadeElementQuery): IBoardFacadeElementGeometryDescriptor[]Parameters
query— Optional. Default:{}. Optional type and visibility filters.
Returns
Geometry descriptors in board z-order. Elements without resolved bounds are skipped.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getElementsGeometry({ elementType: univerAPI.Enum.BoardElementType.Shape }))Types: IBoardFacadeElementGeometryDescriptor · IBoardFacadeElementQuery
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsGeometryByIds
Reads lightweight geometry snapshots for multiple board elements addressed by generated ids.
The returned object preserves every normalized requested id and uses null for missing elements. Use this after
UI multi-selection when an agent needs both bounds and centers for spacing, alignment, or connector planning.
getElementsGeometryByIds(elementIds: string[]): Record<string, IBoardFacadeElementGeometry | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-geometry map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementsGeometryByIds([shape.getId()]))Types: IBoardFacadeElementGeometry · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getElementsMetadataByIds
Gets resolved top-level metadata for multiple generated board element ids.
This is the batch companion to getElementMetadata(). It is useful after a selection or hit-test flow where the
caller already has generated ids and wants resolved visible, selectable, and locked booleans without reading
raw optional model fields.
getElementsMetadataByIds(elementIds: string[]): Record<string, IBoardFacadeElementMetadata | null>Parameters
elementIds— Required. Generated board element ids.
Returns
An id-to-metadata map that preserves requested ids and uses null for missing elements.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')console.log(board.getElementsMetadataByIds([shape.getId()]))Types: IBoardFacadeElementMetadata · Record
Package: @univerjs-pro/boards · Type definitions
FBoard.getId
Gets the board unit id.
getId(): stringReturns
The unit id of this board.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getId())Package: @univerjs-pro/boards · Type definitions
FBoard.getName
Gets the board display name from the snapshot.
getName(): stringReturns
The board name.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getName())Package: @univerjs-pro/boards · Type definitions
FBoard.getNextAvailableBounds
Calculates a simple empty bounds rectangle next to existing board content.
Use this before inserting a newly generated diagram, table, or group of shapes so agent output does not overlap the
current board. The method is a pure read helper: it does not create elements, dispatch commands, or reserve space.
It finds the union bounds of query, then places the requested rectangle to the right or below that occupied area.
When the query matches nothing, it returns the requested size at origin.
getNextAvailableBounds(options: IBoardFacadeGetNextAvailableBoundsOptions): IBoardRect | nullParameters
options— Required. Desired size, spacing, placement, fallback origin, and optional occupancy query.
Returns
Suggested bounds in board coordinates, or null when size or gap values are invalid.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const bounds = board.getNextAvailableBounds({ width: 240, height: 120, placement: univerAPI.Enum.BoardFacadeNextAvailableBoundsPlacement.Right,})console.log(bounds)Types: IBoardRect · IBoardFacadeGetNextAvailableBoundsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.getPermission
Returns the Board unit permission facade.
getPermission(): FBoardPermissionReturns
Permission facade for Edit, Copy, Print, Export, and Comment.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active Board.')await board.getPermission().setReadOnly()Types: FBoardPermission
Package: @univerjs-pro/boards · Type definitions
FBoard.getShape
Returns a live common Shape handle by Board element id.
getShape(shapeId: string): FShape | FConnectorShape | nullParameters
shapeId— Required.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const inserted = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect })const shape = inserted && board.getShape(inserted.getId())if (!shape) throw new Error('Cannot resolve Shape')console.log(shape.getSnapshot())Types: FShape · FConnectorShape
Package: @univerjs-pro/boards · Type definitions
FBoard.getShapes
Returns all live common Shape and Connector handles on the active Board page.
getShapes(): Array<FShape | FConnectorShape>Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getShapes().map((shape) => shape.getId()))Types: FShape · FConnectorShape · Array
Package: @univerjs-pro/boards · Type definitions
FBoard.getTextContent
Gets standalone text as a detached rich-text value.
getTextContent(elementId: string): RichTextValue | nullParameters
elementId— Required. Existing standalone text id.
Returns
Detached rich text, or null when the id is missing or not standalone text.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const text = board.insertText({ text: 'Draft', left: 80, top: 80 })if (!text) throw new Error('Cannot insert text')console.log(board.getTextContent(text.id)?.getData())Types: RichTextValue
Package: @univerjs-pro/boards · Type definitions
FBoard.getThemeData
Gets the current board theme data.
getThemeData(): IBoardThemeDataReturns
The active board theme.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getThemeData().id, board.getThemeData().name)Types: IBoardThemeData
Package: @univerjs-pro/boards · Type definitions
FBoard.id
readonly id: stringPackage: @univerjs-pro/boards · Type definitions
FBoard.insertClassRelation
Inserts a UML relationship as a native editable connector, without moving its existing endpoint shapes.
Aggregation/composition put the whole (diamond) at start; generalization/realization put the parent/interface
(triangle) at end. The name, two roles and two multiplicities become independently editable labels.
insertClassRelation(options: IBoardFacadeInsertClassRelationOptions): IBoardPageElement | nullParameters
options— Required. Relationship type, existing endpoint ids, optional labels and insertion index.
Returns
The inserted element synchronously, or null if validation or the undoable command fails.
Examples
const relation = board.insertClassRelation({ type: 'composition', name: 'owns', start: { elementId: agentId, role: 'owner', multiplicity: '1' }, end: { elementId: toolId, role: 'tools', multiplicity: '0..*' },})if (!relation) throw new Error('Cannot create class relation')Types: IBoardPageElement · IBoardFacadeInsertClassRelationOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertClassRelations
Inserts UML relationships in one undoable command. Every relationship and endpoint must be valid;
otherwise nothing is inserted. Uses the endpoint and label semantics of insertClassRelation.
This is an insertion API, not a replacement of existing connections.
insertClassRelations(relations: IBoardFacadeInsertClassRelationItem[], options?: IBoardFacadeInsertConnectorsOptions): IBoardPageElement[] | nullParameters
relations— Required. Relationships between shapes already on the active page.options— Optional. Default:{}. Optional insertion index and container fitting target.
Returns
Inserted elements synchronously, or null on invalid input or command failure.
Examples
const relations = board.insertClassRelations([ { type: 'generalization', start: { elementId: agentId }, end: { elementId: baseAgentId } }, { type: 'dependency', start: { elementId: agentId }, end: { elementId: toolId }, name: 'uses' },])if (!relations) throw new Error('Cannot create class relations')Types: IBoardPageElement · IBoardFacadeInsertClassRelationItem · IBoardFacadeInsertConnectorsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertConnector
Inserts a connector between two elements or free points.
For agent scripts, prefer fromElementId and toElementId after obtaining ids from insertShapes() or discovery
methods. When endpoint sides and routing are omitted, the facade chooses facing sides and a space-aware persisted
route. The method resolves those ids to shape-site endpoints, creates the connector through the board
connector factory, and dispatches AddBoardElementsOperation so collaboration and undo/redo use the normal command
path without chaining facade APIs or commands.
insertConnector(options: IBoardFacadeInsertConnectorOptions): IBoardPageElement | nullParameters
options— Required. Connector insertion options.
Returns
The generated connector element when the insert command succeeds, otherwise null.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(), style: { endMarker: { type: 'filledTriangle', size: 'md' } },})if (!connector) throw new Error('Cannot insert connector')Types: IBoardPageElement · IBoardFacadeInsertConnectorOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertConnectors
Inserts multiple connectors in a single board command.
Use this after insertShapes() when an agent creates a complete diagram. It resolves fromElementId/toElementId for each
connector, creates all connector elements, and dispatches one addElements command, reducing collaboration traffic
and keeping undo/redo history compact.
insertConnectors(connectors: IBoardFacadeInsertConnectorItem[], options?: IBoardFacadeInsertConnectorsOptions): IBoardPageElement[] | nullParameters
connectors— Required. Connector items to create. Use element ids to address connectors later.options— Optional. Default:{}. Batch insert options such asinsertIndex,fitContainerId.
Returns
The generated connector elements when the batch succeeds, otherwise null.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 560, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connectors = board.insertConnectors([ { fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(), }, { fromElementId: shapes[1].getId(), toElementId: shapes[2].getId(), },])if (!connectors) throw new Error('Cannot insert connectors')Types: IBoardPageElement · IBoardFacadeInsertConnectorItem · IBoardFacadeInsertConnectorsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertEntityRelation
Inserts a native editable crow-foot relationship. Each cardinality describes the endpoint on which it is set;
identifying uses a solid line and nonIdentifying a dashed line. Existing entities are not repositioned.
insertEntityRelation(options: IBoardFacadeInsertEntityRelationOptions): IBoardPageElement | nullParameters
options— Required. Relationship kind, existing endpoint ids, cardinalities and optional name.
Returns
The inserted element synchronously, or null if validation or the undoable command fails.
Examples
const relation = board.insertEntityRelation({ type: 'nonIdentifying', label: 'records', start: { elementId: agentId, cardinality: 'one' }, end: { elementId: runId, cardinality: 'zeroOrMany' },})if (!relation) throw new Error('Cannot create entity relation')Types: IBoardPageElement · IBoardFacadeInsertEntityRelationOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertEntityRelations
Inserts crow-foot relationships atomically in one undoable command. Uses insertEntityRelation semantics;
it does not remove existing connections. An invalid relationship or endpoint rejects the entire batch.
insertEntityRelations(relations: IBoardFacadeInsertEntityRelationItem[], options?: IBoardFacadeInsertConnectorsOptions): IBoardPageElement[] | nullParameters
relations— Required. Relationships between entities already on the active page.options— Optional. Default:{}. Optional insertion index and container fitting target.
Returns
Inserted elements synchronously, or null on invalid input or command failure.
Examples
const relations = board.insertEntityRelations([ { type: 'identifying', label: 'contains', start: { elementId: runId, cardinality: 'one' }, end: { elementId: stepId, cardinality: 'oneOrMany' }, },])if (!relations) throw new Error('Cannot create entity relations')Types: IBoardPageElement · IBoardFacadeInsertEntityRelationItem · IBoardFacadeInsertConnectorsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertImage
Inserts a Board image using agent-friendly options.
Use a element id when an agent may later replace the image source or move the image. The element is created through the Board image factory and then dispatched through the normal add-element command path, so it participates in collaboration and undo/redo like a UI-inserted image.
insertImage(options: IBoardFacadeInsertImageOptions): IBoardPageElement | nullParameters
options— Required. Image source, bounds, and parent.
Returns
The inserted image element, otherwise null when the source, parent, or command is invalid.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const image = board.insertImage({ source: 'https://example.com/image.png', imageSourceType: univerAPI.Enum.ImageSourceType.URL, left: 80, top: 80, width: 320, height: 180,})if (!image) throw new Error('Cannot insert image')Types: IBoardPageElement · IBoardFacadeInsertImageOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertSequenceMessage
Inserts one ordered message using the activation and shared-timeline rules of insertSequenceMessages.
Create native lifeline participants and activation bars before calling this method.
insertSequenceMessage(options: IBoardFacadeInsertSequenceMessageOptions, layout?: Omit<IBoardFacadeInsertSequenceMessagesOptions, 'insertIndex'>): IBoardPageElement | nullParameters
options— Required. Message type, positive order, participant ids and optional explicit activation ids.layout— Optional. Default:{}. Timeline origin, spacing and self-message dimensions in Board units.
Returns
The inserted connector synchronously, or null when the message cannot be bound or inserted.
Examples
const message = board.insertSequenceMessage( { fromParticipantId: agentId, toParticipantId: toolId, type: 'synchronous', order: 1, text: 'execute()', }, { timeOriginY: 160 },)if (!message) throw new Error('Cannot bind sequence message')Types: IBoardPageElement · IBoardFacadeInsertSequenceMessageOptions · Omit · IBoardFacadeInsertSequenceMessagesOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertSequenceMessages
Inserts messages bound to a covering activation, or to the lifeline outside execution spans.
Create activation bars first. Ambiguous overlapping spans require explicit activation IDs.
Bindings are persisted shape sites: editing an activation moves its attached messages with it.
All messages share one world-space timeline. Create targets must have their header center at the
receive time; destroy targets must end their lifeline there. This helper never moves participants.
Message Y is timeOriginY + firstOffsetY + (order - 1) * step; defaults are 72 for the first offset and 48
for the step. Without an explicit origin, the earliest participant header bottom is used.
Orders must be positive, integral and unique within the batch. The entire batch is one undoable insertion.
insertSequenceMessages(messages: IBoardFacadeInsertSequenceMessageItem[], options?: IBoardFacadeInsertSequenceMessagesOptions): IBoardPageElement[] | nullParameters
messages— Required. Ordered messages referencing native lifelines and optional native activation bars on the active page.options— Optional. Default:{}. Shared timeline, self-loop dimensions, insertion index and optional container fitting target.
Returns
Inserted connectors synchronously, or null without partial insertion if any message is invalid.
Examples
const messages = board.insertSequenceMessages( [ { fromParticipantId: agentId, toParticipantId: toolId, type: 'synchronous', order: 1, text: 'execute()', }, { fromParticipantId: toolId, toParticipantId: agentId, type: 'reply', order: 2, text: 'result', }, ], { timeOriginY: 160, firstOffsetY: 48, step: 64 },)if (!messages) throw new Error('Check participant geometry and overlapping activation spans')// Inspect model geometry with analyzeModelLayout(); use analyzeRenderedLayout() in a rendered Board UI// to check measured text and route collisions before capturing a screenshot.Types: IBoardPageElement · IBoardFacadeInsertSequenceMessageItem · IBoardFacadeInsertSequenceMessagesOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertShape
Inserts a Shape or Connector through the common Board Shape host adapter.
Put geometry under transform; top-level left, top, width, and height are rejected. The Board generates
the element id, and the returned live handle exposes that id through getId(). Set text or additional styling on
the handle after creation. Use insertShapeAtPoint() instead when Board-specific drop-target attachment or
textBox options are required.
insertShape(input: IBoardShapeCreateInput): FShape | FConnectorShape | nullParameters
input— Required. Common Shape creation input. Board supplies its own transform defaults when fields are omitted.
Returns
A live common Shape handle, or null when creation fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect, transform: { left: 80, top: 80, width: 180, height: 100 }, name: 'Review card', description: 'Tracks the current review step', visible: true, selectable: true, shapeData: { fill: { fillType: univerAPI.Enum.ShapeFillEnum.SolidFill, color: '#ede9fe' }, stroke: { lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine, color: '#7c3aed', width: 2, }, },})if (!shape) throw new Error('Cannot insert Shape')shape.setRotation(6).setStrokeLineCapType(univerAPI.Enum.ShapeLineCapEnum.Round)shape .getText() .setText('Board card') .setHorizontalAlign(univerAPI.Enum.HorizontalAlign.CENTER) .setVerticalAlign(univerAPI.Enum.VerticalAlign.MIDDLE)const shapeId = shape.getId()const savedShape = board.getShape(shapeId)if (!savedShape || savedShape.getText().getPlainText() !== 'Board card') { throw new Error('Cannot verify inserted Shape')}console.log({ shapeId, transform: savedShape.getTransform() })Types: FShape · FConnectorShape · IBoardShapeCreateInput
Package: @univerjs-pro/boards · Type definitions
FBoard.insertShapeAtPoint
Inserts a shape at a board coordinate and optionally attaches it to the container or swimlane lane at that point.
This is the shortest path for agents that place cards, nodes, or annotations into an existing board region. The
method maps point to left/top, resolves the drop target with resolveDropTargetAtPoint(), and fills
parentId/laneId internally when the caller did not provide explicit parent options.
insertShapeAtPoint(options: IBoardFacadeInsertShapeAtPointOptions): IBoardPageElement | nullParameters
options— Required. Shape insertion options with a requiredpoint.
Returns
The generated shape element when the insert command succeeds, otherwise null.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShapeAtPoint({ point: { x: 180, y: 160 }, shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect, text: 'Dropped card',})if (!shape) throw new Error('Cannot insert shape at point')Types: IBoardPageElement · IBoardFacadeInsertShapeAtPointOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.insertShapes
Inserts multiple live Shapes or Connectors through one atomic Board command.
This is the batch counterpart of insertShape(): every item uses IBoardShapeCreateInput, and every returned value is
a live common Shape handle. All inputs are inserted by one Board command; validation or command failure returns
null without exposing a partially successful result. Geometry belongs under each item's transform, and the
returned handles preserve input order.
insertShapes(inputs: IBoardShapeCreateInput[]): Array<FShape | FConnectorShape> | nullParameters
inputs— Required. Common Shape creation inputs in the requested insertion order.
Returns
Live Shape handles in input order, or null when validation or the atomic command fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect, transform: { left: 80, top: 80, width: 180, height: 100 }, name: 'Start', }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Ellipse, transform: { left: 320, top: 80, width: 180, height: 100 }, name: 'Finish', },])if (!shapes || shapes.length !== 2) throw new Error('Cannot insert Shapes')shapes[0].getText().setText('Start')shapes[1].getText().setText('Finish')const shapeIds = shapes.map((shape) => shape.getId())const verified = shapeIds.every((shapeId) => board.getShape(shapeId) !== null)if (!verified) throw new Error('Cannot verify inserted Shapes')console.log({ shapeIds, transforms: shapes.map((shape) => shape.getTransform()) })Types: Array · FShape · FConnectorShape · IBoardShapeCreateInput
Package: @univerjs-pro/boards · Type definitions
FBoard.insertText
Inserts standalone Board text through the normal command path.
Use this for labels, annotations, headings, and document fragments that should not have a shape background. The returned element remains editable with the standard Board text editor. Prefer a element id when an agent may update the same annotation in a later run.
insertText(options: IBoardFacadeInsertTextOptions): IBoardTextElement | nullParameters
options— Required. Text content, bounds, optional style, and parent.
Returns
The inserted text element, otherwise null when validation or the command fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const text = board.insertText({ text: 'Board heading', left: 80, top: 80, textStyle: { color: '#2563EB', fontSize: 32, bold: true },})if (!text) throw new Error('Cannot insert text')Types: IBoardTextElement · IBoardFacadeInsertTextOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.moveElementsOutOfContainer
Moves elements out of their current container to the Board root.
This is a semantic alias for reparentElements(elementIds, undefined).
moveElementsOutOfContainer(elementIds: string[]): booleanParameters
elementIds— Required. Element ids to move.
Returns
true when the move succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 },})if (!shape || !board.reparentElements([shape.getId()], containerId)) throw new Error('Cannot insert shape')if (!board.moveElementsOutOfContainer([shape.getId()])) throw new Error('Cannot move shape out')Package: @univerjs-pro/boards · Type definitions
FBoard.moveElementsToContainer
Moves elements into a container.
This is a semantic alias for reparentElements(elementIds, containerId), easier for agents to choose when the
target is definitely a container.
moveElementsToContainer(elementIds: string[], containerId: string): booleanParameters
elementIds— Required. Element ids to move.containerId— Required. Target container id.
Returns
true when the move succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 480, top: 80 },})if (!shape || !board.moveElementsToContainer([shape.getId()], containerId)) throw new Error('Cannot move shape')Package: @univerjs-pro/boards · Type definitions
FBoard.normalizeConnectorRouting
Resets selected connectors to the Board orthogonal auto router.
The command preserves endpoints, labels, style, parent scope, and lane membership while clearing manual path state. The change participates in Board undo and redo.
normalizeConnectorRouting(connectorIds: string[]): NormalizeBoardConnectorRoutingResultParameters
connectorIds— Required. Generated connector ids, normally taken from layout issue results.
Returns
The changed and skipped ids. When connectors change, affectedBounds covers the previous connector
routes and their bound endpoint elements; a no-op returns null. The API returns false when the command fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const analysis = board.analyzeModelLayout()if (!analysis) throw new Error('Cannot analyze the active board')const connectorIds = Array.from(new Set(analysis.issues.flatMap((issue) => issue.connectorIds)))if (connectorIds.length > 0) { const result = board.normalizeConnectorRouting(connectorIds) if (!result) throw new Error('Cannot normalize connector routing') console.log(result.changedConnectorIds, result.skippedElementIds)}Types: NormalizeBoardConnectorRoutingResult
Package: @univerjs-pro/boards · Type definitions
FBoard.redo
Redoes the last operation undone in this board.
This method focuses this board before executing redo, making it the preferred redo API for agent scripts that
already hold an FBoard instance.
redo(): booleanReturns
true when an operation was redone; otherwise false.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape || !board.undo() || !board.redo()) throw new Error('Cannot redo shape insertion')Package: @univerjs-pro/boards · Type definitions
FBoard.removeConnectorLabel
Removes one connector label through the Board command layer.
The connector itself and its routing remain unchanged. The removal participates in collaboration and undo/redo,
so board.undo() restores the label text, rich-text document, box style, and position.
removeConnectorLabel(elementId: string, labelId?: string): booleanParameters
elementId— Required. Existing connector id with a label.labelId— Optional.
Returns
true when the label exists and is removed.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const connectorId = 'connector-id'if (!board.removeConnectorLabel(connectorId)) throw new Error('Cannot remove connector label')// Restore the removed label when needed.board.undo()Package: @univerjs-pro/boards · Type definitions
FBoard.removeElement
Removes one board element through the command layer.
The method rejects locally known locked, hidden, unselectable, or membership-locked container content. Prefer id-based lookup before removal in agent scripts so generated ids do not leak into prompts.
removeElement(elementId: string): booleanParameters
elementId— Required. Element id to remove.
Returns
true when the remove command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape || !board.removeElement(shape.getId())) throw new Error('Cannot remove shape')Package: @univerjs-pro/boards · Type definitions
FBoard.removeElements
Removes multiple board elements in one command.
Use this batch API when an agent cleans up several generated elements. It rejects duplicate ids and dispatches one command, which keeps collaboration and undo history compact.
removeElements(elementIds: string[]): booleanParameters
elementIds— Required. Element ids to remove.
Returns
true when all ids pass local checks and the remove command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])if (!shapes || !board.removeElements(shapes.map((shape) => shape.getId()))) throw new Error('Cannot remove shapes')Package: @univerjs-pro/boards · Type definitions
FBoard.removeSwimlaneLane
Removes one lane from a swimlane container.
Empty unlocked lanes are removed directly. When the lane contains children, choose an explicit contentPolicy:
promote children to the swimlane pool, move them to another unlocked lane, or delete them.
removeSwimlaneLane(containerId: string, laneId: string, options?: IBoardFacadeRemoveSwimlaneLaneOptions): booleanParameters
containerId— Required. Swimlane container id.laneId— Required. Lane id to remove.options— Optional. Default:{}. Optional content policy.
Returns
true when the lane is removed.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [ { id: 'todo', title: 'Todo' }, { id: 'done', title: 'Done' }, ], }) || !board.removeSwimlaneLane(swimlaneId, 'done')) throw new Error('Cannot remove lane')Types: IBoardFacadeRemoveSwimlaneLaneOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.renameSwimlaneLane
Renames one swimlane lane.
Empty names are rejected and whitespace is trimmed. Locked lanes cannot be renamed.
renameSwimlaneLane(containerId: string, laneId: string, title: string): booleanParameters
containerId— Required. Swimlane container id.laneId— Required. Lane id to rename.title— Required. New lane title.
Returns
true when the lane title changes.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [{ id: 'todo', title: 'Todo' }], }) || !board.renameSwimlaneLane(swimlaneId, 'todo', 'Ready')) throw new Error('Cannot rename lane')Package: @univerjs-pro/boards · Type definitions
FBoard.reorderElements
Reorders existing elements in board z-order.
reorderElements(elementIds: string[], placement: BoardElementOrderPlacement): booleanParameters
elementIds— Required. Existing element ids.placement— Required. Absolute or one-step z-order placement.
Returns
true when every id exists and the order changes successfully.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 } },])if (!shapes) throw new Error('Cannot insert shapes')const background = shapes[1]if (!board.reorderElements([background.id], 'back')) { throw new Error('Cannot send background to back')}Types: BoardElementOrderPlacement
Package: @univerjs-pro/boards · Type definitions
FBoard.reorderSwimlaneLane
Moves a swimlane lane to a new index.
Locked lanes cannot be reordered. targetIndex is clamped into the valid range, making agent-generated values
safe when they are slightly outside the current lane count.
reorderSwimlaneLane(containerId: string, laneId: string, targetIndex: number): booleanParameters
containerId— Required. Swimlane container id.laneId— Required. Lane id to move.targetIndex— Required. New zero-based index.
Returns
true when the lane order changes.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [ { id: 'todo', title: 'Todo' }, { id: 'done', title: 'Done' }, ], }) || !board.reorderSwimlaneLane(swimlaneId, 'done', 0)) throw new Error('Cannot reorder lane')Package: @univerjs-pro/boards · Type definitions
FBoard.reparentElements
Reparents elements into a container or back to the Board root.
Pass parentId to move elements into a container. Pass undefined to move them out to the Board root. The method
checks membership-locked parents and target container accessibility before dispatching.
reparentElements(elementIds: string[], parentId?: string): booleanParameters
elementIds— Required. Element ids to move.parentId— Optional. Target container id, orundefinedfor the Board root.
Returns
true when the reparent command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80 })) throw new Error('Cannot create container')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 480, top: 80 },})if (!shape || !board.reparentElements([shape.getId()], containerId)) throw new Error('Cannot reparent shape')Package: @univerjs-pro/boards · Type definitions
FBoard.resolveCaptureBounds
Resolves a screenshot target to active-page Board world bounds without requiring a browser renderer.
Omit options for all visible content, pass region for an explicit world rectangle, or pass elementIds for
the union of visible element bounds. Region and element selectors are mutually exclusive.
resolveCaptureBounds(options?: IBoardFacadeCaptureBoundsOptions): ResolveBoardCaptureBoundsResultParameters
options— Optional. Default:{}. Capture selector and world-unit padding.
Returns
Structured bounds or a selector error, or false when the command cannot run.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const [element] = board.describeElements()if (!element) throw new Error('The active board is empty')const target = board.resolveCaptureBounds({ elementIds: [element.id], padding: 48 })if (!target) throw new Error('Cannot resolve Board capture bounds')if (!target.ok) throw new Error(`Cannot capture Board: ${target.code}`)console.log(target.bounds)Types: ResolveBoardCaptureBoundsResult · IBoardFacadeCaptureBoundsOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.resolveContainerAtPoint
Resolves the topmost unlocked container at a board coordinate.
Use this before inserting or moving agent-created elements when you want them to attach to the container under a
point. area: 'content' ignores container headers and uses the usable content area, including swimlane lane
content when available.
resolveContainerAtPoint(point: IBoardFacadePoint, options?: IBoardFacadeResolveContainerAtPointOptions): IBoardContainerElement | nullParameters
point— Required. Point in board coordinates.options— Optional. Default:{}. Container-area options. Defaults to the outer container area.
Returns
The deepest topmost matching container, or null.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80, width: 320, height: 240 })) { throw new Error('Cannot create container')}console.log(board.resolveContainerAtPoint({ x: 160, y: 160 }))Types: IBoardContainerElement · IBoardFacadePoint · IBoardFacadeResolveContainerAtPointOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.resolveDropTargetAtPoint
Resolves the board drop target at a coordinate for agent insert operations.
Use containerId as parentId and laneId as laneId when inserting an element at the same point. The
descriptor gives agents enough context to reason about the target without reading raw container payloads. When the
point is outside a matching container, or outside content bounds when area: 'content' is used, the method returns
null.
resolveDropTargetAtPoint(point: IBoardFacadePoint, options?: IBoardFacadeResolveContainerAtPointOptions): IBoardFacadeDropTarget | nullParameters
point— Required. Point in board coordinates.options— Optional. Default:{}. Container-area options. Defaults to the outer container area.
Returns
Drop target information, or null when no valid target exists at that point.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if (!board.createContainer({ id: containerId, left: 80, top: 80, width: 320, height: 240 })) { throw new Error('Cannot create container')}console.log(board.resolveDropTargetAtPoint({ x: 160, y: 160 }, { area: 'content' }))Types: IBoardFacadeDropTarget · IBoardFacadePoint · IBoardFacadeResolveContainerAtPointOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.save
Save and return the board snapshot, including resource data.
This is a detached serialization export. It is not a live model reference; use facade mutation APIs instead of editing it when changes must participate in undo/redo and collaboration.
save(): IBoardDataReturns
The board snapshot.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const snapshot = board.save()console.log(snapshot.name, Object.keys(snapshot.pages ?? {}).length)Types: IBoardData
Package: @univerjs-pro/boards · Type definitions
FBoard.sendElementsBackward
Moves elements one z-order step backward.
sendElementsBackward(elementIds: string[]): booleanParameters
elementIds— Required. Existing element ids.
Returns
true when the order changes successfully.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 } },])if (!shapes || !board.sendElementsBackward([shapes[1].getId()])) throw new Error('Cannot move shape backward')Package: @univerjs-pro/boards · Type definitions
FBoard.sendElementsToBack
Sends elements to the back.
sendElementsToBack(elementIds: string[]): booleanParameters
elementIds— Required. Existing element ids.
Returns
true when the order changes successfully.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 } },])if (!shapes || !board.sendElementsToBack([shapes[1].getId()])) throw new Error('Cannot send shape to back')Package: @univerjs-pro/boards · Type definitions
FBoard.setConnectorConnection
Patches connector endpoints, routing, or manual waypoints through the normal update command.
setConnectorConnection(elementId: string, patch: IBoardFacadeConnectorConnectionPatch): booleanParameters
elementId— Required. Existing connector id.patch— Required. Endpoint and routing fields to replace.
Returns
true when the connector and endpoints are valid and the update succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 560, top: 80 } },])if (!shapes) throw new Error('Cannot insert connector targets')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(),})if (!connector) throw new Error('Cannot insert connector')const replacement = shapes[2]const changed = board.setConnectorConnection(connector.id, { end: { elementId: replacement.id, connectionSiteId: 3 }, routing: 'curve',})if (!changed) throw new Error('Cannot reconnect edge')Types: IBoardFacadeConnectorConnectionPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setConnectorLabels
Replaces every label on one connector in one undoable command, preserving its endpoints and route.
Pass [] to remove all labels. Label ids must be non-empty and unique within the connector.
autoSize does not wrap automatically; fixedWidth wraps to the specified width and grows vertically;
fixedSize also fixes height. Measured dimensions remain render-derived, not persisted by this method.
setConnectorLabels(elementId: string, labels: readonly IBoardFacadeConnectorLabel[]): booleanParameters
elementId— Required. Existing connector id on the active page.labels— Required. Complete replacement labels with stable ids; plain text or rich document content is supported.
Returns
true synchronously on success; false for invalid labels, a non-connector id or command failure.
Examples
const ok = board.setConnectorLabels(connectorId, [ { id: 'name', content: 'executes', placement: { anchor: 'center' }, layout: { mode: 'autoSize' }, }, { id: 'target', content: '0..*', placement: { anchor: 'end', side: 'left' } },])if (!ok) throw new Error('Cannot replace connector labels')Types: IBoardFacadeConnectorLabel
Package: @univerjs-pro/boards · Type definitions
FBoard.setConnectorLabelStyle
Patches the visual style of one existing connector label through the Board command layer.
Omitted fields preserve their current values. Pass null for fill or stroke to restore the default
transparent/no-border appearance. Set interruptLine to false only when the connector should remain visible
behind the text. lineGap is the extra spacing around the label box in Board units.
setConnectorLabelStyle(elementId: string, patch: IBoardConnectorLabelStylePatch): booleanParameters
elementId— Required. Existing connector id with a label.patch— Required. Label appearance fields to update.
Returns
true when the label exists and the command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const connectorId = 'connector-id'if ( !board.setConnectorLabelStyle(connectorId, { fill: { color: '#ffffff', opacity: 0.92 }, stroke: { color: '#94a3b8', width: 1, lineStrokeType: univerAPI.Enum.ShapeLineTypeEnum.SolidLine, }, interruptLine: true, lineGap: 3, })) throw new Error('Cannot style connector label')// Restore the default transparent label while keeping the route interrupted behind the text.board.setConnectorLabelStyle(connectorId, { fill: null, stroke: null, interruptLine: true })Types: IBoardConnectorLabelStylePatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setConnectorLabelText
Sets one connector label, creating the label when necessary.
Pass a string for plain text or the shared RichTextBuilder returned by univerAPI.newRichText() or
getConnectorLabelText(...).copy(). The builder is detached before the command executes, so later builder
changes do not mutate the Board. The command participates in collaboration and undo/redo.
Text changes preserve declarative layout constraints. Board UI measures content at runtime without writing
derived dimensions into the model. Use updateConnectorLabel(..., { layout }) to change sizing constraints;
successful headless execution does not imply that visual layout has been measured.
setConnectorLabelText(elementId: string, text: BoardFacadeTextContent): booleanParameters
elementId— Required. Existing connector id.text— Required. Plain or rich label content.
Returns
true when the connector exists and the update succeeds or is already current.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(),})if (!connector) throw new Error('Cannot insert connector')const label = univerAPI .newRichText() .align({ horizontal: univerAPI.Enum.HorizontalAlign.CENTER }) .span('Approved', { bold: true, fontSize: 16, color: '#16a34a' })if (!board.setConnectorLabelText(connector.id, label)) { throw new Error('Cannot set label')}Types: BoardFacadeTextContent
Package: @univerjs-pro/boards · Type definitions
FBoard.setConnectorStyle
Patches the visual style of one connector without changing its endpoints or label.
Animation is disabled by default. The available modes are dash (moving dash), particle (one moving dot),
pulse (whole-path highlight), gradient (moving fading highlight), particles (repeated dots), and arrows
(repeated directional arrowheads). Use animation: null to disable an existing animation. A small number of
animated connectors can make data flow easier to read; keep dense diagrams static unless motion adds meaning.
Marker names are validated at runtime; use { type: 'none' } rather than null to hide a marker.
setConnectorStyle(elementId: string, patch: IBoardFacadeConnectorStylePatch): booleanParameters
elementId— Required. Existing connector id.patch— Required. Connector style fields to update.
Returns
true when the connector and patch are valid and the update succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 320, top: 80 } },])if (!shapes) throw new Error('Cannot insert shapes')const connector = board.insertConnector({ fromElementId: shapes[0].getId(), toElementId: shapes[1].getId(),})if ( !connector || !board.setConnectorStyle(connector.id, { stroke: '#4f46e5', strokeWidth: 2, animation: { mode: 'gradient', direction: 'forward', speed: 1 }, })) { throw new Error('Cannot style connector')}// Reverse and accelerate the same animation.if ( !board.setConnectorStyle(connector.id, { animation: { mode: 'gradient', direction: 'reverse', speed: 2 }, })) throw new Error('Cannot update connector animation')// Restore a static connector. `undefined` would preserve the current animation instead.if (!board.setConnectorStyle(connector.id, { animation: null })) { throw new Error('Cannot disable connector animation')}Types: IBoardFacadeConnectorStylePatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setContainerAutoResize
Enables or disables auto-resize for a container.
Auto-resize is useful for agent-generated groups that should grow with their children. The facade rejects disabling auto-resize on a membership-locked container because that would conflict with local container invariants.
setContainerAutoResize(containerId: string, autoResize: boolean): booleanParameters
containerId— Required. Container id.autoResize— Required. Whether the container should auto-resize.
Returns
true when the command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if ( !board.createContainer({ id: containerId, left: 80, top: 80 }) || !board.setContainerAutoResize(containerId, true)) throw new Error('Cannot enable auto-resize')Package: @univerjs-pro/boards · Type definitions
FBoard.setContainerMembershipLocked
Enables or disables membership locking for a container.
A membership-locked container prevents facade operations from moving children out through normal reparent/remove paths. This helps agents protect generated groups after they are finalized.
setContainerMembershipLocked(containerId: string, membershipLocked: boolean): booleanParameters
containerId— Required. Container id.membershipLocked— Required. Whether membership should be locked.
Returns
true when the command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if ( !board.createContainer({ id: containerId, left: 80, top: 80 }) || !board.setContainerMembershipLocked(containerId, true)) throw new Error('Cannot lock membership')Package: @univerjs-pro/boards · Type definitions
FBoard.setContainerStyle
Patches the frame and title style of a generic container or swimlane.
setContainerStyle(elementId: string, patch: IBoardFacadeContainerStylePatch): booleanParameters
elementId— Required. Existing container id.patch— Required. Frame fields and optional partial title style.
Returns
true when the container and patch are valid and the update succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const containerId = `container-${Date.now()}`if ( !board.createContainer({ id: containerId, left: 80, top: 80 }) || !board.setContainerStyle(containerId, { fillColor: '#f8fafc', strokeColor: '#64748b', })) throw new Error('Cannot style container')Types: IBoardFacadeContainerStylePatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setElementMetadata
Updates top-level metadata for one element.
This keeps geometry and element-specific payload intact while using the normal Board command path, so the change participates in undo/redo and collaboration.
setElementMetadata(elementId: string, patch: IBoardFacadeSetElementMetadataPatch): booleanParameters
elementId— Required. Existing element id returned by an insert or discovery API.patch— Required. Metadata fields to update. Explicitundefinedclearsnameordescription.
Returns
true when the element exists and the update succeeds or is already current.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 120, top: 120 }, name: 'Review',})if (!shape || !board.setElementMetadata(shape.getId(), { name: 'Review step', locked: true })) { throw new Error('Cannot update shape metadata')}Types: IBoardFacadeSetElementMetadataPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setElementsMetadata
Updates top-level metadata for several elements in one command.
Every id must exist and be editable; otherwise no element is changed.
setElementsMetadata(patches: Record<string, IBoardFacadeSetElementMetadataPatch>): booleanParameters
patches— Required. Element-id-to-metadata map.
Returns
true when every target is valid and the atomic batch succeeds or is already current.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])if ( !shapes || !board.setElementsMetadata({ [shapes[0].getId()]: { name: 'Start' }, [shapes[1].getId()]: { name: 'Finish' }, })) throw new Error('Cannot update metadata')Types: Record · IBoardFacadeSetElementMetadataPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setElementsTransform
Applies transform patches atomically to several elements.
setElementsTransform(patches: Record<string, IBoardFacadeElementTransformPatch>): booleanParameters
patches— Required. Element-id-to-transform map.
Returns
true when every target and patch is valid and the batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])if ( !shapes || !board.setElementsTransform({ [shapes[0].getId()]: { left: 120 }, [shapes[1].getId()]: { left: 360, rotation: 15 }, })) throw new Error('Cannot transform shapes')Types: Record · IBoardFacadeElementTransformPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setElementTransform
Moves, resizes, rotates, or flips one element without rebuilding its full model.
setElementTransform(elementId: string, patch: IBoardFacadeElementTransformPatch): booleanParameters
elementId— Required. Existing element id.patch— Required. Transform fields to replace; omitted fields keep their current values.
Returns
true when the element and patch are valid and the update succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect, transform: { left: 80, top: 80 }, name: 'Move me',})if (!shape || !board.setElementTransform(shape.getId(), { left: 240, top: 160, rotation: 15 })) { throw new Error('Cannot transform shape')}Types: IBoardFacadeElementTransformPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.setImageBackground
Uses an image as the active Board page background.
The background stays below Board elements and does not participate in selection or pointer interaction.
setImageBackground(options: IBoardFacadeSetImageBackgroundOptions): thisParameters
options— Required. Image source and fill behavior.
Returns
This board, for chaining.
Examples
const board = univerAPI.getActiveBoard()board?.setImageBackground({ source: 'https://example.com/background.jpg', imageSourceType: univerAPI.Enum.ImageSourceType.URL, fit: 'cover',})Types: IBoardFacadeSetImageBackgroundOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.setName
Sets the board display name.
setName(name: string): thisParameters
name— Required. The new board name.
Returns
This board, for chaining.
Examples
const board = univerAPI.getActiveBoard()board?.setName('Planning Board')Package: @univerjs-pro/boards · Type definitions
FBoard.setSwimlaneLaneCollapsed
Collapses or expands one swimlane lane.
Collapsing is rejected for locked lanes. Use this when an agent wants to reduce visual noise without deleting the lane or its children.
setSwimlaneLaneCollapsed(containerId: string, laneId: string, collapsed: boolean): booleanParameters
containerId— Required. Swimlane container id.laneId— Required. Lane id to update.collapsed— Required. Whether the lane should be collapsed.
Returns
true when the collapsed state changes.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [{ id: 'todo', title: 'Todo' }], }) || !board.setSwimlaneLaneCollapsed(swimlaneId, 'todo', true)) throw new Error('Cannot collapse lane')Package: @univerjs-pro/boards · Type definitions
FBoard.setSwimlaneLanes
Replaces the full swimlane model for a swimlane container.
This is a low-level lane operation. Prefer the focused lane APIs for agent scripts because they express intent more clearly. Locked lanes cannot be removed, reordered, resized, renamed, or moved by this method.
setSwimlaneLanes(containerId: string, swimlane: IBoardSwimlaneData): booleanParameters
containerId— Required. Swimlane container id.swimlane— Required. Complete next swimlane model.
Returns
true when the update command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [{ id: 'todo', title: 'Todo' }], })) { throw new Error('Cannot create swimlane')}const element = board.getElement(swimlaneId)if ( !element || element.type !== univerAPI.Enum.BoardElementType.Container || element.containerData.kind !== 'swimlane' || !element.containerData.swimlane || !board.setSwimlaneLanes(swimlaneId, { ...element.containerData.swimlane, laneGap: 16 })) { throw new Error('Cannot update swimlane')}Types: IBoardSwimlaneData
Package: @univerjs-pro/boards · Type definitions
FBoard.setSwimlaneLaneSize
Resizes one swimlane lane.
The method rejects locked lanes and missing swimlane containers. Use meaningful lane ids so agent scripts can modify layouts without relying on generated indexes.
setSwimlaneLaneSize(containerId: string, laneId: string, size: number): booleanParameters
containerId— Required. Swimlane container id.laneId— Required. Lane id to resize.size— Required. New lane size in board coordinates.
Returns
true when the resize command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const swimlaneId = `swimlane-${Date.now()}`if ( !board.createSwimlane({ id: swimlaneId, left: 80, top: 80, lanes: [{ id: 'todo', title: 'Todo' }], }) || !board.setSwimlaneLaneSize(swimlaneId, 'todo', 240)) throw new Error('Cannot resize lane')Package: @univerjs-pro/boards · Type definitions
FBoard.setTextContent
Replaces standalone text content while preserving its bounds and style.
setTextContent(elementId: string, content: BoardFacadeTextContent): booleanParameters
elementId— Required. Existing standalone text id.content— Required. Plain text or a value returned byuniverAPI.newRichText().
Returns
true when the text element exists and the update succeeds or is already current.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const text = board.insertText({ text: 'Draft', left: 80, top: 80 })if (!text || !board.setTextContent(text.id, 'Approved')) throw new Error('Cannot update text')Types: BoardFacadeTextContent
Package: @univerjs-pro/boards · Type definitions
FBoard.setTheme
Applies a board theme by id.
Theme ids come from board theme presets or host-provided theme registration. Passing the current theme id is safe and keeps the example copy-paste runnable.
setTheme(themeIdOrOptions: string | IBoardFacadeSetThemeOptions): booleanParameters
themeIdOrOptions— Required. Theme id or{ themeId }.
Returns
true when the theme command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const currentThemeId = board.getThemeData().idif (!currentThemeId) throw new Error('No board theme id')const changed = board.setTheme(currentThemeId)if (!changed) throw new Error('Cannot apply board theme')Types: IBoardFacadeSetThemeOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.translateElement
Translates one element by a relative board-coordinate delta.
translateElement(elementId: string, translation: IBoardFacadeElementTranslation): booleanParameters
elementId— Required. Existing element id.translation— Required. Relative horizontal and vertical movement.
Returns
true when the delta is finite and non-zero and the update succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape || !board.translateElement(shape.getId(), { dx: 120, dy: 40 })) throw new Error('Cannot move shape')Types: IBoardFacadeElementTranslation
Package: @univerjs-pro/boards · Type definitions
FBoard.translateElements
Translates several elements by the same relative board-coordinate delta in one command.
translateElements(elementIds: string[], translation: IBoardFacadeElementTranslation): booleanParameters
elementIds— Required. Existing element ids.translation— Required. Shared relative movement.
Returns
true when every target is valid and the atomic batch succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])if ( !shapes || !board.translateElements( shapes.map((shape) => shape.getId()), { dx: 40, dy: 80 }, )) { throw new Error('Cannot move shapes')}Types: IBoardFacadeElementTranslation
Package: @univerjs-pro/boards · Type definitions
FBoard.undo
Undoes the last operation in this board.
Unlike univerAPI.undo(), this method first focuses this board, so it remains deterministic when an agent also
edits embedded rich-text documents or other Univer units.
undo(): booleanReturns
true when an operation was undone; otherwise false.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape || !board.undo()) throw new Error('Cannot undo shape insertion')Package: @univerjs-pro/boards · Type definitions
FBoard.updateConnectorLabel
Updates one stable label id in an undoable command; other labels, endpoints and routing remain unchanged. Content and layout replace their entire previous values; placement and style merge individual fields. A null layout restores AutoSize; null placement/style restores defaults. An explicit anchor or path ratio clears the old free offset unless an offset is supplied in the same patch.
updateConnectorLabel(elementId: string, labelId: string, patch: IBoardFacadeConnectorLabelPatch): booleanParameters
elementId— Required. Existing connector id on the active page.labelId— Required. Existing stable label id, as returned bygetConnectorLabels.patch— Required. Content, placement, sizing or style changes. Omitted fields are retained.
Returns
true synchronously on success; false for a missing label, invalid patch or command failure.
Examples
const ok = board.updateConnectorLabel(connectorId, 'name', { content: 'Executes tools with approval', layout: { mode: 'fixedWidth', width: 160 }, placement: { anchor: 'center', offset: null },})if (!ok) throw new Error('Cannot update connector label')Types: IBoardFacadeConnectorLabelPatch
Package: @univerjs-pro/boards · Type definitions
FBoard.updateElement
Updates one element model through the command layer.
This is a low-level API for callers that already have a complete next element model. For agent scripts, prefer intent-specific APIs such as metadata setters, container APIs, and shape/connector insert APIs where possible. Supplying the current model and transform is a successful no-op: it creates neither an undo entry nor a collaboration mutation.
updateElement(elementId: string, options: IBoardFacadeUpdateElementOptions): booleanParameters
elementId— Required. Existing element id to update.options— Required. Next element model and optional transform behavior.
Returns
true when the update command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shape = board.insertShape({ shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 },})if (!shape) throw new Error('Cannot insert shape')const element = board.getElement(shape.getId())if ( !element || !board.updateElement(shape.getId(), { element: { ...element, name: 'Updated shape' } })) { throw new Error('Cannot update shape')}Types: IBoardFacadeUpdateElementOptions
Package: @univerjs-pro/boards · Type definitions
FBoard.wrapElementsInContainer
Wraps existing elements in a new or existing container.
Pass containerId to reuse a known container. Omit it to let the command create a container using title.
Duplicate ids and blocked elements are rejected before dispatch.
wrapElementsInContainer(elementIds: string[], options?: IBoardFacadeWrapElementsInContainerOptions): booleanParameters
elementIds— Required. Element ids to wrap.options— Optional. Default:{}. Optional container id and title.
Returns
true when the wrap command succeeds.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const shapes = board.insertShapes([ { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 80, top: 80 } }, { shapeType: univerAPI.Enum.ShapeTypeEnum.Rect, transform: { left: 280, top: 80 } },])if ( !shapes || !board.wrapElementsInContainer( shapes.map((shape) => shape.getId()), { title: 'Group' }, )) { throw new Error('Cannot wrap shapes')}Types: IBoardFacadeWrapElementsInContainerOptions
Package: @univerjs-pro/boards · Type definitions
@univerjs-pro/boards-chart
FBoard.getChart
Returns a Board Chart by its Chart resource id or Board element id.
getChart(chartIdOrElementId: string): FBoardChart | nullParameters
chartIdOrElementId— Required. A Chart resource id or Board element id.
Returns
The live Board Chart facade, or null if it does not exist.
Examples
const fBoard = univerAPI.getActiveBoard()const fChart = fBoard.getChart('chart-1234')console.log(fChart?.getInfo())Types: FBoardChart
Package: @univerjs-pro/boards-chart · Type definitions
FBoard.getCharts
Returns all Charts in this Board.
getCharts(): FBoardChart[]Returns
Live Chart facades in Board element order.
Examples
const fBoard = univerAPI.getActiveBoard()const fCharts = fBoard.getCharts()fCharts.forEach((fChart) => { console.log(fChart.getId(), fChart.getElementId(), fChart.getInfo())})Types: FBoardChart
Package: @univerjs-pro/boards-chart · Type definitions
FBoard.insertChart
Inserts a Chart into this Board from detached Chart information.
insertChart(info: IBoardChartInfo): Promise<FBoardChart>Parameters
info— Required. The configuration, data source, placement, and ownership produced by a Board Chart Builder.
Returns
A live facade for the inserted Board Chart.
Throws
If the data source or size is invalid, a reference cannot be resolved, or insertion fails.
Examples
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Column) .setSource([ ['Quarter', 'Sales'], ['Q1', 120], ['Q2', 180], ]) .setAbsolutePosition(120, 80) .setSize(640, 360) .setTitle('Quarterly sales') .build()const fChart = await fBoard.insertChart(chartInfo)fChart.setSubtitle('FY 2026')Types: FBoardChart · Promise · IBoardChartInfo
Package: @univerjs-pro/boards-chart · Type definitions
FBoard.newChart
Creates a detached, type-specific Chart Builder for this Board.
newChart<T extends ChartTypeString>(type: T): FBoardChartBuilderOf<T>Parameters
type— Required. The Chart type to create.
Returns
A detached Builder that produces insertable Board Chart information.
Examples
const fBoard = univerAPI.getActiveBoard()const chartInfo = fBoard .newChart(univerAPI.Enum.ChartTypeString.Column) .setSource([ ['Quarter', 'Sales'], ['Q1', 120], ['Q2', 180], ]) .setAbsolutePosition(120, 80) .setSize(640, 360) .setTitle('Quarterly sales') .build()const fChart = await fBoard.insertChart(chartInfo)console.log(fChart.getId(), fChart.getElementId())Types: FBoardChartBuilderOf
Package: @univerjs-pro/boards-chart · Type definitions
@univerjs-pro/boards-exchange-client
FBoard.insertMermaidAsync
Convert Mermaid code and insert the resulting diagram into this Board's active page.
insertMermaidAsync(code: string, options?: IBoardMermaidOptions): Promise<boolean>Parameters
code— Required. Mermaid source code to convert and insertoptions— Optional. Mermaid conversion and insertion options
Returns
A promise that resolves to true when the diagram is inserted; otherwise false
Examples
const board = univerAPI.getActiveBoard()if (board) { const inserted = await board.insertMermaidAsync('flowchart TD; A[Start] --> B[Finish]', { diagramType: 'flowchart', fileName: 'workflow.mermaid', containerName: 'Workflow', selectAfterInsert: true, left: 320, top: 240, })}Types: Promise · IBoardMermaidOptions
Package: @univerjs-pro/boards-exchange-client · Type definitions
@univerjs-pro/boards-mind
FBoard.getMindMap
Gets a structured mind map by its generated container id.
getMindMap(containerId: string): FBoardMindMap | nullParameters
containerId— Required. Mind-map container id.
Returns
Mind-map facade, or null when it is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const inserted = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!inserted) throw new Error('Cannot insert mind map')console.log(board.getMindMap(inserted.getId()))Types: FBoardMindMap
Package: @univerjs-pro/boards-mind · Type definitions
FBoard.getMindMaps
Gets all structured mind maps in Board z-order.
Use this before a bulk audit or migration. The result only contains structured mind-map containers; ordinary containers, shapes, and connectors are excluded.
getMindMaps(): FBoardMindMap[]Returns
Mind map facades, including hidden or locked maps so agents can inspect complete state.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getMindMaps().map((mindMap) => mindMap.getId()))Types: FBoardMindMap
Package: @univerjs-pro/boards-mind · Type definitions
FBoard.insertMindMap
Inserts a structured mind map.
insertMindMap(options: IBoardMindMapFacadeInsertOptions): FBoardMindMap | nullParameters
options— Required. Position, layout, and root-node tree.
Returns
Mind-map facade, or null when insertion fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release', children: [{ text: 'QA' }, { text: 'Launch' }] },})if (!mindMap) throw new Error('Cannot insert mind map')Types: FBoardMindMap · IBoardMindMapFacadeInsertOptions
Package: @univerjs-pro/boards-mind · Type definitions
@univerjs-pro/boards-table
FBoard.getTable
Gets a Board table by its generated host element id.
getTable(elementId: string): FBoardTable | nullParameters
elementId— Required. Board table host element id.
Returns
Table facade, or null when it is missing.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const inserted = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!inserted) throw new Error('Cannot insert table')console.log(board.getTable(inserted.getId()))Types: FBoardTable
Package: @univerjs-pro/boards-table · Type definitions
FBoard.getTables
Gets all table facades in Board z-order.
getTables(): FBoardTable[]Returns
Board table facades.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getTables().map((table) => table.getId()))Types: FBoardTable
Package: @univerjs-pro/boards-table · Type definitions
FBoard.insertTable
Inserts a Board table.
insertTable(options: IBoardTableFacadeInsertOptions): FBoardTable | nullParameters
options— Required. Position, size, dimensions, and optional diagram preset.
Returns
Table facade, or null when insertion fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const table = board.insertTable({ left: 80, top: 80, rows: 3, columns: 3 })if (!table) throw new Error('Cannot insert table')Types: FBoardTable · IBoardTableFacadeInsertOptions
Package: @univerjs-pro/boards-table · Type definitions
@univerjs-pro/boards-thread-comment
FBoard.createElementCommentAsync
Creates a comment for any Board element ID, including shapes, text, images, charts, tables, connectors, mind maps, and ink.
createElementCommentAsync(elementId: string, content: ThreadComment.ThreadCommentContent, options?: IBoardCommentCreateOptions): Promise<boolean>Parameters
elementId— Required. Stable ID of an element on the active Board page.content— Required. Plain text or a Univer document body for rich comment content.options— Optional. Default:{}. Optional stable IDs, author, attachments, and creation time.
Returns
true when the create command succeeds; otherwise, false.
Throws
If the element does not exist on the active page.
If the content is empty.
Examples
const board = univerAPI.getActiveBoard()const chart = board?.getCharts()[0]if (chart) await board?.createElementCommentAsync(chart.getElementId(), 'Verify this chart.')Types: Promise · ThreadComment.ThreadCommentContent · IBoardCommentCreateOptions
Package: @univerjs-pro/boards-thread-comment · Type definitions
FBoard.createPositionCommentAsync
Creates a free-position comment in Board world coordinates.
createPositionCommentAsync(position: IBoardCommentPosition, content: ThreadComment.ThreadCommentContent, options?: IBoardCommentCreateOptions): Promise<boolean>Parameters
position— Required. Position in the Board's unscaled world coordinate system.content— Required. Plain text or a Univer document body for rich comment content.options— Optional. Default:{}. Optional stable IDs, author, attachments, and creation time.
Returns
true when the create command succeeds; otherwise, false.
Throws
If either coordinate is not finite or the content is empty.
Examples
await univerAPI .getActiveBoard() ?.createPositionCommentAsync({ x: 320, y: 180 }, 'Review this area.')Types: Promise · IBoardCommentPosition · ThreadComment.ThreadCommentContent · IBoardCommentCreateOptions
Package: @univerjs-pro/boards-thread-comment · Type definitions
FBoard.getComments
Returns locally loaded element and free-position comments across all pages in this Board.
getComments(): ThreadComment.IFacadeThreadCommentInfo[]Returns
Every locally loaded comment thread owned by this Board.
Examples
const comments = univerAPI.getActiveBoard()?.getComments() ?? []comments.forEach(({ root, anchor }) => console.log(root.id, anchor))Types: ThreadComment.IFacadeThreadCommentInfo
Package: @univerjs-pro/boards-thread-comment · Type definitions
FBoard.getElementComments
Returns locally loaded comments for one stable Board element ID on the active page.
getElementComments(elementId: string): ThreadComment.IFacadeThreadCommentInfo[]Parameters
elementId— Required. Stable ID of the target Board element.
Returns
Matching comment threads for the active page and element.
Examples
const board = univerAPI.getActiveBoard()const elementId = board ? Object.keys(board.getElements())[0] : undefinedconst comments = board && elementId ? board.getElementComments(elementId) : []console.log(comments.length)Types: ThreadComment.IFacadeThreadCommentInfo
Package: @univerjs-pro/boards-thread-comment · Type definitions
FBoard.listCommentsAsync
Synchronizes known threads and returns element and free-position comments across all pages in this Board.
listCommentsAsync(): Promise<ThreadComment.IFacadeThreadCommentInfo[]>Returns
A promise resolving to every synchronized comment thread owned by this Board.
Examples
const board = univerAPI.getActiveBoard()const comments = board ? await board.listCommentsAsync() : []console.log(comments.length)Types: ThreadComment.IFacadeThreadCommentInfo · Promise
Package: @univerjs-pro/boards-thread-comment · Type definitions
FBoard.listElementCommentsAsync
Synchronizes known threads and returns comments for one stable Board element ID on the active page.
listElementCommentsAsync(elementId: string): Promise<ThreadComment.IFacadeThreadCommentInfo[]>Parameters
elementId— Required. Stable ID of the target Board element.
Returns
A promise resolving to matching synchronized comment threads.
Examples
const board = univerAPI.getActiveBoard()const elementId = board ? Object.keys(board.getElements())[0] : undefinedconst comments = board && elementId ? await board.listElementCommentsAsync(elementId) : []console.log(comments.length)Types: ThreadComment.IFacadeThreadCommentInfo · Promise
Package: @univerjs-pro/boards-thread-comment · Type definitions
@univerjs-pro/ink
FBoard.getInks
Lists persistent Ink elements in Board z-order, including hidden or locked Ink.
getInks(): IBoardShapeElement[]Returns
Ink shape elements in Board z-order.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')console.log(board.getInks().length)Types: IBoardShapeElement
Package: @univerjs-pro/ink · Type definitions
FBoard.insertInk
Inserts one persistent Ink element through the normal Board command path.
insertInk(options: IBoardInkFacadeInsertOptions): IBoardShapeElement | nullParameters
options— Required. Ink model, style, element id, and optional container placement.
Returns
The inserted Board shape element, or null when validation or insertion fails.
Examples
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const ink = board.insertInk({ tool: univerAPI.Enum.BoardInkTool.Brush, model: { kind: 'brush', points: [ { x: 80, y: 80, t: 0 }, { x: 160, y: 120, t: 1 }, { x: 240, y: 90, t: 2 }, ], color: '#2563eb', width: 4, opacity: 1, },})if (!ink) throw new Error('Cannot insert ink')Types: IBoardShapeElement · IBoardInkFacadeInsertOptions
Package: @univerjs-pro/ink · Type definitions
你觉得这篇文档如何?