Skip to content

Commit ae63b18

Browse files
committed
chore: rm initialContent hack
1 parent b88222c commit ae63b18

1 file changed

Lines changed: 19 additions & 19 deletions

File tree

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -590,25 +590,25 @@ export class BlockNoteEditor<
590590
);
591591
}
592592

593-
// When y-prosemirror creates an empty document, the `blockContainer` node is created with an `id` of `null`.
594-
// This causes the unique id extension to generate a new id for the initial block, which is not what we want
595-
// Since it will be randomly generated & cause there to be more updates to the ydoc
596-
// This is a hack to make it so that anytime `schema.doc.createAndFill` is called, the initial block id is already set to "initialBlockId"
597-
let cache: Node | undefined = undefined;
598-
const oldCreateAndFill = this.pmSchema.nodes.doc.createAndFill;
599-
this.pmSchema.nodes.doc.createAndFill = (...args: any) => {
600-
if (cache) {
601-
return cache;
602-
}
603-
const ret = oldCreateAndFill.apply(this.pmSchema.nodes.doc, args)!;
604-
605-
// create a copy that we can mutate (otherwise, assigning attrs is not safe and corrupts the pm state)
606-
const jsonNode = JSON.parse(JSON.stringify(ret.toJSON()));
607-
jsonNode.content[0].content[0].attrs.id = "initialBlockId";
608-
609-
cache = Node.fromJSON(this.pmSchema, jsonNode);
610-
return cache;
611-
};
593+
// // When y-prosemirror creates an empty document, the `blockContainer` node is created with an `id` of `null`.
594+
// // This causes the unique id extension to generate a new id for the initial block, which is not what we want
595+
// // Since it will be randomly generated & cause there to be more updates to the ydoc
596+
// // This is a hack to make it so that anytime `schema.doc.createAndFill` is called, the initial block id is already set to "initialBlockId"
597+
// let cache: Node | undefined = undefined;
598+
// const oldCreateAndFill = this.pmSchema.nodes.doc.createAndFill;
599+
// this.pmSchema.nodes.doc.createAndFill = (...args: any) => {
600+
// if (cache) {
601+
// return cache;
602+
// }
603+
// const ret = oldCreateAndFill.apply(this.pmSchema.nodes.doc, args)!;
604+
605+
// // create a copy that we can mutate (otherwise, assigning attrs is not safe and corrupts the pm state)
606+
// const jsonNode = JSON.parse(JSON.stringify(ret.toJSON()));
607+
// jsonNode.content[0].content[0].attrs.id = "initialBlockId";
608+
609+
// cache = Node.fromJSON(this.pmSchema, jsonNode);
610+
// return cache;
611+
// };
612612
this.pmSchema.cached.blockNoteEditor = this;
613613

614614
this._tiptapEditor.on("mount", () => {

0 commit comments

Comments
 (0)