Skip to content

Commit 8642bf4

Browse files
committed
chore: use correct node names
1 parent 826ae2f commit 8642bf4

8 files changed

Lines changed: 810 additions & 44 deletions

File tree

packages/core/src/schema/blocks/createSpec.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function addNodeAndExtensionsToSpec<
241241
// - has distinctive HTML with data-suggestion="true" for round-trip parsing
242242
// - has NO custom nodeView (uses vanilla renderHTML only)
243243
const suggestionNode = Node.create({
244-
name: `suggestion-${blockConfig.type}`,
244+
name: `${blockConfig.type}--attributed`,
245245
content: (blockConfig.content === "inline"
246246
? "inline*"
247247
: blockConfig.content === "none"
@@ -255,30 +255,22 @@ export function addNodeAndExtensionsToSpec<
255255
priority,
256256
addAttributes() {
257257
const attrs = propsToAttributes(blockConfig.propSchema);
258-
const stripped: Record<string, any> = {};
259-
for (const [key, value] of Object.entries(attrs)) {
260-
stripped[key] = {
261-
...value,
262-
// Parse prop values from data attributes on the bn-block-content div
263-
parseHTML: (element: HTMLElement) => {
264-
return element.getAttribute(camelToDataKebab(key));
265-
},
266-
};
267-
}
268258
// The __suggestionData attribute serves two purposes:
269259
// 1. isRequired: true prevents ProseMirror's DOMParser from auto-creating
270260
// suggestion nodes to satisfy optional content expressions
271261
// 2. Rendered as data-suggestion="true" on the wrapper div for HTML parsing
272-
stripped["__suggestionData"] = {
262+
attrs["yjs-suggestion-node"] = {
273263
isRequired: true,
274264
parseHTML: (element: HTMLElement) => {
275265
return element.getAttribute("data-suggestion");
276266
},
277267
renderHTML: (attributes: Record<string, any>) => {
278-
return { "data-suggestion": attributes.__suggestionData || "true" };
268+
return {
269+
"data-suggestion": attributes["yjs-suggestion-node"] || "true",
270+
};
279271
},
280272
};
281-
return stripped;
273+
return attrs;
282274
},
283275
parseHTML() {
284276
// Only parse HTML elements that have both data-suggestion and

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { configureYProsemirror, syncPlugin } from "@y/prosemirror";
1+
import {
2+
configureYProsemirror,
3+
syncPlugin,
4+
ySyncPluginKey,
5+
} from "@y/prosemirror";
26
import {
37
type ExtensionOptions,
48
createExtension,
@@ -118,6 +122,13 @@ export const YSyncExtension = createExtension(
118122
syncPlugin({
119123
suggestionDoc: options.suggestionDoc,
120124
mapAttributionToMark,
125+
attributedNodes: (
126+
nodeName: string,
127+
kinds: { deleted: boolean; inserted: boolean; formatted: boolean },
128+
) => {
129+
console.log(nodeName, kinds);
130+
return Boolean(editor.schema.blockSpecs[nodeName] && kinds.deleted);
131+
},
121132
}),
122133
],
123134
runsBefore: ["default"],

patches/@y__prosemirror@2.0.0-2.patch

Lines changed: 223 additions & 10 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)