diff --git a/client/src/components/highlights/HighlightPopover.vue b/client/src/components/highlights/HighlightPopover.vue
index 3fd12046..9075c24a 100644
--- a/client/src/components/highlights/HighlightPopover.vue
+++ b/client/src/components/highlights/HighlightPopover.vue
@@ -1,15 +1,30 @@
@@ -21,7 +36,7 @@ export interface Props {
top: string;
}
-defineEmits(['close', 'confirm']);
+defineEmits(['close', 'confirm', 'choose-color']);
defineProps();
diff --git a/client/src/directives/highlight.ts b/client/src/directives/highlight.ts
index 5c4b7166..ae7d031c 100644
--- a/client/src/directives/highlight.ts
+++ b/client/src/directives/highlight.ts
@@ -135,8 +135,26 @@ export const getSelectionHandler = (el: HTMLElement, contentBlock: ContentBlockN
const positionOfContentBlock = el.getBoundingClientRect();
const positionOfSelection = paragraph?.getBoundingClientRect();
- const offetTop = positionOfSelection.top - positionOfContentBlock.top;
- popover.show(el, offetTop);
+ const offsetTop = positionOfSelection.top - positionOfContentBlock.top;
+ popover
+ .show({
+ wrapper: el,
+ offsetTop,
+ onChooseColor: (color: string) => {
+ console.log('chosenColor', color);
+ // const newHighlight: Highlight = {
+ // contentBlock: contentBlock.id,
+ // contentIndex:
+ //
+ // };
+ },
+ })
+ .then(() => {
+ console.log('confirmed');
+ })
+ .catch(() => {
+ console.log('canceled');
+ });
// 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 f37df4d7..f85d2365 100644
--- a/client/src/helpers/popover.ts
+++ b/client/src/helpers/popover.ts
@@ -3,8 +3,14 @@ import { createApp } from 'vue';
type ResolveReject = (v?: unknown) => void;
+interface Options {
+ wrapper: HTMLElement;
+ offsetTop: number;
+ onChooseColor: (color: string) => void;
+}
+
export default {
- show(wrapper: HTMLElement, offsetTop: number) {
+ show({ wrapper, offsetTop, onChooseColor }: Options) {
const mountEl = document.createElement('div');
wrapper.appendChild(mountEl);
@@ -39,6 +45,7 @@ export default {
cleanUp();
_reject();
},
+ onChooseColor,
});
popover.mount(mountEl);