Skip to content

Commit 23d8be8

Browse files
committed
fix: get back on mainline y/prosemirror
1 parent 6c0f1e1 commit 23d8be8

7 files changed

Lines changed: 159 additions & 255 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite-plus/client" />

packages/core/src/y/extensions/YSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export const YSyncExtension = createExtension(
130130
// container => schema-invalid. No schema change / storage transform
131131
// needed; `blockContainer` already whitelists the `y-attributed-*`
132132
// marks. See blockMatchNodes.ts.
133-
matchNodes: blockMatchNodes,
133+
customCompare: blockMatchNodes,
134134
}),
135135
],
136136
runsBefore: ["default"],

packages/core/src/y/extensions/blockMatchNodes.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import * as delta from "lib0/delta";
2+
import * as schema from "lib0/schema";
3+
import { $prosemirrorDelta } from "@y/prosemirror";
24

35
/**
46
* Canonical name of a content delta's first block child (the child carried by an
57
* insert op), or `null`. For a BlockNote `blockContainer` (content
68
* `blockContent blockGroup?`) this is its block-content type (paragraph,
79
* heading, image, ...).
810
*/
9-
const firstChildName = (d: delta.DeltaAny): string | null => {
11+
const firstChildName = (
12+
d: schema.Unwrap<typeof $prosemirrorDelta>,
13+
): string | null => {
1014
for (const op of (d as any).children) {
1115
if (delta.$insertOp.check(op)) {
1216
for (const it of op.insert) {
@@ -42,9 +46,8 @@ const firstChildName = (d: delta.DeltaAny): string | null => {
4246
* @returns whether `a` and `b` are the same node (diff in place) vs different (replace)
4347
*/
4448
export const blockMatchNodes = (
45-
a: delta.DeltaAny,
46-
b: delta.DeltaAny,
49+
a: schema.Unwrap<typeof $prosemirrorDelta>,
50+
b: schema.Unwrap<typeof $prosemirrorDelta>,
4751
): boolean =>
48-
(a as any).name === (b as any).name &&
49-
((a as any).name !== "blockContainer" ||
50-
firstChildName(a) === firstChildName(b));
52+
a.name === b.name &&
53+
(a.name !== "blockContainer" || firstChildName(a) === firstChildName(b));

patches/@y__prosemirror@2.0.0-2.patch

Lines changed: 72 additions & 88 deletions
Large diffs are not rendered by default.

patches/lib0@1.0.0-rc.14.patch

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)