匯入匯出
透過 @univerjs-pro/boards-exchange-client,畫板可以匯入 Mermaid 原始碼並匯出 PPTX 檔案。
支援的格式
下表列出本頁前端 API 支援的格式。Office 檔案轉換還需要後端支援對應的文件類型和格式。
| 匯入 | 匯出 |
|---|---|
| Mermaid 原始碼文字 | .pptx |
先註冊 Board 執行環境
TypeScript
univer.registerPlugin(UniverBoardsPlugin)univer.registerPlugin(UniverBoardsUIPlugin)univer.registerPlugin(UniverBoardsExchangeClientPlugin)匯入可能包含選用元素的資料前,請先註冊對應的元素外掛程式:
TypeScript
univer.registerPlugin(UniverBoardsTablePlugin)univer.registerPlugin(UniverBoardsTableUIPlugin)univer.registerPlugin(UniverBoardsMindPlugin)univer.registerPlugin(UniverBoardsMindUIPlugin)快照交接
若要在應用程式層級保存資料,請儲存並還原 Board 快照:
TypeScript
const board = univerAPI.getActiveBoard()const snapshot = board.getData()univer.createUnit(UniverInstanceType.UNIVER_BOARD, snapshot)Facade 匯出與 Mermaid 匯入
TypeScript
import '@univerjs-pro/exchange-client/facade'import '@univerjs-pro/boards-exchange-client/facade'const file = await univerAPI.exportBoardByUnitIdAsync(board.getId())if (file) univerAPI.downloadFile(file, 'board', 'pptx')await board.insertMermaidAsync('flowchart LR\n A[草稿] --> B[審閱]')匯出 PPTX 時,請透過 Univer Server SDK 整合轉換後端,並確認其支援 Board 快照。用戶端授權需另外設定;註冊前端外掛不會自動提供轉換介面。
移除內建匯出選單和 UI 互動
Univer 移除了內建的匯出選單和 UI 互動,底層服務及 Facade API 繼續保留。
如果你的應用程式需要保留原有的匯出選單和 UI 互動,可以參考內建匯出選單和 UI 互動遷移方案,透過自訂外掛完成遷移。範例提供完整原始碼,支援線上檢視和下載。
你覺得這篇文檔如何?