editor: fix crash when inserting a code block

This commit is contained in:
Abdullah Atta
2024-09-23 15:12:57 +05:00
parent f060c65bd5
commit 99c77e6c5f

View File

@@ -243,7 +243,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
tr.replaceSelectionWith(
this.type.create(
{ ...attributes, id: createCodeblockId() },
state.schema.text(text)
text ? state.schema.text(text) : null
)
);
return commands.setTextSelection({ from, to: tr.mapping.map(to) });