@open-slide/core 1.17.1 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,96 @@
1
+ import { Image as ImageIcon, Palette, Presentation } from 'lucide-react';
2
+ import { useMemo } from 'react';
3
+ import { useNavigate } from 'react-router-dom';
4
+ import { useLocale } from '@/lib/use-locale';
5
+ import { useSlideTitles } from '@/lib/use-slide-titles';
6
+ import type { Folder } from '../../lib/sdk';
7
+ import { slideIds } from '../../lib/slides';
8
+ import { FolderIconChip } from '../sidebar/folder-item';
9
+ import { ALL_SLIDES_ID, ASSETS_ID, DRAFT_ID, THEMES_ID } from '../sidebar/sidebar';
10
+ import { type CommandGroupSpec, CommandMenu, type CommandSpec } from './command-menu';
11
+
12
+ export function HomeCommandMenu({
13
+ open,
14
+ onOpenChange,
15
+ folders,
16
+ titleMap,
17
+ onSelectView,
18
+ }: {
19
+ open: boolean;
20
+ onOpenChange: (open: boolean) => void;
21
+ folders: Folder[];
22
+ titleMap: Record<string, string>;
23
+ onSelectView: (id: string) => void;
24
+ }) {
25
+ const t = useLocale();
26
+ const navigate = useNavigate();
27
+ const loadedTitles = useSlideTitles(open);
28
+
29
+ const groups = useMemo<CommandGroupSpec[]>(() => {
30
+ const slides: CommandSpec[] = slideIds.map((id) => ({
31
+ id: `slide-${id}`,
32
+ label: titleMap[id] ?? loadedTitles[id] ?? id,
33
+ icon: <Presentation />,
34
+ keywords: [id],
35
+ run: () => navigate(`/s/${id}`),
36
+ }));
37
+
38
+ const folderItems: CommandSpec[] = [
39
+ {
40
+ id: `view-${ALL_SLIDES_ID}`,
41
+ label: t.home.slides,
42
+ icon: <FolderIconChip icon={{ type: 'emoji', value: '🎞️' }} />,
43
+ keywords: ['all', 'slides'],
44
+ run: () => onSelectView(ALL_SLIDES_ID),
45
+ },
46
+ {
47
+ id: `view-${DRAFT_ID}`,
48
+ label: t.home.draft,
49
+ icon: <FolderIconChip icon={{ type: 'emoji', value: '📝' }} />,
50
+ keywords: ['draft', 'unsorted'],
51
+ run: () => onSelectView(DRAFT_ID),
52
+ },
53
+ ...folders.map((folder) => ({
54
+ id: `view-${folder.id}`,
55
+ label: folder.name,
56
+ icon: <FolderIconChip icon={folder.icon} />,
57
+ keywords: ['folder', folder.id],
58
+ run: () => onSelectView(folder.id),
59
+ })),
60
+ ];
61
+
62
+ const navigation: CommandSpec[] = [
63
+ {
64
+ id: `view-${THEMES_ID}`,
65
+ label: t.home.themes,
66
+ icon: <Palette />,
67
+ keywords: ['themes', 'design'],
68
+ run: () => onSelectView(THEMES_ID),
69
+ },
70
+ ];
71
+ if (import.meta.env.DEV) {
72
+ navigation.push({
73
+ id: `view-${ASSETS_ID}`,
74
+ label: t.home.assets,
75
+ icon: <ImageIcon />,
76
+ keywords: ['assets', 'images', 'files'],
77
+ run: () => onSelectView(ASSETS_ID),
78
+ });
79
+ }
80
+
81
+ return [
82
+ { id: 'slides', heading: t.commandMenu.groupSlides, items: slides },
83
+ { id: 'folders', heading: t.commandMenu.groupFolders, items: folderItems },
84
+ { id: 'navigation', heading: t.commandMenu.groupNavigation, items: navigation },
85
+ ];
86
+ }, [t, folders, titleMap, loadedTitles, navigate, onSelectView]);
87
+
88
+ return (
89
+ <CommandMenu
90
+ open={open}
91
+ onOpenChange={onOpenChange}
92
+ groups={groups}
93
+ placeholder={t.commandMenu.placeholder}
94
+ />
95
+ );
96
+ }
@@ -0,0 +1,171 @@
1
+ import config from 'virtual:open-slide/config';
2
+ import {
3
+ ChevronLeft,
4
+ FileCode2,
5
+ FileImage,
6
+ FileText,
7
+ Grid2x2,
8
+ Link2,
9
+ Maximize,
10
+ MonitorSpeaker,
11
+ Palette,
12
+ Play,
13
+ RectangleHorizontal,
14
+ } from 'lucide-react';
15
+ import { useNavigate } from 'react-router-dom';
16
+ import { format, useLocale } from '@/lib/use-locale';
17
+ import { type CommandGroupSpec, CommandMenu, type CommandSpec } from './command-menu';
18
+
19
+ const { showSlideBrowser, allowHtmlDownload } = config.build;
20
+
21
+ export type SlideCommandHandlers = {
22
+ onPresentWindow: () => void;
23
+ onPresentFullscreen: () => void;
24
+ onPresenterView: () => void;
25
+ onCopyLink: () => void;
26
+ onOverview: () => void;
27
+ onToggleDesignPanel: () => void;
28
+ onExportHtml: () => void;
29
+ onExportPdf: () => void;
30
+ onExportImagePptx: () => void;
31
+ onGoToPage: (index: number) => void;
32
+ };
33
+
34
+ export function SlideCommandMenu({
35
+ open,
36
+ onOpenChange,
37
+ pageCount,
38
+ currentIndex,
39
+ exporting,
40
+ handlers,
41
+ }: {
42
+ open: boolean;
43
+ onOpenChange: (open: boolean) => void;
44
+ pageCount: number;
45
+ currentIndex: number;
46
+ exporting: boolean;
47
+ handlers: SlideCommandHandlers;
48
+ }) {
49
+ const t = useLocale();
50
+ const navigate = useNavigate();
51
+
52
+ const groups: CommandGroupSpec[] = (() => {
53
+ const present: CommandSpec[] = [
54
+ {
55
+ id: 'present-fullscreen',
56
+ label: t.slide.presentFullscreen,
57
+ icon: <Maximize />,
58
+ keywords: ['present', 'fullscreen', 'play'],
59
+ shortcut: 'F',
60
+ run: handlers.onPresentFullscreen,
61
+ },
62
+ {
63
+ id: 'present-window',
64
+ label: t.slide.presentInWindow,
65
+ icon: <Play />,
66
+ keywords: ['present', 'window', 'play'],
67
+ shortcut: '↵',
68
+ run: handlers.onPresentWindow,
69
+ },
70
+ {
71
+ id: 'present-presenter',
72
+ label: t.slide.presentPresenter,
73
+ icon: <MonitorSpeaker />,
74
+ keywords: ['presenter', 'notes', 'speaker'],
75
+ shortcut: 'P',
76
+ run: handlers.onPresenterView,
77
+ },
78
+ ];
79
+
80
+ const deck: CommandSpec[] = [
81
+ {
82
+ id: 'copy-link',
83
+ label: t.slide.copyLink,
84
+ icon: <Link2 />,
85
+ keywords: ['copy', 'link', 'url', 'share'],
86
+ run: handlers.onCopyLink,
87
+ },
88
+ {
89
+ id: 'overview',
90
+ label: t.commandMenu.overview,
91
+ icon: <Grid2x2 />,
92
+ keywords: ['overview', 'grid', 'pages'],
93
+ shortcut: 'O',
94
+ run: handlers.onOverview,
95
+ },
96
+ ];
97
+ if (import.meta.env.DEV) {
98
+ deck.push({
99
+ id: 'design-panel',
100
+ label: t.commandMenu.designPanel,
101
+ icon: <Palette />,
102
+ keywords: ['design', 'style', 'tokens'],
103
+ shortcut: 'D',
104
+ run: handlers.onToggleDesignPanel,
105
+ });
106
+ }
107
+ if (showSlideBrowser) {
108
+ deck.push({
109
+ id: 'back-to-slides',
110
+ label: t.commandMenu.backToSlides,
111
+ icon: <ChevronLeft />,
112
+ keywords: ['home', 'back', 'slides'],
113
+ run: () => navigate('/'),
114
+ });
115
+ }
116
+
117
+ const exports: CommandSpec[] = allowHtmlDownload
118
+ ? [
119
+ {
120
+ id: 'export-html',
121
+ label: t.slide.exportAsHtml,
122
+ icon: <FileCode2 />,
123
+ keywords: ['export', 'html', 'download'],
124
+ disabled: exporting,
125
+ run: handlers.onExportHtml,
126
+ },
127
+ {
128
+ id: 'export-pdf',
129
+ label: t.slide.exportAsPdf,
130
+ icon: <FileText />,
131
+ keywords: ['export', 'pdf', 'download', 'print'],
132
+ disabled: exporting,
133
+ run: handlers.onExportPdf,
134
+ },
135
+ {
136
+ id: 'export-image-pptx',
137
+ label: t.slide.exportAsImagePptx,
138
+ icon: <FileImage />,
139
+ keywords: ['export', 'pptx', 'powerpoint', 'download'],
140
+ disabled: exporting,
141
+ run: handlers.onExportImagePptx,
142
+ },
143
+ ]
144
+ : [];
145
+
146
+ const pages: CommandSpec[] = Array.from({ length: pageCount }, (_, i) => ({
147
+ id: `page-${i + 1}`,
148
+ label: format(t.commandMenu.goToPage, { n: i + 1 }),
149
+ icon: <RectangleHorizontal />,
150
+ keywords: ['page', String(i + 1)],
151
+ active: i === currentIndex,
152
+ run: () => handlers.onGoToPage(i),
153
+ }));
154
+
155
+ return [
156
+ { id: 'present', heading: t.commandMenu.groupPresent, items: present },
157
+ { id: 'deck', heading: t.commandMenu.groupDeck, items: deck },
158
+ { id: 'export', heading: t.commandMenu.groupExport, items: exports },
159
+ { id: 'pages', heading: t.commandMenu.groupPages, items: pages, searchOnly: true },
160
+ ];
161
+ })();
162
+
163
+ return (
164
+ <CommandMenu
165
+ open={open}
166
+ onOpenChange={onOpenChange}
167
+ groups={groups}
168
+ placeholder={t.commandMenu.slidePlaceholder}
169
+ />
170
+ );
171
+ }
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Tooltip, TooltipContent, TooltipProvider } from '@/components/ui/tooltip';
3
+
4
+ /**
5
+ * Shared hover label for the toolbar icon buttons. `children` supplies the
6
+ * `TooltipTrigger`; a button that also opens a menu has to compose it inward
7
+ * (`<DropdownMenuTrigger render={<TooltipTrigger />}>`) — the other nesting
8
+ * order swallows the trigger ref and the tooltip never opens.
9
+ */
10
+ export function IconTooltip({
11
+ label,
12
+ shortcut,
13
+ children,
14
+ }: {
15
+ label: string;
16
+ shortcut?: string;
17
+ children: ReactNode;
18
+ }) {
19
+ return (
20
+ <TooltipProvider delay={200}>
21
+ <Tooltip>
22
+ {children}
23
+ <TooltipContent side="bottom" sideOffset={6} className="flex items-center gap-1.5">
24
+ {label}
25
+ {shortcut && (
26
+ <kbd className="rounded-[3px] bg-background/18 px-1 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-background/85">
27
+ {shortcut}
28
+ </kbd>
29
+ )}
30
+ </TooltipContent>
31
+ </Tooltip>
32
+ </TooltipProvider>
33
+ );
34
+ }
@@ -1,4 +1,5 @@
1
1
  import { Languages } from 'lucide-react';
