From d4ef39e6ca2091970fe8ea038bf794c488b79429 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Wed, 17 Jan 2024 18:33:25 +0300 Subject: [PATCH 1/2] Fix editor menu workflow (#366) --- .../Editor/EditorFloatingMenu/EditorFloatingMenu.tsx | 2 ++ src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx b/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx index a348a430..673da091 100644 --- a/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx +++ b/src/components/Editor/EditorFloatingMenu/EditorFloatingMenu.tsx @@ -93,6 +93,7 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => { const closeUploadModalHandler = () => { setSelectedMenuItem() setMenuOpen(false) + setSelectedMenuItem() } useOutsideClickHandler({ @@ -104,6 +105,7 @@ export const EditorFloatingMenu = (props: FloatingMenuProps) => { if (menuOpen()) { setMenuOpen(false) + setSelectedMenuItem() } }, }) diff --git a/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx b/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx index d30c5cb6..c7bb2d32 100644 --- a/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx +++ b/src/components/Editor/TextBubbleMenu/TextBubbleMenu.tsx @@ -39,6 +39,9 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => { if (!props.shouldShow) { setFootNote() setFootnoteEditorOpen(false) + setLinkEditorOpen(false) + setTextSizeBubbleOpen(false) + setListBubbleOpen(false) } }) @@ -93,11 +96,13 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => { props.editor.chain().focus().setFootnote({ value: footnote }).run() } setFootNote() + setLinkEditorOpen(false) setFootnoteEditorOpen(false) } const handleOpenFootnoteEditor = () => { updateCurrentFootnoteValue() + setLinkEditorOpen(false) setFootnoteEditorOpen(true) } @@ -120,6 +125,7 @@ export const TextBubbleMenu = (props: BubbleMenuProps) => { window.addEventListener('keydown', handleKeyDown) onCleanup(() => { window.removeEventListener('keydown', handleKeyDown) + setLinkEditorOpen(false) }) }) From 5d874ee63947709ecc45504372e838e8d780f576 Mon Sep 17 00:00:00 2001 From: Ilya Y <75578537+ilya-bkv@users.noreply.github.com> Date: Thu, 18 Jan 2024 10:02:37 +0300 Subject: [PATCH 2/2] figcaption editor if not empty (#367) --- src/components/Editor/Editor.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Editor/Editor.tsx b/src/components/Editor/Editor.tsx index 18882032..04b2e984 100644 --- a/src/components/Editor/Editor.tsx +++ b/src/components/Editor/Editor.tsx @@ -260,7 +260,7 @@ export const Editor = (props: Props) => { !e.isActive('image') && !e.isActive('figure')) || e.isActive('footnote') || - e.isActive('figcaption') + (e.isActive('figcaption') && !empty) setShouldShowTextBubbleMenu(result) return result },