From c180aa94f53c2a002ae5bae3973bb7f721bf52ea Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Mon, 22 Jan 2024 16:16:04 +0100 Subject: [PATCH] Show sidebar only after clicking some highlighted text --- .../content-blocks/ContentComponent.vue | 10 +++++++ .../highlights/HighlightSidebar.vue | 10 +++++-- client/src/helpers/highlight-sidebar.ts | 26 +++++++++++++++++++ client/src/layouts/DefaultLayout.vue | 3 --- 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 client/src/helpers/highlight-sidebar.ts diff --git a/client/src/components/content-blocks/ContentComponent.vue b/client/src/components/content-blocks/ContentComponent.vue index 305d0b12..335eab54 100644 --- a/client/src/components/content-blocks/ContentComponent.vue +++ b/client/src/components/content-blocks/ContentComponent.vue @@ -30,6 +30,7 @@ import { constructContentComponentBookmarkMutation } from '@/helpers/update-cont import { useMutation } from '@vue/apollo-composable'; import { HighlightNode } from '@/__generated__/graphql'; import * as Mark from 'mark.js'; +import highlightSidebar from '@/helpers/highlight-sidebar'; export interface Props { component: any; @@ -209,6 +210,14 @@ const markHighlights = () => { ]; instance.markRanges(ranges, { className: `highlight highlight--${highlight.color}`, + each: (newMark) => { + newMark.dataset.id = highlight.id; + console.log(newMark); + newMark.addEventListener('click', () => { + console.log('clicked'); + highlightSidebar.open(); + }); + }, }); } }; @@ -223,6 +232,7 @@ onMounted(() => { .highlight { background-color: Highlight; color: HighlightText; + cursor: pointer; &--alpha { background-color: var(--mark-alpha); diff --git a/client/src/components/highlights/HighlightSidebar.vue b/client/src/components/highlights/HighlightSidebar.vue index 517fcf39..6a680156 100644 --- a/client/src/components/highlights/HighlightSidebar.vue +++ b/client/src/components/highlights/HighlightSidebar.vue @@ -1,6 +1,9 @@