@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>
|
|
@@ -4,6 +4,7 @@ import { type ReactNode, useEffect, useMemo, useState } from 'react';
|
|
|
4
4
|
import { IconTooltip } from '@/components/icon-tooltip';
|
|
5
5
|
import { buttonVariants } from '@/components/ui/button';
|
|
6
6
|
import { TooltipTrigger } from '@/components/ui/tooltip';
|
|
7
|
+
import { IS_APPLE } from '@/lib/keys';
|
|
7
8
|
import { LOCALE_OPTIONS, setLocale } from '@/lib/locale-store';
|
|
8
9
|
import { format, useLocale } from '@/lib/use-locale';
|
|
9
10
|
import { useRestartServer } from '@/lib/use-restart-server';
|
|
@@ -118,9 +119,6 @@ export function CommandMenu({
|
|
|
118
119
|
);
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
const IS_APPLE =
|
|
122
|
-
typeof navigator !== 'undefined' && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
|
|
123
|
-
|
|
124
122
|
export const COMMAND_MENU_SHORTCUT = IS_APPLE ? '⌘K' : 'Ctrl K';
|
|
125
123
|
|
|
126
124
|
export function CommandMenuTrigger({ onClick }: { onClick: () => void }) {
|
|
@@ -12,6 +12,7 @@ export type HistoryEntry = {
|
|
|
12
12
|
undo: () => void;
|
|
13
13
|
redo: () => void;
|
|
14
14
|
coalesceKey?: string;
|
|
15
|
+
pageIndex?: number;
|
|
15
16
|
ts: number;
|
|
16
17
|
};
|
|
17
18
|
|
|
@@ -34,7 +35,15 @@ export function useHistory(): HistoryCtx {
|
|
|
34
35
|
return v;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
export function HistoryProvider({
|
|
38
|
+
export function HistoryProvider({
|
|
39
|
+
pageIndex,
|
|
40
|
+
onPageChange,
|
|
41
|
+
children,
|
|
42
|
+
}: {
|
|
43
|
+
pageIndex?: number;
|
|
44
|
+
onPageChange?: (pageIndex: number) => void;
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}) {
|
|
38
47
|
const stacksRef = useRef<{ past: HistoryEntry[]; future: HistoryEntry[] }>({
|
|
39
48
|
past: [],
|
|
40
49
|
future: [],
|
|
@@ -43,6 +52,15 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
|
|
|
43
52
|
// Set while invoking an entry's undo/redo so providers can skip
|
|
44
53
|
// re-recording the resulting state mutation.
|
|
45
54
|
const suppressedRef = useRef(false);
|
|
55
|
+
const pageRef = useRef({ pageIndex, onPageChange });
|
|
56
|
+
pageRef.current = { pageIndex, onPageChange };
|
|
57
|
+
|
|
58
|
+
// An entry made on another page changes DOM the user can't see, so bring
|
|
59
|
+
// its page into view; the page's remount replays the restored buffer.
|
|
60
|
+
const revealPage = useCallback((entry: HistoryEntry) => {
|
|
61
|
+
const { pageIndex: current, onPageChange: goTo } = pageRef.current;
|
|
62
|
+
if (entry.pageIndex !== undefined && entry.pageIndex !== current) goTo?.(entry.pageIndex);
|
|
63
|
+
}, []);
|
|
46
64
|
|
|
47
65
|
const syncAvailability = useCallback(() => {
|
|
48
66
|
const canUndo = stacksRef.current.past.length > 0;
|
|
@@ -64,12 +82,14 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
|
|
|
64
82
|
top &&
|
|
65
83
|
entry.coalesceKey !== undefined &&
|
|
66
84
|
top.coalesceKey === entry.coalesceKey &&
|
|
85
|
+
top.pageIndex === entry.pageIndex &&
|
|
67
86
|
ts - top.ts < COALESCE_WINDOW_MS
|
|
68
87
|
) {
|
|
69
88
|
const merged: HistoryEntry = {
|
|
70
89
|
undo: top.undo,
|
|
71
90
|
redo: entry.redo,
|
|
72
91
|
coalesceKey: entry.coalesceKey,
|
|
92
|
+
pageIndex: entry.pageIndex,
|
|
73
93
|
ts,
|
|
74
94
|
};
|
|
75
95
|
stacksRef.current = { past: [...past.slice(0, -1), merged], future: [] };
|
|
@@ -98,7 +118,8 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
|
|
|
98
118
|
suppressedRef.current = false;
|
|
99
119
|
syncAvailability();
|
|
100
120
|
}
|
|
101
|
-
|
|
121
|
+
revealPage(top);
|
|
122
|
+
}, [syncAvailability, revealPage]);
|
|
102
123
|
|
|
103
124
|
const redo = useCallback(() => {
|
|
104
125
|
if (suppressedRef.current) return;
|
|
@@ -117,7 +138,8 @@ export function HistoryProvider({ children }: { children: ReactNode }) {
|
|
|
117
138
|
suppressedRef.current = false;
|
|
118
139
|
syncAvailability();
|
|
119
140
|
}
|
|
120
|
-
|
|
141
|
+
revealPage(top);
|
|
142
|
+
}, [syncAvailability, revealPage]);
|
|
121
143
|
|
|
122
144
|
const clear = useCallback(() => {
|
|
123
145
|
stacksRef.current = { past: [], future: [] };
|
|
@@ -37,25 +37,80 @@ export type SelectedTarget = {
|
|
|
37
37
|
canvasPath?: number[];
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
const INSTANCE_ID_ATTR = 'data-slide-instance-id';
|
|
41
|
+
|
|
42
|
+
function elementPath(root: Element, el: Element): number[] | null {
|
|
43
43
|
const path: number[] = [];
|
|
44
|
-
for (let node
|
|
45
|
-
const parent
|
|
46
|
-
if (!parent) return
|
|
44
|
+
for (let node = el; node !== root; ) {
|
|
45
|
+
const parent = node.parentElement;
|
|
46
|
+
if (!parent) return null;
|
|
47
47
|
path.unshift(Array.from(parent.children).indexOf(node));
|
|
48
|
+
node = parent;
|
|
48
49
|
}
|
|
49
|
-
return
|
|
50
|
+
return path;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
function
|
|
53
|
-
let node = root
|
|
54
|
-
if (!path) return null;
|
|
53
|
+
function elementAtPath(root: Element | null, path: number[]): HTMLElement | null {
|
|
54
|
+
let node = root;
|
|
55
55
|
for (const index of path) node = node?.children[index] ?? null;
|
|
56
56
|
return node instanceof HTMLElement ? node : null;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function rememberTarget(target: SelectedTarget): SelectedTarget {
|
|
60
|
+
const root = target.anchor.closest('[data-osd-canvas]');
|
|
61
|
+
const path = root && elementPath(root, target.anchor);
|
|
62
|
+
return path ? { ...target, canvasPath: path } : target;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function findRememberedTarget(root: HTMLElement, path?: number[]): HTMLElement | null {
|
|
66
|
+
if (!path) return null;
|
|
67
|
+
return elementAtPath(root.querySelector('[data-osd-canvas]'), path);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Enough to find an edited element again after its page remounts. The path is
|
|
71
|
+
// relative to the page layer, since an outgoing page shifts canvas-level paths.
|
|
72
|
+
type RevealTarget = {
|
|
73
|
+
line: number;
|
|
74
|
+
column: number;
|
|
75
|
+
anchor: HTMLElement;
|
|
76
|
+
tagName: string;
|
|
77
|
+
pagePath: number[] | null;
|
|
78
|
+
instanceId: string | null;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Only the incoming layer carries it: an interrupted transition relabels and
|
|
82
|
+
// remounts the outgoing one, so anything found there goes stale.
|
|
83
|
+
const PAGE_LAYER_ATTR = 'data-osd-current-page';
|
|
84
|
+
|
|
85
|
+
function captureRevealTarget(target: SelectedTarget): RevealTarget {
|
|
86
|
+
const layer = target.anchor.closest(`[${PAGE_LAYER_ATTR}]`);
|
|
87
|
+
return {
|
|
88
|
+
line: target.line,
|
|
89
|
+
column: target.column,
|
|
90
|
+
anchor: target.anchor,
|
|
91
|
+
tagName: target.anchor.tagName,
|
|
92
|
+
pagePath: layer && elementPath(layer, target.anchor),
|
|
93
|
+
instanceId: target.anchor.getAttribute(INSTANCE_ID_ATTR),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function locateRevealTarget(layer: Element, target: RevealTarget): HTMLElement | null {
|
|
98
|
+
if (target.anchor.isConnected && layer.contains(target.anchor)) return target.anchor;
|
|
99
|
+
if (target.instanceId) {
|
|
100
|
+
const stamped = layer.querySelector<HTMLElement>(
|
|
101
|
+
`[${INSTANCE_ID_ATTR}="${target.instanceId}"]`,
|
|
102
|
+
);
|
|
103
|
+
if (stamped) return stamped;
|
|
104
|
+
}
|
|
105
|
+
const byPath = target.pagePath && elementAtPath(layer, target.pagePath);
|
|
106
|
+
if (byPath?.tagName === target.tagName) return byPath;
|
|
107
|
+
return layer.querySelector<HTMLElement>(`[data-slide-loc="${target.line}:${target.column}"]`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function sameAnchors(a: SelectedTarget[], b: SelectedTarget[]): boolean {
|
|
111
|
+
return a.length === b.length && a.every((target, index) => target.anchor === b[index].anchor);
|
|
112
|
+
}
|
|
113
|
+
|
|
59
114
|
export type InlineEditTarget = SelectedTarget & {
|
|
60
115
|
point?: { x: number; y: number };
|
|
61
116
|
// Double-click entry selects the word under the caret; a single-click
|
|
@@ -107,8 +162,6 @@ function createBucket(line: number, column: number): Bucket {
|
|
|
107
162
|
};
|
|
108
163
|
}
|
|
109
164
|
|
|
110
|
-
const INSTANCE_ID_ATTR = 'data-slide-instance-id';
|
|
111
|
-
|
|
112
165
|
export type DomTextPart = {
|
|
113
166
|
node: Text | HTMLBRElement;
|
|
114
167
|
current: string;
|
|
@@ -382,10 +435,14 @@ export function InspectorProvider({
|
|
|
382
435
|
);
|
|
383
436
|
const [selection, setSelectionState] = useState<SelectedTarget[]>([]);
|
|
384
437
|
const selected = selection.at(-1) ?? null;
|
|
438
|
+
// Targets an undo/redo should select once their page is on screen.
|
|
439
|
+
const pendingRevealRef = useRef<{ pageIndex: number; targets: RevealTarget[] } | null>(null);
|
|
385
440
|
const setSelection = useCallback((targets: SelectedTarget[]) => {
|
|
441
|
+
pendingRevealRef.current = null;
|
|
386
442
|
setSelectionState(targets.map(rememberTarget));
|
|
387
443
|
}, []);
|
|
388
444
|
const setSelected = useCallback((target: SelectedTarget | null) => {
|
|
445
|
+
pendingRevealRef.current = null;
|
|
389
446
|
setSelectionState((previous) => {
|
|
390
447
|
if (!target) return [];
|
|
391
448
|
const primary = previous.at(-1);
|
|
@@ -481,6 +538,61 @@ export function InspectorProvider({
|
|
|
481
538
|
return root.querySelector<HTMLElement>(`[data-slide-loc="${line}:${column}"]`);
|
|
482
539
|
}, []);
|
|
483
540
|
|
|
541
|
+
const pageIndexRef = useRef(pageIndex);
|
|
542
|
+
pageIndexRef.current = pageIndex;
|
|
543
|
+
const findTextAnchor = useCallback(
|
|
544
|
+
(instanceId: string, target?: SelectedTarget & { pageIndex: number }) => {
|
|
545
|
+
const root = document.querySelector<HTMLElement>('[data-inspector-root]');
|
|
546
|
+
if (!root) return null;
|
|
547
|
+
const stamped = root.querySelector<HTMLElement>(`[${INSTANCE_ID_ATTR}="${instanceId}"]`);
|
|
548
|
+
if (stamped) return stamped;
|
|
549
|
+
// Off-page instances must not fall back to the loc: a reused component on
|
|
550
|
+
// the visible page shares it, and replaying this instance's HTML there
|
|
551
|
+
// would clobber that page's text. Their page's remount replays the buffer.
|
|
552
|
+
if (!target || target.pageIndex !== pageIndexRef.current) return null;
|
|
553
|
+
const anchor =
|
|
554
|
+
findRememberedTarget(root, target.canvasPath) ??
|
|
555
|
+
root.querySelector<HTMLElement>(`[data-slide-loc="${target.line}:${target.column}"]`);
|
|
556
|
+
if (!anchor || anchor.tagName !== target.anchor.tagName) return null;
|
|
557
|
+
anchor.setAttribute(INSTANCE_ID_ATTR, instanceId);
|
|
558
|
+
return anchor;
|
|
559
|
+
},
|
|
560
|
+
[],
|
|
561
|
+
);
|
|
562
|
+
|
|
563
|
+
const flushReveal = useCallback((): boolean => {
|
|
564
|
+
const pending = pendingRevealRef.current;
|
|
565
|
+
if (!pending) return true;
|
|
566
|
+
const layer = document.querySelector(
|
|
567
|
+
`[data-inspector-root] [${PAGE_LAYER_ATTR}="${pending.pageIndex}"]`,
|
|
568
|
+
);
|
|
569
|
+
if (!layer) return false;
|
|
570
|
+
const resolved: SelectedTarget[] = [];
|
|
571
|
+
for (const target of pending.targets) {
|
|
572
|
+
const anchor = locateRevealTarget(layer, target);
|
|
573
|
+
const hit = anchor && findSlideSource(anchor, slideId, { hostOnly: true });
|
|
574
|
+
if (hit && hit.anchor === anchor && !resolved.some((t) => t.anchor === anchor)) {
|
|
575
|
+
resolved.push(hit);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
if (resolved.length === 0) return false;
|
|
579
|
+
pendingRevealRef.current = null;
|
|
580
|
+
setSelectionState((previous) =>
|
|
581
|
+
sameAnchors(previous, resolved) ? previous : resolved.map(rememberTarget),
|
|
582
|
+
);
|
|
583
|
+
return true;
|
|
584
|
+
}, [slideId]);
|
|
585
|
+
|
|
586
|
+
// Undo/redo selects what it changed. Off-page targets wait for the page
|
|
587
|
+
// effect below, since the page mounts a render after `pageIndex` changes.
|
|
588
|
+
const revealTargets = useCallback(
|
|
589
|
+
(targets: RevealTarget[], targetPage: number) => {
|
|
590
|
+
pendingRevealRef.current = { pageIndex: targetPage, targets };
|
|
591
|
+
if (targetPage === pageIndexRef.current && !flushReveal()) pendingRevealRef.current = null;
|
|
592
|
+
},
|
|
593
|
+
[flushReveal],
|
|
594
|
+
);
|
|
595
|
+
|
|
484
596
|
// Mutate bucket + DOM without recording history. Shared by `bufferOps`
|
|
485
597
|
// (the public, history-recording entry point) and by `redo` closures.
|
|
486
598
|
const applyOpsRaw = useCallback(
|
|
@@ -671,8 +783,11 @@ export function InspectorProvider({
|
|
|
671
783
|
if (sharedAnchor?.isConnected) sharedStyle[snap.key] = orig ?? '';
|
|
672
784
|
}
|
|
673
785
|
} else if (snap.kind === 'text') {
|
|
674
|
-
const textAnchor = findAnchor(line, column, snap.instanceId);
|
|
675
786
|
if (snap.target) bucket.textTargets.set(snap.instanceId, snap.target);
|
|
787
|
+
const textAnchor = findTextAnchor(
|
|
788
|
+
snap.instanceId,
|
|
789
|
+
bucket.textTargets.get(snap.instanceId),
|
|
790
|
+
);
|
|
676
791
|
if (snap.html !== undefined) bucket.origHtmls.set(snap.instanceId, snap.html);
|
|
677
792
|
if (snap.text !== undefined) bucket.origTexts.set(snap.instanceId, { value: snap.text });
|
|
678
793
|
if (snap.steps.length) bucket.textEdits.set(snap.instanceId, snap.steps);
|
|
@@ -701,7 +816,7 @@ export function InspectorProvider({
|
|
|
701
816
|
}
|
|
702
817
|
refreshCount();
|
|
703
818
|
},
|
|
704
|
-
[findAnchor, refreshCount],
|
|
819
|
+
[findAnchor, findTextAnchor, refreshCount],
|
|
705
820
|
);
|
|
706
821
|
|
|
707
822
|
const bufferOps = useCallback(
|
|
@@ -733,9 +848,14 @@ export function InspectorProvider({
|
|
|
733
848
|
: 'text'
|
|
734
849
|
: 'noop';
|
|
735
850
|
const coalesceKey = `inspector:${target.line}:${target.column}:${first?.kind ?? 'noop'}:${opKey}`;
|
|
851
|
+
const reveal = [captureRevealTarget(target)];
|
|
736
852
|
history.record({
|
|
737
853
|
coalesceKey,
|
|
738
|
-
|
|
854
|
+
pageIndex,
|
|
855
|
+
undo: () => {
|
|
856
|
+
restoreSnapshot(target.line, target.column, snaps);
|
|
857
|
+
revealTargets(reveal, pageIndex);
|
|
858
|
+
},
|
|
739
859
|
redo: () => {
|
|
740
860
|
if (sharedOps.length) {
|
|
741
861
|
applyOpsRaw(
|
|
@@ -746,10 +866,21 @@ export function InspectorProvider({
|
|
|
746
866
|
);
|
|
747
867
|
}
|
|
748
868
|
if (textAfter.length) restoreSnapshot(target.line, target.column, textAfter, true);
|
|
869
|
+
revealTargets(reveal, pageIndex);
|
|
749
870
|
},
|
|
750
871
|
});
|
|
751
872
|
},
|
|
752
|
-
[
|
|
873
|
+
[
|
|
874
|
+
applyOpsRaw,
|
|
875
|
+
snapshotForOps,
|
|
876
|
+
restoreSnapshot,
|
|
877
|
+
findAnchor,
|
|
878
|
+
history,
|
|
879
|
+
ensureInstanceId,
|
|
880
|
+
slideId,
|
|
881
|
+
pageIndex,
|
|
882
|
+
revealTargets,
|
|
883
|
+
],
|
|
753
884
|
);
|
|
754
885
|
|
|
755
886
|
const bufferBatch = useCallback(
|
|
@@ -763,21 +894,35 @@ export function InspectorProvider({
|
|
|
763
894
|
snapshotForOps(edit.line, edit.column, edit.anchor, edit.ops),
|
|
764
895
|
);
|
|
765
896
|
for (const edit of edits) applyOpsRaw(edit.line, edit.column, edit.anchor, edit.ops);
|
|
897
|
+
const reveal = edits.map(captureRevealTarget);
|
|
766
898
|
history.record({
|
|
767
899
|
coalesceKey,
|
|
900
|
+
pageIndex,
|
|
768
901
|
undo: () => {
|
|
769
902
|
for (let index = edits.length - 1; index >= 0; index--) {
|
|
770
903
|
const edit = edits[index];
|
|
771
904
|
restoreSnapshot(edit.line, edit.column, snapshots[index]);
|
|
772
905
|
}
|
|
906
|
+
revealTargets(reveal, pageIndex);
|
|
773
907
|
},
|
|
774
908
|
redo: () => {
|
|
775
909
|
for (const edit of edits)
|
|
776
910
|
applyOpsRaw(edit.line, edit.column, findAnchor(edit.line, edit.column), edit.ops);
|
|
911
|
+
revealTargets(reveal, pageIndex);
|
|
777
912
|
},
|
|
778
913
|
});
|
|
779
914
|
},
|
|
780
|
-
[
|
|
915
|
+
[
|
|
916
|
+
applyOpsRaw,
|
|
917
|
+
snapshotForOps,
|
|
918
|
+
restoreSnapshot,
|
|
919
|
+
findAnchor,
|
|
920
|
+
history,
|
|
921
|
+
committing,
|
|
922
|
+
slideId,
|
|
923
|
+
pageIndex,
|
|
924
|
+
revealTargets,
|
|
925
|
+
],
|
|
781
926
|
);
|
|
782
927
|
|
|
783
928
|
const visual = useVisualEditor({
|
|
@@ -1056,9 +1201,22 @@ export function InspectorProvider({
|
|
|
1056
1201
|
}, [pageIndex, slideId]);
|
|
1057
1202
|
|
|
1058
1203
|
useEffect(() => {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1204
|
+
setSelectionState([]);
|
|
1205
|
+
const pending = pendingRevealRef.current;
|
|
1206
|
+
if (!pending) return;
|
|
1207
|
+
if (pending.pageIndex !== pageIndex) {
|
|
1208
|
+
pendingRevealRef.current = null;
|
|
1209
|
+
return;
|
|
1210
|
+
}
|
|
1211
|
+
if (flushReveal()) return;
|
|
1212
|
+
const root = document.querySelector<HTMLElement>('[data-inspector-root]');
|
|
1213
|
+
if (!root) return;
|
|
1214
|
+
const observer = new MutationObserver(() => {
|
|
1215
|
+
if (flushReveal()) observer.disconnect();
|
|
1216
|
+
});
|
|
1217
|
+
observer.observe(root, { childList: true, subtree: true });
|
|
1218
|
+
return () => observer.disconnect();
|
|
1219
|
+
}, [pageIndex, flushReveal]);
|
|
1062
1220
|
|
|
1063
1221
|
useEffect(() => {
|
|
1064
1222
|
if (!selection.length) return;
|
|
@@ -1452,7 +1610,7 @@ export function InspectPanelButton() {
|
|
|
1452
1610
|
data-inspector-ui
|
|
1453
1611
|
>
|
|
1454
1612
|
<PanelRight className="size-3.5" />
|
|
1455
|
-
<span className="hidden
|
|
1613
|
+
<span className="hidden lg:inline">{t.inspector.format}</span>
|
|
1456
1614
|
</Button>
|
|
1457
1615
|
);
|
|
1458
1616
|
}
|
|
@@ -34,7 +34,7 @@ export function EditorSidebar({
|
|
|
34
34
|
data-editor-sidebar
|
|
35
35
|
inert={!open}
|
|
36
36
|
aria-hidden={!open}
|
|
37
|
-
className="flex h-full shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none"
|
|
37
|
+
className="flex h-full max-h-1/2 shrink-0 justify-end overflow-hidden bg-sidebar transition-[width] ease-swift motion-reduce:transition-none md:max-h-none"
|
|
38
38
|
style={{
|
|
39
39
|
width: animVisible ? PANEL_W : 0,
|
|
40
40
|
transitionDuration: `${PANEL_TRANSITION_MS}ms`,
|
|
@@ -2,9 +2,13 @@ import { Check, Loader2, Redo2, Save, Undo2 } from 'lucide-react';
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
import { usePanelMount } from '@/components/panel/panel-shell';
|
|
4
4
|
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { IS_APPLE } from '@/lib/keys';
|
|
5
6
|
import { useLocale } from '@/lib/use-locale';
|
|
6
7
|
import { cn } from '@/lib/utils';
|
|
7
8
|
|
|
9
|
+
const UNDO_SHORTCUT = IS_APPLE ? '⌘Z' : 'Ctrl Z';
|
|
10
|
+
const REDO_SHORTCUT = IS_APPLE ? '⇧⌘Z' : 'Ctrl Y';
|
|
11
|
+
|
|
8
12
|
type SaveCardProps = {
|
|
9
13
|
dirty: boolean;
|
|
10
14
|
committing: boolean;
|
|
@@ -79,7 +83,7 @@ export function SaveCard({
|
|
|
79
83
|
onClick={onUndo}
|
|
80
84
|
disabled={committing || !canUndo}
|
|
81
85
|
aria-label={t.common.undo}
|
|
82
|
-
title={t.common.undo}
|
|
86
|
+
title={`${t.common.undo} (${UNDO_SHORTCUT})`}
|
|
83
87
|
>
|
|
84
88
|
<Undo2 className="size-3.5" />
|
|
85
89
|
</Button>
|
|
@@ -90,7 +94,7 @@ export function SaveCard({
|
|
|
90
94
|
onClick={onRedo}
|
|
91
95
|
disabled={committing || !canRedo}
|
|
92
96
|
aria-label={t.common.redo}
|
|
93
|
-
title={t.common.redo}
|
|
97
|
+
title={`${t.common.redo} (${REDO_SHORTCUT})`}
|
|
94
98
|
>
|
|
95
99
|
<Redo2 className="size-3.5" />
|
|
96
100
|
</Button>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ReactNode, useRef } from 'react';
|
|
2
|
+
import { type StepController, StepHost } from '../lib/step-context';
|
|
3
|
+
|
|
4
|
+
export function PreviewStepHost({ revealed, children }: { revealed: number; children: ReactNode }) {
|
|
5
|
+
const noopControllerRef = useRef<StepController | null>(null);
|
|
6
|
+
return (
|
|
7
|
+
<StepHost
|
|
8
|
+
isActivePage={false}
|
|
9
|
+
entryDirection="jump"
|
|
10
|
+
controllerRef={noopControllerRef}
|
|
11
|
+
controlledRevealed={revealed}
|
|
12
|
+
>
|
|
13
|
+
{children}
|
|
14
|
+
</StepHost>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plus, Search } from 'lucide-react';
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { toast } from 'sonner';
|
|
4
|
-
import logo from '@/assets/open-slide.
|
|
4
|
+
import logo from '@/assets/open-slide.svg';
|
|
5
5
|
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
|
6
6
|
import type { Folder, FolderIcon } from '@/lib/sdk';
|
|
7
7
|
import { format, useLocale } from '@/lib/use-locale';
|
|
@@ -135,7 +135,7 @@ export function Sidebar({
|
|
|
135
135
|
alt=""
|
|
136
136
|
aria-hidden
|
|
137
137
|
draggable={false}
|
|
138
|
-
className="size-6 shrink-0 select-none
|
|
138
|
+
className="size-6 shrink-0 select-none"
|
|
139
139
|
/>
|
|
140
140
|
<h1 className="font-heading text-[13.5px] font-semibold tracking-tight">
|
|
141
141
|
{t.home.appTitle}
|
|
@@ -809,7 +809,7 @@ export function SlideTransitionLayer({
|
|
|
809
809
|
</div>
|
|
810
810
|
) : null}
|
|
811
811
|
{CurrentPage ? (
|
|
812
|
-
<div ref={incomingLayerRef} className="absolute inset-0">
|
|
812
|
+
<div ref={incomingLayerRef} data-osd-current-page={current} className="absolute inset-0">
|
|
813
813
|
<SlidePageProvider index={current} total={total}>
|
|
814
814
|
<StepHost
|
|
815
815
|
isActivePage
|
|
@@ -197,12 +197,13 @@ export function DesignToggleButton({
|
|
|
197
197
|
size="sm"
|
|
198
198
|
variant={active ? 'default' : 'ghost'}
|
|
199
199
|
onClick={onToggle}
|
|
200
|
+
aria-label={t.stylePanel.designToggle}
|
|
200
201
|
data-design-ui
|
|
201
202
|
title={t.stylePanel.designToggleTitle}
|
|
202
203
|
>
|
|
203
204
|
<Palette className="size-3.5" />
|
|
204
|
-
<span className="hidden
|
|
205
|
-
<kbd className="ml-1 hidden rounded-[3px] bg-foreground/10 px-1 font-mono text-[9.5px] tracking-[0.04em]
|
|
205
|
+
<span className="hidden lg:inline">{t.stylePanel.designToggle}</span>
|
|
206
|
+
<kbd className="ml-1 hidden rounded-[3px] bg-foreground/10 px-1 font-mono text-[9.5px] tracking-[0.04em] lg:inline">
|
|
206
207
|
D
|
|
207
208
|
</kbd>
|
|
208
209
|
</Button>
|
|
@@ -103,6 +103,7 @@ export function ThumbnailRail({
|
|
|
103
103
|
const virtualListRef = useRef<HTMLDivElement | null>(null);
|
|
104
104
|
const verticalViewportRef = useRef<HTMLElement | null>(null);
|
|
105
105
|
const focusCurrentAfterScrollRef = useRef(false);
|
|
106
|
+
const focusAfterArrowRef = useRef(false);
|
|
106
107
|
const [currentPosition, setCurrentPosition] = useState<ThumbnailOffscreenDirection>(null);
|
|
107
108
|
const t = useLocale();
|
|
108
109
|
|
|
@@ -172,6 +173,32 @@ export function ThumbnailRail({
|
|
|
172
173
|
return () => cancelAnimationFrame(frame);
|
|
173
174
|
}, [currentPosition]);
|
|
174
175
|
|
|
176
|
+
useLayoutEffect(() => {
|
|
177
|
+
if (!focusAfterArrowRef.current || !activeRef.current) return;
|
|
178
|
+
activeRef.current.focus({ preventScroll: true });
|
|
179
|
+
focusAfterArrowRef.current = false;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const onThumbnailArrowKeyDown = useCallback(
|
|
183
|
+
(event: React.KeyboardEvent<HTMLButtonElement>, index: number) => {
|
|
184
|
+
if (event.altKey || event.ctrlKey || event.metaKey || event.nativeEvent.isComposing) return;
|
|
185
|
+
const direction =
|
|
186
|
+
event.key === 'ArrowRight' || event.key === 'ArrowDown'
|
|
187
|
+
? 1
|
|
188
|
+
: event.key === 'ArrowLeft' || event.key === 'ArrowUp'
|
|
189
|
+
? -1
|
|
190
|
+
: 0;
|
|
191
|
+
if (!direction) return;
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
event.stopPropagation();
|
|
194
|
+
const next = Math.min(Math.max(index + direction, 0), pages.length - 1);
|
|
195
|
+
if (next === index) return;
|
|
196
|
+
focusAfterArrowRef.current = true;
|
|
197
|
+
onSelect(next);
|
|
198
|
+
},
|
|
199
|
+
[onSelect, pages.length],
|
|
200
|
+
);
|
|
201
|
+
|
|
175
202
|
const renderThumb = useCallback(
|
|
176
203
|
(PageComp: Page, i: number) => {
|
|
177
204
|
const active = i === current;
|
|
@@ -195,6 +222,7 @@ export function ThumbnailRail({
|
|
|
195
222
|
active={active}
|
|
196
223
|
activeRef={active ? activeRef : undefined}
|
|
197
224
|
onSelect={() => onSelect(i)}
|
|
225
|
+
onArrowKeyDown={(event) => onThumbnailArrowKeyDown(event, i)}
|
|
198
226
|
ariaLabel={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
199
227
|
>
|
|
200
228
|
{inner}
|
|
@@ -204,6 +232,7 @@ export function ThumbnailRail({
|
|
|
204
232
|
type="button"
|
|
205
233
|
ref={active ? activeRef : undefined}
|
|
206
234
|
onClick={() => onSelect(i)}
|
|
235
|
+
onKeyDown={(event) => onThumbnailArrowKeyDown(event, i)}
|
|
207
236
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
208
237
|
aria-current={active ? 'page' : undefined}
|
|
209
238
|
className={thumbButtonClass(active)}
|
|
@@ -235,6 +264,7 @@ export function ThumbnailRail({
|
|
|
235
264
|
moduleTransition,
|
|
236
265
|
onReorder,
|
|
237
266
|
onSelect,
|
|
267
|
+
onThumbnailArrowKeyDown,
|
|
238
268
|
pages.length,
|
|
239
269
|
scale,
|
|
240
270
|
thumbWidth,
|
|
@@ -256,6 +286,7 @@ export function ThumbnailRail({
|
|
|
256
286
|
actions={actions}
|
|
257
287
|
activeRef={activeRef}
|
|
258
288
|
onSelect={onSelect}
|
|
289
|
+
onArrowKeyDown={onThumbnailArrowKeyDown}
|
|
259
290
|
scale={scale}
|
|
260
291
|
thumbWidth={horizontalWidth}
|
|
261
292
|
/>
|
|
@@ -411,6 +442,7 @@ function HorizontalVirtualThumbList({
|
|
|
411
442
|
actions,
|
|
412
443
|
activeRef,
|
|
413
444
|
onSelect,
|
|
445
|
+
onArrowKeyDown,
|
|
414
446
|
scale,
|
|
415
447
|
thumbWidth,
|
|
416
448
|
}: {
|
|
@@ -420,6 +452,7 @@ function HorizontalVirtualThumbList({
|
|
|
420
452
|
actions?: ThumbnailActions;
|
|
421
453
|
activeRef: React.MutableRefObject<HTMLButtonElement | null>;
|
|
422
454
|
onSelect: (index: number) => void;
|
|
455
|
+
onArrowKeyDown: (event: React.KeyboardEvent<HTMLButtonElement>, index: number) => void;
|
|
423
456
|
scale: number;
|
|
424
457
|
thumbWidth: number;
|
|
425
458
|
}) {
|
|
@@ -498,6 +531,7 @@ function HorizontalVirtualThumbList({
|
|
|
498
531
|
type="button"
|
|
499
532
|
ref={active ? activeRef : undefined}
|
|
500
533
|
onClick={() => onSelect(i)}
|
|
534
|
+
onKeyDown={(event) => onArrowKeyDown(event, i)}
|
|
501
535
|
aria-label={format(t.thumbnailRail.goToPageAria, { n: i + 1 })}
|
|
502
536
|
aria-current={active ? 'page' : undefined}
|
|
503
537
|
className={cn(
|
|
@@ -921,6 +955,7 @@ function SortableThumb({
|
|
|
921
955
|
active,
|
|
922
956
|
activeRef,
|
|
923
957
|
onSelect,
|
|
958
|
+
onArrowKeyDown,
|
|
924
959
|
ariaLabel,
|
|
925
960
|
children,
|
|
926
961
|
...rest
|
|
@@ -929,6 +964,7 @@ function SortableThumb({
|
|
|
929
964
|
active: boolean;
|
|
930
965
|
activeRef: React.MutableRefObject<HTMLButtonElement | null> | undefined;
|
|
931
966
|
onSelect: () => void;
|
|
967
|
+
onArrowKeyDown: React.KeyboardEventHandler<HTMLButtonElement>;
|
|
932
968
|
ariaLabel: string;
|
|
933
969
|
children: React.ReactNode;
|
|
934
970
|
} & Omit<
|
|
@@ -953,6 +989,7 @@ function SortableThumb({
|
|
|
953
989
|
ref={setRef}
|
|
954
990
|
type="button"
|
|
955
991
|
onClick={onSelect}
|
|
992
|
+
onKeyDownCapture={isDragging ? undefined : onArrowKeyDown}
|
|
956
993
|
aria-label={ariaLabel}
|
|
957
994
|
aria-current={active ? 'page' : undefined}
|
|
958
995
|
style={{
|
package/src/app/favicon.ico
CHANGED
|
Binary file
|