diff --git a/client/src/components/highlights/HighlightPopover.vue b/client/src/components/highlights/HighlightPopover.vue
index 43fe8ea0..3fd12046 100644
--- a/client/src/components/highlights/HighlightPopover.vue
+++ b/client/src/components/highlights/HighlightPopover.vue
@@ -1,12 +1,84 @@
-
Hello
-
-
+
+
+
+
+
diff --git a/client/src/components/icons/NoteIcon.vue b/client/src/components/icons/NoteIcon.vue
index 2d9dba4a..41eb81c4 100644
--- a/client/src/components/icons/NoteIcon.vue
+++ b/client/src/components/icons/NoteIcon.vue
@@ -12,11 +12,3 @@
-
-
diff --git a/client/src/directives/highlight.ts b/client/src/directives/highlight.ts
index fd598148..5c4b7166 100644
--- a/client/src/directives/highlight.ts
+++ b/client/src/directives/highlight.ts
@@ -5,6 +5,7 @@ import log from 'loglevel';
import * as Mark from 'mark.js';
import { ContentBlockNode } from '@/__generated__/graphql';
import ContentBlock from '@/components/ContentBlock.vue';
+import popover from '@/helpers/popover';
// todo: we need to get the following information for a highlight:
// Which ContentBlock? => contentBlock.id
@@ -131,6 +132,11 @@ export const getSelectionHandler = (el: HTMLElement, contentBlock: ContentBlockN
text: range.toString(),
};
console.log(highlightedText);
+
+ const positionOfContentBlock = el.getBoundingClientRect();
+ const positionOfSelection = paragraph?.getBoundingClientRect();
+ const offetTop = positionOfSelection.top - positionOfContentBlock.top;
+ popover.show(el, offetTop);
// todo: how do we save this? maybe we need to move away from the directive and do this inside the mounted
// and unmounted hooks of the ContentBlock
}
diff --git a/client/src/helpers/popover.ts b/client/src/helpers/popover.ts
index fad4b76b..cbea6248 100644
--- a/client/src/helpers/popover.ts
+++ b/client/src/helpers/popover.ts
@@ -4,9 +4,9 @@ import { createApp } from 'vue';
type ResolveReject = (v?: unknown) => void;
export default {
- show() {
+ show(wrapper: HTMLElement, offsetTop: number) {
const mountEl = document.createElement('div');
- document.body.appendChild(mountEl);
+ wrapper.appendChild(mountEl);
let _resolve: ResolveReject, _reject: ResolveReject;
@@ -21,6 +21,7 @@ export default {
};
const popover = createApp(HighlightPopover, {
+ top: `${Math.floor(offsetTop)}px`,
onConfirm() {
cleanUp();
_resolve();