From 10ef9e18280477e2954d83b8186e8d8d2bbb384b Mon Sep 17 00:00:00 2001 From: Untone Date: Fri, 11 Oct 2024 21:43:17 +0300 Subject: [PATCH] editor-fullmenu-fix --- src/components/Editor/Editor.tsx | 4 ++-- src/components/Editor/Toolbar/FullBubbleMenu.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index c0bb6a1b..b4c2ffa4 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -68,7 +68,7 @@ export const EditorComponent = (props: Props) => { BubbleMenu.configure({ pluginKey: 'textBubbleMenu', element: textBubbleMenuRef()!, - shouldShow: ({ editor: e, view, state: { doc, selection } , from, to }) => { + shouldShow: ({ editor: e, view, state: { doc, selection }, from, to }) => { const isEmptyTextBlock = doc.textBetween(from, to).length === 0 && isTextSelection(selection) if (isEmptyTextBlock) { e.chain().focus().removeTextWrap({ class: 'highlight-fake-selection' }).run() @@ -153,7 +153,7 @@ export const EditorComponent = (props: Props) => { html && props.onChange(html) const wordCount: number = e.storage.characterCount.words() const charsCount: number = e.storage.characterCount.characters() - wordCount && countWords({ words: wordCount, characters: charsCount }) + charsCount && countWords({ words: wordCount, characters: charsCount }) } } })) diff --git a/src/components/Editor/Toolbar/FullBubbleMenu.tsx b/src/components/Editor/Toolbar/FullBubbleMenu.tsx index a304b597..9326a44a 100644 --- a/src/components/Editor/Toolbar/FullBubbleMenu.tsx +++ b/src/components/Editor/Toolbar/FullBubbleMenu.tsx @@ -45,9 +45,9 @@ export const FullBubbleMenu = (props: FullBubbleMenuProps) => { const isHighlight = isActive('highlight') // toggle open / close on submenus - createEffect(on(props.shouldShow, setFootnoteEditorOpen)) - createEffect(on(props.shouldShow, setTextSizeBubbleOpen)) - createEffect(on(props.shouldShow, setListBubbleOpen)) + createEffect(on(props.shouldShow, (x) => !x && setFootnoteEditorOpen(false))) + createEffect(on(props.shouldShow, (x) => !x && setTextSizeBubbleOpen(false))) + createEffect(on(props.shouldShow, (x) => !x && setListBubbleOpen(false))) const toggleTextSizeMenu = () => setTextSizeBubbleOpen((x) => !x) const toggleListMenu = () => setListBubbleOpen((x) => !x) const toggleFootnoteEditor = () => setFootnoteEditorOpen((x) => !x)