mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-06 17:57:42 +02:00
EQMS-1636 Fix lost content in editor diff view (#9692)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user