API 参考

FBoardMindMap

本 API 页面目前提供英文正文。代码签名与标识符不随界面语言变化。

Facade for a structured mind map container.

Instances come from getMindMap(), insertMindMap(), or insertMindMap(). Do not construct this class directly because it needs the active Board model and command service.

Access

Access through:

Setup

Register @univerjs-pro/boards-mind or a preset that includes it. In plugin mode, import @univerjs-pro/boards-mind/facade. Additional methods below require their listed plugin packages. See Facade setup.

@univerjs-pro/boards-mind

FBoardMindMap.getBounds

Gets this mind map's resolved Board-coordinate bounds.

The returned object is detached and safe to modify. Bounds include the implicit mind-map container padding and are suitable for collision checks, viewport decisions, or as a diagnostic before bounded reflow.

TypeScript
getBounds(): IBoardRect | null

Returns

Current resolved bounds, or null when the mind map no longer exists.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!mindMap) throw new Error('Cannot insert mind map')const bounds = mindMap.getBounds()if (!bounds) throw new Error('Mind map no longer exists')console.log(`Mind map size: ${bounds.width} × ${bounds.height}`)

Types: IBoardRect

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getDescendants

Gets every non-root node in deterministic depth-first tree order.

TypeScript
getDescendants(): FBoardMindMapNode[]

Returns

Descendant node facades, excluding the root.

Examples

TypeScript
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', children: [{ text: 'Automation' }] }] },})if (!mindMap) throw new Error('Cannot insert mind map')console.log(mindMap.getDescendants().map((node) => node.getText()))

Types: FBoardMindMapNode

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getId

Gets the generated container element id.

TypeScript
getId(): string

Returns

Generated element id for integration event payloads.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!mindMap) throw new Error('Cannot insert mind map')console.log(mindMap.getId())

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getLayout

Gets a detached snapshot of this mind map's active layout.

TypeScript
getLayout(): IBoardMindMapFacadeLayout | null

Returns

Layout fields accepted by setLayout().

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!mindMap) throw new Error('Cannot insert mind map')console.log(mindMap.getLayout())

Types: IBoardMindMapFacadeLayout

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getNode

Gets a node in this mind map by its generated element id.

TypeScript
getNode(nodeId: string): FBoardMindMapNode | null

Parameters

  • nodeId — Required. Mind-map node element id.

Returns

Node facade, or null when it is missing or outside this mind map.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })const root = mindMap?.getRootNode()if (!mindMap || !root) throw new Error('Cannot insert mind map')console.log(mindMap.getNode(root.getId()))

Types: FBoardMindMapNode

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getNodes

Lists nodes in Board z-order.

TypeScript
getNodes(): FBoardMindMapNode[]

Returns

Node facades for this structured mind map.

Examples

TypeScript
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' }] },})if (!mindMap) throw new Error('Cannot insert mind map')console.log(mindMap.getNodes().map((node) => node.getText()))

Types: FBoardMindMapNode

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.getRootNode

Gets the root node facade.

TypeScript
getRootNode(): FBoardMindMapNode | null

Returns

Root node, or null when the structured container is no longer valid.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!mindMap) throw new Error('Cannot insert mind map')console.log(mindMap.getRootNode()?.getText())

Types: FBoardMindMapNode

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.reflow

Rebalances, compacts when necessary, and centers this mind map inside a target rectangle.

Reflow operates on the mind map's managed nodes and connectors; it does not reflow unrelated children of a generic Board container. It also does not reparent the map into the target element. A successful call applies layout metadata, branch sides, node positions, connector routes, and centering atomically as one undo item.

Horizontal maps default to balanced right/left root branches when direction is omitted. The first attempt uses requested or current gaps. Unless compact is false, a failed fit retries once with supported minimum gaps. V1 deliberately preserves node and text size. If that readable layout is still too large, no data changes and the result reports bounds-too-small, requiredBounds, and the diagnostic scale ratio that would be needed.

TypeScript
reflow(options: IBoardMindMapFacadeReflowOptions): IBoardMindMapFacadeReflowResult

Parameters

  • options — Required. Target Board-coordinate bounds, optional inset, and optional layout overrides. Invalid values return invalid-options; they do not throw or mutate the board.

Returns

Detached structured result suitable for headless and agent callers. Check success before using bounds as the final geometry.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')// Create a visible region whose geometry will be used as the reflow target.const zone = board.insertShapes([  {    id: 'release-zone',    shapeType: univerAPI.Enum.ShapeTypeEnum.RoundRect,    left: 80,    top: 80,    width: 1_000,    height: 600,    text: 'Release planning',  },])?.[0]if (!zone) throw new Error('Cannot insert target zone')const mindMap = board.insertMindMap({  id: 'release-map',  left: 180,  top: 180,  root: {    text: 'Release',    children: [      { text: 'Product', children: [{ text: 'Scope' }, { text: 'UX' }] },      { text: 'Engineering', children: [{ text: 'API' }, { text: 'QA' }] },      { text: 'Launch', children: [{ text: 'Docs' }, { text: 'Campaign' }] },    ],  },})if (!mindMap) throw new Error('Cannot insert mind map')const targetBounds = board.getElementBounds(zone.id)if (!targetBounds) throw new Error('Cannot resolve target bounds')const result = mindMap.reflow({ bounds: targetBounds, padding: 24 })if (result.success) {  console.log('Final mind-map bounds', result.bounds)} else if (result.reason === 'bounds-too-small' && result.requiredBounds) {  console.warn('Target is too small', {    requiredWidth: result.requiredBounds.width,    requiredHeight: result.requiredBounds.height,    diagnosticScale: result.scale,  })} else {  throw new Error(`Cannot reflow mind map: ${result.reason ?? 'unknown error'}`)}

Types: IBoardMindMapFacadeReflowResult · IBoardMindMapFacadeReflowOptions

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.remove

Removes this complete structured mind map through the root-node delete operation.

Nodes, managed connectors, and the mind-map container are removed together in one collaborative undo item.

TypeScript
remove(): boolean

Returns

true when the mind map exists and removal succeeds.

Examples

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active board')const mindMap = board.insertMindMap({ left: 120, top: 120, root: { text: 'Release' } })if (!mindMap || !mindMap.remove()) throw new Error('Cannot remove mind map')

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.setBranchLineType

Changes only the branch routing style and recomputes managed connectors.

TypeScript
setBranchLineType(branchLineType: MindMapBranchLineType): boolean

Parameters

  • branchLineType — Required. New branch routing style.

Returns

true when the operation succeeds.

Examples

TypeScript
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' }] },})if (!mindMap || !mindMap.setBranchLineType(univerAPI.Enum.BoardMindMapBranchLineType.Curve)) {  throw new Error('Cannot update branch style')}

Types: MindMapBranchLineType

Package: @univerjs-pro/boards-mind · Type definitions

FBoardMindMap.setLayout

Updates this mind map's layout configuration and recomputes all managed node and branch geometry.

TypeScript
setLayout(options: IBoardMindMapFacadeLayoutOptions): boolean

Parameters

  • options — Required. Layout fields to change. Omitted fields keep their current value.

Returns

true when the operation succeeds.

Examples

TypeScript
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' }] },})if (!mindMap || !mindMap.setLayout({ direction: 'right', horizontalGap: 180 })) {  throw new Error('Cannot update mind-map layout')}

Types: IBoardMindMapFacadeLayoutOptions

Package: @univerjs-pro/boards-mind · Type definitions

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.