@signalsafe/slide-editor-react 0.1.0 → 0.1.3
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 +19 -0
- package/README.md +28 -3
- package/RELEASING.md +4 -0
- package/dist/CopyComponentDialog.d.ts +10 -0
- package/dist/CopyComponentDialog.js +19 -0
- package/dist/CursorOverlay.d.ts +27 -0
- package/dist/CursorOverlay.js +134 -0
- package/dist/SlideCollectionPanel.d.ts +19 -0
- package/dist/SlideCollectionPanel.js +62 -0
- package/dist/SlideEditor.d.ts +2 -2
- package/dist/SlideEditor.js +6 -9
- package/dist/SlideInteractions.d.ts +2 -2
- package/dist/SlideIssuesPanel.d.ts +11 -0
- package/dist/SlideIssuesPanel.js +7 -0
- package/dist/SlideOutline.js +1 -1
- package/dist/SlideTimeline.d.ts +27 -0
- package/dist/SlideTimeline.js +65 -0
- package/dist/SlideWorkspace.d.ts +18 -0
- package/dist/SlideWorkspace.js +11 -0
- package/dist/SpeechControls.js +10 -6
- package/dist/slide-editor.css +243 -0
- package/dist/slideCommands.d.ts +23 -0
- package/dist/slideCommands.js +18 -0
- package/dist/source-manifest.json +18 -9
- package/dist/styles.d.ts +2 -0
- package/dist/useCanvasOverflow.d.ts +2 -2
- package/dist/useCanvasOverflow.js +3 -49
- package/dist/usePlayback.js +27 -23
- package/dist/useSlideWorkspace.d.ts +45 -0
- package/dist/useSlideWorkspace.js +83 -0
- package/docs/current-state-summary.md +19 -1
- package/package.json +47 -12
package/dist/SpeechControls.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
|
-
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
4
4
|
import { narrationStart } from './narration.js';
|
|
5
5
|
function narrationStatus(supported, enabled, status) {
|
|
6
6
|
if (!supported)
|
|
@@ -61,7 +61,6 @@ function beginNarration(session, synth, next, renderedText, segment, nextIndex,
|
|
|
61
61
|
if (current.current?.utterance !== next)
|
|
62
62
|
return;
|
|
63
63
|
current.current = null;
|
|
64
|
-
setSpokenText('');
|
|
65
64
|
processed.current = nextIndex - 1;
|
|
66
65
|
onBusyChange(false);
|
|
67
66
|
const explanation = `Narration could not play: ${message}. Disable Narration to continue silently.`;
|
|
@@ -100,8 +99,16 @@ export function SpeechControls({ settings, onSettingsChange, segments, contextKe
|
|
|
100
99
|
const speechPaused = useRef(false);
|
|
101
100
|
const processed = useRef(-1);
|
|
102
101
|
const latestTime = useRef(timeMs);
|
|
103
|
-
latestTime.current = timeMs;
|
|
102
|
+
useLayoutEffect(() => { latestTime.current = timeMs; }, [timeMs]);
|
|
104
103
|
const signature = JSON.stringify(segments);
|
|
104
|
+
const session = [contextKey, signature, segments, enabled, voice, speed, volume, supported, onBusyChange];
|
|
105
|
+
const [previousSession, setPreviousSession] = useState(session);
|
|
106
|
+
if (session.some((value, index) => !Object.is(value, previousSession[index]))) {
|
|
107
|
+
setPreviousSession(session);
|
|
108
|
+
setSpokenText('');
|
|
109
|
+
setStatus('Ready');
|
|
110
|
+
setError('');
|
|
111
|
+
}
|
|
105
112
|
useEffect(() => {
|
|
106
113
|
if (!supported)
|
|
107
114
|
return;
|
|
@@ -113,14 +120,11 @@ export function SpeechControls({ settings, onSettingsChange, segments, contextKe
|
|
|
113
120
|
}, [supported]);
|
|
114
121
|
useEffect(() => {
|
|
115
122
|
current.current = null;
|
|
116
|
-
setSpokenText('');
|
|
117
123
|
speechPaused.current = false;
|
|
118
124
|
processed.current = narrationStart(segments, latestTime.current) - 1;
|
|
119
125
|
if (supported)
|
|
120
126
|
window.speechSynthesis.cancel();
|
|
121
127
|
onBusyChange(false);
|
|
122
|
-
setStatus('Ready');
|
|
123
|
-
setError('');
|
|
124
128
|
return () => {
|
|
125
129
|
current.current = null;
|
|
126
130
|
if (supported)
|
package/dist/slide-editor.css
CHANGED
|
@@ -53,3 +53,246 @@
|
|
|
53
53
|
font: var(--bs-body-font-size) / var(--bs-body-line-height) var(--bs-body-font-family);
|
|
54
54
|
color: var(--bs-body-color);
|
|
55
55
|
}
|
|
56
|
+
|
|
57
|
+
/* Shared slide ruler and event markers. */
|
|
58
|
+
|
|
59
|
+
.lesson-callout-timeline {
|
|
60
|
+
background: var(--bs-body-bg);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.lesson-time-track {
|
|
64
|
+
position: relative;
|
|
65
|
+
height: 2rem;
|
|
66
|
+
background: var(--bs-tertiary-bg);
|
|
67
|
+
border: 1px solid var(--bs-border-color);
|
|
68
|
+
border-radius: var(--bs-border-radius);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.lesson-time-window {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
bottom: 0;
|
|
75
|
+
background: var(--bs-primary-bg-subtle);
|
|
76
|
+
border-inline: 2px solid var(--bs-primary);
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.lesson-time-range {
|
|
81
|
+
position: absolute;
|
|
82
|
+
inset: 0 auto 0 calc(var(--lesson-time-thumb-size, 1rem) / -2);
|
|
83
|
+
width: calc(100% + var(--lesson-time-thumb-size, 1rem));
|
|
84
|
+
margin: 0;
|
|
85
|
+
background: transparent;
|
|
86
|
+
pointer-events: none;
|
|
87
|
+
appearance: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.lesson-time-range::-webkit-slider-runnable-track {
|
|
91
|
+
background: transparent;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.lesson-time-range::-webkit-slider-thumb {
|
|
95
|
+
appearance: none;
|
|
96
|
+
width: var(--lesson-time-thumb-size, 1rem);
|
|
97
|
+
height: 1.75rem;
|
|
98
|
+
border: 2px solid var(--bs-body-bg);
|
|
99
|
+
border-radius: 0.25rem;
|
|
100
|
+
background: var(--bs-primary);
|
|
101
|
+
cursor: ew-resize;
|
|
102
|
+
pointer-events: auto;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.lesson-time-range::-moz-range-track {
|
|
106
|
+
background: transparent;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.lesson-time-range::-moz-range-thumb {
|
|
110
|
+
width: var(--lesson-time-thumb-size, 1rem);
|
|
111
|
+
height: 1.75rem;
|
|
112
|
+
border: 2px solid var(--bs-body-bg);
|
|
113
|
+
border-radius: 0.25rem;
|
|
114
|
+
background: var(--bs-primary);
|
|
115
|
+
cursor: ew-resize;
|
|
116
|
+
pointer-events: auto;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.lesson-time-range:focus-visible {
|
|
120
|
+
outline: 2px solid var(--bs-primary);
|
|
121
|
+
outline-offset: 3px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.lesson-time-start {
|
|
125
|
+
z-index: 1;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.lesson-time-end {
|
|
129
|
+
z-index: 2;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* One shared scale: round playback marker above the callout's rectangular bounds. */
|
|
133
|
+
.lesson-time-playhead {
|
|
134
|
+
z-index: 3;
|
|
135
|
+
top: -0.6rem;
|
|
136
|
+
bottom: auto;
|
|
137
|
+
height: 1rem;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.lesson-time-playhead::-webkit-slider-thumb {
|
|
141
|
+
width: var(--lesson-time-thumb-size, 1rem);
|
|
142
|
+
height: 1rem;
|
|
143
|
+
border-radius: 50%;
|
|
144
|
+
background: var(--bs-dark);
|
|
145
|
+
cursor: ew-resize;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.lesson-time-playhead::-moz-range-thumb {
|
|
149
|
+
width: var(--lesson-time-thumb-size, 1rem);
|
|
150
|
+
height: 1rem;
|
|
151
|
+
border-radius: 50%;
|
|
152
|
+
background: var(--bs-dark);
|
|
153
|
+
cursor: ew-resize;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.lesson-time-cursor {
|
|
157
|
+
position: absolute;
|
|
158
|
+
transform: translateX(-50%);
|
|
159
|
+
top: 0;
|
|
160
|
+
bottom: 0;
|
|
161
|
+
border-left: 2px solid var(--bs-dark);
|
|
162
|
+
pointer-events: none;
|
|
163
|
+
z-index: 2;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.lesson-time-playhead:focus-visible {
|
|
167
|
+
outline: none;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.lesson-time-playhead:focus-visible::-webkit-slider-thumb {
|
|
171
|
+
outline: 2px solid var(--bs-primary);
|
|
172
|
+
outline-offset: 2px;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.lesson-time-playhead:focus-visible::-moz-range-thumb {
|
|
176
|
+
outline: 2px solid var(--bs-primary);
|
|
177
|
+
outline-offset: 2px;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.lesson-timeline-event {
|
|
181
|
+
position: absolute;
|
|
182
|
+
z-index: 3;
|
|
183
|
+
top: -1.1rem;
|
|
184
|
+
width: 1rem;
|
|
185
|
+
height: 1rem;
|
|
186
|
+
padding: 0;
|
|
187
|
+
border: 2px solid var(--bs-body-bg);
|
|
188
|
+
border-radius: 50%;
|
|
189
|
+
background: var(--bs-info);
|
|
190
|
+
transform: translateX(-50%);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.lesson-timeline-event[aria-pressed='true'] {
|
|
194
|
+
outline: 2px solid var(--bs-primary);
|
|
195
|
+
outline-offset: 1px;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.lesson-timeline-motion {
|
|
199
|
+
position: absolute;
|
|
200
|
+
bottom: 0;
|
|
201
|
+
height: 0.25rem;
|
|
202
|
+
pointer-events: none;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
/* Same-time events share one exact clock position and remain individually selectable. */
|
|
207
|
+
.lesson-timeline-event-group {
|
|
208
|
+
position: absolute;
|
|
209
|
+
z-index: 4;
|
|
210
|
+
top: -2.25rem;
|
|
211
|
+
width: 5rem;
|
|
212
|
+
min-height: 0;
|
|
213
|
+
padding-block: 0.1rem;
|
|
214
|
+
font-size: 0.75rem;
|
|
215
|
+
transform: translateX(-50%);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.lesson-timeline-event-group[data-selected='true'] {
|
|
219
|
+
border-color: var(--bs-primary);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/* Shared cursor overlay. */
|
|
223
|
+
|
|
224
|
+
.lesson-demo-overlay {
|
|
225
|
+
position: absolute;
|
|
226
|
+
inset: 0;
|
|
227
|
+
pointer-events: none;
|
|
228
|
+
z-index: 10;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.lesson-demo-cursor {
|
|
232
|
+
position: absolute;
|
|
233
|
+
transform-origin: 1px 1px;
|
|
234
|
+
line-height: 0;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.lesson-demo-click {
|
|
238
|
+
position: absolute;
|
|
239
|
+
border: 3px solid currentColor;
|
|
240
|
+
border-radius: 50%;
|
|
241
|
+
transform: translate(-50%, -50%);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.lesson-slides-columns {
|
|
245
|
+
display: grid;
|
|
246
|
+
align-items: start;
|
|
247
|
+
}
|
|
248
|
+
.lesson-slides-columns > *,
|
|
249
|
+
.lesson-slide-center {
|
|
250
|
+
min-width: 0;
|
|
251
|
+
}
|
|
252
|
+
.slide-editor .lesson-slide-center {
|
|
253
|
+
border: 1px solid var(--bs-border-color);
|
|
254
|
+
border-radius: var(--bs-border-radius);
|
|
255
|
+
background: var(--bs-body-bg);
|
|
256
|
+
}
|
|
257
|
+
.slide-editor .lesson-slide-center:has(.slide-authoring) {
|
|
258
|
+
border: 0;
|
|
259
|
+
}
|
|
260
|
+
.slide-editor .lesson-slide-center:has(.slide-authoring) > .center-playback-footer {
|
|
261
|
+
border: 1px solid var(--bs-border-color);
|
|
262
|
+
border-radius: 0 0 var(--bs-border-radius) var(--bs-border-radius);
|
|
263
|
+
}
|
|
264
|
+
.slide-editor .slide-settings label {
|
|
265
|
+
display: block;
|
|
266
|
+
margin: 0;
|
|
267
|
+
}
|
|
268
|
+
.slide-editor .slide-settings label > :is(input, select) {
|
|
269
|
+
margin-top: 0.25rem;
|
|
270
|
+
}
|
|
271
|
+
.slide-editor .slide-settings {
|
|
272
|
+
display: grid;
|
|
273
|
+
gap: 0.75rem;
|
|
274
|
+
min-width: 0;
|
|
275
|
+
}
|
|
276
|
+
.slide-editor .lesson-slide-center:has(.slide-authoring:not([data-active-tab='Canvas']))
|
|
277
|
+
.center-playback-footer {
|
|
278
|
+
display: none;
|
|
279
|
+
}
|
|
280
|
+
.slide-editor .narration-settings {
|
|
281
|
+
border: 0;
|
|
282
|
+
display: flex;
|
|
283
|
+
flex-wrap: wrap;
|
|
284
|
+
align-items: center;
|
|
285
|
+
gap: 1rem;
|
|
286
|
+
}
|
|
287
|
+
.slide-editor .narration-settings label {
|
|
288
|
+
min-width: 0;
|
|
289
|
+
}
|
|
290
|
+
.slide-editor .narration-settings .editor-checkbox {
|
|
291
|
+
display: flex;
|
|
292
|
+
align-items: center;
|
|
293
|
+
gap: 0.5rem;
|
|
294
|
+
}
|
|
295
|
+
.slide-editor .narration-settings legend {
|
|
296
|
+
font-size: 1rem;
|
|
297
|
+
font-weight: 600;
|
|
298
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Slide, type SlideDeck } from './deck.js';
|
|
2
|
+
import type { useSlideWorkspace } from './useSlideWorkspace.js';
|
|
3
|
+
/** Pure deck commands with host-supplied identity/content factories and mutation policy. */
|
|
4
|
+
export declare function slideCommands<S extends Slide, C>({ deck, workspace, canAdd, onChange, create, duplicate: duplicateFactory }: Readonly<{
|
|
5
|
+
deck: SlideDeck<S, C>;
|
|
6
|
+
workspace: ReturnType<typeof useSlideWorkspace<S>>;
|
|
7
|
+
canAdd: boolean;
|
|
8
|
+
onChange: (deck: SlideDeck<S, C>, label: string) => void;
|
|
9
|
+
create: (index: number) => {
|
|
10
|
+
slide: S;
|
|
11
|
+
content: C;
|
|
12
|
+
};
|
|
13
|
+
duplicate: (slide: S, content: C) => {
|
|
14
|
+
slide: S;
|
|
15
|
+
content: C;
|
|
16
|
+
} | undefined;
|
|
17
|
+
}>): {
|
|
18
|
+
add: () => void;
|
|
19
|
+
duplicate: (position?: number) => void;
|
|
20
|
+
remove: (position?: number) => void;
|
|
21
|
+
move: (offset: number, position?: number) => void;
|
|
22
|
+
reorder: (sourceId: string, targetId: string, after?: boolean) => void;
|
|
23
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { insertSlide, removeSlide, reorderSlide } from './deck.js';
|
|
2
|
+
/** Pure deck commands with host-supplied identity/content factories and mutation policy. */
|
|
3
|
+
export function slideCommands({ deck, workspace, canAdd, onChange, create, duplicate: duplicateFactory }) {
|
|
4
|
+
const { index, editing, select, requestSlideFocus, setMoveAnnouncement } = workspace;
|
|
5
|
+
const add = () => { if (!editing || !canAdd)
|
|
6
|
+
return; const next = create(deck.slides.length); onChange(insertSlide(deck, next.slide, next.content), 'Slide added'); select(deck.slides.length); };
|
|
7
|
+
const duplicate = (position = index) => { if (!editing || !canAdd)
|
|
8
|
+
return; const source = deck.slides[position]; if (!source || !Object.hasOwn(deck.content, source.id))
|
|
9
|
+
return; const next = duplicateFactory(source, deck.content[source.id]); if (!next)
|
|
10
|
+
return; onChange(insertSlide(deck, next.slide, next.content, position + 1), 'Slide duplicated'); requestSlideFocus(next.slide.id); select(position + 1); };
|
|
11
|
+
const remove = (position = index) => { if (!editing || deck.slides.length <= 1)
|
|
12
|
+
return; const next = removeSlide(deck, deck.slides[position].id); onChange(next, 'Slide deleted'); const nextIndex = Math.min(position, next.slides.length - 1); requestSlideFocus(next.slides[nextIndex].id); select(nextIndex); };
|
|
13
|
+
const move = (offset, position = index) => { const target = position + offset; if (!editing || target < 0 || target >= deck.slides.length)
|
|
14
|
+
return; const source = deck.slides[position]; const slides = [...deck.slides]; slides.splice(position, 1); slides.splice(target, 0, source); onChange({ ...deck, slides }, 'Slide moved'); requestSlideFocus(source.id); select(target); };
|
|
15
|
+
const reorder = (sourceId, targetId, after = false) => { const source = deck.slides.find(item => item.id === sourceId); if (!editing || !source || sourceId === targetId)
|
|
16
|
+
return; const next = reorderSlide(deck, sourceId, targetId, after); onChange(next, 'Slide moved'); select(next.slides.findIndex(item => item.id === deck.slides[index].id)); setMoveAnnouncement(`Slide order updated. ${source.title} is now slide ${next.slides.indexOf(source) + 1}.`); };
|
|
17
|
+
return { add, duplicate, remove, move, reorder };
|
|
18
|
+
}
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
{
|
|
2
|
+
"src/CopyComponentDialog.tsx": "a94690c9b57eb47c808c343201e264b514880d59a423b091bce12865ef48b599",
|
|
3
|
+
"src/CursorOverlay.tsx": "35b5363627e9a0599e51273f2b185089c30b043ab234375f1cd34e695ed63c59",
|
|
2
4
|
"src/ResponsiveViewport.tsx": "f6ebba20cbc95e27a69e1ae98b002d38f21d00f3121822bc104b75815935d654",
|
|
3
|
-
"src/
|
|
4
|
-
"src/
|
|
5
|
-
"src/
|
|
5
|
+
"src/SlideCollectionPanel.tsx": "dc3cec042d9614f305199b6c5c24065eea74ef39a8ef6c2baf548877eeb5adaa",
|
|
6
|
+
"src/SlideEditor.tsx": "a66480d68a01fa0e58d985e7b1204e8358acf7f9ff3a7b131f2d9046be254826",
|
|
7
|
+
"src/SlideInteractions.tsx": "3cef67c530cd97e715ce264ec278c1dc5358eee32443dfd4eaa27dc23ee15dba",
|
|
8
|
+
"src/SlideIssuesPanel.tsx": "5aab462eeea585bc708e1b9d986b0565f508671bf68efffca252f6a1405ae966",
|
|
9
|
+
"src/SlideOutline.tsx": "e8cbcd8c1386c0f03bda744604add1e23fef0e3ae1431d1f2ab1f153678b0ee6",
|
|
6
10
|
"src/SlideOverview.tsx": "bc69f5813071ad7d2b4d8fe2b47c19b72556a4a7242897a3ff7f5e9fd10e82aa",
|
|
7
11
|
"src/SlidePlaybackControls.tsx": "d69fdf5646b9b72dc79df3d694c41f02a58b84b05dbf560142c30a8ef53a1eee",
|
|
8
12
|
"src/SlidePlayer.tsx": "8ad893667c8661d2dd805a112f54017d6fd5e3da7f6a170607abae107a8af158",
|
|
9
|
-
"src/
|
|
13
|
+
"src/SlideTimeline.tsx": "96af0dfe489b3283aa46c28e72cc26cc66296511318bf49392e689ef8fa9fe83",
|
|
14
|
+
"src/SlideWorkspace.tsx": "08d6a06ed5da0d252f01bd153038f0d1830a4b028de367f456fb34b2e31a1f13",
|
|
15
|
+
"src/SpeechControls.tsx": "e76ef5a6ddf8d2da1ab7ba5a8258e269523820b266d93cedf6d5cc19a6801226",
|
|
10
16
|
"src/deck.ts": "116360eaec4fa6dd44d5ffb859e4a3b64c2e85e33e89649fd4c1ab5346885b87",
|
|
11
17
|
"src/narration.ts": "9d299bfb41ddd7fad3a37f75b84229a7e14d21485e61dff8b4f63a2cdb82f4c8",
|
|
12
18
|
"src/narrationDom.ts": "63dc17012fe6208f78a6ad941efc953331a78d4e31dbfbe33a6f3577eafcd000",
|
|
13
|
-
"src/slide-editor.css": "
|
|
19
|
+
"src/slide-editor.css": "f55ffea7302cd0b3b5634d20b8316c0390375f7d2fbe40d9e94e3945347cde91",
|
|
20
|
+
"src/slideCommands.ts": "89c3883ca41e6ef82d60a4c4ea167a90b04a50a224865221e4593a87187991d0",
|
|
21
|
+
"src/styles.d.ts": "92928288338e79b01c9489616dd824dcddf1f22cb6a520056c8f516a69ea46cd",
|
|
14
22
|
"src/thumbnailObservers.ts": "07f2e0efb338d0826076bef72963b491b44894c3658d5425cfe0799f73794750",
|
|
15
|
-
"src/useCanvasOverflow.ts": "
|
|
16
|
-
"src/usePlayback.ts": "
|
|
23
|
+
"src/useCanvasOverflow.ts": "591fc96a2e31c43c87f95c4f05877f6c72069b9865e5a43710a12b1fe7198dc7",
|
|
24
|
+
"src/usePlayback.ts": "832e37693e73013f6dd37ed7f26c3432ff69a68cf2c1c541fe1f16f2e9ba20ae",
|
|
25
|
+
"src/useSlideWorkspace.ts": "46af462f6a0627be112efac4376c3d9d79e2c896a6e94ae7c6c5edd6a8cdc5d6",
|
|
17
26
|
"src/validationIssueRows.ts": "9aefc967eddbb5878ece976f54c364b346142855e65e4a3c6d8c5c6c6c482c9c",
|
|
18
|
-
"package.json": "
|
|
27
|
+
"package.json": "ab42eb5736ec48c0cc9a92e42d23659d90a48943f2bf0cd8fda9b801295a5fb3",
|
|
19
28
|
"tsconfig.json": "d0afb06c670b0c2aafbbd4809e34d79bb65a82073561efe96b6e86736fffb71e",
|
|
20
|
-
"scripts/build.mjs": "
|
|
29
|
+
"scripts/build.mjs": "9a9d3a89a1d811640dc3fcad70c03a2c38ec5fb6216003286d235d02651c5947"
|
|
21
30
|
}
|
package/dist/styles.d.ts
ADDED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
/** Slide consumers use the content owner's leaf-overflow measurement. */
|
|
3
3
|
export declare function useCanvasOverflow(canvas: RefObject<HTMLElement | null>, blocks: readonly {
|
|
4
4
|
type: string;
|
|
5
5
|
props: {
|
|
@@ -1,51 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
1
|
+
import { useContentOverflow } from '@signalsafe/content-editor-react/useContentOverflow';
|
|
2
|
+
/** Slide consumers use the content owner's leaf-overflow measurement. */
|
|
3
3
|
export function useCanvasOverflow(canvas, blocks, enabled, width, onChange) {
|
|
4
|
-
|
|
5
|
-
callback.current = onChange;
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
const element = canvas.current;
|
|
8
|
-
if (!enabled || !element) {
|
|
9
|
-
callback.current?.([]);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
let frame = 0;
|
|
13
|
-
const measure = () => {
|
|
14
|
-
cancelAnimationFrame(frame);
|
|
15
|
-
frame = requestAnimationFrame(() => {
|
|
16
|
-
const ids = blocks
|
|
17
|
-
.filter((block) => !['Row', 'Column'].includes(block.type))
|
|
18
|
-
.flatMap((block) => blockOverflows(element, block.props.id) ? [block.props.id] : []);
|
|
19
|
-
callback.current?.(ids);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure);
|
|
23
|
-
resize?.observe(element);
|
|
24
|
-
const observer = new MutationObserver(measure);
|
|
25
|
-
observer.observe(element, {
|
|
26
|
-
subtree: true,
|
|
27
|
-
childList: true,
|
|
28
|
-
characterData: true,
|
|
29
|
-
attributes: true,
|
|
30
|
-
attributeFilter: ['style', 'class', 'hidden'],
|
|
31
|
-
});
|
|
32
|
-
element.addEventListener('load', measure, true);
|
|
33
|
-
measure();
|
|
34
|
-
return () => {
|
|
35
|
-
cancelAnimationFrame(frame);
|
|
36
|
-
resize?.disconnect();
|
|
37
|
-
observer.disconnect();
|
|
38
|
-
element.removeEventListener('load', measure, true);
|
|
39
|
-
};
|
|
40
|
-
}, [canvas, blocks, enabled, width]);
|
|
41
|
-
}
|
|
42
|
-
function blockOverflows(element, id) {
|
|
43
|
-
const node = Array.from(element.querySelectorAll('[data-block-id]'))
|
|
44
|
-
.find((item) => item.dataset.blockId === id);
|
|
45
|
-
if (!node || node.querySelector('.content-inline-editor'))
|
|
46
|
-
return false;
|
|
47
|
-
const children = Array.from(node.children)
|
|
48
|
-
.filter((item) => !item.hasAttribute('data-slide-canvas-tools'));
|
|
49
|
-
return children.some((item) => item.clientWidth > 0 &&
|
|
50
|
-
item.scrollWidth > Math.min(item.clientWidth, node.clientWidth) + 2);
|
|
4
|
+
useContentOverflow(canvas, blocks, enabled, width, onChange);
|
|
51
5
|
}
|
package/dist/usePlayback.js
CHANGED
|
@@ -1,25 +1,41 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
2
2
|
export function usePlayback(durationMs, slideId, narrationBusy = false, onComplete) {
|
|
3
3
|
const [timeMs, setTimeMs] = useState(0);
|
|
4
|
-
const [
|
|
4
|
+
const [requestedPlaying, setPlaying] = useState(false);
|
|
5
|
+
const [completed, setCompleted] = useState(false);
|
|
5
6
|
const [speed, setSpeed] = useState(1);
|
|
6
|
-
const [revision, setRevision] = useState(
|
|
7
|
+
const [revision, setRevision] = useState(1);
|
|
8
|
+
const [context, setContext] = useState({ durationMs, slideId });
|
|
9
|
+
const contextChanged = !Object.is(context.durationMs, durationMs) || context.slideId !== slideId;
|
|
10
|
+
if (contextChanged) {
|
|
11
|
+
setContext({ durationMs, slideId });
|
|
12
|
+
setTimeMs(0);
|
|
13
|
+
setPlaying(false);
|
|
14
|
+
setCompleted(false);
|
|
15
|
+
setRevision(current => current + 1);
|
|
16
|
+
}
|
|
17
|
+
const playing = requestedPlaying && !completed;
|
|
18
|
+
if (!contextChanged && playing && timeMs >= durationMs && !narrationBusy)
|
|
19
|
+
setCompleted(true);
|
|
7
20
|
const complete = useRef(onComplete);
|
|
8
|
-
|
|
21
|
+
const position = useRef({ timeMs, narrationBusy });
|
|
9
22
|
const anchor = useRef(null);
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
complete.current = onComplete;
|
|
25
|
+
position.current = { timeMs, narrationBusy };
|
|
26
|
+
}, [onComplete, timeMs, narrationBusy]);
|
|
27
|
+
useLayoutEffect(() => { anchor.current = null; }, [slideId, durationMs]);
|
|
10
28
|
const pause = useCallback(() => {
|
|
11
29
|
setPlaying(false);
|
|
12
30
|
anchor.current = null;
|
|
13
31
|
}, []);
|
|
14
32
|
const seek = useCallback((next) => {
|
|
15
33
|
setPlaying(false);
|
|
34
|
+
setCompleted(false);
|
|
16
35
|
setTimeMs(Math.max(0, Math.min(durationMs, next)));
|
|
17
36
|
setRevision((current) => current + 1);
|
|
18
37
|
anchor.current = null;
|
|
19
38
|
}, [durationMs]);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
seek(0);
|
|
22
|
-
}, [slideId, seek]);
|
|
23
39
|
useEffect(() => {
|
|
24
40
|
const visibility = () => {
|
|
25
41
|
if (document.hidden)
|
|
@@ -45,26 +61,14 @@ export function usePlayback(durationMs, slideId, narrationBusy = false, onComple
|
|
|
45
61
|
};
|
|
46
62
|
}, [durationMs, playing, speed]);
|
|
47
63
|
useEffect(() => {
|
|
48
|
-
if (
|
|
49
|
-
pause();
|
|
64
|
+
if (completed)
|
|
50
65
|
complete.current?.();
|
|
51
|
-
|
|
52
|
-
}, [timeMs, durationMs, narrationBusy, playing, pause]);
|
|
53
|
-
const position = useRef({ timeMs, narrationBusy });
|
|
54
|
-
position.current = { timeMs, narrationBusy };
|
|
66
|
+
}, [completed]);
|
|
55
67
|
const play = useCallback(() => {
|
|
56
68
|
if (position.current.timeMs >= durationMs && !position.current.narrationBusy)
|
|
57
69
|
seek(0);
|
|
70
|
+
setCompleted(false);
|
|
58
71
|
setPlaying(true);
|
|
59
72
|
}, [durationMs, seek]);
|
|
60
|
-
return {
|
|
61
|
-
timeMs,
|
|
62
|
-
playing,
|
|
63
|
-
speed,
|
|
64
|
-
revision,
|
|
65
|
-
pause,
|
|
66
|
-
seek,
|
|
67
|
-
setSpeed,
|
|
68
|
-
play,
|
|
69
|
-
};
|
|
73
|
+
return { timeMs, playing, speed, revision, pause, seek, setSpeed, play };
|
|
70
74
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Slide } from './deck.js';
|
|
2
|
+
/** Selection, focus and continuous playback shared by slide-authoring workspaces. */
|
|
3
|
+
export declare function useSlideWorkspace<S extends Slide>(slides: readonly S[], readOnly?: boolean, onPreviewChange?: (preview: boolean) => void, options?: Readonly<{
|
|
4
|
+
selection?: 'index' | 'identity';
|
|
5
|
+
advanceOnComplete?: boolean;
|
|
6
|
+
}>): {
|
|
7
|
+
index: number;
|
|
8
|
+
root: import("react").RefObject<HTMLElement>;
|
|
9
|
+
requestSlideFocus: (id: string, target?: "row" | "inspector" | "child") => void;
|
|
10
|
+
moveAnnouncement: string;
|
|
11
|
+
setMoveAnnouncement: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
12
|
+
addOpen: boolean;
|
|
13
|
+
setAddOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
14
|
+
preview: boolean;
|
|
15
|
+
changePreview: (value: boolean) => void;
|
|
16
|
+
overview: boolean;
|
|
17
|
+
setOverview: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
18
|
+
continuous: boolean;
|
|
19
|
+
setContinuous: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
20
|
+
selection: number;
|
|
21
|
+
expanded: boolean;
|
|
22
|
+
setExpanded: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
23
|
+
inspector: HTMLElement | null;
|
|
24
|
+
setInspector: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
|
|
25
|
+
tree: HTMLElement | null;
|
|
26
|
+
setTree: import("react").Dispatch<import("react").SetStateAction<HTMLElement | null>>;
|
|
27
|
+
volume: number;
|
|
28
|
+
setVolume: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
29
|
+
setBusy: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
30
|
+
playback: {
|
|
31
|
+
timeMs: number;
|
|
32
|
+
playing: boolean;
|
|
33
|
+
speed: number;
|
|
34
|
+
revision: number;
|
|
35
|
+
pause: () => void;
|
|
36
|
+
seek: (next: number) => void;
|
|
37
|
+
setSpeed: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
38
|
+
play: () => void;
|
|
39
|
+
};
|
|
40
|
+
setRequestedIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
41
|
+
setRequestedId: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
42
|
+
select: (position: number) => void;
|
|
43
|
+
openComponentPicker: () => void;
|
|
44
|
+
editing: boolean;
|
|
45
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { findOutlineElement } from '@signalsafe/content-editor-react/collectionNavigation';
|
|
3
|
+
import { usePlayback } from './usePlayback.js';
|
|
4
|
+
/** Selection, focus and continuous playback shared by slide-authoring workspaces. */
|
|
5
|
+
export function useSlideWorkspace(slides, readOnly = false, onPreviewChange, options = {}) {
|
|
6
|
+
const [requestedIndex, setRequestedIndex] = useState(0);
|
|
7
|
+
const [requestedId, setRequestedId] = useState(slides[0]?.id);
|
|
8
|
+
const identityIndex = slides.findIndex(slide => slide.id === requestedId);
|
|
9
|
+
const index = options.selection === 'identity' ? Math.max(0, identityIndex) : slides[requestedIndex] ? requestedIndex : 0;
|
|
10
|
+
const root = useRef(null);
|
|
11
|
+
const focusSlide = useRef(undefined);
|
|
12
|
+
const collectionFocus = useRef('row');
|
|
13
|
+
const [moveAnnouncement, setMoveAnnouncement] = useState('');
|
|
14
|
+
const [addOpen, setAddOpen] = useState(false);
|
|
15
|
+
const [preview, setPreview] = useState(false);
|
|
16
|
+
const changePreview = (value) => { setPreview(value); onPreviewChange?.(value); };
|
|
17
|
+
const [overview, setOverview] = useState(false);
|
|
18
|
+
const [continuous, setContinuous] = useState(false);
|
|
19
|
+
const [selection, setSelection] = useState(0);
|
|
20
|
+
const [expanded, setExpanded] = useState(true);
|
|
21
|
+
const [inspector, setInspector] = useState(null);
|
|
22
|
+
const [tree, setTree] = useState(null);
|
|
23
|
+
const [busy, setBusy] = useState(false);
|
|
24
|
+
const [volume, setVolume] = useState(1);
|
|
25
|
+
const slide = slides[index];
|
|
26
|
+
const playback = usePlayback(slide?.durationMs ?? 0, slide?.id ?? '', busy, () => {
|
|
27
|
+
if (options.advanceOnComplete === false)
|
|
28
|
+
return;
|
|
29
|
+
if (index < slides.length - 1) {
|
|
30
|
+
setRequestedIndex(index + 1);
|
|
31
|
+
setRequestedId(slides[index + 1].id);
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
setContinuous(false);
|
|
35
|
+
});
|
|
36
|
+
const play = playback.play;
|
|
37
|
+
useEffect(() => { if (continuous)
|
|
38
|
+
play(); }, [slide?.id, continuous, play]);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!focusSlide.current)
|
|
41
|
+
return;
|
|
42
|
+
if (collectionFocus.current === 'row') {
|
|
43
|
+
findOutlineElement(root.current, 'data-outline-collection', focusSlide.current)?.focus();
|
|
44
|
+
focusSlide.current = undefined;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const target = collectionFocus.current;
|
|
48
|
+
const frame = requestAnimationFrame(() => {
|
|
49
|
+
if (target === 'inspector')
|
|
50
|
+
inspector?.querySelector('input, textarea, select')?.focus();
|
|
51
|
+
else {
|
|
52
|
+
const child = tree?.querySelector('[data-outline-block]');
|
|
53
|
+
child?.click();
|
|
54
|
+
child?.focus();
|
|
55
|
+
}
|
|
56
|
+
focusSlide.current = undefined;
|
|
57
|
+
collectionFocus.current = 'row';
|
|
58
|
+
});
|
|
59
|
+
return () => cancelAnimationFrame(frame);
|
|
60
|
+
}, [slides, index, selection, inspector, tree]);
|
|
61
|
+
const select = (position) => {
|
|
62
|
+
if (options.selection === 'identity') {
|
|
63
|
+
playback.pause();
|
|
64
|
+
setRequestedId(slides[position]?.id);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
setContinuous(false);
|
|
68
|
+
playback.pause();
|
|
69
|
+
playback.seek(0);
|
|
70
|
+
setRequestedIndex(position);
|
|
71
|
+
setExpanded(true);
|
|
72
|
+
setSelection(value => value + 1);
|
|
73
|
+
};
|
|
74
|
+
const openComponentPicker = () => { playback.pause(); setExpanded(true); setAddOpen(true); };
|
|
75
|
+
const requestSlideFocus = (id, target = 'row') => {
|
|
76
|
+
focusSlide.current = id;
|
|
77
|
+
collectionFocus.current = target;
|
|
78
|
+
};
|
|
79
|
+
return { index, root, requestSlideFocus, moveAnnouncement, setMoveAnnouncement,
|
|
80
|
+
addOpen, setAddOpen, preview, changePreview, overview, setOverview, continuous, setContinuous,
|
|
81
|
+
selection, expanded, setExpanded, inspector, setInspector, tree, setTree, volume, setVolume,
|
|
82
|
+
setBusy, playback, setRequestedIndex, setRequestedId, select, openComponentPicker, editing: !readOnly && !preview };
|
|
83
|
+
}
|