Skip to content

Commit 10cdbfb

Browse files
authored
fix(core): input rules can handle when a new block is empty now (#2013)
1 parent 32ba514 commit 10cdbfb

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -794,29 +794,31 @@ export class BlockNoteEditor<
794794
editor: this,
795795
});
796796
if (replaceWith) {
797-
const blockInfo = getBlockInfoFromTransaction(
798-
state.tr,
799-
);
797+
const cursorPosition =
798+
this.getTextCursorPosition();
800799

801-
// TODO this is weird, why do we need it?
802800
if (
803-
blockInfo.isBlockContainer &&
804-
blockInfo.blockContent.node.type.spec
805-
.content === "inline*"
801+
this.schema.blockSchema[
802+
cursorPosition.block.type
803+
].content !== "inline"
806804
) {
807-
const tr = state.tr.deleteRange(
808-
range.from,
809-
range.to,
810-
);
811-
updateBlockTr(
812-
tr,
813-
blockInfo.bnBlock.beforePos,
814-
replaceWith,
815-
range.from,
816-
range.to,
817-
);
818805
return undefined;
819806
}
807+
808+
const blockInfo = getBlockInfoFromTransaction(
809+
state.tr,
810+
);
811+
const tr = state.tr.deleteRange(
812+
range.from,
813+
range.to,
814+
);
815+
816+
updateBlockTr(
817+
tr,
818+
blockInfo.bnBlock.beforePos,
819+
replaceWith,
820+
);
821+
return undefined;
820822
}
821823
return null;
822824
},

0 commit comments

Comments
 (0)