К содержимому

Комментарии ​

Комментарии привязаны к тексту и едут вместе с ним при правке.

Комментарии

Пока нет комментариев

Кресло «Осло»

Мягкое кресло на каркасе из массива дуба. Чехол снимается и стирается при 30 °C.

  • Ширина 78 см, глубина 84 см, высота 92 см

  • Высота сиденья 42 см

  • Выдерживает до 120 кг

Выделите текст и нажмите кнопку комментария в панели у выделения.

Храните комментарии ​

Сохраняйте обсуждения у себя и передайте редактору адаптер с методами list, create, reply, resolve и remove:

interface CommentsAdapter { list(doc: string, signal: AbortSignal): Promise<readonly CommentThread[]>; create(doc: string, comment: NewComment): Promise<CommentThread>; reply(doc: string, threadId: string, reply: NewReply): Promise<CommentThread>; resolve(doc: string, threadId: string, resolved: boolean): Promise<CommentThread>; remove(doc: string, threadId: string): Promise<void>; move?(doc: string, threadId: string, anchor: CommentAnchor): Promise<void>; subscribe?(doc: string, listener: (event: CommentEvent) => void): () => void;}
interface CommentThread { readonly id: string; readonly anchor: CommentAnchor; readonly author: PresenceUser; readonly body: string; readonly createdAt: string; readonly resolved: boolean; readonly replies: readonly CommentReply[];}

create, reply и resolve возвращают обсуждение целиком, каким его сохранил сервер. Привязку anchor адаптер хранит как есть: в ней id блоков и смещения в тексте.

Добавьте move, и новое место отметки после правки переживёт перезагрузку страницы. Через subscribe редактор узнаёт о новых и изменённых обсуждениях соавторов без перезагрузки.

Подключите к редактору ​

Передайте адаптер в useEditorComments, плагин — в plugins, а кнопку комментария — в selectionActions:

vue
<template> <NuiEditor ref="editor" v-model="document" format="json" label="Описание товара" :plugins="[comments.plugin]" :selection-actions="[comments.action.value]" > <template #overlay> <NuiEditorCommentPopover :comments="comments" :editor="api" /> </template> </NuiEditor> <NuiEditorComments :comments="comments" /></template><script setup lang="ts">import { computed, shallowRef, useTemplateRef } from 'vue';import { NuiEditorCommentPopover, NuiEditorComments, useEditorComments,} from '@numior/kit/collaboration/vue';import type { DocJSON } from '@numior/kit/editor-core';import { NuiEditor, type NuiEditorApi } from '@numior/kit/editor';const document = shallowRef<DocJSON>();const editor = useTemplateRef<{ editor: NuiEditorApi }>('editor');const api = computed(() => editor.value?.editor);const comments = useEditorComments({ doc: 'oslo-chair', user: { id: 'anna', name: 'Анна Титова' }, adapter: shopComments, editor: () => api.value,});</script>

Поповер в слоте overlay открывает форму нового комментария у выделения и обсуждение по клику на отмеченный текст. NuiEditorComments выводит все обсуждения списком, например в боковой панели.

При совместной работе добавьте плагин к плагинам из useCollabEditor: [...plugins.value, comments.plugin].

useEditorComments: (options: UseEditorCommentsOptions) => CollabComments
interface UseEditorCommentsOptions { readonly doc: string; readonly user: PresenceUser; readonly adapter: CommentsAdapter; readonly editor: () => NuiEditorApi | undefined;}
interface CollabComments { readonly plugin: Plugin; readonly user: PresenceUser; readonly threads: ComputedRef<readonly CommentThreadView[]>; readonly active: Readonly<ShallowRef<string | undefined>>; readonly opened: Readonly<ShallowRef<string | undefined>>; readonly drafting: Readonly<Ref<boolean>>; readonly failed: Readonly<Ref<boolean>>; readonly revision: Readonly<Ref<number>>; readonly action: ComputedRef<NuiEditorSelectionAction>; readonly spot: () => CommentSpot | undefined; readonly openAt: (pos: number) => void; readonly close: () => void; readonly cancel: () => void; readonly submit: (body: string) => Promise<boolean>; readonly reply: (id: string, body: string) => Promise<boolean>; readonly resolve: (id: string, resolved: boolean) => Promise<void>; readonly remove: (id: string) => Promise<void>; readonly activate: (id: string) => void;}

