Add per-notebook icons and sync

This commit is contained in:
Yuri Karamian
2026-08-03 01:05:07 +02:00
parent e62404d4c0
commit 550d3ab3e9
7 changed files with 479 additions and 25 deletions
+50
View File
@@ -0,0 +1,50 @@
export const NOTEBOOK_ICON_OPTIONS = [
{ id: 'book', label: 'Book' },
{ id: 'folder', label: 'Folder' },
{ id: 'briefcase', label: 'Work' },
{ id: 'home', label: 'Home' },
{ id: 'star', label: 'Star' },
{ id: 'heart', label: 'Heart' },
{ id: 'lightbulb', label: 'Ideas' },
{ id: 'code', label: 'Code' },
{ id: 'flask', label: 'Research' },
{ id: 'graduation', label: 'Study' },
{ id: 'calendar', label: 'Calendar' },
{ id: 'tasks', label: 'Tasks' },
{ id: 'archive', label: 'Archive' },
{ id: 'globe', label: 'Globe' },
{ id: 'plane', label: 'Travel' },
{ id: 'palette', label: 'Creative' }
] as const;
export type NotebookIconId = (typeof NOTEBOOK_ICON_OPTIONS)[number]['id'];
const BUILTIN_PREFIX = 'builtin:';
const BUILTIN_IDS: Record<NotebookIconId, true> = {
book: true,
folder: true,
briefcase: true,
home: true,
star: true,
heart: true,
lightbulb: true,
code: true,
flask: true,
graduation: true,
calendar: true,
tasks: true,
archive: true,
globe: true,
plane: true,
palette: true
};
export function encodeBuiltinNotebookIcon(icon: NotebookIconId): string {
return `${BUILTIN_PREFIX}${icon}`;
}
export function decodeBuiltinNotebookIcon(value: string | null | undefined): NotebookIconId | null {
if (!value?.startsWith(BUILTIN_PREFIX)) return null;
const icon = value.slice(BUILTIN_PREFIX.length);
return Object.hasOwn(BUILTIN_IDS, icon) ? icon as NotebookIconId : null;
}