Skip to content

Commit 6629ef3

Browse files
committed
fix(web): ignore replaced selection in delimiter guard
1 parent d5a5161 commit 6629ef3

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

‎apps/web/src/composer-rich-text-doc.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,5 +1173,25 @@ describe("inline code entry", () => {
11731173
type(editor, ` bar${open}`);
11741174
expect(serializeEditorDoc(editor.state.doc).value).toBe(`${open}\`foo\` bar${open}`);
11751175
expect(marked(editor, mark)).toEqual(["foo", " bar"]);
1176+
1177+
editor.commands.setContent({
1178+
type: "doc",
1179+
content: [
1180+
{
1181+
type: "paragraph",
1182+
content: [
1183+
{ type: "text", text: `${open}foo tail ` },
1184+
{ type: "text", text: "x", marks: [{ type: "code" }] },
1185+
],
1186+
},
1187+
],
1188+
});
1189+
editor.commands.setTextSelection({
1190+
from: open.length + 4,
1191+
to: editor.state.doc.content.size - 1,
1192+
});
1193+
type(editor, open);
1194+
expect(serializeEditorDoc(editor.state.doc).value).toBe(`${open}foo${open}`);
1195+
expect(marked(editor, mark)).toEqual(["foo"]);
11761196
});
11771197
});

‎apps/web/src/composer-rich-text-doc.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function markInputRuleOutsideCode(find: RegExp, type: MarkType) {
161161
if (
162162
code &&
163163
(state.doc.rangeHasMark(range.from + match[0].search(/\S/), textStart, code) ||
164-
state.doc.rangeHasMark(textEnd, range.to, code))
164+
state.doc.rangeHasMark(textEnd, state.selection.from, code))
165165
) {
166166
return null;
167167
}

0 commit comments

Comments
 (0)