Поведение ​

  • Отметка едет вместе с текстом при своих правках и правках соавторов.
  • Если отмеченный текст удалили, обсуждение остаётся в списке с пометкой «Текст удалён».
  • Решённое обсуждение снимает отметку и уходит в конец списка. «Открыть снова» возвращает отметку на сохранённое место.
  • Удалить обсуждение может только его автор.
  • Документ только для чтения тоже можно комментировать: в панели у выделения останется одна кнопка комментария.

API ​

NuiEditorComments

Свойства

Имя
Тип
По умолчанию
Описание
commentsобязательно
CollabComments
—
Комментарии документа из useEditorComments.
labels
Partial<Omit<NuiCollabMessages, "present">>
—
Свои тексты вместо встроенных из collabMessages, по одному ключу.

Тексты

Ключ
Русский
English
add
Добавить комментарий
Add comment
alternativeEmpty
Пусто
Empty
alternativeFalse
Нет
No
alternativeHide
Скрыть
Hide
alternativeRestore
Вернуть
Put back
alternativeShow
Показать в документе
Show in the document
alternativeTrue
Да
Yes
alternativeUnknown
Другой участник
Another participant
alternatives
Перезаписанные значения
Overwritten values
cancel
Отмена
Cancel
closeVersion
Закрыть
Close
comments
Комментарии
Comments
empty
Пока нет комментариев
No comments yet
failed
Не удалось сохранить комментарий
The comment could not be saved
failureDiverged
Ваша копия новее документа на сервере.
Your copy is ahead of the document kept on the server.
failureDocument
Правка другого участника не подошла к вашей копии.
A change made by someone else did not fit your copy.
failureInvalid
Сервер не принял одну из ваших правок.
The server did not accept one of your changes.
failureProtocol
Сервер прислал ответ, который страница не смогла прочитать.
The server sent a reply this page could not read.
failureReadOnly
Документ открыт только для чтения, пока вы не откроете его заново.
The document is read-only until you open it again.
failureRejoin
Открыть заново
Open again
failureSchema
Страница работает на версии приложения старее той, что нужна документу. Обновите страницу.
This page runs an older version of the application than the document needs. Reload the page.
failureTitle
Правки больше не отправляются
Your changes are no longer sent
failureUnsent
({ count }) => `Не отправлено правок: ${count}. Скопируйте нужное, прежде чем открыть документ заново.`
({ count }) => `${count} ${plural('en', count, { one: 'change of yours was', other: 'changes of yours were' })} not sent. Copy what you need before you open the document again.`
history
История версий
Version history
historyFailed
История версий недоступна
The version history is unavailable
lost
Текст удалён
The text was removed
noChanges
В этой версии нет изменений
Nothing changed in this version
noVersions
Сохранённых версий пока нет
No saved versions yet
placeholder
Напишите комментарий
Write a comment
present
Сейчас в документе
People in this document
remove
Удалить
Delete
reopen
Открыть снова
Reopen
reply
Ответить
Reply
replyPlaceholder
Напишите ответ
Write a reply
reportDamaged
Копию на этом устройстве не удалось прочитать
The copy saved on this device cannot be read
reportStep
({ subject }) => `${subject}: сохранённые правки нельзя перевести на новую версию`
({ subject }) => `${subject}: saved changes cannot be converted to the new version`
reportTitle
Документ открыт только для чтения
This document is read-only
reportUnsent
({ count }) => `Неотправленные правки сохранены на этом устройстве: ${count}`
({ count }) => `${count} unsent ${plural('en', count, { one: 'change is', other: 'changes are' })} kept on this device`
reportVersion
({ subject, stored, current }) => `${subject}: у сохранённой копии версия ${stored}, приложение ждёт ${current}`
({ subject, stored, current }) => `${subject}: the saved copy has version ${stored}, this application expects ${current}`
resolve
Решить
Resolve
resolved
Решён
Resolved
restore
Восстановить эту версию
Restore this version
saveVersion
Сохранить версию
Save version
send
Отправить
Send
show
Показать в тексте
Show in text
showChanges
Показать изменения
Show changes

NuiEditorCommentPopover

Свойства

Имя
Тип
По умолчанию
Описание
commentsобязательно
CollabComments
—
Комментарии документа из useEditorComments.
editorобязательно
NuiEditorApi
—
API редактора: поповер встаёт у выделения или у отмеченного текста.
labels
Partial<Omit<NuiCollabMessages, "present">>
—
Свои тексты вместо встроенных из collabMessages, по одному ключу.

Изменить страницу

Поиск

Esc