容器与泳道

容器让画板能够表示带边框的区域、泳道、UML 包块以及其他父子结构。容器的归属关系通过子元素的 parentId 存储;对于泳道,则还会使用 laneId

创建容器

TypeScript
const board = univerAPI.getActiveBoard()if (!board) throw new Error('No active Board')const containerId = 'scope'const containerCreated = board.createContainer({  id: containerId,  title: 'Scope',  left: 80,  top: 80,  width: 640,  height: 360,})if (!containerCreated) {  throw new Error('Cannot create container')}

将元素移入容器

TypeScript
board.moveElementsToContainer(['card-1', 'card-2'], containerId)board.fitContainerToContent(containerId)

配置归属行为

TypeScript
board.setContainerMembershipLocked(containerId, true)board.setContainerAutoResize(containerId, false)

泳道

泳道是带有分道配置的容器。使用专用的 facade API 可以添加、移除分道,调整分道大小与顺序,以及折叠和重命名分道。

TypeScript
const swimlaneId = 'delivery'const swimlaneCreated = board.createSwimlane({  id: swimlaneId,  left: 80,  top: 80,  width: 720,  height: 360,  orientation: 'horizontal',  lanes: [    { id: 'todo', title: 'Todo', size: 240 },    { id: 'done', title: 'Done', size: 240 },  ],})if (!swimlaneCreated) {  throw new Error('Cannot create swimlane')}board.renameSwimlaneLane(swimlaneId, 'todo', 'Backlog')

你觉得这篇文档如何?

© 2026 DreamNum Co., Ltd.