@open-slide/core 2.0.0 → 2.1.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-Cu5_qRyE.js → build-COxfoC_P.js} +1 -1
- package/dist/cli/bin.js +105 -15
- package/dist/{config-BQ6rD2iE.js → config-CNhYSo4C.js} +79 -896
- package/dist/{config-GMR1QUlM.d.ts → config-DHPbCCnt.d.ts} +1 -1
- package/dist/{dev-BK641O5e.js → dev-CujpTS3T.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -3
- package/dist/locale/index.d.ts +5 -2
- package/dist/locale/index.js +2 -2
- package/dist/{preview-BuCI-RMW.js → preview-kU5R6QXJ.js} +1 -1
- package/dist/{types-BcbaKTNY.d.ts → types-BGUi9COY.d.ts} +1 -1
- package/dist/update-CPBitJQq.js +905 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DlZoAc2-.js → zh-tw-BbFb4PZW.js} +519 -1
- package/package.json +4 -4
- package/skills/apply-comments/SKILL.md +1 -0
- package/skills/create-slide/SKILL.md +2 -0
- package/skills/current-slide/SKILL.md +1 -0
- package/skills/slide-authoring/SKILL.md +31 -1
- package/src/app/app.tsx +2 -0
- package/src/app/assets/open-slide.svg +39 -0
- package/src/app/components/command/command-menu.tsx +1 -3
- package/src/app/components/history-provider.tsx +25 -3
- package/src/app/components/inspector/inspector-provider.tsx +179 -21
- package/src/app/components/panel/editor-sidebar.tsx +1 -1
- package/src/app/components/panel/save-card.tsx +6 -2
- package/src/app/components/preview-step-host.tsx +16 -0
- package/src/app/components/sidebar/sidebar.tsx +2 -2
- package/src/app/components/slide-transition-layer.tsx +1 -1
- package/src/app/components/style-panel/style-panel.tsx +3 -2
- package/src/app/components/thumbnail-rail.tsx +37 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/favicon.svg +39 -0
- package/src/app/index.html +2 -1
- package/src/app/lib/keys.ts +3 -0
- package/src/app/lib/locale-store.ts +6 -1
- package/src/app/lib/print-ready.ts +9 -6
- package/src/app/routes/presenter.tsx +1 -16
- package/src/app/routes/preview.tsx +169 -0
- package/src/app/routes/slide.tsx +113 -65
- package/src/locale/es.ts +548 -0
- package/src/locale/index.ts +1 -0
- package/src/locale/types.ts +1 -1
- package/src/app/assets/open-slide.png +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="tile" x1="256" y1="16" x2="256" y2="496" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop offset="0" stop-color="#FFFFFF"/>
|
|
5
|
+
<stop offset="1" stop-color="#EFEBE6"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
<linearGradient id="tile-edge" x1="256" y1="16" x2="256" y2="496" gradientUnits="userSpaceOnUse">
|
|
8
|
+
<stop offset="0" stop-color="#FFFFFF"/>
|
|
9
|
+
<stop offset="0.5" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
10
|
+
<stop offset="1" stop-color="#000000" stop-opacity="0.08"/>
|
|
11
|
+
</linearGradient>
|
|
12
|
+
<linearGradient id="slide" x1="256" y1="172" x2="256" y2="340" gradientUnits="userSpaceOnUse">
|
|
13
|
+
<stop offset="0" stop-color="#FF8A5E"/>
|
|
14
|
+
<stop offset="0.45" stop-color="#FE5226"/>
|
|
15
|
+
<stop offset="1" stop-color="#EE4316"/>
|
|
16
|
+
</linearGradient>
|
|
17
|
+
<linearGradient id="slide-edge" x1="256" y1="172" x2="256" y2="340" gradientUnits="userSpaceOnUse">
|
|
18
|
+
<stop offset="0" stop-color="#FFFFFF" stop-opacity="0.55"/>
|
|
19
|
+
<stop offset="0.35" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
20
|
+
<stop offset="0.8" stop-color="#B8300C" stop-opacity="0"/>
|
|
21
|
+
<stop offset="1" stop-color="#B8300C" stop-opacity="0.5"/>
|
|
22
|
+
</linearGradient>
|
|
23
|
+
<radialGradient id="slide-sheen" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(196 184) rotate(32) scale(200 110)">
|
|
24
|
+
<stop offset="0" stop-color="#FFFFFF" stop-opacity="0.26"/>
|
|
25
|
+
<stop offset="1" stop-color="#FFFFFF" stop-opacity="0"/>
|
|
26
|
+
</radialGradient>
|
|
27
|
+
<filter id="lift" x="60" y="140" width="392" height="260" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
|
|
28
|
+
<feDropShadow dx="0" dy="18" stdDeviation="16" flood-color="#FE5226" flood-opacity="0.32"/>
|
|
29
|
+
<feDropShadow dx="0" dy="3" stdDeviation="3" flood-color="#8A2306" flood-opacity="0.22"/>
|
|
30
|
+
</filter>
|
|
31
|
+
</defs>
|
|
32
|
+
<rect x="16" y="16" width="480" height="480" rx="112" fill="url(#tile)"/>
|
|
33
|
+
<rect x="17.5" y="17.5" width="477" height="477" rx="110.5" stroke="url(#tile-edge)" stroke-width="3"/>
|
|
34
|
+
<g filter="url(#lift)">
|
|
35
|
+
<rect x="112" y="172" width="288" height="168" rx="34" fill="url(#slide)"/>
|
|
36
|
+
</g>
|
|
37
|
+
<rect x="112" y="172" width="288" height="168" rx="34" fill="url(#slide-sheen)"/>
|
|
38
|
+
<rect x="113.5" y="173.5" width="285" height="165" rx="32.5" stroke="url(#slide-edge)" stroke-width="3"/>
|
|
39
|
+
</svg>
|
package/src/app/index.html
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" href="./favicon.ico" />
|
|
5
|
+
<link rel="icon" href="./favicon.ico" sizes="32x32" />
|
|
6
|
+
<link rel="icon" href="./favicon.svg" type="image/svg+xml" />
|
|
6
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
8
|
<title>open-slide</title>
|
|
8
9
|
<style>
|
package/src/app/lib/keys.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export const IS_APPLE =
|
|
2
|
+
typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
|
|
3
|
+
|
|
1
4
|
export function isTypingTarget(target: EventTarget | null): boolean {
|
|
2
5
|
return (
|
|
3
6
|
target instanceof HTMLElement && (target.isContentEditable || target.matches('input, textarea'))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import config from 'virtual:open-slide/config';
|
|
2
2
|
import { useSyncExternalStore } from 'react';
|
|
3
3
|
import { en } from '../../locale/en';
|
|
4
|
+
import { es } from '../../locale/es';
|
|
4
5
|
import { ja } from '../../locale/ja';
|
|
5
6
|
import type { Locale } from '../../locale/types';
|
|
6
7
|
import { zhCN } from '../../locale/zh-cn';
|
|
@@ -13,6 +14,7 @@ const LOCALES: Record<LocaleId, Locale> = {
|
|
|
13
14
|
'zh-TW': zhTW,
|
|
14
15
|
'zh-CN': zhCN,
|
|
15
16
|
ja,
|
|
17
|
+
es,
|
|
16
18
|
};
|
|
17
19
|
|
|
18
20
|
export const LOCALE_OPTIONS: ReadonlyArray<{ id: LocaleId; label: string }> = [
|
|
@@ -20,13 +22,16 @@ export const LOCALE_OPTIONS: ReadonlyArray<{ id: LocaleId; label: string }> = [
|
|
|
20
22
|
{ id: 'zh-TW', label: '繁體中文' },
|
|
21
23
|
{ id: 'zh-CN', label: '简体中文' },
|
|
22
24
|
{ id: 'ja', label: '日本語' },
|
|
25
|
+
{ id: 'es', label: 'Español' },
|
|
23
26
|
];
|
|
24
27
|
|
|
25
28
|
const STORAGE_KEY = 'open-slide:locale';
|
|
26
29
|
const configLocale = config.locale as Locale | undefined;
|
|
27
30
|
|
|
28
31
|
function isLocaleId(value: string | null): value is LocaleId {
|
|
29
|
-
return
|
|
32
|
+
return (
|
|
33
|
+
value === 'en' || value === 'zh-TW' || value === 'zh-CN' || value === 'ja' || value === 'es'
|
|
34
|
+
);
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
function readStored(): Locale {
|
|
@@ -11,27 +11,30 @@ export async function waitForFonts(): Promise<void> {
|
|
|
11
11
|
await document.fonts.ready;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Resolves false when any target was still missing at the deadline.
|
|
14
15
|
export async function waitForDataWaitfor(
|
|
15
16
|
root: HTMLElement,
|
|
16
17
|
timeoutMs = DEFAULT_WAITFOR_TIMEOUT_MS,
|
|
17
|
-
): Promise<
|
|
18
|
+
): Promise<boolean> {
|
|
18
19
|
const targets = Array.from(root.querySelectorAll<HTMLElement>('[data-waitfor]'));
|
|
19
|
-
if (targets.length === 0) return;
|
|
20
|
+
if (targets.length === 0) return true;
|
|
20
21
|
const deadline = performance.now() + timeoutMs;
|
|
21
|
-
await Promise.all(
|
|
22
|
+
const results = await Promise.all(
|
|
22
23
|
targets.map(async (el) => {
|
|
23
24
|
const selector = el.getAttribute('data-waitfor');
|
|
24
|
-
if (!selector) return;
|
|
25
|
+
if (!selector) return true;
|
|
25
26
|
while (performance.now() < deadline) {
|
|
26
27
|
try {
|
|
27
|
-
if (el.querySelector(selector)) return;
|
|
28
|
+
if (el.querySelector(selector)) return true;
|
|
28
29
|
} catch {
|
|
29
|
-
return; // invalid selector — skip rather than hang
|
|
30
|
+
return true; // invalid selector — skip rather than hang
|
|
30
31
|
}
|
|
31
32
|
await nextFrame();
|
|
32
33
|
}
|
|
34
|
+
return false;
|
|
33
35
|
}),
|
|
34
36
|
);
|
|
37
|
+
return results.every(Boolean);
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
export function isFrameAnimationSettled(frame: Element): boolean {
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
} from 'lucide-react';
|
|
12
12
|
import {
|
|
13
13
|
type KeyboardEvent as ReactKeyboardEvent,
|
|
14
|
-
type ReactNode,
|
|
15
14
|
useCallback,
|
|
16
15
|
useEffect,
|
|
17
16
|
useRef,
|
|
@@ -29,12 +28,12 @@ import {
|
|
|
29
28
|
type PresenterState,
|
|
30
29
|
usePresenterChannel,
|
|
31
30
|
} from '../components/present/use-presenter-channel';
|
|
31
|
+
import { PreviewStepHost } from '../components/preview-step-host';
|
|
32
32
|
import { SlideCanvas } from '../components/slide-canvas';
|
|
33
33
|
import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
|
|
34
34
|
import { SlidePageProvider } from '../lib/page-context';
|
|
35
35
|
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from '../lib/sdk';
|
|
36
36
|
import { loadSlide, slideIds } from '../lib/slides';
|
|
37
|
-
import { type StepController, StepHost } from '../lib/step-context';
|
|
38
37
|
import { useSlideModule } from '../lib/use-slide-module';
|
|
39
38
|
|
|
40
39
|
export function Presenter() {
|
|
@@ -653,20 +652,6 @@ function SectionLabel({ children }: { children: React.ReactNode }) {
|
|
|
653
652
|
return <span className="eyebrow">{children}</span>;
|
|
654
653
|
}
|
|
655
654
|
|
|
656
|
-
function PreviewStepHost({ revealed, children }: { revealed: number; children: ReactNode }) {
|
|
657
|
-
const noopControllerRef = useRef<StepController | null>(null);
|
|
658
|
-
return (
|
|
659
|
-
<StepHost
|
|
660
|
-
isActivePage={false}
|
|
661
|
-
entryDirection="jump"
|
|
662
|
-
controllerRef={noopControllerRef}
|
|
663
|
-
controlledRevealed={revealed}
|
|
664
|
-
>
|
|
665
|
-
{children}
|
|
666
|
-
</StepHost>
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
|
|
670
655
|
function Clock() {
|
|
671
656
|
const [now, setNow] = useState(() => new Date());
|
|
672
657
|
const t = useLocale();
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Component, type ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useParams, useSearchParams } from 'react-router-dom';
|
|
3
|
+
import { useDocumentTitle } from '@/lib/use-document-title';
|
|
4
|
+
import { PreviewStepHost } from '../components/preview-step-host';
|
|
5
|
+
import { SlideCanvas } from '../components/slide-canvas';
|
|
6
|
+
import { nextPaint, sleep } from '../lib/dom';
|
|
7
|
+
import { SlidePageProvider } from '../lib/page-context';
|
|
8
|
+
import { isFrameAnimationSettled, waitForDataWaitfor, waitForFonts } from '../lib/print-ready';
|
|
9
|
+
import { useSlideModule } from '../lib/use-slide-module';
|
|
10
|
+
|
|
11
|
+
const SETTLE_TIMEOUT_MS = 10_000;
|
|
12
|
+
const POLL_INTERVAL_MS = 50;
|
|
13
|
+
|
|
14
|
+
type Settle = { status: 'loading' } | { status: 'ready' } | { status: 'error'; message: string };
|
|
15
|
+
|
|
16
|
+
function parseIntParam(raw: string | null): number | null {
|
|
17
|
+
if (raw === null || raw.trim() === '') return null;
|
|
18
|
+
const n = Number(raw);
|
|
19
|
+
return Number.isInteger(n) ? n : Number.NaN;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function settlesWithin(promise: Promise<unknown>, ms: number): Promise<boolean> {
|
|
23
|
+
return Promise.race([promise.then(() => true), sleep(ms).then(() => false)]);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function decodeImages(root: HTMLElement): Promise<unknown> {
|
|
27
|
+
const images = Array.from(root.querySelectorAll('img'));
|
|
28
|
+
return Promise.all(images.map((img) => img.decode().catch(() => {})));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type PageErrorBoundaryProps = {
|
|
32
|
+
resetKey: unknown;
|
|
33
|
+
onError: (error: unknown) => void;
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
class PageErrorBoundary extends Component<PageErrorBoundaryProps, { failed: boolean }> {
|
|
38
|
+
state = { failed: false };
|
|
39
|
+
|
|
40
|
+
static getDerivedStateFromError() {
|
|
41
|
+
return { failed: true };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
componentDidCatch(error: unknown) {
|
|
45
|
+
this.props.onError(error);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
componentDidUpdate(prev: PageErrorBoundaryProps) {
|
|
49
|
+
if (this.state.failed && prev.resetKey !== this.props.resetKey) {
|
|
50
|
+
this.setState({ failed: false });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
render() {
|
|
55
|
+
return this.state.failed ? null : this.props.children;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function Preview() {
|
|
60
|
+
const { slideId = '' } = useParams();
|
|
61
|
+
const [searchParams] = useSearchParams();
|
|
62
|
+
const { slide, error: loadError } = useSlideModule(slideId);
|
|
63
|
+
const frameRef = useRef<HTMLDivElement>(null);
|
|
64
|
+
const [settle, setSettle] = useState<Settle>({ status: 'loading' });
|
|
65
|
+
const [renderError, setRenderError] = useState<{ page: unknown; message: string } | null>(null);
|
|
66
|
+
|
|
67
|
+
const pageParam = parseIntParam(searchParams.get('p'));
|
|
68
|
+
const stepParam = parseIntParam(searchParams.get('step'));
|
|
69
|
+
const pages = slide?.default ?? [];
|
|
70
|
+
const pageNumber = pageParam ?? 1;
|
|
71
|
+
const Page = pages[pageNumber - 1];
|
|
72
|
+
|
|
73
|
+
let inputError = loadError;
|
|
74
|
+
if (!inputError && slide) {
|
|
75
|
+
if (pages.length === 0) inputError = `Slide "${slideId}" has no pages.`;
|
|
76
|
+
else if (!Page) {
|
|
77
|
+
inputError = `Page ${searchParams.get('p')} is out of range (1–${pages.length}).`;
|
|
78
|
+
} else if (stepParam !== null && (Number.isNaN(stepParam) || stepParam < 0)) {
|
|
79
|
+
inputError = `Invalid step "${searchParams.get('step')}" — expected a non-negative integer.`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
useDocumentTitle(slide ? `${slide.meta?.title ?? slideId} · ${pageNumber}` : undefined);
|
|
84
|
+
|
|
85
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: a new step reveals content that has to settle again
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
setSettle({ status: 'loading' });
|
|
88
|
+
if (!Page || inputError) return;
|
|
89
|
+
let cancelled = false;
|
|
90
|
+
(async () => {
|
|
91
|
+
await nextPaint();
|
|
92
|
+
const frame = frameRef.current;
|
|
93
|
+
if (!frame) return;
|
|
94
|
+
const deadline = performance.now() + SETTLE_TIMEOUT_MS;
|
|
95
|
+
const remaining = () => Math.max(0, deadline - performance.now());
|
|
96
|
+
const fontsLoaded = await settlesWithin(waitForFonts(), remaining());
|
|
97
|
+
const targetsFound = await waitForDataWaitfor(frame, remaining());
|
|
98
|
+
const imagesDecoded = await settlesWithin(decodeImages(frame), remaining());
|
|
99
|
+
while (!cancelled && !isFrameAnimationSettled(frame) && remaining() > 0) {
|
|
100
|
+
await sleep(POLL_INTERVAL_MS);
|
|
101
|
+
}
|
|
102
|
+
const animationsSettled = isFrameAnimationSettled(frame);
|
|
103
|
+
await nextPaint();
|
|
104
|
+
if (cancelled) return;
|
|
105
|
+
const pending = [
|
|
106
|
+
!fontsLoaded && 'fonts to load',
|
|
107
|
+
!targetsFound && 'a [data-waitfor] target to appear',
|
|
108
|
+
!imagesDecoded && 'images to decode',
|
|
109
|
+
!animationsSettled && 'animations to finish',
|
|
110
|
+
].filter(Boolean);
|
|
111
|
+
setSettle(
|
|
112
|
+
pending.length > 0
|
|
113
|
+
? { status: 'error', message: `Timed out waiting for ${pending.join(', ')}.` }
|
|
114
|
+
: { status: 'ready' },
|
|
115
|
+
);
|
|
116
|
+
})();
|
|
117
|
+
return () => {
|
|
118
|
+
cancelled = true;
|
|
119
|
+
};
|
|
120
|
+
}, [Page, inputError, stepParam]);
|
|
121
|
+
|
|
122
|
+
const pageError = renderError && renderError.page === Page ? renderError.message : null;
|
|
123
|
+
const error = inputError ?? pageError ?? (settle.status === 'error' ? settle.message : null);
|
|
124
|
+
const state = error ? 'error' : settle.status;
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
ref={frameRef}
|
|
129
|
+
data-osd-preview={state}
|
|
130
|
+
data-osd-preview-page={Page ? pageNumber : undefined}
|
|
131
|
+
data-osd-preview-total={slide ? pages.length : undefined}
|
|
132
|
+
className="h-screen w-screen overflow-hidden bg-black"
|
|
133
|
+
>
|
|
134
|
+
{error ? (
|
|
135
|
+
<pre
|
|
136
|
+
data-osd-preview-error
|
|
137
|
+
className="m-0 p-6 font-mono text-[14px] whitespace-pre-wrap text-red-400"
|
|
138
|
+
>
|
|
139
|
+
{error}
|
|
140
|
+
</pre>
|
|
141
|
+
) : (
|
|
142
|
+
slide &&
|
|
143
|
+
Page && (
|
|
144
|
+
<SlideCanvas flat freezeMotion design={slide.design}>
|
|
145
|
+
<SlidePageProvider index={pageNumber - 1} total={pages.length}>
|
|
146
|
+
<PageErrorBoundary
|
|
147
|
+
resetKey={Page}
|
|
148
|
+
onError={(e) =>
|
|
149
|
+
setRenderError({
|
|
150
|
+
page: Page,
|
|
151
|
+
message: `Page ${pageNumber} threw while rendering:\n${e instanceof Error ? (e.stack ?? e.message) : String(e)}`,
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
{stepParam === null ? (
|
|
156
|
+
<Page />
|
|
157
|
+
) : (
|
|
158
|
+
<PreviewStepHost revealed={stepParam}>
|
|
159
|
+
<Page />
|
|
160
|
+
</PreviewStepHost>
|
|
161
|
+
)}
|
|
162
|
+
</PageErrorBoundary>
|
|
163
|
+
</SlidePageProvider>
|
|
164
|
+
</SlideCanvas>
|
|
165
|
+
)
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -45,8 +45,12 @@ import { DesignToggleButton } from '@/components/style-panel/style-panel';
|
|
|
45
45
|
import { Button, buttonVariants } from '@/components/ui/button';
|
|
46
46
|
import {
|
|
47
47
|
DropdownMenu,
|
|
48
|
+
DropdownMenuCheckboxItem,
|
|
48
49
|
DropdownMenuContent,
|
|
50
|
+
DropdownMenuGroup,
|
|
49
51
|
DropdownMenuItem,
|
|
52
|
+
DropdownMenuRadioGroup,
|
|
53
|
+
DropdownMenuRadioItem,
|
|
50
54
|
DropdownMenuSeparator,
|
|
51
55
|
DropdownMenuShortcut,
|
|
52
56
|
DropdownMenuTrigger,
|
|
@@ -67,6 +71,7 @@ import { useClickPageNavigation } from '@/lib/use-click-page-navigation';
|
|
|
67
71
|
import { useDocumentTitle } from '@/lib/use-document-title';
|
|
68
72
|
import { useIsMobile } from '@/lib/use-is-mobile';
|
|
69
73
|
import { format, useLocale } from '@/lib/use-locale';
|
|
74
|
+
import { useMediaQuery } from '@/lib/use-media-query';
|
|
70
75
|
import { useWheelPageNavigation } from '@/lib/use-wheel-page-navigation';
|
|
71
76
|
import { cn } from '@/lib/utils';
|
|
72
77
|
import { SlideCommandMenu } from '../components/command/slide-command-menu';
|
|
@@ -142,6 +147,8 @@ export function Slide() {
|
|
|
142
147
|
const slideViewportRef = useRef<HTMLElement>(null);
|
|
143
148
|
const t = useLocale();
|
|
144
149
|
const isMobile = useIsMobile();
|
|
150
|
+
const compactToolbar = useMediaQuery('(max-width: 1023.98px)');
|
|
151
|
+
const narrowToolbar = useMediaQuery('(max-width: 639.98px)');
|
|
145
152
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
146
153
|
|
|
147
154
|
const modulePages = useMemo(() => slide?.default ?? [], [slide]);
|
|
@@ -586,7 +593,7 @@ export function Slide() {
|
|
|
586
593
|
};
|
|
587
594
|
|
|
588
595
|
const exportMenuItems = (
|
|
589
|
-
|
|
596
|
+
<DropdownMenuGroup>
|
|
590
597
|
<DropdownMenuItem disabled={exporting} onClick={exportHtml}>
|
|
591
598
|
<FileCode2 />
|
|
592
599
|
{t.slide.exportAsHtml}
|
|
@@ -604,11 +611,11 @@ export function Slide() {
|
|
|
604
611
|
<FileImage />
|
|
605
612
|
{t.slide.exportAsImagePptx}
|
|
606
613
|
</DropdownMenuItem>
|
|
607
|
-
|
|
614
|
+
</DropdownMenuGroup>
|
|
608
615
|
);
|
|
609
616
|
|
|
610
617
|
return (
|
|
611
|
-
<HistoryProvider>
|
|
618
|
+
<HistoryProvider pageIndex={index} onPageChange={goTo}>
|
|
612
619
|
<InspectorProvider
|
|
613
620
|
slideId={slideId}
|
|
614
621
|
pageIndex={index}
|
|
@@ -617,9 +624,8 @@ export function Slide() {
|
|
|
617
624
|
>
|
|
618
625
|
<SelectionReporter />
|
|
619
626
|
<div className="flex h-dvh flex-col overflow-hidden bg-sidebar text-foreground">
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
<div className="flex flex-1 items-center gap-1.5 md:flex-none md:gap-2">
|
|
627
|
+
<header className="grid min-h-12 shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-1 px-2 py-2 md:px-3">
|
|
628
|
+
<div className="col-start-1 row-start-1 flex min-w-0 items-center gap-1.5 md:gap-2">
|
|
623
629
|
{showSlideBrowser && (
|
|
624
630
|
<button
|
|
625
631
|
type="button"
|
|
@@ -656,29 +662,23 @@ export function Slide() {
|
|
|
656
662
|
{import.meta.env.DEV && <AgentConnectedBadge />}
|
|
657
663
|
</div>
|
|
658
664
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
and min-w-0 lets it truncate instead of overlapping the icons on narrow widths. */}
|
|
662
|
-
<div className="pointer-events-none relative flex min-w-0 justify-center px-2 md:absolute md:inset-x-0">
|
|
663
|
-
<div className="pointer-events-auto min-w-0 max-w-[34rem]">
|
|
665
|
+
<div className="col-span-3 row-start-2 flex min-w-0 justify-center sm:col-span-1 sm:col-start-2 sm:row-start-1">
|
|
666
|
+
<div className="min-w-0 max-w-[34rem]">
|
|
664
667
|
<InlineTitleEditor title={title} onSubmit={(next) => renameSlide(slideId, next)} />
|
|
665
668
|
</div>
|
|
666
669
|
</div>
|
|
667
670
|
|
|
668
|
-
<div className="
|
|
669
|
-
{view === 'slides' && <InspectModeSwitcher />}
|
|
670
|
-
{import.meta.env.DEV && view === 'slides' && (
|
|
671
|
+
<div className="col-start-3 row-start-1 flex items-center justify-end gap-1">
|
|
672
|
+
{view === 'slides' && !narrowToolbar && <InspectModeSwitcher />}
|
|
673
|
+
{import.meta.env.DEV && view === 'slides' && !compactToolbar && (
|
|
671
674
|
<span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
|
|
672
675
|
)}
|
|
673
|
-
{view === 'slides' && (
|
|
676
|
+
{view === 'slides' && !compactToolbar && (
|
|
674
677
|
<button
|
|
675
678
|
type="button"
|
|
676
679
|
aria-label={t.slide.copyLink}
|
|
677
680
|
title={t.slide.copyLink}
|
|
678
|
-
className={
|
|
679
|
-
buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
|
|
680
|
-
'hidden md:inline-flex',
|
|
681
|
-
)}
|
|
681
|
+
className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
|
|
682
682
|
onClick={copyLink}
|
|
683
683
|
>
|
|
684
684
|
<span className="relative grid size-4 place-items-center">
|
|
@@ -697,17 +697,14 @@ export function Slide() {
|
|
|
697
697
|
</span>
|
|
698
698
|
</button>
|
|
699
699
|
)}
|
|
700
|
-
{view === 'slides' && allowHtmlDownload && (
|
|
700
|
+
{view === 'slides' && allowHtmlDownload && !compactToolbar && (
|
|
701
701
|
<DropdownMenu>
|
|
702
702
|
<DropdownMenuTrigger
|
|
703
703
|
type="button"
|
|
704
704
|
disabled={exporting}
|
|
705
705
|
aria-label={t.slide.download}
|
|
706
706
|
title={t.slide.download}
|
|
707
|
-
className={
|
|
708
|
-
buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
|
|
709
|
-
'hidden md:inline-flex',
|
|
710
|
-
)}
|
|
707
|
+
className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
|
|
711
708
|
>
|
|
712
709
|
{exporting ? (
|
|
713
710
|
<Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
|
|
@@ -720,17 +717,13 @@ export function Slide() {
|
|
|
720
717
|
</DropdownMenuContent>
|
|
721
718
|
</DropdownMenu>
|
|
722
719
|
)}
|
|
723
|
-
{view === 'slides' && (
|
|
724
|
-
<DropdownMenu>
|
|
720
|
+
{view === 'slides' && compactToolbar && (
|
|
721
|
+
<DropdownMenu key={narrowToolbar ? 'narrow' : 'compact'}>
|
|
725
722
|
<DropdownMenuTrigger
|
|
726
723
|
type="button"
|
|
727
|
-
disabled={exporting}
|
|
728
724
|
aria-label={t.slide.moreActions}
|
|
729
725
|
title={t.slide.moreActions}
|
|
730
|
-
className={
|
|
731
|
-
buttonVariants({ variant: 'ghost', size: 'icon-sm' }),
|
|
732
|
-
'inline-flex md:hidden',
|
|
733
|
-
)}
|
|
726
|
+
className={buttonVariants({ variant: 'ghost', size: 'icon-sm' })}
|
|
734
727
|
>
|
|
735
728
|
{exporting ? (
|
|
736
729
|
<Loader2 className="size-4 animate-spin motion-reduce:animate-none" />
|
|
@@ -739,34 +732,43 @@ export function Slide() {
|
|
|
739
732
|
)}
|
|
740
733
|
</DropdownMenuTrigger>
|
|
741
734
|
<DropdownMenuContent align="end" className="min-w-[200px]">
|
|
742
|
-
|
|
743
|
-
<
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
735
|
+
{narrowToolbar && import.meta.env.DEV && (
|
|
736
|
+
<EditorMenuItems
|
|
737
|
+
designOpen={designOpen}
|
|
738
|
+
onDesignToggle={() => setDesignOpen((v) => !v)}
|
|
739
|
+
/>
|
|
740
|
+
)}
|
|
741
|
+
<DropdownMenuGroup>
|
|
742
|
+
<DropdownMenuItem onClick={() => setCommandOpen(true)}>
|
|
743
|
+
<Terminal />
|
|
744
|
+
{t.commandMenu.trigger}
|
|
745
|
+
</DropdownMenuItem>
|
|
746
|
+
<DropdownMenuItem onClick={copyLink}>
|
|
747
|
+
<Link2 />
|
|
748
|
+
{t.slide.copyLink}
|
|
749
|
+
</DropdownMenuItem>
|
|
750
|
+
</DropdownMenuGroup>
|
|
750
751
|
{allowHtmlDownload && <DropdownMenuSeparator />}
|
|
751
752
|
{allowHtmlDownload && exportMenuItems}
|
|
752
753
|
</DropdownMenuContent>
|
|
753
754
|
</DropdownMenu>
|
|
754
755
|
)}
|
|
755
|
-
{view === 'slides' && (
|
|
756
|
+
{view === 'slides' && !narrowToolbar && (
|
|
756
757
|
<DesignToggleButton active={designOpen} onToggle={() => setDesignOpen((v) => !v)} />
|
|
757
758
|
)}
|
|
758
|
-
{view === 'slides' && <InspectPanelButton />}
|
|
759
|
+
{view === 'slides' && !narrowToolbar && <InspectPanelButton />}
|
|
759
760
|
<span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
|
|
760
761
|
{view === 'slides' && (
|
|
761
762
|
<div className="inline-flex items-stretch">
|
|
762
763
|
<Button
|
|
763
764
|
size="sm"
|
|
764
765
|
variant="brand"
|
|
766
|
+
aria-label={t.slide.present}
|
|
765
767
|
onClick={() => setPlayMode(isMobile ? 'window' : 'fullscreen')}
|
|
766
|
-
className="px-2.5
|
|
768
|
+
className="rounded-r-none px-2.5 lg:px-3"
|
|
767
769
|
>
|
|
768
770
|
<Play className="size-3.5 fill-current" />
|
|
769
|
-
<span className="hidden
|
|
771
|
+
<span className="hidden lg:inline">{t.slide.present}</span>
|
|
770
772
|
</Button>
|
|
771
773
|
<DropdownMenu>
|
|
772
774
|
<DropdownMenuTrigger
|
|
@@ -775,32 +777,34 @@ export function Slide() {
|
|
|
775
777
|
title={t.slide.presentMenuAria}
|
|
776
778
|
className={cn(
|
|
777
779
|
buttonVariants({ variant: 'brand', size: 'sm' }),
|
|
778
|
-
'
|
|
780
|
+
'rounded-l-none px-1.5 shadow-[inset_1px_0_0_oklch(0_0_0/0.12),inset_0_1px_0_oklch(1_0_0/0.18),0_1px_0_oklch(0_0_0/0.16)]',
|
|
779
781
|
)}
|
|
780
782
|
>
|
|
781
783
|
<ChevronDown className="size-3.5" />
|
|
782
784
|
</DropdownMenuTrigger>
|
|
783
785
|
<DropdownMenuContent align="end" className="min-w-[200px]">
|
|
784
|
-
<
|
|
785
|
-
<
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
<
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
786
|
+
<DropdownMenuGroup>
|
|
787
|
+
<DropdownMenuItem onClick={() => setPlayMode('window')}>
|
|
788
|
+
<Play />
|
|
789
|
+
{t.slide.presentInWindow}
|
|
790
|
+
<DropdownMenuShortcut>↵</DropdownMenuShortcut>
|
|
791
|
+
</DropdownMenuItem>
|
|
792
|
+
<DropdownMenuItem onClick={() => setPlayMode('fullscreen')}>
|
|
793
|
+
<Maximize />
|
|
794
|
+
{t.slide.presentFullscreen}
|
|
795
|
+
<DropdownMenuShortcut>F</DropdownMenuShortcut>
|
|
796
|
+
</DropdownMenuItem>
|
|
797
|
+
<DropdownMenuItem
|
|
798
|
+
onClick={() => {
|
|
799
|
+
if (slideId) openPresenterWindow(slideId);
|
|
800
|
+
setPlayMode('window');
|
|
801
|
+
}}
|
|
802
|
+
>
|
|
803
|
+
<MonitorSpeaker />
|
|
804
|
+
{t.slide.presentPresenter}
|
|
805
|
+
<DropdownMenuShortcut>P</DropdownMenuShortcut>
|
|
806
|
+
</DropdownMenuItem>
|
|
807
|
+
</DropdownMenuGroup>
|
|
804
808
|
</DropdownMenuContent>
|
|
805
809
|
</DropdownMenu>
|
|
806
810
|
</div>
|
|
@@ -1051,6 +1055,47 @@ function ResizableRail(props: {
|
|
|
1051
1055
|
);
|
|
1052
1056
|
}
|
|
1053
1057
|
|
|
1058
|
+
function EditorMenuItems({
|
|
1059
|
+
designOpen,
|
|
1060
|
+
onDesignToggle,
|
|
1061
|
+
}: {
|
|
1062
|
+
designOpen: boolean;
|
|
1063
|
+
onDesignToggle: () => void;
|
|
1064
|
+
}) {
|
|
1065
|
+
const t = useLocale();
|
|
1066
|
+
const { active, toggle, panelOpen, panelHidden, togglePanel } = useInspector();
|
|
1067
|
+
return (
|
|
1068
|
+
<>
|
|
1069
|
+
<DropdownMenuGroup>
|
|
1070
|
+
<DropdownMenuRadioGroup
|
|
1071
|
+
value={active ? 'edit' : 'preview'}
|
|
1072
|
+
onValueChange={(value) => {
|
|
1073
|
+
if ((value === 'edit') !== active) toggle();
|
|
1074
|
+
}}
|
|
1075
|
+
>
|
|
1076
|
+
<DropdownMenuRadioItem value="preview">{t.inspector.previewMode}</DropdownMenuRadioItem>
|
|
1077
|
+
<DropdownMenuRadioItem value="edit">{t.inspector.editMode}</DropdownMenuRadioItem>
|
|
1078
|
+
</DropdownMenuRadioGroup>
|
|
1079
|
+
<DropdownMenuCheckboxItem
|
|
1080
|
+
checked={designOpen}
|
|
1081
|
+
onCheckedChange={onDesignToggle}
|
|
1082
|
+
closeOnClick
|
|
1083
|
+
>
|
|
1084
|
+
{t.stylePanel.designToggle}
|
|
1085
|
+
</DropdownMenuCheckboxItem>
|
|
1086
|
+
<DropdownMenuCheckboxItem
|
|
1087
|
+
checked={active && panelOpen && !panelHidden}
|
|
1088
|
+
onCheckedChange={togglePanel}
|
|
1089
|
+
closeOnClick
|
|
1090
|
+
>
|
|
1091
|
+
{t.inspector.format}
|
|
1092
|
+
</DropdownMenuCheckboxItem>
|
|
1093
|
+
</DropdownMenuGroup>
|
|
1094
|
+
<DropdownMenuSeparator />
|
|
1095
|
+
</>
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1054
1099
|
function AgentConnectedBadge() {
|
|
1055
1100
|
const t = useLocale();
|
|
1056
1101
|
const connected = useAgentSocketConnected();
|
|
@@ -1061,6 +1106,7 @@ function AgentConnectedBadge() {
|
|
|
1061
1106
|
render={
|
|
1062
1107
|
<button
|
|
1063
1108
|
type="button"
|
|
1109
|
+
aria-label={connected ? t.slide.agentConnected : t.slide.agentDisconnected}
|
|
1064
1110
|
className="ml-1 flex shrink-0 cursor-help items-center gap-1.5 rounded-[3px] border border-hairline bg-card px-1.5 py-0.5 text-[10.5px] text-foreground/85 outline-none transition-colors duration-150 hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring/30"
|
|
1065
1111
|
>
|
|
1066
1112
|
<span aria-hidden className="relative flex size-1.5 items-center justify-center">
|
|
@@ -1073,7 +1119,9 @@ function AgentConnectedBadge() {
|
|
|
1073
1119
|
<span className="relative inline-flex size-1.5 rounded-full bg-rose-500" />
|
|
1074
1120
|
)}
|
|
1075
1121
|
</span>
|
|
1076
|
-
|
|
1122
|
+
<span className="hidden xl:inline">
|
|
1123
|
+
{connected ? t.slide.agentConnected : t.slide.agentDisconnected}
|
|
1124
|
+
</span>
|
|
1077
1125
|
</button>
|
|
1078
1126
|
}
|
|
1079
1127
|
/>
|