feat: add logos editor

This commit is contained in:
2026-03-15 21:12:05 +01:00
parent 929359b4bc
commit 290217791f
8 changed files with 2972 additions and 168 deletions

View File

@@ -1,37 +1,24 @@
/**
* Per-recollection graph persistence (localStorage).
* Saves and loads StoredGraphState (version + nodes + edges). Used by useCanvasGraph and export.
* Per-recollection graph persistence. Re-exports from recollectionStore for backward compatibility.
* New code should use recollectionStore (getGraph, setGraph, removeRecollectionData) directly.
*/
import type { StoredGraphState } from '@/lib/graph/state'
import {
getGraph,
setGraph,
removeRecollectionData,
RECOLLECTION_FILE_EXT,
RECOLLECTION_VERSION,
type StoredGraphState,
} from './recollectionStore'
export type { StoredGraphState }
export const RECOLLECTION_FILE_EXT = '.zui.json'
export const RECOLLECTION_VERSION = 1
const GRAPH_KEY_PREFIX = 'zui_graph_'
export { RECOLLECTION_FILE_EXT, RECOLLECTION_VERSION }
export function getGraphStorageKey(recollectionId: string): string {
return `${GRAPH_KEY_PREFIX}${recollectionId}`
return `zui_graph_${recollectionId}`
}
export function loadGraphFromStorage(recollectionId: string): StoredGraphState | null {
try {
const raw = localStorage.getItem(getGraphStorageKey(recollectionId))
if (!raw) return null
const data = JSON.parse(raw) as unknown
if (!data || typeof data !== 'object' || !Array.isArray((data as StoredGraphState).nodes) || !Array.isArray((data as StoredGraphState).edges))
return null
return data as StoredGraphState
} catch {
return null
}
}
export function saveGraphToStorage(recollectionId: string, state: StoredGraphState): void {
localStorage.setItem(getGraphStorageKey(recollectionId), JSON.stringify(state))
}
export function removeGraphFromStorage(recollectionId: string): void {
localStorage.removeItem(getGraphStorageKey(recollectionId))
}
export const loadGraphFromStorage = getGraph
export const saveGraphToStorage = setGraph
export const removeGraphFromStorage = removeRecollectionData