From 4c691c0edb9abaabeeff754cafbb20382aaee57d Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 22 Oct 2024 18:34:07 -0700 Subject: [PATCH] refac: rich text input behaviour --- src/lib/components/common/RichTextInput.svelte | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/components/common/RichTextInput.svelte b/src/lib/components/common/RichTextInput.svelte index 491cbdb10..62a0ec54a 100644 --- a/src/lib/components/common/RichTextInput.svelte +++ b/src/lib/components/common/RichTextInput.svelte @@ -168,11 +168,12 @@ } function boldRule(schema) { - return markInputRule(/\*([^*]+)\*/, schema.marks.strong); + return markInputRule(/(?<=^|\s)\*([^*]+)\*(?=\s|$)/, schema.marks.strong); } function italicRule(schema) { - return markInputRule(/\_([^*]+)\_/, schema.marks.em); + // Using lookbehind and lookahead to prevent the space from being consumed + return markInputRule(/(?<=^|\s)_([^*_]+)_(?=\s|$)/, schema.marks.em); } // Initialize Editor State and View