Filter ProseA hover cards with the provided hash
This commit is contained in:
parent
cb2c19fada
commit
7bdf6ccd13
|
|
@ -1,26 +1,49 @@
|
||||||
<template>
|
<template>
|
||||||
<template v-if="content && content.length > 0">
|
<template v-if="content && content.length > 0">
|
||||||
<Suspense :timeout="0">
|
<div><MarkdownRenderer #default v-if="data" :node="data" :proses="proses"></MarkdownRenderer></div>
|
||||||
<MarkdownRenderer #default :key="key" v-if="node" :node="node" :proses="proses"></MarkdownRenderer>
|
|
||||||
<template #fallback><Loading /></template>
|
|
||||||
</Suspense>
|
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { hash } from 'ohash'
|
import type { Component } from 'vue';
|
||||||
|
import { heading } from 'hast-util-heading';
|
||||||
|
import { headingRank } from 'hast-util-heading-rank';
|
||||||
|
import { parseId } from '~/shared/general.utils';
|
||||||
|
import type { Root } from 'hast';
|
||||||
|
|
||||||
const { content } = defineProps({
|
const { content, proses, filter } = defineProps<{
|
||||||
content: {
|
content: string
|
||||||
type: String,
|
proses?: Array<string | Component>
|
||||||
required: true,
|
filter?: string
|
||||||
},
|
}>();
|
||||||
proses: {
|
|
||||||
type: Object
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const parser = useMarkdown();
|
const parser = useMarkdown(), data = ref<Root>();
|
||||||
const key = computed(() => hash(content));
|
|
||||||
const node = computed(() => content ? parser(content) : undefined);
|
const node = computed(() => content ? parser(content) : undefined);
|
||||||
|
watch([node], () => {
|
||||||
|
if(!node.value)
|
||||||
|
data.value = undefined;
|
||||||
|
else if(!filter)
|
||||||
|
{
|
||||||
|
data.value = node.value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const start = node.value?.children.findIndex(e => heading(e) && parseId(e.properties.id as string | undefined) === filter) ?? -1;
|
||||||
|
|
||||||
|
if(start === -1)
|
||||||
|
data.value = node.value;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let end = start;
|
||||||
|
const rank = headingRank(node.value.children[start])!;
|
||||||
|
while(end < node.value.children.length)
|
||||||
|
{
|
||||||
|
end++;
|
||||||
|
if(heading(node.value.children[end]) && headingRank(node.value.children[end])! >= rank)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
data.value = { ...node.value, children: node.value.children.slice(start, end) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, { immediate: true, });
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -154,26 +154,22 @@ const pinchHandler = usePinch(({ event, offset: [z] }: { event: Event, offset: n
|
||||||
zoom.value = clamp(z / 2048, minZoom.value, 3);
|
zoom.value = clamp(z / 2048, minZoom.value, 3);
|
||||||
}, {
|
}, {
|
||||||
domTarget: canvas,
|
domTarget: canvas,
|
||||||
eventOptions: { passive: false, }
|
|
||||||
})
|
})
|
||||||
const dragHandler = useDrag(({ event, delta: [x, y] }: { event: Event, delta: number[] }) => {
|
const dragHandler = useDrag(({ event, delta: [x, y] }: { event: Event, delta: number[] }) => {
|
||||||
dispX.value += x / zoom.value;
|
dispX.value += x / zoom.value;
|
||||||
dispY.value += y / zoom.value;
|
dispY.value += y / zoom.value;
|
||||||
}, {
|
}, {
|
||||||
domTarget: canvas,
|
domTarget: canvas,
|
||||||
eventOptions: { passive: false, }
|
|
||||||
})
|
})
|
||||||
const wheelHandler = useWheel(({ event, delta: [x, y] }: { event: Event, delta: number[] }) => {
|
const wheelHandler = useWheel(({ event, delta: [x, y] }: { event: Event, delta: number[] }) => {
|
||||||
zoom.value = clamp(zoom.value + y * -0.001, minZoom.value, 3);
|
zoom.value = clamp(zoom.value + y * -0.001, minZoom.value, 3);
|
||||||
}, {
|
}, {
|
||||||
domTarget: canvas,
|
domTarget: canvas,
|
||||||
eventOptions: { passive: false, }
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Suspense>
|
<div>
|
||||||
<template #default>
|
|
||||||
<div id="canvas" ref="canvas" class="absolute top-0 left-0 overflow-hidden w-full h-full touch-none"
|
<div id="canvas" ref="canvas" class="absolute top-0 left-0 overflow-hidden w-full h-full touch-none"
|
||||||
:style="{ '--zoom-multiplier': (1 / Math.pow(zoom, 0.7)) }">
|
:style="{ '--zoom-multiplier': (1 / Math.pow(zoom, 0.7)) }">
|
||||||
<div class="border border-light-35 dark:border-dark-35 bg-light-10 dark:bg-dark-10 absolute sm:top-2 top-10 left-2 z-[35] overflow-hidden">
|
<div class="border border-light-35 dark:border-dark-35 bg-light-10 dark:bg-dark-10 absolute sm:top-2 top-10 left-2 z-[35] overflow-hidden">
|
||||||
|
|
@ -216,9 +212,5 @@ const wheelHandler = useWheel(({ event, delta: [x, y] }: { event: Event, delta:
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</div>
|
||||||
<template #fallback>
|
|
||||||
<div class="loading"></div>
|
|
||||||
</template>
|
|
||||||
</Suspense>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -1,21 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<NuxtLink class="text-accent-blue inline-flex items-center" v-if="overview"
|
<NuxtLink class="text-accent-blue inline-flex items-center"
|
||||||
:to="{ name: 'explore-path', params: { path: overview.path }, hash: hash }" :class="class">
|
:to="overview ? { name: 'explore-path', params: { path: overview.path }, hash: hash } : href" :class="class">
|
||||||
<HoverCard class="max-w-[600px] max-h-[600px] w-full overflow-auto z-[45]" :class="{'overflow-hidden !p-0': overview.type === 'canvas'}" @open="load">
|
<HoverCard class="max-w-[600px] max-h-[600px] w-full overflow-auto z-[45]" :class="{'overflow-hidden !p-0': overview?.type === 'canvas'}" @open="load" :disabled="!overview">
|
||||||
<template #content>
|
<template #content>
|
||||||
<template v-if="loading">
|
<Loading v-if="loading" />
|
||||||
<Loading />
|
<Markdown v-else-if="overview?.type === 'markdown'" class="px-10" :content="content!.content" :filter="hash.substring(1)" />
|
||||||
</template>
|
<Canvas v-else-if="overview?.type === 'canvas'" class="w-[600px] h-[600px] relative" :canvas="JSON.parse(content!.content)" />
|
||||||
<template v-else-if="overview.type === 'markdown'">
|
|
||||||
<div class="px-10">
|
|
||||||
<Markdown :content="content!.content" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<template v-else-if="overview.type === 'canvas'">
|
|
||||||
<div class="w-[600px] h-[600px] relative">
|
|
||||||
<Canvas :canvas="JSON.parse(content!.content)" />
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</template>
|
</template>
|
||||||
<template #default>
|
<template #default>
|
||||||
<slot v-bind="$attrs"></slot>
|
<slot v-bind="$attrs"></slot>
|
||||||
|
|
@ -23,11 +13,6 @@
|
||||||
</template>
|
</template>
|
||||||
</HoverCard>
|
</HoverCard>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<NuxtLink v-else-if="href" :to="href" :class="class" class="text-accent-blue inline-flex items-center">
|
|
||||||
<slot v-bind="$attrs"></slot>
|
|
||||||
<Icon class="w-4 h-4 inline-block" v-if="overview && overview.type !== 'markdown'" :height="20" :width="20" :icon="iconByType[overview.type]" />
|
|
||||||
</NuxtLink>
|
|
||||||
<slot :class="class" v-else v-bind="$attrs"></slot>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
||||||
BIN
db.sqlite-shm
BIN
db.sqlite-shm
Binary file not shown.
BIN
db.sqlite-wal
BIN
db.sqlite-wal
Binary file not shown.
|
|
@ -19,6 +19,8 @@
|
||||||
"codemirror": "^6.0.1",
|
"codemirror": "^6.0.1",
|
||||||
"drizzle-orm": "^0.35.3",
|
"drizzle-orm": "^0.35.3",
|
||||||
"hast": "^1.0.0",
|
"hast": "^1.0.0",
|
||||||
|
"hast-util-heading": "^3.0.0",
|
||||||
|
"hast-util-heading-rank": "^3.0.0",
|
||||||
"lodash.capitalize": "^4.2.1",
|
"lodash.capitalize": "^4.2.1",
|
||||||
"mdast-util-find-and-replace": "^3.0.1",
|
"mdast-util-find-and-replace": "^3.0.1",
|
||||||
"nodemailer": "^6.9.16",
|
"nodemailer": "^6.9.16",
|
||||||
|
|
|
||||||
4
todo.md
4
todo.md
|
|
@ -1,8 +1,8 @@
|
||||||
- [x] Mot de passe oublié
|
- [x] Mot de passe oublié
|
||||||
- [x] Rename auto des liens au changement de path
|
- [x] Rename auto des liens au changement de path
|
||||||
- [ ] Autocomplete des liens dans l'editeur
|
|
||||||
- [ ] Editeur de graphe
|
|
||||||
- [ ] Filtrage de lien avec le header id
|
- [ ] Filtrage de lien avec le header id
|
||||||
|
- [ ] Editeur de graphe
|
||||||
|
- [ ] Autocomplete des liens dans l'editeur
|
||||||
- [ ] Embed de lien (le ![[]] de Obsidian)
|
- [ ] Embed de lien (le ![[]] de Obsidian)
|
||||||
- [ ] Rework la structure projet
|
- [ ] Rework la structure projet
|
||||||
- [ ] Limite de taille par projet (100 Mo ?)
|
- [ ] Limite de taille par projet (100 Mo ?)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue