Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: hover popup not showing on bold links

thecodrr6329b2c28c1d
diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
index 420c3b64c..ed8faf416 100644
--- a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
+++ b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
@@ -10,8 +10,7 @@ export type HoverPopupProps = {
selectedNode: NodeWithOffset;
};
-const handlers: Record<string, (props: HoverPopupProps) => JSX.Element | null> =
- { ...LinkHoverPopupHandler };
+const handlers = [LinkHoverPopupHandler];
const HOVER_TIMEOUT = 500;
@@ -48,10 +47,10 @@ export function HoverPopupHandler(props: FloatingMenuProps) {
hoverTimeoutId.current = setTimeout(
() => {
- const nodeName = element.nodeName.toLowerCase();
- const PopupHandler = handlers[nodeName];
+ const PopupHandler = handlers.find((h) => h.isActive(element));
if (!PopupHandler || !editor.current) return;
+ const { popup: Popup } = PopupHandler;
const pos = editor.current.view.posAtDOM(element, 0);
const node = editor.current.view.state.doc.nodeAt(pos);
@@ -59,7 +58,7 @@ export function HoverPopupHandler(props: FloatingMenuProps) {
const hidePopup = showPopup({
popup: () => (
- <PopupHandler
+ <Popup
editor={editor}
selectedNode={{
node,
diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
index c89ceb188..284d4a0ae 100644
--- a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
+++ b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
@@ -28,4 +28,7 @@ function LinkHoverPopup(props: HoverPopupProps) {
);
}
-export const LinkHoverPopupHandler = { a: LinkHoverPopup };
+export const LinkHoverPopupHandler = {
+ isActive: (e: HTMLElement) => !!e.closest("a"),
+ popup: LinkHoverPopup,
+};