From 71c78ed53b3d6d66604036c1733591ee6abe15fc Mon Sep 17 00:00:00 2001 From: fleonus Date: Thu, 31 Mar 2022 22:03:34 +0200 Subject: [PATCH 1/3] Allow getReferenceClientRect to be overridden Prefer using getReferenceClientRect in tippyOptions if available. This allows modifying the position of the bubble menu in a different location for block level elements, like above a table cell or a code block. --- packages/extension-bubble-menu/src/bubble-menu-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts index a0e25157..ec0d557f 100644 --- a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts +++ b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts @@ -180,7 +180,7 @@ export class BubbleMenuView { } this.tippy?.setProps({ - getReferenceClientRect: () => { + getReferenceClientRect: this.tippyOptions.getReferenceClientRect || () => { if (isNodeSelection(state.selection)) { const node = view.nodeDOM(from) as HTMLElement From 285f89b5a901f3efed429903d90733865e3220ff Mon Sep 17 00:00:00 2001 From: fleonus Date: Thu, 31 Mar 2022 22:12:06 +0200 Subject: [PATCH 2/3] Allow overriding getReferenceClientRect in floating menu --- packages/extension-floating-menu/src/floating-menu-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index 4ab1b0b8..caffdffc 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -156,7 +156,7 @@ export class FloatingMenuView { } this.tippy?.setProps({ - getReferenceClientRect: () => posToDOMRect(view, from, to), + getReferenceClientRect: this.tippyOptions.getReferenceClientRect || () => posToDOMRect(view, from, to), }) this.show() From 70dc4fc29f7230a1ca31cc3814703b2d10be638a Mon Sep 17 00:00:00 2001 From: Himanshu Kapoor Date: Thu, 31 Mar 2022 22:18:40 +0200 Subject: [PATCH 3/3] chore: lint fixes --- packages/extension-bubble-menu/src/bubble-menu-plugin.ts | 4 ++-- packages/extension-floating-menu/src/floating-menu-plugin.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts index ec0d557f..14872a03 100644 --- a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts +++ b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts @@ -180,7 +180,7 @@ export class BubbleMenuView { } this.tippy?.setProps({ - getReferenceClientRect: this.tippyOptions.getReferenceClientRect || () => { + getReferenceClientRect: this.tippyOptions?.getReferenceClientRect || (() => { if (isNodeSelection(state.selection)) { const node = view.nodeDOM(from) as HTMLElement @@ -190,7 +190,7 @@ export class BubbleMenuView { } return posToDOMRect(view, from, to) - }, + }), }) this.show() diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index caffdffc..1440492e 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -156,7 +156,7 @@ export class FloatingMenuView { } this.tippy?.setProps({ - getReferenceClientRect: this.tippyOptions.getReferenceClientRect || () => posToDOMRect(view, from, to), + getReferenceClientRect: this.tippyOptions?.getReferenceClientRect || (() => posToDOMRect(view, from, to)), }) this.show()