New useContent composable to store global navigation state. Fixes for Markdown and Canvas

This commit is contained in:
2024-12-30 20:46:24 +01:00
parent 031a51c2fe
commit 9515132659
31 changed files with 320 additions and 220 deletions

4
types/api.d.ts vendored
View File

@@ -1,3 +1,5 @@
import type { FileType } from '~/types/content';
export interface SuccessHandler
{
success: true;
@@ -25,9 +27,7 @@ export interface Navigation {
children?: Navigation[];
}
export type FileMetadata = Record<string, boolean | string | number>;
export type FileType = 'markdown' | 'canvas' | 'file' | 'folder';
export interface File {
project: number;
path: string;
owner: number;
title: string;

4
types/auth.d.ts vendored
View File

@@ -30,8 +30,8 @@ export interface UserRawData {
}
export interface UserExtendedData {
signin: Date;
lastTimestamp: Date;
signin: string;
lastTimestamp: string;
logCount: number;
}

33
types/content.d.ts vendored Normal file
View File

@@ -0,0 +1,33 @@
import { explorerContentTable } from "~/db/schema";
import type { CanvasContent } from "./canvas";
export type FileType = typeof explorerContentTable.$inferSelect.type;
export type Overview = Omit<typeof explorerContentTable.$inferSelect, 'content'>;
export type Content = { content: string };
export type ExploreContent= Overview & Partial<Content>;
export type TreeItem = ExploreContent & { children?: TreeItem[] };
export interface ContentComposable {
content: Ref<ExploreContent[]>
tree: ComputedRef<TreeItem[]>
/**
* Fetch the overview of every content from the server.
*/
fetch: (force: boolean) => Promise<void>
/**
* Get the given content from the server.
*/
get: (path: string) => Promise<void>
}
export type MarkdownContent = string;
export type FileContent = any;
export type FolderContent = null;
export interface ContentTypeMap
{
markdown: MarkdownContent;
canvas: CanvasContent;
file: FileContent;
folder: FolderContent;
}