diff --git a/packages/text-editor/src/components/ReferenceInput.svelte b/packages/text-editor/src/components/ReferenceInput.svelte index c5ed7a508b..827deb831d 100644 --- a/packages/text-editor/src/components/ReferenceInput.svelte +++ b/packages/text-editor/src/components/ReferenceInput.svelte @@ -166,6 +166,11 @@ a.action(evt?.target as HTMLElement, editorHandler) } + function updateFormattingState () { + isBold = textEditor.checkIsActive('bold') + isItalic = textEditor.checkIsActive('italic') + } + function toggleBold () { textEditor.toggleBold() textEditor.focus() @@ -201,6 +206,7 @@ textEditor.clear() }} extensions={editorExtensions} + on:selection-update={updateFormattingState} /> {#if showSend} diff --git a/packages/text-editor/src/components/TextEditor.svelte b/packages/text-editor/src/components/TextEditor.svelte index a98f4f5185..b5c0a42f10 100644 --- a/packages/text-editor/src/components/TextEditor.svelte +++ b/packages/text-editor/src/components/TextEditor.svelte @@ -53,6 +53,9 @@ export function insertText (text: string): void { editor.commands.insertContent(text as HTMLContent) } + export function checkIsActive (markName: string) { + return editor.isActive(markName) + } export function toggleBold () { editor.commands.toggleBold() } @@ -119,7 +122,8 @@ onUpdate: () => { content = editor.getHTML() dispatch('value', content) - } + }, + onSelectionUpdate: () => dispatch('selection-update') }) }) })