Skip to content
Snippets Groups Projects
Commit 6756b758 authored by Vukile Langa's avatar Vukile Langa
Browse files

revert(services): undo changes to `OverlayService`

parent af267725
No related branches found
No related tags found
1 merge request!607Show image meta fields on keyboard navigation v2
......@@ -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,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment