Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(md): update floatWith handlers in link menu to match mentions menu (#920)

Seamusca0f5f3da90a
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
index c4b1b78f37..dabe1adf76 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
@@ -332,32 +332,31 @@ export function FloatingLinkMenu(props: { closePopup?: () => void }) {
return data.data;
});
+ const floatWithElementProps = () =>
+ linkInfo()?.linkRef
+ ? {
+ element: () => linkInfo()?.linkRef,
+ useBlockBoundary: true,
+ }
+ : undefined;
+
+ const floatWithSelectionProps = () =>
+ !linkInfo()?.linkRef && linkInfo()?.selection
+ ? {
+ selection: linkInfo()?.selection,
+ reactiveOnContainer: editor.getRootElement(),
+ useBlockBoundary: true,
+ }
+ : undefined;
+
const MenuWrapper = (props: ParentProps) => {
return (
- <Switch fallback={<div class="display-none">{props.children}</div>}>
- <Match when={linkInfo()?.linkRef !== undefined}>
- <div
- class="p-2 fixed bg-menu top-0 left-0 text-sm z-action-menu ring ring-edge min-w-100"
- use:floatWithElement={{
- element: () => linkInfo()?.linkRef,
- useBlockBoundary: true,
- }}
- use:clickOutside={() => {
- setMenuOpen(false);
- setIsEditing(false);
- }}
- ref={menuRef}
- >
- {props.children}
- </div>
- </Match>
- <Match when={linkInfo()?.selection}>
+ <Show when={linkInfo()?.linkRef || linkInfo()?.selection}>
+ <ScopedPortal scope="block">
<div
- class="p-2 fixed bg-menu top-0 left-0 text-sm z-action-menu ring ring-edge rounded-md shadow-lg min-w-80"
- use:floatWithSelection={{
- selection: linkInfo()?.selection,
- useBlockBoundary: true,
- }}
+ class="p-2 fixed bg-menu top-0 left-0 text-sm z-modal-content ring ring-edge rounded-md shadow-lg min-w-80"
+ use:floatWithElement={floatWithElementProps()}
+ use:floatWithSelection={floatWithSelectionProps()}
use:clickOutside={() => {
setMenuOpen(false);
setIsEditing(false);
@@ -366,8 +365,8 @@ export function FloatingLinkMenu(props: { closePopup?: () => void }) {
>
{props.children}
</div>
- </Match>
- </Switch>
+ </ScopedPortal>
+ </Show>
);
};