@signalsafe/slide-editor-react 0.0.0-stage → 0.1.2
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/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +86 -2
- package/RELEASING.md +44 -0
- package/dist/ResponsiveViewport.d.ts +14 -0
- package/dist/ResponsiveViewport.js +20 -0
- package/dist/SlideEditor.d.ts +20 -0
- package/dist/SlideEditor.js +31 -0
- package/dist/SlideInteractions.d.ts +22 -0
- package/dist/SlideInteractions.js +17 -0
- package/dist/SlideOutline.d.ts +16 -0
- package/dist/SlideOutline.js +14 -0
- package/dist/SlideOverview.d.ts +10 -0
- package/dist/SlideOverview.js +34 -0
- package/dist/SlidePlaybackControls.d.ts +10 -0
- package/dist/SlidePlaybackControls.js +22 -0
- package/dist/SlidePlayer.d.ts +13 -0
- package/dist/SlidePlayer.js +26 -0
- package/dist/SpeechControls.d.ts +21 -0
- package/dist/SpeechControls.js +186 -0
- package/dist/deck.d.ts +26 -0
- package/dist/deck.js +47 -0
- package/dist/narration.d.ts +10 -0
- package/dist/narration.js +37 -0
- package/dist/narrationDom.d.ts +3 -0
- package/dist/narrationDom.js +14 -0
- package/dist/slide-editor.css +55 -0
- package/dist/source-manifest.json +22 -0
- package/dist/styles.d.ts +2 -0
- package/dist/thumbnailObservers.d.ts +2 -0
- package/dist/thumbnailObservers.js +27 -0
- package/dist/useCanvasOverflow.d.ts +8 -0
- package/dist/useCanvasOverflow.js +51 -0
- package/dist/usePlayback.d.ts +14 -0
- package/dist/usePlayback.js +74 -0
- package/dist/validationIssueRows.d.ts +6 -0
- package/dist/validationIssueRows.js +10 -0
- package/docs/README.md +42 -0
- package/docs/current-state-summary.md +48 -0
- package/package.json +139 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## @signalsafe/slide-editor-react 0.1.2
|
|
4
|
+
|
|
5
|
+
- Fix the npm publication archive path. The 0.1.1 tag is retained as an unpublished release attempt.
|
|
6
|
+
- Preserve playback completion, narration sessions, seeking, visibility handling and overflow behavior under the React Hooks 7 rules.
|
|
7
|
+
- Adopt Content Editor 0.1.5 and the merged dependency updates.
|
|
8
|
+
- Support TypeScript 6 CSS declarations while retaining all four 100% coverage gates.
|
|
9
|
+
|
|
10
|
+
## @signalsafe/slide-editor-react 0.1.0
|
|
11
|
+
|
|
12
|
+
- Extract reusable typed deck operations, controlled editing and read-only playback.
|
|
13
|
+
- Share outline/overview, narration, interaction and viewport primitives without lesson or simulator dependencies.
|
|
14
|
+
- Move lesson contracts, workflow and provider integration into DeliveryPlus while preserving existing saved documents and pending inspector/draft fixes.
|
|
15
|
+
- Provide explicit exports, source fingerprints, MIT licensing, an independent synthetic demo and retained repository history.
|
|
16
|
+
- Preserve the legacy lesson release tags; slide releases use the `slide-editor-v` prefix.
|
|
17
|
+
|
|
18
|
+
Historical lesson-editor source and unpublished working differences were preserved
|
|
19
|
+
before extraction. The legacy distribution remains separate; this release does not
|
|
20
|
+
provide compatibility forwarding exports or rewrite saved lesson JSON.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Josh Martin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @signalsafe/slide-editor-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Documentation](docs/README.md) · [Current state](docs/current-state-summary.md) ·
|
|
4
|
+
[Live demo](https://signalsafesoftware.github.io/slide-editor-react/) ·
|
|
5
|
+
[npm](https://www.npmjs.com/package/@signalsafe/slide-editor-react) ·
|
|
6
|
+
[GitHub](https://github.com/SignalSafeSoftware/slide-editor-react) · [MIT license](LICENSE)
|
|
7
|
+
|
|
8
|
+
Reusable controlled slide editing and read-only presentation playback for React 18.
|
|
9
|
+
The package owns deck operations, outline/overview, playback clocks, speech controls,
|
|
10
|
+
interaction sessions and responsive viewport primitives. Hosts supply typed content
|
|
11
|
+
renderers, identifiers and persistence. Lesson contracts, metadata, publication,
|
|
12
|
+
actor-scoped recovery and simulator/image service adapters belong to DeliveryPlus.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @signalsafe/slide-editor-react react react-dom react-bootstrap bootstrap bootstrap-icons
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Load the host styles once:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
24
|
+
import 'bootstrap-icons/font/bootstrap-icons.css';
|
|
25
|
+
import '@signalsafe/content-editor-react/styles.css';
|
|
26
|
+
import '@signalsafe/slide-editor-react/styles.css';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Controlled editor
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useState } from 'react';
|
|
33
|
+
import { SlideEditor } from '@signalsafe/slide-editor-react/SlideEditor';
|
|
34
|
+
import type { Slide, SlideDeck } from '@signalsafe/slide-editor-react/deck';
|
|
35
|
+
|
|
36
|
+
export function PresentationEditor() {
|
|
37
|
+
const [deck, onChange] = useState<SlideDeck<Slide, string>>({
|
|
38
|
+
slides: [{ id: 'intro', title: 'Introduction', durationMs: 10000, transition: 'fade' }],
|
|
39
|
+
content: { intro: 'Your presentation.' },
|
|
40
|
+
});
|
|
41
|
+
return <SlideEditor deck={deck} onChange={onChange}
|
|
42
|
+
createSlide={() => ({
|
|
43
|
+
slide: { id: crypto.randomUUID(), title: 'New slide', durationMs: 10000, transition: 'fade' },
|
|
44
|
+
content: '',
|
|
45
|
+
})}
|
|
46
|
+
duplicateSlide={(slide, content) => ({
|
|
47
|
+
slide: { ...slide, id: crypto.randomUUID(), title: `${slide.title} (copy)` }, content,
|
|
48
|
+
})}
|
|
49
|
+
renderSlide={(slide, content, _time, update) => <label>{slide.title}
|
|
50
|
+
<textarea value={content} onChange={event => update(event.target.value)} />
|
|
51
|
+
</label>} />;
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Read-only player
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { SlidePlayer } from '@signalsafe/slide-editor-react/SlidePlayer';
|
|
59
|
+
|
|
60
|
+
<SlidePlayer deck={deck}
|
|
61
|
+
renderSlide={(slide, content, playback) => <article>
|
|
62
|
+
<h2>{slide.title}</h2><p>{content}</p>
|
|
63
|
+
<small>{playback.timeMs} ms</small>
|
|
64
|
+
</article>} />
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`SlidePlayer` supports controlled `slideId`/`onSlideChange`, completion callbacks,
|
|
68
|
+
and a narration-busy gate. Renderers receive the playback controller and volume
|
|
69
|
+
for typed content, timeline and speech composition. Hosts choose completion policy.
|
|
70
|
+
The editor also supplies this presentation state as its fifth renderer argument.
|
|
71
|
+
|
|
72
|
+
Validate incoming decks with `createSlideDeckSchema` from `/deck`, providing
|
|
73
|
+
validators for slide extensions and content. The neutral model has no required
|
|
74
|
+
lesson, phone payload, HTTP schema, authentication or browser draft store.
|
|
75
|
+
Use explicit export subpaths; there is no wildcard forwarding API.
|
|
76
|
+
|
|
77
|
+
## Development and migration
|
|
78
|
+
|
|
79
|
+
Use Node 24 and Yarn 1.22.22. Run `yarn check:boundaries`, `yarn typecheck`,
|
|
80
|
+
`yarn lint`, `yarn test:coverage`, `yarn build` and `yarn showcase:build`.
|
|
81
|
+
The independent demo contains synthetic string content and licensed icon assets.
|
|
82
|
+
|
|
83
|
+
The repository retains its predecessor history and tags. New slide releases use
|
|
84
|
+
`slide-editor-vVERSION` tags so historical lesson-editor tags remain unchanged.
|
|
85
|
+
DeliveryPlus retains the `deliveryplus-slides-v3` envelope and existing storage keys;
|
|
86
|
+
this package does not rename persisted lesson JSON or provide old lesson API aliases.
|
|
87
|
+
See [release procedure](RELEASING.md) and [migration boundaries](docs/README.md).
|
package/RELEASING.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Releases and Pages
|
|
2
|
+
|
|
3
|
+
Use Node 24 and Yarn 1.22.22. Run the established gates:
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
yarn install --frozen-lockfile --ignore-scripts
|
|
7
|
+
yarn check:boundaries
|
|
8
|
+
yarn typecheck
|
|
9
|
+
yarn lint
|
|
10
|
+
yarn test:coverage
|
|
11
|
+
yarn build
|
|
12
|
+
yarn showcase:build
|
|
13
|
+
npm pack --ignore-scripts --dry-run
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Keep all four slide coverage thresholds at 100%. Check ESM, declarations, CSS,
|
|
17
|
+
source fingerprints and shipped README, LICENSE, changelog and documentation.
|
|
18
|
+
Keep lesson/learning/simulator dependencies and host HTTP contracts out of portable
|
|
19
|
+
source. Validate packed consumers and actual host integration before adoption.
|
|
20
|
+
|
|
21
|
+
## Review and publication
|
|
22
|
+
|
|
23
|
+
Changes go through a pull request, Dependency review and the existing verify/Sonar
|
|
24
|
+
gate. Preserve history, existing tag identities, repository visibility and required
|
|
25
|
+
checks. The Pages workflow deploys checked synthetic demo assets from main using
|
|
26
|
+
the GitHub Pages environment and OIDC permissions.
|
|
27
|
+
|
|
28
|
+
New slide releases use `slide-editor-vVERSION`; legacy `vVERSION` tags identify the
|
|
29
|
+
predecessor package and must never be overwritten. A release tag must match the
|
|
30
|
+
manifest version. The release workflow re-verifies, packs and checks the exact
|
|
31
|
+
archive, stores its SHA-256 checksum, then publishes that archive to npm.
|
|
32
|
+
|
|
33
|
+
The first package publication requires authenticated npm maintainer access. After
|
|
34
|
+
bootstrap, configure npm trusted publishing for organization `SignalSafeSoftware`,
|
|
35
|
+
repository `slide-editor-react`, workflow `release.yml`, allowing publication.
|
|
36
|
+
Trusted publishing is tied to the repository identity and exact workflow filename.
|
|
37
|
+
The private repository visibility is preserved; do not assert public npm provenance
|
|
38
|
+
for a private source repository. Never expose a token in logs or committed files.
|
|
39
|
+
|
|
40
|
+
Verify the npm version, tarball integrity, source fingerprints and public demo after
|
|
41
|
+
publication. Only then replace DeliveryPlus's local migration candidate with the
|
|
42
|
+
exact registry version and integrity-pinned lockfile and remove its temporary local
|
|
43
|
+
candidate exception. Run host package/source checks, lint/types, focused integration
|
|
44
|
+
coverage and affected builds. Preserve unrelated uncommitted host work.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Explicit widths exercise the same container breakpoints as learner playback. */
|
|
2
|
+
export type SlideViewport = 'full' | 'desktop' | 'tablet' | 'mobile' | `${number}`;
|
|
3
|
+
export declare const SLIDE_VIEWPORTS: readonly Readonly<{
|
|
4
|
+
id: SlideViewport;
|
|
5
|
+
label: string;
|
|
6
|
+
width: number | undefined;
|
|
7
|
+
}>[];
|
|
8
|
+
export declare function viewportWidth(id: SlideViewport): number | undefined;
|
|
9
|
+
export declare function viewportId(width: number | null): SlideViewport;
|
|
10
|
+
export declare function ViewportSelect({ label, value, onChange }: Readonly<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: SlideViewport;
|
|
13
|
+
onChange: (value: SlideViewport) => void;
|
|
14
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EditorViewportSelect, EDITOR_VIEWPORT_PRESETS } from '@signalsafe/content-editor-react/EditorViewportSelect';
|
|
3
|
+
export const SLIDE_VIEWPORTS = [
|
|
4
|
+
{ id: 'full', label: 'Available', width: undefined },
|
|
5
|
+
...EDITOR_VIEWPORT_PRESETS.map(({ width, label }) => ({ id: width === 375 ? 'mobile' : width === 768 ? 'tablet' : width === 992 ? 'desktop' : `${width}`, label, width })),
|
|
6
|
+
];
|
|
7
|
+
export function viewportWidth(id) {
|
|
8
|
+
const width = SLIDE_VIEWPORTS.find(item => item.id === id)?.width ?? Number(id);
|
|
9
|
+
return Number.isInteger(width) && width >= 240 && width <= 7680 ? width : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function viewportId(width) {
|
|
12
|
+
if (width === null)
|
|
13
|
+
return 'full';
|
|
14
|
+
return SLIDE_VIEWPORTS.find(item => item.width === width)?.id ?? `${width}`;
|
|
15
|
+
}
|
|
16
|
+
export function ViewportSelect({ label, value, onChange }) {
|
|
17
|
+
const width = viewportWidth(value);
|
|
18
|
+
const options = SLIDE_VIEWPORTS.some(item => item.id === value) ? SLIDE_VIEWPORTS : [...SLIDE_VIEWPORTS, { id: value, label: `Custom (${width}px)`, width }];
|
|
19
|
+
return _jsx(EditorViewportSelect, { label: label, value: value, options: options, onChange: onChange });
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Slide, type SlideDeck } from './deck.js';
|
|
3
|
+
import { type SlidePlaybackState } from './usePlayback.js';
|
|
4
|
+
/** Controlled slide shell. Domain inspectors, data providers and content renderers are slots. */
|
|
5
|
+
export declare function SlideEditor<S extends Slide, C>({ deck, onChange, renderSlide, readOnly, label, createSlide, duplicateSlide, children }: Readonly<{
|
|
6
|
+
deck: SlideDeck<S, C>;
|
|
7
|
+
onChange?: (deck: SlideDeck<S, C>) => void;
|
|
8
|
+
renderSlide: (slide: S, content: C, timeMs: number, updateContent: (content: C) => void, playback: SlidePlaybackState) => ReactNode;
|
|
9
|
+
createSlide?: () => {
|
|
10
|
+
slide: S;
|
|
11
|
+
content: C;
|
|
12
|
+
};
|
|
13
|
+
duplicateSlide?: (slide: S, content: C) => {
|
|
14
|
+
slide: S;
|
|
15
|
+
content: C;
|
|
16
|
+
};
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
label?: string;
|
|
19
|
+
children?: ReactNode;
|
|
20
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { EditorSidebarLayout } from '@signalsafe/content-editor-react/EditorSidebarLayout';
|
|
4
|
+
import { EditorPanel } from '@signalsafe/content-editor-react/EditorPanel';
|
|
5
|
+
import { Button } from 'react-bootstrap';
|
|
6
|
+
import { SlideOutline } from './SlideOutline.js';
|
|
7
|
+
import { SlidePlaybackControls } from './SlidePlaybackControls.js';
|
|
8
|
+
import { insertSlide, removeSlide, replaceSlides, reorderSlide } from './deck.js';
|
|
9
|
+
import { usePlayback } from './usePlayback.js';
|
|
10
|
+
/** Controlled slide shell. Domain inspectors, data providers and content renderers are slots. */
|
|
11
|
+
export function SlideEditor({ deck, onChange, renderSlide, readOnly = false, label = 'Slide editor', createSlide, duplicateSlide, children }) {
|
|
12
|
+
const [selectedId, setSelectedId] = useState(deck.slides[0]?.id);
|
|
13
|
+
const [volume, setVolume] = useState(1);
|
|
14
|
+
const slide = deck.slides.find(item => item.id === selectedId) ?? deck.slides[0];
|
|
15
|
+
if (!slide)
|
|
16
|
+
throw new Error('A presentation must contain a slide.');
|
|
17
|
+
const playback = usePlayback(slide.durationMs, slide.id);
|
|
18
|
+
const editing = !readOnly && !!onChange;
|
|
19
|
+
const select = (index) => { playback.pause(); setSelectedId(deck.slides[index]?.id); };
|
|
20
|
+
return _jsx("section", { className: "slide-editor content-editor-shell", "aria-label": label, children: _jsxs(EditorSidebarLayout, { showRight: false, children: [_jsx("aside", { children: _jsx(EditorPanel, { title: "Slides", actions: editing && createSlide && _jsx(Button, { type: "button", size: "sm", onClick: () => {
|
|
21
|
+
const next = createSlide();
|
|
22
|
+
onChange?.(insertSlide(deck, next.slide, next.content));
|
|
23
|
+
setSelectedId(next.slide.id);
|
|
24
|
+
}, children: "Add slide" }), children: _jsx(SlideOutline, { slides: deck.slides, selectedId: slide.id, editing: !readOnly && !!onChange, expanded: false, actions: position => editing && _jsxs(_Fragment, { children: [duplicateSlide && _jsx(Button, { type: "button", size: "sm", "aria-label": `Duplicate slide ${position + 1}`, onClick: () => {
|
|
25
|
+
const original = deck.slides[position];
|
|
26
|
+
const next = duplicateSlide(original, deck.content[original.id]);
|
|
27
|
+
onChange?.(insertSlide(deck, next.slide, next.content, position + 1));
|
|
28
|
+
setSelectedId(next.slide.id);
|
|
29
|
+
}, children: "Duplicate" }), _jsx(Button, { type: "button", size: "sm", "aria-label": `Remove slide ${position + 1}`, disabled: deck.slides.length === 1, onClick: () => onChange?.(removeSlide(deck, deck.slides[position].id)), children: "Remove" })] }), onSelect: select, onToggle: select, onReorder: (source, target, after) => onChange?.(reorderSlide(deck, source, target, after)) }) }) }), _jsxs("div", { "data-slide-deck-current": true, children: [renderSlide(slide, deck.content[slide.id], playback.timeMs, content => { if (editing)
|
|
30
|
+
onChange?.(replaceSlides(deck, deck.slides, { ...deck.content, [slide.id]: content })); }, { ...playback, volume }), children, _jsx(SlidePlaybackControls, { playback: playback, durationMs: slide.durationMs, volume: volume, onVolume: setVolume })] })] }) });
|
|
31
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
/** Slides adapt navigation and playback to the generic content interaction session. */
|
|
3
|
+
export declare function SlideInteractionProvider({ children, onNavigate, canNavigate, ...session }: Readonly<{
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
authoring?: boolean;
|
|
6
|
+
resetKey?: string | number;
|
|
7
|
+
playbackActive?: boolean;
|
|
8
|
+
onNavigate?: (direction: 'next' | 'previous') => void;
|
|
9
|
+
canNavigate?: Readonly<{
|
|
10
|
+
next: boolean;
|
|
11
|
+
previous: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
blocks?: readonly Readonly<{
|
|
14
|
+
type?: string;
|
|
15
|
+
props: Readonly<{
|
|
16
|
+
id: string;
|
|
17
|
+
parentId?: string | null;
|
|
18
|
+
eventKey?: string | null;
|
|
19
|
+
}>;
|
|
20
|
+
}>[];
|
|
21
|
+
selectedId?: string;
|
|
22
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { ContentInteractionProvider } from '@signalsafe/content-editor-react/ContentInteractionProvider';
|
|
4
|
+
/** Slides adapt navigation and playback to the generic content interaction session. */
|
|
5
|
+
export function SlideInteractionProvider({ children, onNavigate, canNavigate, ...session }) {
|
|
6
|
+
const handleAction = useCallback((action) => {
|
|
7
|
+
if (action.action === 'next-slide')
|
|
8
|
+
onNavigate?.('next');
|
|
9
|
+
if (action.action === 'previous-slide')
|
|
10
|
+
onNavigate?.('previous');
|
|
11
|
+
}, [onNavigate]);
|
|
12
|
+
const next = canNavigate?.next;
|
|
13
|
+
const previous = canNavigate?.previous;
|
|
14
|
+
const canExecute = useCallback((action) => action.action === 'next-slide' ? next !== false :
|
|
15
|
+
action.action === 'previous-slide' ? previous !== false : true, [next, previous]);
|
|
16
|
+
return _jsx(ContentInteractionProvider, { ...session, onAction: handleAction, canExecute: canExecute, children: children });
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { KeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import type { Slide } from './deck.js';
|
|
3
|
+
/** Shared slide rows; hosts add their selected slide's content tree and domain actions. */
|
|
4
|
+
export declare function SlideOutline<S extends Slide>({ slides, selectedId, editing, expanded, title, onSelect, onToggle, onKeyDown, onReorder, actions, children }: Readonly<{
|
|
5
|
+
slides: readonly S[];
|
|
6
|
+
selectedId: string;
|
|
7
|
+
editing: boolean;
|
|
8
|
+
expanded: boolean;
|
|
9
|
+
title?: (slide: S) => string;
|
|
10
|
+
onSelect: (position: number) => void;
|
|
11
|
+
onToggle: (position: number) => void;
|
|
12
|
+
onKeyDown?: (event: KeyboardEvent<HTMLElement>, position: number) => void;
|
|
13
|
+
onReorder: (source: string, target: string, after?: boolean) => void;
|
|
14
|
+
actions?: (position: number) => ReactNode;
|
|
15
|
+
children?: ReactNode;
|
|
16
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ListGroup } from 'react-bootstrap';
|
|
3
|
+
import { EditorCollectionRow } from '@signalsafe/content-editor-react/EditorCollectionRow';
|
|
4
|
+
import { ReorderTarget } from '@signalsafe/content-editor-react/ReorderTarget';
|
|
5
|
+
import { ReorderHandle, SLIDE_DRAG_TYPE } from '@signalsafe/content-editor-react/ReorderHandle';
|
|
6
|
+
/** Shared slide rows; hosts add their selected slide's content tree and domain actions. */
|
|
7
|
+
export function SlideOutline({ slides, selectedId, editing, expanded, title, onSelect, onToggle, onKeyDown, onReorder, actions, children }) {
|
|
8
|
+
return _jsx(ListGroup, { variant: "flush", className: "slide-tree-list editor-tree-list", role: "region", "aria-label": "Slides and content", tabIndex: 0, children: slides.map((slide, position) => _jsxs("div", { children: [_jsx(ReorderTarget, { className: "slide-tree-row", type: SLIDE_DRAG_TYPE, label: `slide ${position + 1}`, onMove: (source, after) => { if (editing)
|
|
9
|
+
onReorder(source, slide.id, after); }, children: _jsx(EditorCollectionRow, { id: slide.id, index: position, title: title?.(slide) || slide.title, selected: slide.id === selectedId, current: slide.id === selectedId ? 'step' : undefined, expanded: editing ? slide.id === selectedId && expanded : undefined, toggleLabel: `${slide.id === selectedId && expanded ? 'Collapse' : 'Expand'} slide ${position + 1}`, onToggle: () => onToggle(position), onSelect: () => onSelect(position), onKeyDown: event => onKeyDown?.(event, position), handle: editing && _jsx(ReorderHandle, { id: slide.id, label: `slide ${position + 1}`, type: SLIDE_DRAG_TYPE, onMove: offset => {
|
|
10
|
+
const target = slides[position + offset];
|
|
11
|
+
if (target)
|
|
12
|
+
onReorder(slide.id, target.id, offset === 1);
|
|
13
|
+
} }), actions: actions?.(position) }) }), slide.id === selectedId && expanded && editing && children] }, slide.id)) });
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Slide } from './deck.js';
|
|
3
|
+
export declare function SlideOverview<S extends Slide>({ slides, renderThumbnail, selectedId, editing, onSelect, onReorder, }: Readonly<{
|
|
4
|
+
slides: readonly S[];
|
|
5
|
+
renderThumbnail: (slide: S) => ReactNode;
|
|
6
|
+
selectedId: string;
|
|
7
|
+
editing: boolean;
|
|
8
|
+
onSelect: (index: number) => void;
|
|
9
|
+
onReorder: (source: string, target: string, after?: boolean) => void;
|
|
10
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { collectionKeyIndex } from '@signalsafe/content-editor-react/collectionNavigation';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { ReorderHandle, SLIDE_DRAG_TYPE } from '@signalsafe/content-editor-react/ReorderHandle';
|
|
5
|
+
import { ReorderTarget } from '@signalsafe/content-editor-react/ReorderTarget';
|
|
6
|
+
import { observeSlideThumbnail } from './thumbnailObservers.js';
|
|
7
|
+
function SlideThumbnail({ children }) {
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const [width, setWidth] = useState(160);
|
|
10
|
+
const [visible, setVisible] = useState(typeof IntersectionObserver === 'undefined');
|
|
11
|
+
useEffect(() => observeSlideThumbnail(ref.current, setWidth, () => setVisible(true)), []);
|
|
12
|
+
return (_jsx("div", { ref: ref, className: "slide-thumbnail", "data-slide-thumbnail": true, "aria-hidden": "true", children: visible && _jsx("div", { className: "slide-thumbnail-viewport", style: { width: 1024, height: 576, transform: `scale(${width / 1024})` }, children: children }) }));
|
|
13
|
+
}
|
|
14
|
+
export function SlideOverview({ slides, renderThumbnail, selectedId, editing, onSelect, onReorder, }) {
|
|
15
|
+
return (_jsx("section", { className: "slide-overview p-2", "aria-label": "Slide overview", children: slides.map((slide, index) => (_jsxs(ReorderTarget, { type: SLIDE_DRAG_TYPE, label: `slide ${index + 1}`, className: "slide-overview-item", onMove: (source, after) => {
|
|
16
|
+
if (editing)
|
|
17
|
+
onReorder(source, slide.id, after);
|
|
18
|
+
}, children: [_jsxs("button", { type: "button", className: `btn w-100 text-start p-1 ${selectedId === slide.id ? 'btn-outline-primary' : 'btn-outline-secondary'}`, "aria-label": `Open slide ${index + 1}: ${slide.title}`, "aria-current": selectedId === slide.id ? 'step' : undefined, onClick: () => onSelect(index), onKeyDown: (event) => {
|
|
19
|
+
const next = collectionKeyIndex(event.key, index, slides.length, true);
|
|
20
|
+
if (next === undefined || !slides[next])
|
|
21
|
+
return;
|
|
22
|
+
event.preventDefault();
|
|
23
|
+
onSelect(next);
|
|
24
|
+
event.currentTarget
|
|
25
|
+
.closest('[aria-label="Slide overview"]')
|
|
26
|
+
?.querySelectorAll('[data-slide-overview-select]')
|
|
27
|
+
.item(next)
|
|
28
|
+
?.focus();
|
|
29
|
+
}, "data-slide-overview-select": true, children: [_jsx(SlideThumbnail, { children: renderThumbnail(slide) }), _jsxs("span", { className: "d-block text-truncate mt-1", children: [index + 1, ". ", slide.title] }), _jsxs("small", { className: "d-block text-body-secondary", children: [slide.durationMs / 1000, "s"] })] }), editing && (_jsx(ReorderHandle, { id: slide.id, type: SLIDE_DRAG_TYPE, label: `overview slide ${index + 1}`, onMove: (offset) => {
|
|
30
|
+
const target = slides[index + offset];
|
|
31
|
+
if (target)
|
|
32
|
+
onReorder(slide.id, target.id, offset === 1);
|
|
33
|
+
} }))] }, slide.id))) }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import type { usePlayback } from './usePlayback.js';
|
|
3
|
+
export declare function SlidePlaybackControls({ playback, timeline, durationMs, volume, onVolume, playDisabled, }: Readonly<{
|
|
4
|
+
playback: ReturnType<typeof usePlayback>;
|
|
5
|
+
timeline?: ReactNode;
|
|
6
|
+
durationMs: number;
|
|
7
|
+
volume: number;
|
|
8
|
+
onVolume: (volume: number) => void;
|
|
9
|
+
playDisabled?: boolean;
|
|
10
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import { Button, Form } from 'react-bootstrap';
|
|
4
|
+
export function SlidePlaybackControls({ playback, timeline, durationMs, volume, onVolume, playDisabled = false, }) {
|
|
5
|
+
const previousVolume = useRef(volume > 0 ? volume : 1);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (volume > 0)
|
|
8
|
+
previousVolume.current = volume;
|
|
9
|
+
}, [volume]);
|
|
10
|
+
const muted = volume === 0;
|
|
11
|
+
const soundAction = muted ? 'Unmute narration' : 'Mute narration';
|
|
12
|
+
let volumeIcon = 'up';
|
|
13
|
+
if (muted)
|
|
14
|
+
volumeIcon = 'mute';
|
|
15
|
+
else if (volume < 0.5)
|
|
16
|
+
volumeIcon = 'down';
|
|
17
|
+
return (_jsxs("footer", { className: "center-playback-footer", children: [timeline ?? (_jsx(Form.Range, { "aria-label": "Slide time", min: 0, max: durationMs, step: 100, value: playback.timeMs, onChange: (event) => playback.seek(Number(event.target.value)) })), _jsxs("div", { className: "d-flex justify-content-between align-items-center gap-2 flex-wrap", children: [_jsxs("div", { className: "slide-playback-actions d-flex flex-wrap align-items-center gap-2", children: [_jsx(Button, { type: "button", variant: "outline-secondary", size: "sm", "aria-label": playback.playing ? 'Pause' : 'Play', title: playback.playing ? 'Pause' : 'Play', disabled: !playback.playing && playDisabled, onClick: playback.playing ? playback.pause : playback.play, children: _jsx("i", { "aria-hidden": "true", className: `bi bi-${playback.playing ? 'pause-fill' : 'play-fill'}` }) }), _jsx(Button, { type: "button", variant: "outline-secondary", size: "sm", "aria-label": "Restart", title: "Restart", onClick: () => playback.seek(0), children: _jsx("i", { className: "bi bi-arrow-counterclockwise", "aria-hidden": "true" }) }), _jsx(Button, { type: "button", variant: "outline-secondary", size: "sm", "aria-label": soundAction, title: soundAction, "aria-pressed": muted, onClick: () => {
|
|
18
|
+
if (!muted)
|
|
19
|
+
previousVolume.current = volume;
|
|
20
|
+
onVolume(muted ? previousVolume.current : 0);
|
|
21
|
+
}, children: _jsx("i", { className: `bi bi-volume-${volumeIcon}-fill`, "aria-hidden": "true" }) }), _jsx(Form.Range, { className: "slide-volume", "aria-label": "Narration volume", min: 0, max: 1, step: 0.05, value: volume, onChange: (event) => onVolume(Number(event.target.value)) })] }), _jsxs("div", { className: "slide-playback-status ms-auto d-flex flex-wrap align-items-center gap-2", children: [_jsxs("output", { className: "text-nowrap", children: [(playback.timeMs / 1000).toFixed(1), "s / ", durationMs / 1000, "s"] }), _jsx(Form.Select, { className: "w-auto", size: "sm", "aria-label": "Playback speed", value: playback.speed, onChange: (event) => playback.setSpeed(Number(event.target.value)), children: [0.5, 0.75, 1, 1.25, 1.5, 2].map((speed) => (_jsxs("option", { value: speed, children: [speed, "\u00D7"] }, speed))) })] })] })] }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type Slide, type SlideDeck } from './deck.js';
|
|
3
|
+
import { type SlidePlaybackState } from './usePlayback.js';
|
|
4
|
+
/** A read-only presentation over typed host content; completion policy stays with the host. */
|
|
5
|
+
export declare function SlidePlayer<S extends Slide, C>({ deck, renderSlide, slideId, onSlideChange, onComplete, narrationBusy, label, }: Readonly<{
|
|
6
|
+
deck: SlideDeck<S, C>;
|
|
7
|
+
renderSlide: (slide: S, content: C, playback: SlidePlaybackState) => ReactNode;
|
|
8
|
+
slideId?: string;
|
|
9
|
+
onSlideChange?: (id: string) => void;
|
|
10
|
+
onComplete?: (slide: S) => void;
|
|
11
|
+
narrationBusy?: boolean;
|
|
12
|
+
label?: string;
|
|
13
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Button } from 'react-bootstrap';
|
|
4
|
+
import { replaceSlides } from './deck.js';
|
|
5
|
+
import { usePlayback } from './usePlayback.js';
|
|
6
|
+
import { SlidePlaybackControls } from './SlidePlaybackControls.js';
|
|
7
|
+
import { SlideInteractionProvider } from './SlideInteractions.js';
|
|
8
|
+
/** A read-only presentation over typed host content; completion policy stays with the host. */
|
|
9
|
+
export function SlidePlayer({ deck, renderSlide, slideId, onSlideChange, onComplete, narrationBusy = false, label = 'Slide presentation', }) {
|
|
10
|
+
replaceSlides(deck, deck.slides);
|
|
11
|
+
const [selected, select] = useState(deck.slides[0].id);
|
|
12
|
+
const [volume, setVolume] = useState(1);
|
|
13
|
+
const requested = slideId ?? selected;
|
|
14
|
+
const index = deck.slides.findIndex(slide => slide.id === requested);
|
|
15
|
+
const position = index < 0 ? 0 : index;
|
|
16
|
+
const slide = deck.slides[position];
|
|
17
|
+
const playback = usePlayback(slide.durationMs, slide.id, narrationBusy, () => onComplete?.(slide));
|
|
18
|
+
const navigate = (direction) => {
|
|
19
|
+
const target = deck.slides[position + (direction === 'next' ? 1 : -1)];
|
|
20
|
+
playback.pause();
|
|
21
|
+
select(target.id);
|
|
22
|
+
onSlideChange?.(target.id);
|
|
23
|
+
};
|
|
24
|
+
const canNavigate = { previous: position > 0, next: position < deck.slides.length - 1 };
|
|
25
|
+
return _jsxs("section", { className: "slide-editor content-editor-shell", "aria-label": label, children: [_jsx(SlideInteractionProvider, { resetKey: slide.id, playbackActive: playback.playing, onNavigate: navigate, canNavigate: canNavigate, children: _jsx("div", { "data-slide-deck-current": true, children: renderSlide(slide, deck.content[slide.id], { ...playback, volume }) }) }), _jsxs("nav", { "aria-label": "Slide navigation", className: "d-flex justify-content-between gap-2 p-2", children: [_jsx(Button, { type: "button", disabled: !canNavigate.previous, onClick: () => navigate('previous'), children: "Previous slide" }), _jsxs("span", { "aria-live": "polite", children: [position + 1, " / ", deck.slides.length] }), _jsx(Button, { type: "button", disabled: !canNavigate.next, onClick: () => navigate('next'), children: "Next slide" })] }), _jsx(SlidePlaybackControls, { playback: playback, durationMs: slide.durationMs, volume: volume, onVolume: setVolume })] });
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type NarrationSegment } from './narration.js';
|
|
2
|
+
export declare function SpeechControls({ settings, onSettingsChange, segments, contextKey, settingsTarget, playing, timeMs, speed, volume, onBusyChange, onError, resolveText, }: Readonly<{
|
|
3
|
+
settings: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
voice: string;
|
|
6
|
+
};
|
|
7
|
+
onSettingsChange?: (settings: {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
voice: string;
|
|
10
|
+
}) => void;
|
|
11
|
+
segments: readonly NarrationSegment[];
|
|
12
|
+
contextKey: string;
|
|
13
|
+
settingsTarget: HTMLElement | null;
|
|
14
|
+
playing: boolean;
|
|
15
|
+
timeMs: number;
|
|
16
|
+
speed: number;
|
|
17
|
+
volume: number;
|
|
18
|
+
onBusyChange: (busy: boolean) => void;
|
|
19
|
+
onError: () => void;
|
|
20
|
+
resolveText?: (segment: NarrationSegment) => string | undefined;
|
|
21
|
+
}>): import("react").JSX.Element;
|