Skip to content

Commit a790d16

Browse files
authored
fix: disable input rules for numbered headings #1789 (#2032)
1 parent f6b4683 commit a790d16

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/core/src/blocks/ListItem/BulletListItem/block.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
12
import { createBlockNoteExtension } from "../../../editor/BlockNoteExtension.js";
23
import { createBlockConfig, createBlockSpec } from "../../../schema/index.js";
34
import {
@@ -103,7 +104,14 @@ export const createBulletListItemBlockSpec = createBlockSpec(
103104
inputRules: [
104105
{
105106
find: new RegExp(`^[-+*]\\s$`),
106-
replace() {
107+
replace({ editor }) {
108+
const blockInfo = getBlockInfoFromSelection(
109+
editor.prosemirrorState,
110+
);
111+
112+
if (blockInfo.blockNoteType === "heading") {
113+
return;
114+
}
107115
return {
108116
type: "bulletListItem",
109117
props: {},

packages/core/src/blocks/ListItem/NumberedListItem/block.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getBlockInfoFromSelection } from "../../../api/getBlockInfoFromPos.js";
12
import { createBlockNoteExtension } from "../../../editor/BlockNoteExtension.js";
23
import { createBlockConfig, createBlockSpec } from "../../../schema/index.js";
34
import {
@@ -95,7 +96,14 @@ export const createNumberedListItemBlockSpec = createBlockSpec(
9596
inputRules: [
9697
{
9798
find: new RegExp(`^(\\d+)\\.\\s$`),
98-
replace({ match }) {
99+
replace({ match, editor }) {
100+
const blockInfo = getBlockInfoFromSelection(
101+
editor.prosemirrorState,
102+
);
103+
104+
if (blockInfo.blockNoteType === "heading") {
105+
return;
106+
}
99107
const start = parseInt(match[1]);
100108
return {
101109
type: "numberedListItem",

0 commit comments

Comments
 (0)