From 1cbd2854bb4f8c18a49dff3e793235c61db542b7 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sun, 28 Sep 2025 20:51:57 +0100 Subject: [PATCH] fix menus --- .../components/callout/callout-menu.tsx | 6 ++--- .../editor/components/drawio/drawio-menu.tsx | 1 + .../components/excalidraw/excalidraw-menu.tsx | 1 + .../editor/components/image/image-menu.tsx | 1 + .../editor/components/link/link-menu.tsx | 27 ++++++++++++++----- .../editor/components/link/link-preview.tsx | 1 + .../components/subpages/subpages-menu.tsx | 2 +- .../editor/components/video/video-menu.tsx | 1 + apps/server/src/ee | 2 +- 9 files changed, 30 insertions(+), 12 deletions(-) diff --git a/apps/client/src/features/editor/components/callout/callout-menu.tsx b/apps/client/src/features/editor/components/callout/callout-menu.tsx index 9c9c1c98..e1bd6069 100644 --- a/apps/client/src/features/editor/components/callout/callout-menu.tsx +++ b/apps/client/src/features/editor/components/callout/callout-menu.tsx @@ -50,6 +50,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) { ); const getReferencedVirtualElement = useCallback(() => { + if (!editor) return; const { selection } = editor.state; const predicate = (node: PMNode) => node.type.name === "callout"; const parent = findParentNode(predicate)(selection); @@ -63,9 +64,6 @@ export function CalloutMenu({ editor }: EditorMenuProps) { }; } - console.log('callout') - - const domRect = posToDOMRect(editor.view, selection.from, selection.to); return { getBoundingClientRect: () => domRect, @@ -117,7 +115,7 @@ export function CalloutMenu({ editor }: EditorMenuProps) { return ( { + if (!editor) return; const { selection } = editor.state; const predicate = (node: PMNode) => node.type.name === "drawio"; const parent = findParentNode(predicate)(selection); diff --git a/apps/client/src/features/editor/components/excalidraw/excalidraw-menu.tsx b/apps/client/src/features/editor/components/excalidraw/excalidraw-menu.tsx index b651f38f..06e79515 100644 --- a/apps/client/src/features/editor/components/excalidraw/excalidraw-menu.tsx +++ b/apps/client/src/features/editor/components/excalidraw/excalidraw-menu.tsx @@ -38,6 +38,7 @@ export function ExcalidrawMenu({ editor }: EditorMenuProps) { }); const getReferencedVirtualElement = useCallback(() => { + if (!editor) return; const { selection } = editor.state; const predicate = (node: PMNode) => node.type.name === "excalidraw"; const parent = findParentNode(predicate)(selection); diff --git a/apps/client/src/features/editor/components/image/image-menu.tsx b/apps/client/src/features/editor/components/image/image-menu.tsx index 2c206ae3..6f2c9b9c 100644 --- a/apps/client/src/features/editor/components/image/image-menu.tsx +++ b/apps/client/src/features/editor/components/image/image-menu.tsx @@ -49,6 +49,7 @@ export function ImageMenu({ editor }: EditorMenuProps) { ); const getReferencedVirtualElement = useCallback(() => { + if (!editor) return; const { selection } = editor.state; const predicate = (node: PMNode) => node.type.name === "image"; const parent = findParentNode(predicate)(selection); diff --git a/apps/client/src/features/editor/components/link/link-menu.tsx b/apps/client/src/features/editor/components/link/link-menu.tsx index 041e5c3d..a5205a04 100644 --- a/apps/client/src/features/editor/components/link/link-menu.tsx +++ b/apps/client/src/features/editor/components/link/link-menu.tsx @@ -1,10 +1,10 @@ import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react/menus"; -import { offset } from "@floating-ui/dom"; import React, { useCallback, useState } from "react"; import { EditorMenuProps } from "@/features/editor/components/table/types/types.ts"; import { LinkEditorPanel } from "@/features/editor/components/link/link-editor-panel.tsx"; import { LinkPreviewPanel } from "@/features/editor/components/link/link-preview.tsx"; import { Card } from "@mantine/core"; +import { useEditorState } from "@tiptap/react"; export function LinkMenu({ editor, appendTo }: EditorMenuProps) { const [showEdit, setShowEdit] = useState(false); @@ -13,7 +13,19 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) { return editor.isActive("link"); }, [editor]); - const { href: link } = editor.getAttributes("link"); + const editorState = useEditorState({ + editor, + selector: (ctx) => { + if (!ctx.editor) { + return null; + } + + const link = ctx.editor.getAttributes("link"); + return { + href: link.href, + }; + }, + }); const handleEdit = useCallback(() => { setShowEdit(true); @@ -49,7 +61,7 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) { return ( { @@ -57,7 +69,7 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) { }, placement: "bottom", offset: 5, - // zIndex: 101, + // zIndex: 101, }} shouldShow={shouldShow} > @@ -68,11 +80,14 @@ export function LinkMenu({ editor, appendTo }: EditorMenuProps) { padding="xs" bg="var(--mantine-color-body)" > - + ) : ( diff --git a/apps/client/src/features/editor/components/link/link-preview.tsx b/apps/client/src/features/editor/components/link/link-preview.tsx index 8b0de952..2a7b42a0 100644 --- a/apps/client/src/features/editor/components/link/link-preview.tsx +++ b/apps/client/src/features/editor/components/link/link-preview.tsx @@ -34,6 +34,7 @@ export const LinkPreviewPanel = ({ rel="noopener noreferrer" className={classes.link} > + ss {url} diff --git a/apps/client/src/features/editor/components/subpages/subpages-menu.tsx b/apps/client/src/features/editor/components/subpages/subpages-menu.tsx index 2341d4be..eb9bfd9d 100644 --- a/apps/client/src/features/editor/components/subpages/subpages-menu.tsx +++ b/apps/client/src/features/editor/components/subpages/subpages-menu.tsx @@ -58,7 +58,7 @@ export const SubpagesMenu = React.memo( return ( { + if (!editor) return; const { selection } = editor.state; const predicate = (node: PMNode) => node.type.name === "video"; const parent = findParentNode(predicate)(selection); diff --git a/apps/server/src/ee b/apps/server/src/ee index 3af21def..d2ead431 160000 --- a/apps/server/src/ee +++ b/apps/server/src/ee @@ -1 +1 @@ -Subproject commit 3af21def15eb7ea7eb400086eeaf97991938a5fd +Subproject commit d2ead431819025e735e8b8e63d6d898d76c417e6