Elements

Elements are the visible content of a Board: text, images, shapes, and connectors. Changes made through the FBoard facade follow the normal command path, so undo, redo, and collaboration apply to them as well.

Read elements

Obtain the active Board before reading its active page. When only stable IDs, types, bounds, and ordering are required, use descriptors instead of depending on the full internal snapshot.

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const elements = board.describeElements()const shapes = board.findElements({  elementType: univerAPI.Enum.BoardElementType.Shape,})

Insert shapes and text

Use the semantic insert methods instead of constructing low-level element snapshots. For insertShape, transform carries the geometry, and the returned live shape handle exposes the text and style APIs.

TypeScript
const shape = board.insertShape({  shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect,  transform: { left: 80, top: 80, width: 180, height: 100 },  name: 'Review card',})if (!shape) throw new Error('Cannot insert shape')shape.getText().setText('Review')shape.setRotation(6)

insertText adds standalone text, and insertImage adds images. When several elements must be added with one command, use the batch variants.

Edit shape text

Use the shape returned by insertShape() in the example below, or the shape obtained in the previous section. getText() returns a live FShapeText handle. Call getPlainText() to read the text, setText() to replace all of it, and the font, color, and alignment methods to format it.

TypeScript
if (!shape) throw new Error('Shape is not available')const shapeText = shape.getText()console.log(shapeText.getPlainText())shapeText  .setText('Quarterly review')  .setFontSize(18)  .setColor('#2563eb')  .setBold(true)  .setHorizontalAlign(univerAPI.Enum.HorizontalAlign.CENTER)  .setVerticalAlign(univerAPI.Enum.VerticalAlign.MIDDLE)

setText() replaces the existing text. Use setRichText() when a single shape requires several styles. To modify existing rich text, call getRichText()?.copy(), edit the builder, and pass it to setRichText(). Changes to that detached builder are not applied automatically. Text style and text box padding and layout describe further options.

TypeScript
const richText = univerAPI.newRichText()  .text('Quarterly ')  .bold('review')shapeText.setRichText(richText)

Connect elements

A connector can attach to existing element IDs. Keep the returned connector or its ID when its style, label, or endpoints are to be changed later.

TypeScript
const target = board.insertShape({  shapeType: univerAPI.Enum.ShapeTypeEnum.Rect,  transform: { left: 360, top: 80, width: 180, height: 100 },})if (!target) throw new Error('Cannot insert target')const connector = board.insertConnector({  fromElementId: shape.getId(),  toElementId: target.getId(),  style: { endMarker: { type: 'filledTriangle', size: 'md' } },})if (!connector) throw new Error('Cannot insert connector')

Transform and arrange elements

Pass only the properties that must change. The ordering, alignment, distribution, and automatic layout methods also accept element IDs.

TypeScript
if (!board.setElementTransform(shape.getId(), { left: 120, top: 140, rotation: 12 })) {  throw new Error('Cannot transform shape')}if (!board.bringElementsToFront([shape.getId()])) {  throw new Error('Cannot bring shape to front')}

Remove elements

removeElement removes a single element, and removeElements removes a batch atomically. Both return whether the command succeeded.

TypeScript
if (!board.removeElements([connector.id, target.getId()])) {  throw new Error('Cannot remove elements')}

For framed groups and swimlanes, continue with Containers & Swimlanes. The Boards facade reference and the Board element data model provide further details.

How is this guide?

© 2026 DreamNum Co., Ltd.