2
+ import { IconTooltip } from '@/components/icon-tooltip';
2
3
  import { buttonVariants } from '@/components/ui/button';
3
4
  import {
4
5
  DropdownMenu,
@@ -6,6 +7,7 @@ import {
6
7
  DropdownMenuItem,
7
8
  DropdownMenuTrigger,
8
9
  } from '@/components/ui/dropdown-menu';
10
+ import { TooltipTrigger } from '@/components/ui/tooltip';
9
11
  import { LOCALE_OPTIONS, setLocale } from '@/lib/locale-store';
10
12
  import { useLocale } from '@/lib/use-locale';
11
13
  import { cn } from '@/lib/utils';
@@ -15,14 +17,19 @@ export function LanguageToggle() {
15
17
 
16
18
  return (
17
19
  <DropdownMenu>
18
- <DropdownMenuTrigger
19
- type="button"
20
- aria-label={t.languageToggle.toggleAria}
21
- title={t.languageToggle.title}
22
- className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }))}
23
- >
24
- <Languages className="size-3.5" />
25
- </DropdownMenuTrigger>
20
+ <IconTooltip label={t.languageToggle.title}>
21
+ <DropdownMenuTrigger
22
+ render={
23
+ <TooltipTrigger
24
+ type="button"
25
+ aria-label={t.languageToggle.toggleAria}
26
+ className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }))}
27
+ />
28
+ }
29
+ >
30
+ <Languages className="size-3.5" />
31
+ </DropdownMenuTrigger>
32
+ </IconTooltip>
26
33
  <DropdownMenuContent align="end" className="min-w-[140px]">
