Add highlights to nested content content-blocks
Also refactor the ContentListBlock component
This commit is contained in:
parent
6a70d3ca9e
commit
56b973f02e
|
|
@ -33,6 +33,7 @@ import Mark from 'mark.js';
|
||||||
import highlightSidebar from '@/helpers/highlight-sidebar';
|
import highlightSidebar from '@/helpers/highlight-sidebar';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
|
// todo: use useful types here
|
||||||
component: any;
|
component: any;
|
||||||
parent: any;
|
parent: any;
|
||||||
highlights: HighlightNode[];
|
highlights: HighlightNode[];
|
||||||
|
|
|
||||||
|
|
@ -9,33 +9,38 @@
|
||||||
</content-list>
|
</content-list>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup lang="ts">
|
||||||
import { defineAsyncComponent } from 'vue';
|
import ContentList from '@/components/content-blocks/ContentList.vue';
|
||||||
const ContentList = defineAsyncComponent(() => import('@/components/content-blocks/ContentList.vue'));
|
import ContentBlock from '@/components/ContentBlock.vue';
|
||||||
const ContentBlock = defineAsyncComponent(() => import('@/components/ContentBlock.vue'));
|
import { computed } from '@vue/reactivity';
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
// todo: use useful types here
|
||||||
|
contents: any[];
|
||||||
|
parent: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
const contentBlocks = computed(() => {
|
||||||
|
return props.contents.map((contentBlock) => {
|
||||||
|
const contents = contentBlock.value ? [...contentBlock.value] : [];
|
||||||
|
return Object.assign({}, contentBlock, {
|
||||||
|
contents,
|
||||||
|
indent: true,
|
||||||
|
bookmarks: props.parent.bookmarks,
|
||||||
|
notes: props.parent.notes,
|
||||||
|
highlights: props.parent.highlights,
|
||||||
|
root: props.parent.id,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
export default {
|
export default {
|
||||||
|
// can't really declare names with the new script setup syntax, that's why this is still here
|
||||||
|
// todo: does this name still matter anywhere?
|
||||||
name: 'ContentBlockList',
|
name: 'ContentBlockList',
|
||||||
props: ['contents', 'parent'],
|
|
||||||
|
|
||||||
components: {
|
|
||||||
ContentList,
|
|
||||||
ContentBlock,
|
|
||||||
},
|
|
||||||
|
|
||||||
computed: {
|
|
||||||
contentBlocks() {
|
|
||||||
return this.contents.map((contentBlock) => {
|
|
||||||
const contents = contentBlock.value ? [...contentBlock.value] : [];
|
|
||||||
return Object.assign({}, contentBlock, {
|
|
||||||
contents,
|
|
||||||
indent: true,
|
|
||||||
bookmarks: this.parent.bookmarks,
|
|
||||||
notes: this.parent.notes,
|
|
||||||
root: this.parent.id,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue