diff --git a/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js b/wax-prosemirror-core/src/config/defaultServices/OverlayService/usePosition.js index 86ca2b293b406e37c4c3b294dd3aca7ba8942af3..7861b32faaf403ce8c05ae9ce17b3129eb8be397 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,