@open-slide/core 1.17.1 → 1.19.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.
- package/dist/{build-DaL4Gjn-.js → build-CaV_vhIw.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-DIvIP8vY.d.ts → config-CDHB8Oow.d.ts} +2 -1
- package/dist/{config-CCHio3pk.js → config-GA6NMgs_.js} +1 -0
- package/dist/{dev-DLRQoCkT.js → dev-D57ui2yV.js} +1 -1
- package/dist/{format-CxmsgcBh.js → format-74A3B6zu.js} +120 -4
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-D3qVGc0S.js → preview-D40Zw_o0.js} +1 -1
- package/dist/{types-Di7nvL8V.d.ts → types-8HghULIe.d.ts} +32 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +6 -3
- package/src/app/components/command/command-menu.tsx +227 -0
- package/src/app/components/command/command.tsx +142 -0
- package/src/app/components/command/home-command-menu.tsx +96 -0
- package/src/app/components/command/slide-command-menu.tsx +171 -0
- package/src/app/components/icon-tooltip.tsx +34 -0
- package/src/app/components/language-toggle.tsx +15 -8
- package/src/app/components/player.tsx +8 -1
- package/src/app/components/present/use-presenter-channel.ts +2 -1
- package/src/app/components/sidebar/sidebar-footer.tsx +2 -37
- package/src/app/components/sidebar/sidebar.tsx +4 -0
- package/src/app/components/theme-toggle.tsx +16 -9
- package/src/app/lib/export-html.ts +15 -2
- package/src/app/lib/use-restart-server.ts +78 -0
- package/src/app/lib/use-slide-titles.ts +29 -0
- package/src/app/routes/home-shell.tsx +15 -0
- package/src/app/routes/presenter.tsx +214 -8
- package/src/app/routes/slide.tsx +92 -17
- package/src/locale/en.ts +30 -0
- package/src/locale/ja.ts +30 -0
- package/src/locale/types.ts +33 -0
- package/src/locale/zh-cn.ts +30 -0
- package/src/locale/zh-tw.ts +30 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Command as CommandPrimitive } from 'cmdk';
|
|
2
|
+
import { Search } from 'lucide-react';
|
|
3
|
+
import type * as React from 'react';
|
|
4
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle } from '@/components/ui/dialog';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
|
|
7
|
+
function Command({ className, ...props }: React.ComponentProps<typeof CommandPrimitive>) {
|
|
8
|
+
return (
|
|
9
|
+
<CommandPrimitive
|
|
10
|
+
data-slot="command"
|
|
11
|
+
className={cn('flex h-full w-full flex-col overflow-hidden', className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CommandDialog({
|
|
18
|
+
open,
|
|
19
|
+
onOpenChange,
|
|
20
|
+
title,
|
|
21
|
+
description,
|
|
22
|
+
children,
|
|
23
|
+
}: {
|
|
24
|
+
open: boolean;
|
|
25
|
+
onOpenChange: (open: boolean) => void;
|
|
26
|
+
title: string;
|
|
27
|
+
description: string;
|
|
28
|
+
children: React.ReactNode;
|
|
29
|
+
}) {
|
|
30
|
+
return (
|
|
31
|
+
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
32
|
+
<DialogContent
|
|
33
|
+
showCloseButton={false}
|
|
34
|
+
className="top-[14vh] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-[560px]"
|
|
35
|
+
>
|
|
36
|
+
<DialogTitle className="sr-only">{title}</DialogTitle>
|
|
37
|
+
<DialogDescription className="sr-only">{description}</DialogDescription>
|
|
38
|
+
{children}
|
|
39
|
+
</DialogContent>
|
|
40
|
+
</Dialog>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function CommandInput({
|
|
45
|
+
className,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<typeof CommandPrimitive.Input>) {
|
|
48
|
+
return (
|
|
49
|
+
<div className="flex items-center gap-2 border-b border-hairline px-3">
|
|
50
|
+
<Search className="size-3.5 shrink-0 text-muted-foreground" aria-hidden />
|
|
51
|
+
<CommandPrimitive.Input
|
|
52
|
+
data-slot="command-input"
|
|
53
|
+
className={cn(
|
|
54
|
+
'h-11 w-full bg-transparent text-[13px] outline-none placeholder:text-muted-foreground/70 disabled:opacity-50',
|
|
55
|
+
className,
|
|
56
|
+
)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function CommandList({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.List>) {
|
|
64
|
+
return (
|
|
65
|
+
<CommandPrimitive.List
|
|
66
|
+
data-slot="command-list"
|
|
67
|
+
className={cn(
|
|
68
|
+
'max-h-[min(56vh,380px)] scroll-py-1 overflow-y-auto overscroll-contain p-1',
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function CommandEmpty({ ...props }: React.ComponentProps<typeof CommandPrimitive.Empty>) {
|
|
77
|
+
return (
|
|
78
|
+
<CommandPrimitive.Empty
|
|
79
|
+
data-slot="command-empty"
|
|
80
|
+
className="px-3 py-10 text-center text-[12.5px] text-muted-foreground"
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function CommandGroup({
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: React.ComponentProps<typeof CommandPrimitive.Group>) {
|
|
90
|
+
return (
|
|
91
|
+
<CommandPrimitive.Group
|
|
92
|
+
data-slot="command-group"
|
|
93
|
+
className={cn(
|
|
94
|
+
'overflow-hidden pt-1.5 pb-1 [&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-hairline',
|
|
95
|
+
'[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pt-1 [&_[cmdk-group-heading]]:pb-1.5',
|
|
96
|
+
'[&_[cmdk-group-heading]]:text-[10px] [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:tracking-[0.08em] [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:text-muted-foreground/70',
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function CommandItem({ className, ...props }: React.ComponentProps<typeof CommandPrimitive.Item>) {
|
|
105
|
+
return (
|
|
106
|
+
<CommandPrimitive.Item
|
|
107
|
+
data-slot="command-item"
|
|
108
|
+
className={cn(
|
|
109
|
+
'relative flex cursor-default select-none items-center gap-2 rounded-[5px] px-2 py-1.5 text-[12.5px] outline-none',
|
|
110
|
+
'data-[selected=true]:bg-muted data-[selected=true]:text-foreground',
|
|
111
|
+
'data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-45',
|
|
112
|
+
"[&_svg]:size-3.5 [&_svg]:shrink-0 [&_svg]:text-muted-foreground [&_svg:not([class*='opacity'])]:opacity-80",
|
|
113
|
+
className,
|
|
114
|
+
)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function CommandShortcut({ className, ...props }: React.ComponentProps<'kbd'>) {
|
|
121
|
+
return (
|
|
122
|
+
<kbd
|
|
123
|
+
data-slot="command-shortcut"
|
|
124
|
+
className={cn(
|
|
125
|
+
'ml-auto shrink-0 rounded-[3px] bg-muted px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.04em] text-muted-foreground',
|
|
126
|
+
className,
|
|
127
|
+
)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
Command,
|
|
135
|
+
CommandDialog,
|
|
136
|
+
CommandEmpty,
|
|
137
|
+
CommandGroup,
|
|
138
|
+
CommandInput,
|
|
139
|
+
CommandItem,
|
|
140
|
+
CommandList,
|
|
141
|
+
CommandShortcut,
|
|
142
|
+
};
|
|
@@ -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
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
@@ -40,6 +40,7 @@ type Props = {
|
|
|
40
40
|
allowExit?: boolean;
|
|
41
41
|
controls?: boolean;
|
|
42
42
|
slideId?: string;
|
|
43
|
+
onSwitchSlide?: (slideId: string) => void;
|
|
43
44
|
/**
|
|
44
45
|
* When true, the Player enters the browser Fullscreen API on mount.
|
|
45
46
|
* When false, it renders as a window-sized overlay (viewport-filling)
|
|
@@ -58,6 +59,7 @@ export function Player({
|
|
|
58
59
|
allowExit = true,
|
|
59
60
|
controls = false,
|
|
60
61
|
slideId,
|
|
62
|
+
onSwitchSlide,
|
|
61
63
|
fullscreen = true,
|
|
62
64
|
}: Props) {
|
|
63
65
|
const isMobile = useIsMobile();
|
|
@@ -250,9 +252,11 @@ export function Player({
|
|
|
250
252
|
setBlackout((cur) => (cur === msg.mode ? null : msg.mode));
|
|
251
253
|
} else if (msg.type === 'request-state') {
|
|
252
254
|
send({ type: 'state', state: presenterStateRef.current });
|
|
255
|
+
} else if (msg.type === 'switch-slide') {
|
|
256
|
+
if (msg.slideId !== slideId) onSwitchSlide?.(msg.slideId);
|
|
253
257
|
}
|
|
254
258
|
},
|
|
255
|
-
[goNext, goPrev, handleIndexChange, pages.length],
|
|
259
|
+
[goNext, goPrev, handleIndexChange, pages.length, slideId, onSwitchSlide],
|
|
256
260
|
);
|
|
257
261
|
|
|
258
262
|
const channel = usePresenterChannel(slideId ?? '__none__', (msg) => {
|
|
@@ -402,7 +406,10 @@ export function Player({
|
|
|
402
406
|
style={design ? { background: design.palette.bg } : undefined}
|
|
403
407
|
>
|
|
404
408
|
<SlideCanvas flat design={design}>
|
|
409
|
+
{/* Keyed per deck so a presenter-driven deck switch cuts instead of
|
|
410
|
+
animating a transition between two unrelated decks. */}
|
|
405
411
|
<SlideTransitionLayer
|
|
412
|
+
key={slideId}
|
|
406
413
|
pages={pages}
|
|
407
414
|
index={index}
|
|
408
415
|
total={pages.length}
|
|
@@ -16,7 +16,8 @@ export type PresenterCommand =
|
|
|
16
16
|
| { type: 'prev' }
|
|
17
17
|
| { type: 'request-state' }
|
|
18
18
|
| { type: 'restart-timer' }
|
|
19
|
-
| { type: 'toggle-blackout'; mode: 'black' | 'white' }
|
|
19
|
+
| { type: 'toggle-blackout'; mode: 'black' | 'white' }
|
|
20
|
+
| { type: 'switch-slide'; slideId: string };
|
|
20
21
|
|
|
21
22
|
type Handler = (msg: PresenterCommand) => void;
|
|
22
23
|
|
|
@@ -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
|
|
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
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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')}
|