Table
Board table support is split into model and UI packages. A browser editor that needs editable table elements on the Board canvas must register both packages.
Register table support
import { UniverBoardsTablePlugin } from '@univerjs-pro/boards-table'import { UniverBoardsTableUIPlugin } from '@univerjs-pro/boards-table-ui'import BoardsTableUIEnUS from '@univerjs-pro/boards-table-ui/locale/en-US'import '@univerjs-pro/boards-table/facade'import '@univerjs-pro/boards-table-ui/lib/index.css'univer.registerPlugin(UniverBoardsTablePlugin)univer.registerPlugin(UniverBoardsTableUIPlugin)Mobile support
Configure the mobile editor first. In the plugin-mode setup described on this page, replace the desktop registrations below with the mobile exports from the same packages, and do so before opening a document. Keep the model plugins, styles, locales, and Facade imports, and do not register both variants.
| Package | Desktop registration | Mobile registration |
|---|---|---|
@univerjs-pro/boards-table-ui | UniverBoardsTableUIPlugin | UniverBoardsTableMobileUIPlugin |
Package responsibilities
@univerjs-pro/boards-tableintegrates table elements with the Board model.@univerjs-pro/boards-table-uiadds table rendering and editing UI on the Board canvas. It also provides the@univerjs-pro/boards-table-ui/locale/*locale files and the@univerjs-pro/boards-table-ui/lib/index.cssstylesheet that browser editors require.
Snapshot data
A Board table element stores a tableId and the fields common to every Board element. The table plugin owns the table payload, and the element references the payload through Board resources.
const table = board.insertTable({ left: 120, top: 120, width: 480, height: 280, rows: 3, columns: 4,})if (!table) throw new Error('Cannot insert Board table')Register table support before opening a snapshot that contains table elements.
Stable table colors
When a Board table is inserted or its style changes, the plugin stores the resolved theme palette with that table. Existing tables keep their colors when the global Univer theme changes. Selecting another table style creates a new theme snapshot owned by that table.
How is this guide?