diff --git a/bun.lockb b/bun.lockb index d0453b3..ea2c86a 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/base/DraggableTree.vue b/components/base/DraggableTree.vue new file mode 100644 index 0000000..33ff564 --- /dev/null +++ b/components/base/DraggableTree.vue @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/base/DraggableTreeItem.vue b/components/base/DraggableTreeItem.vue new file mode 100644 index 0000000..7649ebe --- /dev/null +++ b/components/base/DraggableTreeItem.vue @@ -0,0 +1,140 @@ + + + + + + + + + + \ No newline at end of file diff --git a/db.sqlite b/db.sqlite index d23b34b..cc60573 100644 Binary files a/db.sqlite and b/db.sqlite differ diff --git a/db.sqlite-shm b/db.sqlite-shm index 16848b9..9ecd351 100644 Binary files a/db.sqlite-shm and b/db.sqlite-shm differ diff --git a/db.sqlite-wal b/db.sqlite-wal index 3741197..5c680f5 100644 Binary files a/db.sqlite-wal and b/db.sqlite-wal differ diff --git a/package.json b/package.json index 6a8bd65..69ff00f 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "^1.4.0", + "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.0.3", "@iconify/vue": "^4.1.2", "@nuxtjs/color-mode": "^3.5.2", "@nuxtjs/tailwindcss": "^6.12.2", diff --git a/pages/explore/edit/[...path].vue b/pages/explore/edit/[...path].vue index 8dd0394..40ace66 100644 --- a/pages/explore/edit/[...path].vue +++ b/pages/explore/edit/[...path].vue @@ -20,7 +20,7 @@ - + @@ -51,12 +51,13 @@ import FakeA from '~/components/prose/FakeA.vue'; const route = useRouter().currentRoute; const path = computed(() => Array.isArray(route.value.params.path) ? route.value.params.path[0] : route.value.params.path); const { user, loggedIn } = useUserSession(); +const sessionContent = useSessionStorage(path.value, undefined); const toaster = useToast(); const saveStatus = ref<'idle' | 'pending' | 'success' | 'error'>('idle'); const { data: page, status, error } = await useLazyFetch(`/api/file/${encodeURIComponent(path.value)}`, { watch: [ route, path ]}); -const content = computed(() => page.value?.content); +const content = computed(() => sessionContent.value ?? page.value?.content); const debounced = useDebounce(content, 250); if(!loggedIn || (page.value && page.value.owner !== user.value?.id)) @@ -64,6 +65,10 @@ if(!loggedIn || (page.value && page.value.owner !== user.value?.id)) useRouter().replace({ name: 'explore-path', params: { path: path.value } }); } +watch(debounced, (value) => { + sessionContent.value = value; +}); + async function save(): Promise { saveStatus.value = 'pending'; diff --git a/pages/explore/edit/index.vue b/pages/explore/edit/index.vue index a24c1d6..6e27d9d 100644 --- a/pages/explore/edit/index.vue +++ b/pages/explore/edit/index.vue @@ -1,37 +1,49 @@ - - d[any] - Configuration du projet - - - - - - - - { handleSelect(); selected = isSelected ? undefined : item.value; }"> - {{ item.value.title }} - - - - - - - - - - - - - + + d[any] - Configuration du projet + + + + + + + + + { handleSelect(); selected = isSelected ? undefined : item.value; }"> + {{ item.value.title }} + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/api/navigation.get.ts b/server/api/navigation.get.ts index e386e92..12fe548 100644 --- a/server/api/navigation.get.ts +++ b/server/api/navigation.get.ts @@ -2,7 +2,7 @@ import useDatabase from '~/composables/useDatabase'; import { explorerContentTable } from '~/db/schema'; import type { NavigationItem } from '~/schemas/navigation'; -export type NavigationTreeItem = NavigationItem & { children?: NavigationItem[] }; +export type NavigationTreeItem = NavigationItem & { children?: NavigationTreeItem[] }; export default defineEventHandler(async (e) => { const { user } = await getUserSession(e); diff --git a/shared/general.utils.ts b/shared/general.utils.ts index 6643232..58fabe4 100644 --- a/shared/general.utils.ts +++ b/shared/general.utils.ts @@ -2,6 +2,10 @@ export function unifySlug(slug: string | string[]): string { return (Array.isArray(slug) ? slug.join('/') : slug); } +export function parsePath(path: string): string +{ + return path.toLowerCase().replaceAll(" ", "-").normalize("NFD").replace(/[\u0300-\u036f]/g, ""); +} export function parseId(id: string | undefined): string |undefined { return id?.normalize('NFD')?.replace(/[\u0300-\u036f]/g, '')?.replace(/^\d\. */g, '')?.replace(/\s/g, "-")?.replace(/%/g, "-percent")?.replace(/\?/g, "-q")?.toLowerCase();