Minimal history handler, handle node move. Auto parse JSON content for accurate typing.

This commit is contained in:
2025-01-09 16:41:36 +01:00
parent b1a9eb859e
commit 62950be032
6 changed files with 315 additions and 102 deletions

View File

@@ -1,3 +1,4 @@
import type { CanvasContent } from '~/types/canvas';
import type { FileType } from '~/types/content';
export function unifySlug(slug: string | string[]): string
@@ -46,6 +47,20 @@ export function clamp(x: number, min: number, max: number): number {
return min;
return x;
}
export function convertContent(type: FileType, content: string): CanvasContent | string {
switch(type)
{
case 'canvas':
return JSON.parse(content) as CanvasContent;
case 'map':
case 'file':
case 'folder':
case 'markdown':
return content;
default:
return content;
}
}
export const iconByType: Record<FileType, string> = {
'folder': 'lucide:folder',