From 6756b75828a4050861cfa658c230b451556f5267 Mon Sep 17 00:00:00 2001 From: Vukile Langa <vukilelanga@me.com> Date: Fri, 5 Jul 2024 10:40:30 +0200 Subject: [PATCH] revert(services): undo changes to `OverlayService` --- .../OverlayService/usePosition.js | 35 ++++--------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js b/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js index 86ca2b293..7861b32fa 100644 --- a/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js +++ b/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js @@ -12,10 +12,7 @@ const defaultOverlay = { }; export default options => { - const { - activeView, - pmViews: { main }, - } = useContext(WaxContext); + const { activeView } = useContext(WaxContext); const [position, setPosition] = useState({ position: 'absolute', @@ -28,21 +25,11 @@ export default options => { /* Sets Default position at the end of the annotation. You can overwrite the default position in your component. */ - const calculatePosition = (focusedView, from, to, componentType = '') => { - let offset = 15; - let WaxSurface = focusedView.dom.getBoundingClientRect(); - - if (componentType === 'imageAltText') { - offset = -25; - } - - if (['imageAltText', 'imageLongDesc'].includes(componentType)) { - WaxSurface = main.dom.getBoundingClientRect(); - } - + const calculatePosition = (focusedView, from, to) => { + const WaxSurface = focusedView.dom.getBoundingClientRect(); const end = focusedView.coordsAtPos(to); const left = end.left - WaxSurface.left; - const top = end.top - WaxSurface.top + offset; + const top = end.top - WaxSurface.top + 15; return { top, left, @@ -64,24 +51,14 @@ export default options => { }; const displayOnNode = (focusedView, overlayOptions) => { - const { - nodeType, - followCursor, - findInParent, - componentType, - } = overlayOptions; + const { nodeType, followCursor, findInParent } = overlayOptions; const PMnode = focusedView.state.schema.nodes[nodeType]; node = DocumentHelpers.findNode(focusedView.state, PMnode, findInParent); if (!isObject(node)) return defaultOverlay; const { from, to } = followCursor ? focusedView.state.selection : node; - const { left, top } = calculatePosition( - focusedView, - from, - to, - componentType, - ); + const { left, top } = calculatePosition(focusedView, from, to); return { left, -- GitLab