@open-slide/core 2.0.1 → 2.2.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-DOgOEZZA.js → build-DTmKJyjX.js} +1 -1
- package/dist/cli/bin.js +4 -4
- package/dist/{config-hT1o6Jct.js → config-Ces2X_3T.js} +159 -17
- package/dist/{config-GMR1QUlM.d.ts → config-CpmGqpQi.d.ts} +1 -1
- package/dist/{dev-_YkLNJRt.js → dev-ldYag-pR.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-pABcGTQh.js → preview-GYMbZvvk.js} +1 -1
- package/dist/{types-BcbaKTNY.d.ts → types-CvAqFqsY.d.ts} +10 -5
- package/dist/{update-moCkSyvg.js → update-CPBitJQq.js} +24 -14
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DlZoAc2-.js → zh-tw-B7_Oqv2q.js} +550 -17
- package/package.json +3 -3
- package/skills/apply-comments/SKILL.md +10 -6
- 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/icon-switcher-indicator.tsx +1 -1
- package/src/app/components/inspector/comment-layer.tsx +992 -0
- package/src/app/components/inspector/inspect-overlay.tsx +2 -39
- package/src/app/components/inspector/inspector-panel.tsx +9 -92
- package/src/app/components/inspector/inspector-provider.tsx +299 -67
- 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 +76 -1
- 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/inspector/freeze-motion.ts +61 -0
- package/src/app/lib/inspector/use-comments.ts +32 -3
- 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 +119 -70
- package/src/app/styles.css +64 -80
- package/src/locale/en.ts +7 -4
- package/src/locale/es.ts +550 -0
- package/src/locale/index.ts +1 -0
- package/src/locale/ja.ts +7 -5
- package/src/locale/types.ts +10 -5
- package/src/locale/zh-cn.ts +7 -4
- package/src/locale/zh-tw.ts +7 -4
- package/src/app/assets/open-slide.png +0 -0
- package/src/app/components/inspector/comment-widget.tsx +0 -119
|
@@ -5,7 +5,7 @@ description: Apply pending @slide-comment markers written by the open-slide insp
|
|
|
5
5
|
|
|
6
6
|
# Apply slide comments
|
|
7
7
|
|
|
8
|
-
The open-slide editor has
|
|
8
|
+
The open-slide editor has a comment mode that lets the user click a rendered page element, or drag across a region of the page, and attach a textual comment (e.g. *"make this red"*, *"change to 'Open Slide Rocks'"*). Each comment is persisted as an in-source JSX marker inside `slides/<slideId>/index.tsx`.
|
|
9
9
|
|
|
10
10
|
Your job: read those markers, perform the described edits, and delete the markers.
|
|
11
11
|
|
|
@@ -17,8 +17,10 @@ Your job: read those markers, perform the described edits, and delete the marker
|
|
|
17
17
|
{/* @slide-comment id="c-<8hex>" ts="<ISO>" text="<base64url(JSON)>" */}
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
- `text` is base64url-encoded JSON: `{"note": "...", "hint"?: "..."}`.
|
|
20
|
+
- Sits as the **first child inside** the JSX element it refers to (i.e. between that element's opening `>` and its other children). The marker is dropped *into* its target, not floated above it. Newly written markers get a line of their own; older ones may share a line with the content that follows them.
|
|
21
|
+
- `text` is base64url-encoded JSON: `{"note": "...", "hint"?: "...", "rect"?: {"x", "y", "w", "h"}, "page"?: n}`.
|
|
22
|
+
- `rect` is present when the comment was left on a dragged region rather than on an element. Values are pixels on the 1920×1080 page canvas, measured from the page's top-left corner. The marker still sits inside the deepest element that contains the region, but the note refers to what is *inside* that region — possibly several children, or only part of the enclosing element.
|
|
23
|
+
- `page` is the 0-based index (into the default export array) of the page the comment was left on.
|
|
22
24
|
- Detection regex (authoritative — use exactly this):
|
|
23
25
|
|
|
24
26
|
```
|
|
@@ -33,13 +35,14 @@ Your job: read those markers, perform the described edits, and delete the marker
|
|
|
33
35
|
|
|
34
36
|
2. **Read the file and find all markers.**
|
|
35
37
|
- Run the regex above against the whole file.
|
|
36
|
-
- For each match, base64url-decode `text` and `JSON.parse` it to get `{ note, hint? }`.
|
|
37
|
-
- Record each hit as `{ id, lineIndex (0-based), note, hint }`.
|
|
38
|
+
- For each match, base64url-decode `text` and `JSON.parse` it to get `{ note, hint?, rect?, page? }`.
|
|
39
|
+
- Record each hit as `{ id, lineIndex (0-based), note, hint, rect, page }`.
|
|
38
40
|
- If there are no markers, tell the user and stop.
|
|
39
41
|
|
|
40
42
|
3. **Understand each comment in context.**
|
|
41
43
|
- The targeted JSX element is the **enclosing** element of the marker — i.e. read upward from the marker line until you reach the unclosed JSX opening tag whose body the marker lives in. That element is the target. (For self-closing elements like `<img />`, the inspector hoists the marker to the nearest non-self-closing ancestor; in that case the comment usually refers to a child of the enclosing element rather than the enclosing element itself — use the `note` text to disambiguate.)
|
|
42
44
|
- Read enough surrounding code (parent element, sibling elements, inline styles) to apply the change faithfully. A comment inside a `<div>` with an inline `background` style usually refers to that element's styling, for example.
|
|
45
|
+
- When the payload has a `rect`, work out which children of the enclosing element fall inside that region (compare their positions and sizes against the rect on the 1920×1080 canvas) and apply the note to those — not to the whole enclosing element.
|
|
43
46
|
- If the `note` is ambiguous, do the smallest reasonable interpretation and mention the assumption in your summary.
|
|
44
47
|
|
|
45
48
|
4. **Apply edits in reverse line order.**
|
|
@@ -47,12 +50,13 @@ Your job: read those markers, perform the described edits, and delete the marker
|
|
|
47
50
|
- Processing top-down would invalidate line numbers for later markers as the file shrinks/grows.
|
|
48
51
|
|
|
49
52
|
5. **Remove each marker after applying its edit.**
|
|
50
|
-
- Delete the
|
|
53
|
+
- Delete the marker token. If nothing else is left on that line, delete the whole line including its trailing `\n`; if content shares the line, keep that content.
|
|
51
54
|
- Never leave a marker behind for an edit you applied — that signals a failure. Markers deliberately skipped per the edge cases below stay in place.
|
|
52
55
|
|
|
53
56
|
6. **Verify.**
|
|
54
57
|
- After all edits, re-read the file and confirm the only remaining markers are ones you reported as skipped.
|
|
55
58
|
- Confirm the edited JSX is well-formed (balanced tags, no dangling attributes). If the project's `package.json` has typecheck/lint scripts, run them with the project's package manager; scaffolded projects ship neither TypeScript nor a linter — there, rely on the running dev server (or the `build` script) to surface compile errors. Fix any errors you introduced.
|
|
59
|
+
- If the dev server is running, screenshot each edited page via `/s/<id>/preview?p=N` to confirm the change looks right — see **Previewing a page visually** in `slide-authoring`.
|
|
56
60
|
|
|
57
61
|
7. **Report.**
|
|
58
62
|
- Summarise: `N applied, M skipped` plus a one-line description of each change (including the slide id).
|
|
@@ -82,6 +82,8 @@ If the user asked for a speech script / speaker notes (in the initial request or
|
|
|
82
82
|
|
|
83
83
|
Run the checklist in `slide-authoring` ("Self-review before finishing"). It covers structural correctness, layout discipline, and asset existence.
|
|
84
84
|
|
|
85
|
+
If the dev server is already running, screenshot each page through the preview route and fix what looks off — see **Previewing a page visually** in `slide-authoring`.
|
|
86
|
+
|
|
85
87
|
## Step 8 — Hand off to the user
|
|
86
88
|
|
|
87
89
|
Tell the user:
|
|
@@ -95,6 +95,7 @@ User: "tighten the spacing on this page"
|
|
|
95
95
|
3. Read `pagePath` (e.g. `slides/q2-roadmap/index.tsx`).
|
|
96
96
|
4. Identify the page at `pageIndex` in the default-exported array.
|
|
97
97
|
5. Consult the `slide-authoring` skill for spacing rules, then edit that page in place.
|
|
98
|
+
6. To check the result visually, screenshot `s/<slideId>/preview?p=<pageNumber>` on the dev server — see **Previewing a page visually** in `slide-authoring`.
|
|
98
99
|
|
|
99
100
|
If `current.json` is missing or stale, ask: "Which slide and page should I tighten? The dev server hasn't published a current page recently."
|
|
100
101
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: slide-authoring
|
|
3
|
-
description: Technical reference for writing or editing open-slide pages — file contract, 1920×1080 canvas, type scale, layout, palette/visual direction, assets, speaker notes, stepped reveals, page transitions, and morph transitions. Consult this whenever you are about to write or modify any file under `slides/<id>/`, including from inside the `create-slide` or `apply-comments` workflows, or for any ad-hoc slide edit. Triggers on phrases like "edit slide", "tweak this page", "fix the layout", "change the palette", "reveal one by one", "add a transition", "morph transition", "write the speaker notes", "generate the script / talk track", "investigate the slide framework", "how do slides work here".
|
|
3
|
+
description: Technical reference for writing or editing open-slide pages — file contract, 1920×1080 canvas, type scale, layout, palette/visual direction, assets, speaker notes, stepped reveals, page transitions, and morph transitions. Consult this whenever you are about to write or modify any file under `slides/<id>/`, including from inside the `create-slide` or `apply-comments` workflows, or for any ad-hoc slide edit. Triggers on phrases like "edit slide", "tweak this page", "fix the layout", "change the palette", "reveal one by one", "add a transition", "morph transition", "write the speaker notes", "generate the script / talk track", "preview / screenshot a page", "check how it looks", "investigate the slide framework", "how do slides work here".
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Authoring open-slide pages
|
|
@@ -335,6 +335,35 @@ This applies whenever the *visual element* repeats, not whenever the *data* does
|
|
|
335
335
|
- Arrow keys / PageUp / PageDown navigate. `F` enters fullscreen play mode.
|
|
336
336
|
- In play mode: Space/→ next, ← prev, Esc exit.
|
|
337
337
|
- Hot reload: edit `index.tsx` and the browser updates live.
|
|
338
|
+
- Dev-only preview route `/s/<id>/preview?p=N` renders one page with no editor chrome — see **Previewing a page visually**.
|
|
339
|
+
|
|
340
|
+
## Previewing a page visually
|
|
341
|
+
|
|
342
|
+
After writing or editing a page, look at it — the vertical-budget math catches overflow, but not clashing colors, awkward wraps, or a broken image. While the dev server runs, every page has a chrome-less preview URL; don't drive the full editor UI (home → deck → thumbnail) to get there.
|
|
343
|
+
|
|
344
|
+
1. **Find the dev server.** Read `node_modules/.open-slide/server.json` (written on startup, removed on shutdown):
|
|
345
|
+
|
|
346
|
+
```json
|
|
347
|
+
{ "url": "http://localhost:5173/", "port": 5173, "pid": 41234, "startedAt": "…" }
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Missing file = the dev server isn't running. Don't start it yourself unless the user asked; skip the visual check and mention it in your hand-off.
|
|
351
|
+
|
|
352
|
+
2. **Open** `<url>s/<slideId>/preview?p=<pageNumber>` — `p` is 1-based. Add `&step=<n>` to show only the first `n` `<Step>`s of a stepped page (default: fully revealed).
|
|
353
|
+
|
|
354
|
+
3. **Wait** for `[data-osd-preview="ready"]` — set once fonts, `data-waitfor` targets, images, and entry animations have settled. It becomes `[data-osd-preview="error"]` instead when the slide id is unknown, the page is out of range, the page throws while rendering, or something hasn't settled within 10 s (a font or image never loaded, a `data-waitfor` target never appeared, an animation is still running); `[data-osd-preview-error]` holds the message. Fix the cause rather than screenshotting anyway.
|
|
355
|
+
|
|
356
|
+
4. **Screenshot** with a **1920×1080 viewport** so the page renders at native size (smaller viewports scale it down to fit). Use whatever browser tool you have (Playwright / Chrome MCP, a browser-automation tool). If the project already has Playwright installed, the CLI works too — `--no` stops `npx` from downloading it:
|
|
357
|
+
|
|
358
|
+
```bash
|
|
359
|
+
npx --no playwright screenshot --viewport-size "1920,1080" \
|
|
360
|
+
--wait-for-selector '[data-osd-preview="ready"]' \
|
|
361
|
+
"http://localhost:5173/s/<slideId>/preview?p=3" /tmp/<slideId>-p3.png
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
If no browser tool is available, don't install one without asking — skip the visual check.
|
|
365
|
+
|
|
366
|
+
Then view the image and fix what you see. The preview hot-reloads like the editor, and it never moves the user's cursor in `current.json`.
|
|
338
367
|
|
|
339
368
|
## Self-review before finishing
|
|
340
369
|
|
|
@@ -353,6 +382,7 @@ This applies whenever the *visual element* repeats, not whenever the *data* does
|
|
|
353
382
|
- [ ] If a `SlideTransition` is declared, every page sits in one family — same duration band (200–280 ms), same easing pair, same hold-then-fade-in shape (no enter delay, no `throughBackground` outside a deliberate section break), magnitude under 12 px / 3%. No six-different-vocabularies decks. When in doubt, omit transitions entirely. (Pages that opt into `morph` may exceed the band to match the morph — see `references/morph.md`.)
|
|
354
383
|
- [ ] If a transition opts into `morph`: every morph `id` is unique per page and stable across the pair, morph geometry is pixel-constant (never measured after mount), no `transform` sits on the morph node, and entrance animations are gated behind `useIsActivePage()`.
|
|
355
384
|
- [ ] If the user asked for a speech script / speaker notes, it lives in `export const notes` (index-aligned with the page array) — not in a markdown or text file.
|
|
385
|
+
- [ ] If the dev server is running, you previewed every page you touched (see **Previewing a page visually**) and fixed what looked off.
|
|
356
386
|
- [ ] Nothing outside `slides/<id>/` was edited.
|
|
357
387
|
|
|
358
388
|
## Anti-patterns
|
package/src/app/app.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { AssetsPage } from './routes/assets';
|
|
|
7
7
|
import { Home } from './routes/home';
|
|
8
8
|
import { HomeShell } from './routes/home-shell';
|
|
9
9
|
import { Presenter } from './routes/presenter';
|
|
10
|
+
import { Preview } from './routes/preview';
|
|
10
11
|
import { Slide } from './routes/slide';
|
|
11
12
|
import { ThemeDetailPage, ThemesGalleryPage } from './routes/themes';
|
|
12
13
|
|
|
@@ -27,6 +28,7 @@ export function App() {
|
|
|
27
28
|
)}
|
|
28
29
|
<Route path="/s/:slideId" element={<Slide />} />
|
|
29
30
|
<Route path="/s/:slideId/presenter" element={<Presenter />} />
|
|
31
|
+
{import.meta.env.DEV && <Route path="/s/:slideId/preview" element={<Preview />} />}
|
|
30
32
|
<Route path="*" element={<NotFound />} />
|
|
31
33
|
</Routes>
|
|
32
34
|
</TooltipProvider>
|
|
@@ -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: [] };
|