mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 23:14:07 +08:00
WIP
This commit is contained in:
@@ -7,7 +7,8 @@ import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|||||||
import { computeHistoryBlockDiff } from "@/features/page-history/utils/history-diff";
|
import { computeHistoryBlockDiff } from "@/features/page-history/utils/history-diff";
|
||||||
import classes from "./history-diff.module.css";
|
import classes from "./history-diff.module.css";
|
||||||
import historyClasses from "./history.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 {
|
export interface HistoryEditorProps {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -33,6 +34,37 @@ export function HistoryEditor({
|
|||||||
deleted: 0,
|
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(() => {
|
useEffect(() => {
|
||||||
if (editor && content) {
|
if (editor && content) {
|
||||||
let decorationSet = DecorationSet.empty;
|
let decorationSet = DecorationSet.empty;
|
||||||
|
|||||||
@@ -69,6 +69,7 @@
|
|||||||
"linkifyjs": "^4.3.2",
|
"linkifyjs": "^4.3.2",
|
||||||
"marked": "13.0.3",
|
"marked": "13.0.3",
|
||||||
"ms": "3.0.0-canary.1",
|
"ms": "3.0.0-canary.1",
|
||||||
|
"prosemirror-changeset": "2.3.1",
|
||||||
"qrcode": "^1.5.4",
|
"qrcode": "^1.5.4",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"y-indexeddb": "^9.0.12",
|
"y-indexeddb": "^9.0.12",
|
||||||
|
|||||||
Generated
+3
@@ -168,6 +168,9 @@ importers:
|
|||||||
ms:
|
ms:
|
||||||
specifier: 3.0.0-canary.1
|
specifier: 3.0.0-canary.1
|
||||||
version: 3.0.0-canary.1
|
version: 3.0.0-canary.1
|
||||||
|
prosemirror-changeset:
|
||||||
|
specifier: 2.3.1
|
||||||
|
version: 2.3.1
|
||||||
qrcode:
|
qrcode:
|
||||||
specifier: ^1.5.4
|
specifier: ^1.5.4
|
||||||
version: 1.5.4
|
version: 1.5.4
|
||||||
|
|||||||
Reference in New Issue
Block a user