You've already forked obsidian-visualiser
Minimal history handler, handle node move. Auto parse JSON content for accurate typing.
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user