# FBoardMindMap

> Language fallback: requested `zh-CN`; content is `en-US`.

- Human documentation: [https://docs.univer.ai/zh-CN/reference/facade/board-mind-map](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map)

- Agent Markdown: [https://docs.univer.ai/zh-CN/reference/facade/board-mind-map.md](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map.md)

- Requested language: `zh-CN`

- Content language: `en-US`

- Documentation version: `1.0.0-rc.0`

- Source: [facade/board-mind-map.mdx](https://github.com/dream-num/documentation/blob/dev/content/reference/facade/board-mind-map.mdx)

---

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:

* [`FBoard.insertMindMap()`](https://docs.univer.ai/zh-CN/reference/facade/board.md#insertmindmap)
* [`FBoard.getMindMap()`](https://docs.univer.ai/zh-CN/reference/facade/board.md#getmindmap)
* [`FBoard.getMindMaps()`](https://docs.univer.ai/zh-CN/reference/facade/board.md#getmindmaps)

## Setup

Register [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) 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](https://docs.univer.ai/zh-CN/guides/boards/getting-started/facade.md).

## `@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**

```ts
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`](https://unpkg.com/@univerjs-pro/boards@1.0.0-rc.0/lib/types/utils/board-container-transform.util.d.ts)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `FBoardMindMap.getDescendants`

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

```typescript
getDescendants(): FBoardMindMapNode[]
```

**Returns**

Descendant node facades, excluding the root.

**Examples**

```ts
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`](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map-node.md)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `FBoardMindMap.getId`

Gets the generated container element id.

```typescript
getId(): string
```

**Returns**

Generated element id for integration event payloads.

**Examples**

```ts
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`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `FBoardMindMap.getLayout`

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

```typescript
getLayout(): IBoardMindMapFacadeLayout | null
```

**Returns**

Layout fields accepted by `setLayout()`.

**Examples**

```ts
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`](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map-node.md)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `FBoardMindMap.getNodes`

Lists nodes in Board z-order.

```typescript
getNodes(): FBoardMindMapNode[]
```

**Returns**

Node facades for this structured mind map.

**Examples**

```ts
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`](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map-node.md)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://docs.univer.ai/zh-CN/reference/facade/board-mind-map-node.md)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts) · [`IBoardMindMapFacadeReflowOptions`](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/types.d.ts)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

### `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**

```ts
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`](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)

**Package:** [`@univerjs-pro/boards-mind`](https://docs.univer.ai/zh-CN/reference/packages/plugins/univerjs-pro/boards-mind.md) · [Type definitions](https://unpkg.com/@univerjs-pro/boards-mind@1.0.0-rc.0/lib/types/facade/f-board-mind-map.d.ts)
