表格
畫板的表格支援分為模型包和 UI 包。瀏覽器編輯器如果需要在畫板畫布上提供可編輯的表格元素,必須同時註冊這兩個包。
註冊表格支援
TypeScript
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)行動裝置支援
先完成行動版編輯器的配置。在本頁介紹的外掛模式初始化程式碼中,將下表的桌面版註冊替換為同一套件匯出的行動版外掛,並且必須在開啟文件前完成替換。模型外掛、樣式、語言套件與 Facade 匯入都要保留,兩個版本不能同時註冊。
| 套件 | 桌面版註冊 | 行動版註冊 |
|---|---|---|
@univerjs-pro/boards-table-ui | UniverBoardsTableUIPlugin | UniverBoardsTableMobileUIPlugin |
套件職責
@univerjs-pro/boards-table將表格元素整合至 Board 模型。@univerjs-pro/boards-table-ui在畫板畫布上新增表格渲染和編輯介面,併為瀏覽器端編輯器提供@univerjs-pro/boards-table-ui/locale/*和@univerjs-pro/boards-table-ui/lib/index.css。
快照資料
畫板表格元素儲存 tableId 和畫板元素的通用欄位。表格外掛負責管理表格載荷,元素透過畫板資源引用該載荷。
TypeScript
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')開啟包含 table 元素的快照之前,先登錄檔格支援。
穩定的表格色彩
插入 Board 表格或更改其樣式時,外掛會將解析後的主題色板與該表格一併儲存。即使全域性 Univer 主題發生變化,已有表格仍會保留原有的顏色;選擇其他表格樣式時,會生成該表格自有的新主題快照。
你覺得這篇文檔如何?