Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix crash when inserting a code block

Abdullah Atta99c77e6c5fc0
diff --git a/packages/editor/src/extensions/code-block/code-block.ts b/packages/editor/src/extensions/code-block/code-block.ts
index def3d7cb3..e7f287daf 100644
--- a/packages/editor/src/extensions/code-block/code-block.ts
+++ b/packages/editor/src/extensions/code-block/code-block.ts
@@ -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) });