Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useEditorState } from "../../../hooks/useEditorState.js";
import { useExtension } from "../../../hooks/useExtension.js";
import { useDictionary } from "../../../i18n/dictionary.js";
import { EditLinkMenuItems } from "../../LinkToolbar/EditLinkMenuItems.js";
import { useEditorChange } from "../../../hooks/useEditorChange.js";

function checkLinkInSchema(
editor: BlockNoteEditor<BlockSchema, any, StyleSchema>,
Expand Down Expand Up @@ -53,6 +54,11 @@ export const CreateLinkButton = () => {
return () => showSelection(false);
}, [showPopover, showSelection]);

useEditorChange(() => {
// Close the popover when the editor is updated after a link has been created
setShowPopover(false);
}, editor);

const state = useEditorState({
editor,
selector: ({ editor }) => {
Expand Down Expand Up @@ -106,7 +112,10 @@ export const CreateLinkButton = () => {
}

return (
<Components.Generic.Popover.Root open={showPopover}>
<Components.Generic.Popover.Root
open={showPopover}
onOpenChange={setShowPopover}
>
<Components.Generic.Popover.Trigger>
{/* TODO: hide tooltip on click */}
<Components.FormattingToolbar.Button
Expand All @@ -119,7 +128,7 @@ export const CreateLinkButton = () => {
dict.generic.ctrl_shortcut,
)}
icon={<RiLink />}
onClick={() => setShowPopover(true)}
onClick={() => setShowPopover(open => !open)}
/>
</Components.Generic.Popover.Trigger>
<Components.Generic.Popover.Content
Expand Down
Loading