From 5df714b4efdd382ea873bb1d3ab01fe6deac753d Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Tue, 19 Aug 2025 16:09:45 +0700 Subject: [PATCH] EQMS-1636 Fix lost content in editor diff view (#9692) Signed-off-by: Alexander Onnikov --- .../components/CollaborationDiffViewer.svelte | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/text-editor-resources/src/components/CollaborationDiffViewer.svelte b/plugins/text-editor-resources/src/components/CollaborationDiffViewer.svelte index d6183a1bd6..9e738b4cb5 100644 --- a/plugins/text-editor-resources/src/components/CollaborationDiffViewer.svelte +++ b/plugins/text-editor-resources/src/components/CollaborationDiffViewer.svelte @@ -18,7 +18,7 @@ import { Analytics } from '@hcengineering/analytics' import { MarkupNode } from '@hcengineering/text' import { onDestroy, onMount } from 'svelte' - import { Doc as Ydoc } from 'yjs' + import { Doc as Ydoc, encodeStateAsUpdate, applyUpdate } from 'yjs' import { Editor, Extension, mergeAttributes } from '@tiptap/core' import { Plugin, PluginKey } from '@tiptap/pm/state' @@ -41,6 +41,15 @@ let _decoration = DecorationSet.empty let oldContent: MarkupNode | undefined + $: ydocCopy = copyYdoc(ydoc) + + function copyYdoc (ydoc: Ydoc): Ydoc { + const copy = new Ydoc() + const update = encodeStateAsUpdate(ydoc) + applyUpdate(copy, update) + return copy + } + function updateEditor (editor: Editor, ydoc: Ydoc, field?: string): void { const r = calculateDecorations(editor, oldContent, createYdocDocument(editor.schema, ydoc, field)) if (r !== undefined) { @@ -78,9 +87,15 @@ onMount(async () => { const kit = await getEditorKit({ collaboration: { - collaboration: { document: ydoc, field }, + collaboration: { document: ydocCopy, field }, collaborationCursor: false, inlineComments: false + }, + qms: { + qmsInlineComment: { + isHighlightModeOn: () => false, + getNodeHighlight: () => null + } } })