From a09e35ba8f67e2fe64fce69c4cc88366d7417c95 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 31 Jan 2026 18:34:25 +0000 Subject: [PATCH] WIP --- .../components/history-editor.tsx | 34 ++++++++++++++++++- package.json | 1 + pnpm-lock.yaml | 3 ++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/apps/client/src/features/page-history/components/history-editor.tsx b/apps/client/src/features/page-history/components/history-editor.tsx index 908efa46..bdd43722 100644 --- a/apps/client/src/features/page-history/components/history-editor.tsx +++ b/apps/client/src/features/page-history/components/history-editor.tsx @@ -7,7 +7,8 @@ import { Decoration, DecorationSet } from "@tiptap/pm/view"; import { computeHistoryBlockDiff } from "@/features/page-history/utils/history-diff"; import classes from "./history-diff.module.css"; import historyClasses from "./history.module.css"; - +import { recreateTransform } from "@docmost/editor-ext"; +import { Node, Schema, DOMSerializer } from "@tiptap/pm/model"; export interface HistoryEditorProps { title: string; @@ -33,6 +34,37 @@ export function HistoryEditor({ deleted: 0, }); + useEffect(() => { + if (editor && previousContent && content) { + const schema = editor.schema; + + try { + console.log( + "previousContent type:", + previousContent?.type, + "content type:", + content?.type, + ); + const docOld = Node.fromJSON(schema, previousContent); + const docNew = Node.fromJSON(schema, content); + + const t0 = performance.now(); + const transform = recreateTransform(docOld, docNew, { + complexSteps: true, + wordDiffs: true, + simplifyDiff: true, + }); + console.log( + `recreateTransform: ${(performance.now() - t0).toFixed(3)}ms`, + ); + + //console.log(transform); + } catch (e) { + console.error("Node.fromJSON failed:", e); + } + } + }, [editor]); + useEffect(() => { if (editor && content) { let decorationSet = DecorationSet.empty; diff --git a/package.json b/package.json index 771f0ae7..efed7d63 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "linkifyjs": "^4.3.2", "marked": "13.0.3", "ms": "3.0.0-canary.1", + "prosemirror-changeset": "2.3.1", "qrcode": "^1.5.4", "uuid": "^11.1.0", "y-indexeddb": "^9.0.12", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8c891957..1982f561 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -168,6 +168,9 @@ importers: ms: specifier: 3.0.0-canary.1 version: 3.0.0-canary.1 + prosemirror-changeset: + specifier: 2.3.1 + version: 2.3.1 qrcode: specifier: ^1.5.4 version: 1.5.4