27
34
  {LOCALE_OPTIONS.map((option) => (
28
35
  <DropdownMenuItem
@@ -5,26 +5,19 @@ import { toast } from 'sonner';
5
5
  import { Button } from '@/components/ui/button';
6
6
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
7
7
  import { format, useLocale } from '@/lib/use-locale';
8
+ import { useRestartServer } from '@/lib/use-restart-server';
8
9
 
9
10
  type UpdateCheck = { current: string; latest: string | null; outdated: boolean };
10
- type ServerStatus = { executionId: string; canRestart: boolean };
11
11
  type UpdateStatus = 'idle' | 'running' | 'done' | 'error';
12
12
 
13
13
  const buttonClassName =
14
14
  'h-6 w-fit rounded-[5px] border border-background/15 bg-background/8 px-2 text-[11px] text-background shadow-none hover:bg-background/14';
15
15
 
16
- async function fetchServerStatus(): Promise<ServerStatus | null> {
17
- const res = await fetch('/__server-status');
18
- if (!res.ok) return null;
19
- return (await res.json()) as ServerStatus;
20
- }
21
-
22
16
  export function SidebarFooter() {
23
17
  const t = useLocale();
24
18
  const [update, setUpdate] = useState<UpdateCheck | null>(null);
25
19
  const [updateStatus, setUpdateStatus] = useState<UpdateStatus>('idle');
26
- const [canRestart, setCanRestart] = useState(false);
27
- const [restarting, setRestarting] = useState(false);
20
+ const { canRestart, restarting, restartServer } = useRestartServer();
28
21
  const [open, setOpen] = useState(false);
29
22
 
30
23
  useEffect(() => {
@@ -36,11 +29,6 @@ export function SidebarFooter() {
36
29
  if (!cancelled && data?.outdated) setUpdate(data);
37
30
  })
38
31
  .catch(() => {});
39
- fetchServerStatus()
40
- .then((status) => {
41
- if (!cancelled && status) setCanRestart(status.canRestart);
42
- })
43
- .catch(() => {});
44
32
  return () => {
45
33
  cancelled = true;
46
34
  };
@@ -65,29 +53,6 @@ export function SidebarFooter() {
65
53
  }
66
54
  }
67
55
 
68
- async function restartServer() {
69
- if (restarting) return;
70
- setRestarting(true);
71
- try {
72
- const before = await fetchServerStatus();
73
- if (!before) throw new Error('server status unavailable');
74
- const res = await fetch('/__restart-server', { method: 'POST' });
75
- if (!res.ok) throw new Error('restart failed');
76
- for (let attempt = 0; attempt < 30; attempt++) {
77
- await new Promise((resolve) => setTimeout(resolve, 500));
78
- const status = await fetchServerStatus().catch(() => null);
79
- if (status && status.executionId !== before.executionId) {
80
- window.location.reload();
81
- return;
82
- }
83
- }
84
- throw new Error('restart timed out');
85
- } catch {
86
- setRestarting(false);
87
- toast.error(t.home.restartServerFailed);
88
- }
89
- }
90
-
91
56
  const versionRow = (
92
57
  <span className="inline-flex cursor-default items-center gap-1.5">
93
58
  {update?.latest && <span className="size-1.5 rounded-full bg-brand" aria-hidden />}
@@ -7,6 +7,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover
7
7
  import type { Folder, FolderIcon } from '@/lib/sdk';
8
8
  import { format, useLocale } from '@/lib/use-locale';
9
9
  import { cn } from '@/lib/utils';
10
+ import { CommandMenuTrigger } from '../command/command-menu';
10
11
  import { FolderIconChip, FolderItem } from './folder-item';
11
12
  import { IconPicker, PRESET_COLORS } from './icon-picker';
12
13
  import { SidebarFooter } from './sidebar-footer';
@@ -33,6 +34,7 @@ export function Sidebar({
33
34
  onDropToFolder,
34
35
  onDropToDraft,
35
36
  onReorder,
37
+ onOpenCommandMenu,
36
38
  }: {
37
39
  folders: Folder[];
38
40
  countFor: (folderId: string | null) => number;
@@ -48,6 +50,7 @@ export function Sidebar({
48
50
  onDropToFolder: (folderId: string, slideId: string) => void;
49
51
  onDropToDraft: (slideId: string) => void;
50
52
  onReorder: (ids: string[]) => void;
53
+ onOpenCommandMenu: () => void;
51
54
  }) {
52
55
  const [dragId, setDragId] = useState<string | null>(null);
53
56
  const [dropTarget, setDropTarget] = useState<{ id: string; before: boolean } | null>(null);
@@ -130,6 +133,7 @@ export function Sidebar({
130
133
  <div className="flex items-center justify-between px-4 pt-5 pb-4">
131
134
  <h1 className="font-heading text-lg font-bold tracking-tight">{t.home.appTitle}</h1>
132
135
  <div className="-mr-1.5 flex items-center">
136
+ <CommandMenuTrigger onClick={onOpenCommandMenu} />
133
137
  <LanguageToggle />
134
138
  <ThemeToggle />
135
139
  </div>
@@ -1,6 +1,7 @@
1
1
  import { Monitor, Moon, Sun } from 'lucide-react';
2
2
  import { useTheme } from 'next-themes';
3
3
  import { useEffect, useState } from 'react';
4
+ import { IconTooltip } from '@/components/icon-tooltip';
4
5
  import { buttonVariants } from '@/components/ui/button';
5
6
  import {
6
7
  DropdownMenu,
@@ -8,6 +9,7 @@ import {
8
9
  DropdownMenuItem,
9
10
  DropdownMenuTrigger,
10
11
  } from '@/components/ui/dropdown-menu';
12
+ import { TooltipTrigger } from '@/components/ui/tooltip';
11
13
  import { useLocale } from '@/lib/use-locale';
12
14
  import { cn } from '@/lib/utils';
13
15
 
@@ -22,15 +24,20 @@ export function ThemeToggle() {
22
24
 
23
25
  return (
24
26
  <DropdownMenu>
25
- <DropdownMenuTrigger
26
- type="button"
27
- aria-label={t.themeToggle.toggleAria}
28
- title={t.themeToggle.title}
29
- className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }), 'relative')}
30
- >
31
- <Sun className="size-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
32
- <Moon className="absolute size-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
33
- </DropdownMenuTrigger>
27
+ <IconTooltip label={t.themeToggle.title}>
28
+ <DropdownMenuTrigger
29
+ render={
30
+ <TooltipTrigger
31
+ type="button"
32
+ aria-label={t.themeToggle.toggleAria}
33
+ className={cn(buttonVariants({ variant: 'ghost', size: 'icon-sm' }), 'relative')}
34
+ />
35
+ }
36
+ >
37
+ <Sun className="size-3.5 scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
38
+ <Moon className="absolute size-3.5 scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
39
+ </DropdownMenuTrigger>
40
+ </IconTooltip>
34
41
  <DropdownMenuContent align="end" className="min-w-[140px]">
35
42
  <DropdownMenuItem
36
43
  onClick={() => setTheme('light')}
@@ -0,0 +1,78 @@
1
+ import { useCallback, useEffect, useSyncExternalStore } from 'react';
2
+ import { toast } from 'sonner';
3
+ import { useLocale } from '@/lib/use-locale';
4
+
5
+ type ServerStatus = { executionId: string; canRestart: boolean };
6
+
7
+ async function fetchServerStatus(): Promise<ServerStatus | null> {
8
+ const res = await fetch('/__server-status');
9
+ if (!res.ok) return null;
10
+ return (await res.json()) as ServerStatus;
11
+ }
12
+
13
+ // Module scope, not per-hook state: the sidebar footer and the command menu can
14
+ // both be mounted, and each firing its own POST plus polling loop would race.
15
+ let state = { canRestart: false, restarting: false };
16
+ let statusProbed = false;
17
+ let inFlight: Promise<boolean> | null = null;
18
+ const listeners = new Set<() => void>();
19
+
20
+ function setState(next: Partial<typeof state>): void {
21
+ state = { ...state, ...next };
22
+ for (const listener of listeners) listener();
23
+ }
24
+
25
+ function subscribe(listener: () => void): () => void {
26
+ listeners.add(listener);
27
+ return () => {
28
+ listeners.delete(listener);
29
+ };
30
+ }
31
+
32
+ function getSnapshot(): typeof state {
33
+ return state;
34
+ }
35
+
36
+ async function performRestart(): Promise<boolean> {
37
+ const before = await fetchServerStatus();
38
+ if (!before) return false;
39
+ const res = await fetch('/__restart-server', { method: 'POST' });
40
+ if (!res.ok) return false;
41
+ // A different executionId means the replacement process is serving.
42
+ for (let attempt = 0; attempt < 30; attempt++) {
43
+ await new Promise((resolve) => setTimeout(resolve, 500));
44
+ const status = await fetchServerStatus().catch(() => null);
45
+ if (status && status.executionId !== before.executionId) {
46
+ window.location.reload();
47
+ return true;
48
+ }
49
+ }
50
+ return false;
51
+ }
52
+
53
+ export function useRestartServer() {
54
+ const t = useLocale();
55
+ const { canRestart, restarting } = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
56
+
57
+ useEffect(() => {
58
+ if (!import.meta.env.DEV || statusProbed) return;
59
+ statusProbed = true;
60
+ fetchServerStatus()
61
+ .then((status) => {
62
+ if (status) setState({ canRestart: status.canRestart });
63
+ })
64
+ .catch(() => {});
65
+ }, []);
66
+
67
+ const restartServer = useCallback(async () => {
68
+ if (inFlight) return;
69
+ inFlight = performRestart().catch(() => false);
70
+ setState({ restarting: true });
71
+ const restarted = await inFlight;
72
+ inFlight = null;
73
+ setState({ restarting: false });
74
+ if (!restarted) toast.error(t.home.restartServerFailed);
75
+ }, [t.home.restartServerFailed]);
76
+
77
+ return { canRestart, restarting, restartServer };
78
+ }
@@ -0,0 +1,29 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { loadSlide, slideIds } from './slides';
3
+
4
+ /**
5
+ * Resolves every deck's display title once `enabled` first turns true. The home
6
+ * grid only mounts the cards of the selected folder, so cross-folder search
7
+ * needs its own pass over the slide modules — kept lazy since it imports them all.
8
+ */
9
+ export function useSlideTitles(enabled: boolean): Record<string, string> {
10
+ const [titles, setTitles] = useState<Record<string, string>>({});
11
+ const startedRef = useRef(false);
12
+
13
+ useEffect(() => {
14
+ if (!enabled || startedRef.current) return;
15
+ startedRef.current = true;
16
+ void Promise.all(
17
+ slideIds.map(async (id): Promise<[string, string]> => {
18
+ try {
19
+ const mod = await loadSlide(id);
20
+ return [id, mod.meta?.title ?? id];
21
+ } catch {
22
+ return [id, id];
23
+ }
24
+ }),
25
+ ).then((entries) => setTitles(Object.fromEntries(entries)));
26
+ }, [enabled]);
27
+
28
+ return titles;
29
+ }
@@ -14,6 +14,8 @@ import { useAssets } from '@/lib/assets';
14
14
  import { useFolders } from '@/lib/folders';
15
15
  import { format, useLocale } from '@/lib/use-locale';
16
16
  import { cn } from '@/lib/utils';
17
+ import { CommandMenuTrigger } from '../components/command/command-menu';
18
+ import { HomeCommandMenu } from '../components/command/home-command-menu';
17
19
  import { FolderIconChip } from '../components/sidebar/folder-item';
18
20
  import { ALL_SLIDES_ID, ASSETS_ID, Sidebar, THEMES_ID } from '../components/sidebar/sidebar';
19
21
  import type { FoldersManifest } from '../lib/sdk';
@@ -62,6 +64,9 @@ export function HomeShell() {
62
64
 
63
65
  const selectedId = pathToSelectedId(location.pathname, searchParams);
64
66
 
67
+ const [commandOpen, setCommandOpen] = useState(false);
68
+ const openCommandMenu = useCallback(() => setCommandOpen(true), []);
69
+
65
70
  const [titleMap, setTitleMap] = useState<Record<string, string>>({});
66
71
  const reportTitle = useCallback((slideId: string, slideTitle: string) => {
67
72
  setTitleMap((prev) =>
@@ -158,6 +163,7 @@ export function HomeShell() {
158
163
  toast.error(t.home.toastFolderDeleteFailed);
159
164
  }
160
165
  }}
166
+ onOpenCommandMenu={openCommandMenu}
161
167
  onDropToFolder={(folderId, slideId) => moveSlideWithToast(slideId, folderId)}
162
168
  onDropToDraft={(slideId) => moveSlideWithToast(slideId, null)}
163
169
  onReorder={async (ids) => {
@@ -174,6 +180,7 @@ export function HomeShell() {
174
180
  <div className="flex items-center justify-between border-b border-hairline bg-sidebar px-4 py-3 md:hidden">
175
181
  <h1 className="font-heading text-lg font-bold tracking-tight">{t.home.appTitle}</h1>
176
182
  <div className="-mr-1.5 flex items-center gap-0.5">
183
+ <CommandMenuTrigger onClick={openCommandMenu} />
177
184
  <LanguageToggle />
178
185
  <ThemeToggle />
179
186
  <DropdownMenu>
@@ -234,6 +241,14 @@ export function HomeShell() {
234
241
  <Outlet context={ctx} />
235
242
  </div>
236
243
  </div>
244
+
245
+ <HomeCommandMenu
246
+ open={commandOpen}
247
+ onOpenChange={setCommandOpen}
248
+ folders={manifest.folders}
249
+ titleMap={titleMap}
250
+ onSelectView={selectFolder}
251
+ />
237
252
  </div>
238
253
  );
239
254
  }