@open-slide/core 1.11.1 → 1.12.1
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-CtmQSpg-.js → build-L2yL1hTo.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-Bk2i4eJ1.js → config-OT4T-im0.js} +123 -4
- package/dist/{config-14qk4fP8.d.ts → config-x493taft.d.ts} +1 -1
- package/dist/{dev-DplvRqZx.js → dev-DJUpPCGT.js} +1 -1
- package/dist/{format-BvBmqbNW.js → format-7j0EzhuV.js} +28 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-p4gcc8ip.js → preview-Bf8up6-P.js} +1 -1
- package/dist/{types-D_q_ylIe.d.ts → types-CHmFPIG_.d.ts} +6 -0
- package/dist/vite/index.d.ts +2 -2
- package/dist/vite/index.js +1 -1
- package/package.json +5 -5
- package/skills/slide-authoring/SKILL.md +20 -0
- package/src/app/components/inspector/inspector-panel.tsx +5 -1
- package/src/app/components/overview-grid.tsx +363 -0
- package/src/app/components/player.tsx +5 -2
- package/src/app/components/sidebar/sidebar-footer.tsx +57 -3
- package/src/app/components/slide-canvas.tsx +1 -0
- package/src/app/components/thumbnail-rail.tsx +37 -7
- package/src/app/lib/export-html.ts +1 -1
- package/src/app/lib/print-ready.test.ts +32 -0
- package/src/app/lib/print-ready.ts +4 -7
- package/src/app/routes/slide.tsx +198 -144
- package/src/locale/en.ts +6 -0
- package/src/locale/ja.ts +6 -0
- package/src/locale/types.ts +6 -0
- package/src/locale/zh-cn.ts +6 -0
- package/src/locale/zh-tw.ts +6 -0
- package/src/app/components/present/overview-grid.tsx +0 -177
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from 'react';
|
|
2
|
-
import { format, useLocale } from '@/lib/use-locale';
|
|
3
|
-
import { cn } from '@/lib/utils';
|
|
4
|
-
import type { DesignSystem } from '../../lib/design';
|
|
5
|
-
import { SlidePageProvider } from '../../lib/page-context';
|
|
6
|
-
import type { Page } from '../../lib/sdk';
|
|
7
|
-
import { CANVAS_HEIGHT, CANVAS_WIDTH } from '../../lib/sdk';
|
|
8
|
-
import { SlideCanvas } from '../slide-canvas';
|
|
9
|
-
|
|
10
|
-
const THUMB_W = 320;
|
|
11
|
-
const THUMB_H = (THUMB_W * CANVAS_HEIGHT) / CANVAS_WIDTH;
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
pages: Page[];
|
|
15
|
-
design?: DesignSystem;
|
|
16
|
-
open: boolean;
|
|
17
|
-
current: number;
|
|
18
|
-
onClose: () => void;
|
|
19
|
-
onSelect: (index: number) => void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function PresentOverviewGrid({ pages, design, open, current, onClose, onSelect }: Props) {
|
|
23
|
-
const [focused, setFocused] = useState(current);
|
|
24
|
-
const gridRef = useRef<HTMLDivElement>(null);
|
|
25
|
-
const focusedRef = useRef<HTMLButtonElement | null>(null);
|
|
26
|
-
const t = useLocale();
|
|
27
|
-
|
|
28
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: only re-sync on open transition
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (open) setFocused(current);
|
|
31
|
-
}, [open]);
|
|
32
|
-
|
|
33
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: `focused` swaps which button holds the ref; we must re-run to focus the new node
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!open) return;
|
|
36
|
-
focusedRef.current?.focus();
|
|
37
|
-
focusedRef.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
38
|
-
}, [focused, open]);
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
if (!open) return;
|
|
42
|
-
const onKey = (e: KeyboardEvent) => {
|
|
43
|
-
if (e.target instanceof HTMLElement && e.target.matches('input, textarea')) return;
|
|
44
|
-
const cols = computeCols(gridRef.current);
|
|
45
|
-
if (e.key === 'ArrowRight') {
|
|
46
|
-
e.preventDefault();
|
|
47
|
-
e.stopPropagation();
|
|
48
|
-
setFocused((i) => Math.min(pages.length - 1, i + 1));
|
|
49
|
-
} else if (e.key === 'ArrowLeft') {
|
|
50
|
-
e.preventDefault();
|
|
51
|
-
e.stopPropagation();
|
|
52
|
-
setFocused((i) => Math.max(0, i - 1));
|
|
53
|
-
} else if (e.key === 'ArrowDown') {
|
|
54
|
-
e.preventDefault();
|
|
55
|
-
e.stopPropagation();
|
|
56
|
-
setFocused((i) => Math.min(pages.length - 1, i + cols));
|
|
57
|
-
} else if (e.key === 'ArrowUp') {
|
|
58
|
-
e.preventDefault();
|
|
59
|
-
e.stopPropagation();
|
|
60
|
-
setFocused((i) => Math.max(0, i - cols));
|
|
61
|
-
} else if (e.key === 'Home') {
|
|
62
|
-
e.preventDefault();
|
|
63
|
-
e.stopPropagation();
|
|
64
|
-
setFocused(0);
|
|
65
|
-
} else if (e.key === 'End') {
|
|
66
|
-
e.preventDefault();
|
|
67
|
-
e.stopPropagation();
|
|
68
|
-
setFocused(pages.length - 1);
|
|
69
|
-
} else if (e.key === 'Enter') {
|
|
70
|
-
e.preventDefault();
|
|
71
|
-
e.stopPropagation();
|
|
72
|
-
onSelect(focused);
|
|
73
|
-
onClose();
|
|
74
|
-
} else if (e.key === 'Escape') {
|
|
75
|
-
e.preventDefault();
|
|
76
|
-
e.stopPropagation();
|
|
77
|
-
onClose();
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
window.addEventListener('keydown', onKey, true);
|
|
81
|
-
return () => window.removeEventListener('keydown', onKey, true);
|
|
82
|
-
}, [open, pages.length, focused, onClose, onSelect]);
|
|
83
|
-
|
|
84
|
-
if (!open) return null;
|
|
85
|
-
return (
|
|
86
|
-
<div
|
|
87
|
-
role="dialog"
|
|
88
|
-
aria-modal="true"
|
|
89
|
-
aria-label={t.present.overviewDialogAria}
|
|
90
|
-
className="absolute inset-0 z-50 flex flex-col bg-black/95 backdrop-blur-sm"
|
|
91
|
-
>
|
|
92
|
-
<div className="flex shrink-0 items-baseline justify-between px-8 pt-6 pb-3">
|
|
93
|
-
<span className="eyebrow text-white/55">{t.present.overviewEyebrow}</span>
|
|
94
|
-
<span className="font-mono text-[11px] text-white/55 tabular-nums">
|
|
95
|
-
{(focused + 1).toString().padStart(2, '0')} · {pages.length.toString().padStart(2, '0')}
|
|
96
|
-
</span>
|
|
97
|
-
</div>
|
|
98
|
-
<div ref={gridRef} className="min-h-0 flex-1 overflow-auto px-8 pb-8">
|
|
99
|
-
<div
|
|
100
|
-
className="grid justify-center gap-5"
|
|
101
|
-
style={{
|
|
102
|
-
gridTemplateColumns: `repeat(auto-fill, ${THUMB_W}px)`,
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
{pages.map((PageComp, i) => {
|
|
106
|
-
const isFocused = i === focused;
|
|
107
|
-
const isCurrent = i === current;
|
|
108
|
-
return (
|
|
109
|
-
<button
|
|
110
|
-
// biome-ignore lint/suspicious/noArrayIndexKey: pages list is render-stable
|
|
111
|
-
key={i}
|
|
112
|
-
ref={isFocused ? focusedRef : undefined}
|
|
113
|
-
type="button"
|
|
114
|
-
onClick={() => {
|
|
115
|
-
onSelect(i);
|
|
116
|
-
onClose();
|
|
117
|
-
}}
|
|
118
|
-
onMouseEnter={() => setFocused(i)}
|
|
119
|
-
aria-label={format(t.present.overviewGoToAria, { n: i + 1 })}
|
|
120
|
-
aria-current={isCurrent ? 'true' : undefined}
|
|
121
|
-
className={cn(
|
|
122
|
-
'group/thumb flex flex-col items-start gap-2 rounded-[6px] p-1.5 outline-none transition-colors',
|
|
123
|
-
isFocused ? 'bg-white/10' : 'hover:bg-white/5',
|
|
124
|
-
)}
|
|
125
|
-
>
|
|
126
|
-
<div
|
|
127
|
-
className={cn(
|
|
128
|
-
'relative w-full overflow-hidden rounded-[4px] bg-black ring-1 ring-white/10 transition-shadow',
|
|
129
|
-
isFocused && 'ring-2 ring-[var(--brand,#ef4444)]',
|
|
130
|
-
)}
|
|
131
|
-
style={{ height: THUMB_H }}
|
|
132
|
-
>
|
|
133
|
-
<SlideCanvas
|
|
134
|
-
scale={THUMB_W / CANVAS_WIDTH}
|
|
135
|
-
center={false}
|
|
136
|
-
flat
|
|
137
|
-
freezeMotion
|
|
138
|
-
design={design}
|
|
139
|
-
>
|
|
140
|
-
<SlidePageProvider index={i} total={pages.length}>
|
|
141
|
-
<PageComp />
|
|
142
|
-
</SlidePageProvider>
|
|
143
|
-
</SlideCanvas>
|
|
144
|
-
{isCurrent && (
|
|
145
|
-
<span
|
|
146
|
-
aria-hidden
|
|
147
|
-
className="pointer-events-none absolute top-1.5 right-1.5 rounded-[3px] bg-[var(--brand,#ef4444)] px-1.5 py-0.5 font-mono text-[9.5px] tracking-[0.06em] uppercase text-white"
|
|
148
|
-
>
|
|
149
|
-
{t.present.nowBadge}
|
|
150
|
-
</span>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
<span
|
|
154
|
-
className={cn(
|
|
155
|
-
'font-mono text-[10.5px] tracking-[0.08em] tabular-nums uppercase',
|
|
156
|
-
isFocused || isCurrent ? 'text-white/85' : 'text-white/45',
|
|
157
|
-
)}
|
|
158
|
-
>
|
|
159
|
-
{(i + 1).toString().padStart(2, '0')}
|
|
160
|
-
</span>
|
|
161
|
-
</button>
|
|
162
|
-
);
|
|
163
|
-
})}
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function computeCols(grid: HTMLDivElement | null) {
|
|
171
|
-
if (!grid) return 4;
|
|
172
|
-
const inner = grid.firstElementChild as HTMLElement | null;
|
|
173
|
-
if (!inner) return 4;
|
|
174
|
-
const cs = getComputedStyle(inner);
|
|
175
|
-
const cols = cs.gridTemplateColumns.split(' ').filter(Boolean).length;
|
|
176
|
-
return Math.max(1, cols);
|
|
177
|
-
}
|