Comments
Register the comment plugins after the product editor and the license configuration are complete, and load the shared and product UI styles together with the locale resources. The product plugin owns its comment resources, so it must be registered before a snapshot is restored.
pnpm add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/boards-thread-comment @univerjs-pro/boards-thread-comment-uinpm install @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/boards-thread-comment @univerjs-pro/boards-thread-comment-uiyarn add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/boards-thread-comment @univerjs-pro/boards-thread-comment-uibun add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/boards-thread-comment @univerjs-pro/boards-thread-comment-uiimport { UniverBoardsThreadCommentPlugin } from '@univerjs-pro/boards-thread-comment'import { UniverBoardsThreadCommentUIPlugin } from '@univerjs-pro/boards-thread-comment-ui'import ProductLocale from '@univerjs-pro/boards-thread-comment-ui/locale/en-US'import { LocaleType, mergeLocales } from '@univerjs/core'import SharedLocale from '@univerjs/thread-comment-ui/locale/en-US'import '@univerjs/thread-comment-ui/lib/index.css'import '@univerjs-pro/boards-thread-comment-ui/lib/index.css'univerAPI.loadLocales(LocaleType.EN_US, mergeLocales(SharedLocale, ProductLocale))univer.registerPlugin(UniverBoardsThreadCommentPlugin)univer.registerPlugin(UniverBoardsThreadCommentUIPlugin)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-thread-comment-ui | UniverBoardsThreadCommentUIPlugin | UniverBoardsThreadCommentMobileUIPlugin |
Comment Facade
Import the shared comment Facade and the product Facade before these methods are called. The product helpers create stable anchors, and the shared API handles replies, updates, resolution, and deletion. getComments() reads local state. listCommentsAsync() synchronizes the threads it already knows about through the configured data source; it does not discover every thread on the server.
import '@univerjs/thread-comment/facade'import '@univerjs-pro/boards-thread-comment/facade'const board = univerAPI.getActiveBoard()if (board) { await board.createPositionCommentAsync({ x: 320, y: 180 }, 'Review this area.') console.log(await board.listCommentsAsync())}import '@univerjs/thread-comment/facade'const [thread] = univerAPI.getComments({ resolved: false })if (thread) { await univerAPI.replyCommentAsync({ unitId: thread.unitId, subUnitId: thread.subUnitId, threadId: thread.threadId, content: 'Reviewed.', })}Shared discussions
For shared discussions, integrate the Comment Service and Endpoint through the Server SDK, then register UniverThreadCommentDataSourcePlugin from @univerjs-pro/thread-comment-datasource after the collaboration and license configuration is complete. The supplied data source calls /universer-api/comment/unit/{unitId}/... and /universer-api/user/list, so the application must expose these routes. Comment reads and writes require their own server permissions; document editing permissions do not cover them.
How is this guide?