コメント

プラグイン情報

製品エディターとライセンスの設定後にコメントプラグインを登録し、共通 UI と製品 UI のスタイル・言語リソースを読み込みます。コメントリソースは製品プラグインが管理するため、スナップショットの復元前に登録してください。

Shell
pnpm add @univerjs/thread-comment @univerjs/thread-comment-ui @univerjs-pro/slides-thread-comment @univerjs-pro/slides-thread-comment-ui
TypeScript
import { UniverSlidesThreadCommentPlugin } from '@univerjs-pro/slides-thread-comment'import { UniverSlidesThreadCommentUIPlugin } from '@univerjs-pro/slides-thread-comment-ui'import ProductLocale from '@univerjs-pro/slides-thread-comment-ui/locale/ja-JP'import { LocaleType, mergeLocales } from '@univerjs/core'import SharedLocale from '@univerjs/thread-comment-ui/locale/ja-JP'import '@univerjs/thread-comment-ui/lib/index.css'import '@univerjs-pro/slides-thread-comment-ui/lib/index.css'univerAPI.loadLocales(LocaleType.JA_JP, mergeLocales(SharedLocale, ProductLocale))univer.registerPlugin(UniverSlidesThreadCommentPlugin)univer.registerPlugin(UniverSlidesThreadCommentUIPlugin)

モバイル対応

まずモバイルエディターを設定します。このページのプラグインモードの初期化コードで、以下のデスクトップ登録を同じパッケージのモバイル版に置き換え、文書を開く前に完了してください。モデル、スタイル、言語ファイル、Facade は維持し、両方を同時に登録しないでください。

パッケージデスクトップの登録モバイルの登録
@univerjs-pro/slides-thread-comment-uiUniverSlidesThreadCommentUIPluginUniverSlidesThreadCommentMobileUIPlugin

コメント Facade

共通のコメント Facade と製品 Facade を両方インポートします。製品のメソッドは安定したアンカーを作成し、共通 API は返信・更新・解決・削除を扱います。getComments() はローカル状態を読み取ります。listCommentsAsync() は設定済みデータソースを通じて既知のスレッドを同期し、サーバー上の全スレッドを検索するものではありません。

TypeScript
import '@univerjs/thread-comment/facade'import '@univerjs-pro/slides-thread-comment/facade'const element = univerAPI.getActivePresentation()?.getSlideByIndex(0)?.getElements()[0]if (element) {  await element.createCommentAsync('Please review this element.')  console.log(await element.listCommentsAsync())}
TypeScript
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.',  })}

共有ディスカッション

Server SDK で Comment Service と Endpoint を統合し、共同編集とライセンスの設定後に @univerjs-pro/thread-comment-datasource の UniverThreadCommentDataSourcePlugin を登録します。付属のデータソースは /universer-api/comment/unit/{unitId}/... と /universer-api/user/list を使います。アプリからこれらのルートを公開してください。サーバーは文書の編集権限とは別に、コメントの読み書きを認可する必要があります。

このガイドはいかがですか?

© 2026 DreamNum Co., Ltd.