@interlacejs/editor 1.1.0 → 1.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/README.md +35 -8
- package/dist/index.cjs +1668 -1340
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -21
- package/dist/index.d.ts +99 -21
- package/dist/index.js +1556 -1225
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,57 +1,22 @@
|
|
|
1
1
|
// src/components/interlace-editor.tsx
|
|
2
2
|
import {
|
|
3
3
|
ContentInstance as ContentInstance2,
|
|
4
|
-
DEFAULT_STRINGS as DEFAULT_STRINGS5
|
|
4
|
+
DEFAULT_STRINGS as DEFAULT_STRINGS5,
|
|
5
|
+
themeToCssVariables
|
|
5
6
|
} from "@interlacejs/core";
|
|
6
|
-
import { useCallback as useCallback7, useEffect as
|
|
7
|
+
import { useCallback as useCallback7, useEffect as useEffect7, useMemo as useMemo2, useRef as useRef9, useState as useState6 } from "react";
|
|
7
8
|
|
|
8
9
|
// src/tokens.ts
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
surfaceRaised: "#f8fafc",
|
|
20
|
-
ground: "#f6f7f9",
|
|
21
|
-
errorBg: "#fef2f2",
|
|
22
|
-
errorText: "#b91c1c",
|
|
23
|
-
errorBorder: "#fecaca",
|
|
24
|
-
white: "#ffffff",
|
|
25
|
-
black: "#000000"
|
|
26
|
-
};
|
|
27
|
-
var FONTS = {
|
|
28
|
-
display: 'Georgia, "Times New Roman", Times, serif',
|
|
29
|
-
body: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
30
|
-
};
|
|
31
|
-
var SPACE = {
|
|
32
|
-
1: 4,
|
|
33
|
-
2: 8,
|
|
34
|
-
3: 12,
|
|
35
|
-
4: 16,
|
|
36
|
-
5: 24
|
|
37
|
-
};
|
|
38
|
-
var RADIUS = {
|
|
39
|
-
sm: 4,
|
|
40
|
-
md: 8,
|
|
41
|
-
lg: 12
|
|
42
|
-
};
|
|
43
|
-
var SHADOWS = {
|
|
44
|
-
sm: "0 1px 2px 0 rgba(15, 23, 42, 0.04)",
|
|
45
|
-
md: "0 4px 12px -2px rgba(15, 23, 42, 0.08)"
|
|
46
|
-
};
|
|
47
|
-
var TYPE = {
|
|
48
|
-
xs: 12,
|
|
49
|
-
sm: 13,
|
|
50
|
-
base: 15,
|
|
51
|
-
md: 16,
|
|
52
|
-
lg: 20,
|
|
53
|
-
xl: 24
|
|
54
|
-
};
|
|
10
|
+
import {
|
|
11
|
+
COLORS,
|
|
12
|
+
CONTROL_HEIGHT,
|
|
13
|
+
FOCUS_RING,
|
|
14
|
+
FONTS,
|
|
15
|
+
RADIUS,
|
|
16
|
+
SHADOWS,
|
|
17
|
+
SPACE,
|
|
18
|
+
TYPE
|
|
19
|
+
} from "@interlacejs/core";
|
|
55
20
|
|
|
56
21
|
// src/hooks/use-authoring-store.ts
|
|
57
22
|
import {
|
|
@@ -142,6 +107,9 @@ function useContentTypeEditorMount({
|
|
|
142
107
|
const mountedSessionRef = useRef(null);
|
|
143
108
|
const onChangeRef = useRef(onChange);
|
|
144
109
|
onChangeRef.current = onChange;
|
|
110
|
+
const stableOnChange = useRef(
|
|
111
|
+
(newData) => onChangeRef.current(newData)
|
|
112
|
+
).current;
|
|
145
113
|
const contentType = contentTypeId ? registry.get(contentTypeId) : void 0;
|
|
146
114
|
useEffect(() => {
|
|
147
115
|
const session = mountedSessionRef.current;
|
|
@@ -161,14 +129,14 @@ function useContentTypeEditorMount({
|
|
|
161
129
|
const isNewSession = !currentSession || currentSession.contentType !== contentType;
|
|
162
130
|
if (isNewSession) {
|
|
163
131
|
container.innerHTML = "";
|
|
164
|
-
contentType.renderEditor(container, data,
|
|
132
|
+
contentType.renderEditor(container, data, stableOnChange);
|
|
165
133
|
mountedSessionRef.current = { container, contentType };
|
|
166
134
|
} else if (contentType.updateEditor) {
|
|
167
|
-
contentType.updateEditor(container, data,
|
|
135
|
+
contentType.updateEditor(container, data, stableOnChange);
|
|
168
136
|
} else {
|
|
169
137
|
contentType.unmount?.(container);
|
|
170
138
|
container.innerHTML = "";
|
|
171
|
-
contentType.renderEditor(container, data,
|
|
139
|
+
contentType.renderEditor(container, data, stableOnChange);
|
|
172
140
|
mountedSessionRef.current = { container, contentType };
|
|
173
141
|
}
|
|
174
142
|
}, [active, contentTypeId, contentType, data, containerRef]);
|
|
@@ -217,88 +185,203 @@ function ContentTypeEditor({
|
|
|
217
185
|
import {
|
|
218
186
|
DEFAULT_STRINGS
|
|
219
187
|
} from "@interlacejs/core";
|
|
220
|
-
import { useCallback as useCallback3, useRef as
|
|
188
|
+
import { useCallback as useCallback3, useRef as useRef5, useState as useState2 } from "react";
|
|
221
189
|
|
|
222
190
|
// src/components/content-type-picker.tsx
|
|
223
|
-
import {
|
|
191
|
+
import { useRef as useRef3 } from "react";
|
|
192
|
+
|
|
193
|
+
// src/components/ui.tsx
|
|
194
|
+
import { ensureInterlaceStyles } from "@interlacejs/core";
|
|
195
|
+
import React2, { useEffect as useEffect2, useId } from "react";
|
|
224
196
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
197
|
+
function useInterlaceStyles() {
|
|
198
|
+
useEffect2(() => {
|
|
199
|
+
ensureInterlaceStyles();
|
|
200
|
+
}, []);
|
|
201
|
+
}
|
|
202
|
+
var Button = React2.forwardRef(
|
|
203
|
+
function Button2({ variant = "secondary", icon = false, className, type, ...rest }, ref) {
|
|
204
|
+
useInterlaceStyles();
|
|
205
|
+
const classes = [
|
|
206
|
+
"interlace-btn",
|
|
207
|
+
`interlace-btn--${variant}`,
|
|
208
|
+
icon ? "interlace-btn--icon" : null,
|
|
209
|
+
className
|
|
210
|
+
].filter(Boolean).join(" ");
|
|
211
|
+
return /* @__PURE__ */ jsx2("button", { ref, type: type ?? "button", className: classes, ...rest });
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
function Field({
|
|
215
|
+
label,
|
|
216
|
+
hint,
|
|
217
|
+
error,
|
|
218
|
+
children,
|
|
219
|
+
className,
|
|
220
|
+
style
|
|
221
|
+
}) {
|
|
222
|
+
useInterlaceStyles();
|
|
223
|
+
const id = useId();
|
|
224
|
+
const hintId = hint ? `${id}-hint` : void 0;
|
|
225
|
+
const errorId = error ? `${id}-error` : void 0;
|
|
226
|
+
const describedBy = [hintId, errorId].filter(Boolean).join(" ") || void 0;
|
|
227
|
+
return /* @__PURE__ */ jsxs(
|
|
228
|
+
"div",
|
|
229
|
+
{
|
|
230
|
+
className: ["interlace-field", className].filter(Boolean).join(" "),
|
|
231
|
+
style,
|
|
232
|
+
children: [
|
|
233
|
+
/* @__PURE__ */ jsx2("label", { className: "interlace-label", htmlFor: id, children: label }),
|
|
234
|
+
children({ id, describedBy, invalid: Boolean(error) }),
|
|
235
|
+
hint ? /* @__PURE__ */ jsx2("p", { id: hintId, className: "interlace-hint", children: hint }) : null,
|
|
236
|
+
error ? /* @__PURE__ */ jsx2(
|
|
237
|
+
"p",
|
|
238
|
+
{
|
|
239
|
+
id: errorId,
|
|
240
|
+
className: "interlace-hint",
|
|
241
|
+
style: { color: COLORS.errorText },
|
|
242
|
+
children: error
|
|
243
|
+
}
|
|
244
|
+
) : null
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
function SectionHeading({
|
|
250
|
+
children,
|
|
251
|
+
level = 3,
|
|
252
|
+
style
|
|
253
|
+
}) {
|
|
254
|
+
const Tag = level === 3 ? "h3" : "h4";
|
|
255
|
+
return /* @__PURE__ */ jsx2(
|
|
256
|
+
Tag,
|
|
257
|
+
{
|
|
258
|
+
style: {
|
|
259
|
+
margin: 0,
|
|
260
|
+
fontFamily: level === 3 ? FONTS.display : FONTS.body,
|
|
261
|
+
fontSize: level === 3 ? TYPE.md : TYPE.sm,
|
|
262
|
+
fontWeight: 600,
|
|
263
|
+
color: COLORS.text,
|
|
264
|
+
...style
|
|
265
|
+
},
|
|
266
|
+
children
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
function IssueList({
|
|
271
|
+
title,
|
|
272
|
+
issues,
|
|
273
|
+
children
|
|
274
|
+
}) {
|
|
275
|
+
return /* @__PURE__ */ jsxs(
|
|
276
|
+
"div",
|
|
277
|
+
{
|
|
278
|
+
role: "status",
|
|
279
|
+
style: {
|
|
280
|
+
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
281
|
+
borderRadius: RADIUS.md,
|
|
282
|
+
border: `1px solid ${COLORS.warningBorder}`,
|
|
283
|
+
background: COLORS.warningBg,
|
|
284
|
+
color: COLORS.warningText,
|
|
285
|
+
fontFamily: FONTS.body,
|
|
286
|
+
fontSize: TYPE.sm
|
|
287
|
+
},
|
|
288
|
+
children: [
|
|
289
|
+
/* @__PURE__ */ jsx2("strong", { style: { display: "block", marginBottom: SPACE[1] }, children: title }),
|
|
290
|
+
/* @__PURE__ */ jsx2("ul", { style: { margin: 0, paddingLeft: SPACE[4] }, children: issues.map((issue, i) => /* @__PURE__ */ jsx2("li", { children: issue }, i)) }),
|
|
291
|
+
children
|
|
292
|
+
]
|
|
293
|
+
}
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/components/content-type-picker.tsx
|
|
298
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
225
299
|
var ContentTypePicker = ({
|
|
226
300
|
registeredTypes,
|
|
301
|
+
options,
|
|
227
302
|
selectedType,
|
|
228
|
-
onSelect
|
|
303
|
+
onSelect,
|
|
304
|
+
label = "Content type"
|
|
229
305
|
}) => {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
/* @__PURE__ */ jsx2("span", { children: isOpen ? "\u25BC" : "\u25B6" })
|
|
254
|
-
]
|
|
255
|
-
}
|
|
256
|
-
),
|
|
257
|
-
isOpen && /* @__PURE__ */ jsx2(
|
|
258
|
-
"div",
|
|
259
|
-
{
|
|
260
|
-
style: {
|
|
261
|
-
position: "absolute",
|
|
262
|
-
top: "100%",
|
|
263
|
-
left: 0,
|
|
264
|
-
right: 0,
|
|
265
|
-
backgroundColor: COLORS.surface,
|
|
266
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
267
|
-
borderTop: "none",
|
|
268
|
-
borderRadius: `0 0 ${RADIUS.sm}px ${RADIUS.sm}px`,
|
|
269
|
-
maxHeight: "200px",
|
|
270
|
-
overflowY: "auto",
|
|
271
|
-
zIndex: 10,
|
|
272
|
-
boxShadow: SHADOWS.md
|
|
273
|
-
},
|
|
274
|
-
children: registeredTypes.map((typeId) => /* @__PURE__ */ jsx2(
|
|
275
|
-
"div",
|
|
306
|
+
useInterlaceStyles();
|
|
307
|
+
const items = options ?? registeredTypes.map((id) => ({ id }));
|
|
308
|
+
const refs = useRef3([]);
|
|
309
|
+
const selectedIndex = items.findIndex((item) => item.id === selectedType);
|
|
310
|
+
const handleKeyDown = (index) => (e) => {
|
|
311
|
+
const delta = e.key === "ArrowDown" || e.key === "ArrowRight" ? 1 : e.key === "ArrowUp" || e.key === "ArrowLeft" ? -1 : 0;
|
|
312
|
+
if (!delta) return;
|
|
313
|
+
e.preventDefault();
|
|
314
|
+
const next = (index + delta + items.length) % items.length;
|
|
315
|
+
refs.current[next]?.focus();
|
|
316
|
+
};
|
|
317
|
+
return /* @__PURE__ */ jsx3(
|
|
318
|
+
"div",
|
|
319
|
+
{
|
|
320
|
+
role: "radiogroup",
|
|
321
|
+
"aria-label": label,
|
|
322
|
+
"data-testid": "content-type-picker",
|
|
323
|
+
style: { display: "grid", gap: SPACE[2] },
|
|
324
|
+
children: items.map((item, index) => {
|
|
325
|
+
const checked = item.id === selectedType;
|
|
326
|
+
const tabbable = checked || selectedIndex === -1 && index === 0;
|
|
327
|
+
return /* @__PURE__ */ jsxs2(
|
|
328
|
+
"button",
|
|
276
329
|
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
setIsOpen(false);
|
|
280
|
-
},
|
|
281
|
-
style: {
|
|
282
|
-
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
283
|
-
cursor: "pointer",
|
|
284
|
-
backgroundColor: selectedType === typeId ? COLORS.accentLighter : COLORS.surface,
|
|
285
|
-
borderBottom: `1px solid ${COLORS.border}`,
|
|
286
|
-
color: selectedType === typeId ? COLORS.accent : COLORS.text,
|
|
287
|
-
fontSize: TYPE.base,
|
|
288
|
-
transition: "background-color 150ms ease"
|
|
330
|
+
ref: (el) => {
|
|
331
|
+
refs.current[index] = el;
|
|
289
332
|
},
|
|
290
|
-
|
|
333
|
+
type: "button",
|
|
334
|
+
role: "radio",
|
|
335
|
+
"aria-checked": checked,
|
|
336
|
+
tabIndex: tabbable ? 0 : -1,
|
|
337
|
+
className: "interlace-choice interlace-focusable",
|
|
338
|
+
"data-testid": `content-type-option-${item.id}`,
|
|
339
|
+
onClick: () => onSelect(item.id),
|
|
340
|
+
onKeyDown: handleKeyDown(index),
|
|
341
|
+
children: [
|
|
342
|
+
/* @__PURE__ */ jsx3(
|
|
343
|
+
"span",
|
|
344
|
+
{
|
|
345
|
+
"aria-hidden": "true",
|
|
346
|
+
style: {
|
|
347
|
+
flex: "none",
|
|
348
|
+
width: 16,
|
|
349
|
+
height: 16,
|
|
350
|
+
marginTop: 2,
|
|
351
|
+
borderRadius: "50%",
|
|
352
|
+
boxSizing: "border-box",
|
|
353
|
+
border: `2px solid ${checked ? COLORS.accent : COLORS.borderStrong}`,
|
|
354
|
+
boxShadow: checked ? `inset 0 0 0 3px ${COLORS.surface}` : "none",
|
|
355
|
+
background: checked ? COLORS.accent : COLORS.surface
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
),
|
|
359
|
+
/* @__PURE__ */ jsxs2("span", { style: { display: "grid", gap: 2 }, children: [
|
|
360
|
+
/* @__PURE__ */ jsx3(
|
|
361
|
+
"span",
|
|
362
|
+
{
|
|
363
|
+
style: {
|
|
364
|
+
fontFamily: FONTS.body,
|
|
365
|
+
fontSize: TYPE.base - 1,
|
|
366
|
+
fontWeight: 600
|
|
367
|
+
},
|
|
368
|
+
children: item.label ?? item.id
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
item.description ? /* @__PURE__ */ jsx3("span", { style: { fontSize: TYPE.sm, color: COLORS.textMuted }, children: item.description }) : null
|
|
372
|
+
] })
|
|
373
|
+
]
|
|
291
374
|
},
|
|
292
|
-
|
|
293
|
-
)
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
375
|
+
item.id
|
|
376
|
+
);
|
|
377
|
+
})
|
|
378
|
+
}
|
|
379
|
+
);
|
|
297
380
|
};
|
|
298
381
|
|
|
299
382
|
// src/components/placement-editor.tsx
|
|
300
|
-
import { useCallback as useCallback2, useEffect as
|
|
301
|
-
import { jsx as
|
|
383
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef4 } from "react";
|
|
384
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
302
385
|
var PLACEMENT_MIN_SIZE = 1;
|
|
303
386
|
function clampValue(value, min, max) {
|
|
304
387
|
return Math.max(min, Math.min(value, max));
|
|
@@ -432,13 +515,13 @@ var PlacementEditor = ({
|
|
|
432
515
|
placement,
|
|
433
516
|
onPlacementChange
|
|
434
517
|
}) => {
|
|
435
|
-
const frameRef =
|
|
436
|
-
const dragRef =
|
|
437
|
-
const placementRef =
|
|
518
|
+
const frameRef = useRef4(null);
|
|
519
|
+
const dragRef = useRef4(null);
|
|
520
|
+
const placementRef = useRef4(placement);
|
|
438
521
|
placementRef.current = placement;
|
|
439
|
-
const onPlacementChangeRef =
|
|
522
|
+
const onPlacementChangeRef = useRef4(onPlacementChange);
|
|
440
523
|
onPlacementChangeRef.current = onPlacementChange;
|
|
441
|
-
|
|
524
|
+
useEffect3(() => {
|
|
442
525
|
return () => {
|
|
443
526
|
dragRef.current?.cleanup();
|
|
444
527
|
};
|
|
@@ -530,7 +613,7 @@ var PlacementEditor = ({
|
|
|
530
613
|
},
|
|
531
614
|
[]
|
|
532
615
|
);
|
|
533
|
-
return /* @__PURE__ */
|
|
616
|
+
return /* @__PURE__ */ jsx4(
|
|
534
617
|
"div",
|
|
535
618
|
{
|
|
536
619
|
ref: frameRef,
|
|
@@ -541,7 +624,7 @@ var PlacementEditor = ({
|
|
|
541
624
|
inset: 0,
|
|
542
625
|
pointerEvents: "none"
|
|
543
626
|
},
|
|
544
|
-
children: /* @__PURE__ */
|
|
627
|
+
children: /* @__PURE__ */ jsx4(
|
|
545
628
|
"div",
|
|
546
629
|
{
|
|
547
630
|
tabIndex: 0,
|
|
@@ -558,7 +641,7 @@ var PlacementEditor = ({
|
|
|
558
641
|
height: `${placement.height}%`,
|
|
559
642
|
backgroundColor: COLORS.accentLight,
|
|
560
643
|
border: `2px solid ${COLORS.accent}`,
|
|
561
|
-
borderRadius: `${RADIUS.sm}
|
|
644
|
+
borderRadius: `${RADIUS.sm}`,
|
|
562
645
|
boxSizing: "border-box",
|
|
563
646
|
cursor: "move",
|
|
564
647
|
pointerEvents: "auto",
|
|
@@ -566,7 +649,7 @@ var PlacementEditor = ({
|
|
|
566
649
|
transition: "box-shadow 150ms ease",
|
|
567
650
|
boxShadow: SHADOWS.sm
|
|
568
651
|
},
|
|
569
|
-
children: HANDLE_DEFS.map((handle) => /* @__PURE__ */
|
|
652
|
+
children: HANDLE_DEFS.map((handle) => /* @__PURE__ */ jsx4(
|
|
570
653
|
"div",
|
|
571
654
|
{
|
|
572
655
|
role: "separator",
|
|
@@ -580,7 +663,7 @@ var PlacementEditor = ({
|
|
|
580
663
|
height: HANDLE_SIZE,
|
|
581
664
|
backgroundColor: COLORS.surface,
|
|
582
665
|
border: `2px solid ${COLORS.accent}`,
|
|
583
|
-
borderRadius: `${RADIUS.sm}
|
|
666
|
+
borderRadius: `${RADIUS.sm}`,
|
|
584
667
|
boxSizing: "border-box",
|
|
585
668
|
cursor: handle.cursor,
|
|
586
669
|
pointerEvents: "auto",
|
|
@@ -595,21 +678,14 @@ var PlacementEditor = ({
|
|
|
595
678
|
}
|
|
596
679
|
);
|
|
597
680
|
};
|
|
598
|
-
var PLACEMENT_INPUT_STYLE = {
|
|
599
|
-
width: "60px",
|
|
600
|
-
padding: `${SPACE[1]}px`,
|
|
601
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
602
|
-
borderRadius: RADIUS.sm,
|
|
603
|
-
fontSize: TYPE.sm,
|
|
604
|
-
color: COLORS.text
|
|
605
|
-
};
|
|
606
681
|
var PlacementInputs = ({
|
|
607
682
|
placement,
|
|
608
683
|
onPlacementChange
|
|
609
684
|
}) => {
|
|
610
|
-
|
|
685
|
+
useInterlaceStyles();
|
|
686
|
+
const placementRef = useRef4(placement);
|
|
611
687
|
placementRef.current = placement;
|
|
612
|
-
const onChangeRef =
|
|
688
|
+
const onChangeRef = useRef4(onPlacementChange);
|
|
613
689
|
onChangeRef.current = onPlacementChange;
|
|
614
690
|
const commit = useCallback2(
|
|
615
691
|
(partial, intent) => {
|
|
@@ -619,83 +695,67 @@ var PlacementInputs = ({
|
|
|
619
695
|
},
|
|
620
696
|
[]
|
|
621
697
|
);
|
|
622
|
-
|
|
698
|
+
const fields = [
|
|
699
|
+
{
|
|
700
|
+
key: "x",
|
|
701
|
+
label: "X",
|
|
702
|
+
testId: "placement-editor-input-x",
|
|
703
|
+
intent: "move"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
key: "y",
|
|
707
|
+
label: "Y",
|
|
708
|
+
testId: "placement-editor-input-y",
|
|
709
|
+
intent: "move"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
key: "width",
|
|
713
|
+
label: "Width",
|
|
714
|
+
testId: "placement-editor-input-w",
|
|
715
|
+
intent: "resize"
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
key: "height",
|
|
719
|
+
label: "Height",
|
|
720
|
+
testId: "placement-editor-input-h",
|
|
721
|
+
intent: "resize"
|
|
722
|
+
}
|
|
723
|
+
];
|
|
724
|
+
return /* @__PURE__ */ jsx4(
|
|
623
725
|
"div",
|
|
624
726
|
{
|
|
625
727
|
"data-testid": "placement-editor-inputs",
|
|
626
728
|
style: {
|
|
627
|
-
display: "
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
fontSize: TYPE.xs,
|
|
631
|
-
alignItems: "center",
|
|
632
|
-
flexWrap: "wrap",
|
|
633
|
-
color: COLORS.textMuted
|
|
729
|
+
display: "grid",
|
|
730
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(72px, 1fr))",
|
|
731
|
+
gap: SPACE[2]
|
|
634
732
|
},
|
|
635
|
-
children: [
|
|
636
|
-
/* @__PURE__ */
|
|
637
|
-
|
|
638
|
-
"
|
|
639
|
-
|
|
640
|
-
"
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
{
|
|
656
|
-
type: "number",
|
|
657
|
-
"data-testid": "placement-editor-input-y",
|
|
658
|
-
value: placement.y.toFixed(1),
|
|
659
|
-
onChange: (e) => commit({ y: parseFloat(e.target.value) || 0 }, "move"),
|
|
660
|
-
style: PLACEMENT_INPUT_STYLE
|
|
661
|
-
}
|
|
662
|
-
)
|
|
663
|
-
] }),
|
|
664
|
-
/* @__PURE__ */ jsxs2("label", { children: [
|
|
665
|
-
"W:",
|
|
666
|
-
" ",
|
|
667
|
-
/* @__PURE__ */ jsx3(
|
|
668
|
-
"input",
|
|
669
|
-
{
|
|
670
|
-
type: "number",
|
|
671
|
-
"data-testid": "placement-editor-input-w",
|
|
672
|
-
value: placement.width.toFixed(1),
|
|
673
|
-
onChange: (e) => commit({ width: parseFloat(e.target.value) || 0 }, "resize"),
|
|
674
|
-
style: PLACEMENT_INPUT_STYLE
|
|
675
|
-
}
|
|
676
|
-
)
|
|
677
|
-
] }),
|
|
678
|
-
/* @__PURE__ */ jsxs2("label", { children: [
|
|
679
|
-
"H:",
|
|
680
|
-
" ",
|
|
681
|
-
/* @__PURE__ */ jsx3(
|
|
682
|
-
"input",
|
|
683
|
-
{
|
|
684
|
-
type: "number",
|
|
685
|
-
"data-testid": "placement-editor-input-h",
|
|
686
|
-
value: placement.height.toFixed(1),
|
|
687
|
-
onChange: (e) => commit({ height: parseFloat(e.target.value) || 0 }, "resize"),
|
|
688
|
-
style: PLACEMENT_INPUT_STYLE
|
|
689
|
-
}
|
|
690
|
-
)
|
|
691
|
-
] })
|
|
692
|
-
]
|
|
733
|
+
children: fields.map((field) => /* @__PURE__ */ jsxs3("label", { className: "interlace-field", children: [
|
|
734
|
+
/* @__PURE__ */ jsx4("span", { className: "interlace-label", style: { fontWeight: 500 }, children: field.label }),
|
|
735
|
+
/* @__PURE__ */ jsx4(
|
|
736
|
+
"input",
|
|
737
|
+
{
|
|
738
|
+
type: "number",
|
|
739
|
+
className: "interlace-input",
|
|
740
|
+
inputMode: "decimal",
|
|
741
|
+
min: field.intent === "resize" ? 1 : 0,
|
|
742
|
+
max: 100,
|
|
743
|
+
step: 0.5,
|
|
744
|
+
"data-testid": field.testId,
|
|
745
|
+
value: placement[field.key].toFixed(1),
|
|
746
|
+
onChange: (e) => commit(
|
|
747
|
+
{ [field.key]: parseFloat(e.target.value) || 0 },
|
|
748
|
+
field.intent
|
|
749
|
+
)
|
|
750
|
+
}
|
|
751
|
+
)
|
|
752
|
+
] }, field.key))
|
|
693
753
|
}
|
|
694
754
|
);
|
|
695
755
|
};
|
|
696
756
|
|
|
697
757
|
// src/components/inspector-panel.tsx
|
|
698
|
-
import { Fragment, jsx as
|
|
758
|
+
import { Fragment, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
699
759
|
var DEFAULT_INSPECTOR_PANEL_STRINGS = {
|
|
700
760
|
...DEFAULT_STRINGS,
|
|
701
761
|
inspectorHeading: "Hook details",
|
|
@@ -704,19 +764,20 @@ var DEFAULT_INSPECTOR_PANEL_STRINGS = {
|
|
|
704
764
|
hookTypeLabel: "Type",
|
|
705
765
|
blockingTypeLabel: "Blocking",
|
|
706
766
|
nonBlockingTypeLabel: "Non-blocking",
|
|
707
|
-
timestampLabel: "
|
|
708
|
-
startLabel: "
|
|
709
|
-
endLabel: "
|
|
710
|
-
placementLabel: "
|
|
711
|
-
contentTypeLabel: "Content type"
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
767
|
+
timestampLabel: "Pauses at (seconds)",
|
|
768
|
+
startLabel: "Starts at (seconds)",
|
|
769
|
+
endLabel: "Ends at (seconds)",
|
|
770
|
+
placementLabel: "Position & size (%)",
|
|
771
|
+
contentTypeLabel: "Content type",
|
|
772
|
+
titlePlaceholder: "e.g. Check your understanding",
|
|
773
|
+
titleHint: "Students see this above the content.",
|
|
774
|
+
blockingTypeDescription: "Pauses the video until answered",
|
|
775
|
+
nonBlockingTypeDescription: "Floats over the video for a time range",
|
|
776
|
+
placementHint: "Drag the box on the video, or type exact values.",
|
|
777
|
+
changeContentTypeLabel: "Change type",
|
|
778
|
+
changeContentTypeWarning: "Choosing a different type clears this hook's content.",
|
|
779
|
+
cancelChangeContentTypeLabel: "Keep current type",
|
|
780
|
+
issuesHeading: "This hook needs attention"
|
|
720
781
|
};
|
|
721
782
|
var InspectorPanel = ({
|
|
722
783
|
entry,
|
|
@@ -726,12 +787,15 @@ var InspectorPanel = ({
|
|
|
726
787
|
placement,
|
|
727
788
|
onPlacementChange,
|
|
728
789
|
onDelete,
|
|
790
|
+
onHookTypeChange,
|
|
729
791
|
strings: stringsOverride
|
|
730
792
|
}) => {
|
|
793
|
+
useInterlaceStyles();
|
|
794
|
+
const [changingType, setChangingType] = useState2(false);
|
|
731
795
|
const strings = { ...DEFAULT_INSPECTOR_PANEL_STRINGS, ...stringsOverride };
|
|
732
|
-
const onChangeRef =
|
|
796
|
+
const onChangeRef = useRef5(onTitleChange);
|
|
733
797
|
onChangeRef.current = onTitleChange;
|
|
734
|
-
const onDeleteRef =
|
|
798
|
+
const onDeleteRef = useRef5(onDelete);
|
|
735
799
|
onDeleteRef.current = onDelete;
|
|
736
800
|
const handleKeyDown = useCallback3(
|
|
737
801
|
(e) => {
|
|
@@ -744,184 +808,261 @@ var InspectorPanel = ({
|
|
|
744
808
|
[]
|
|
745
809
|
);
|
|
746
810
|
const isBlocking = entry.hookType === "blocking";
|
|
747
|
-
|
|
811
|
+
const issues = entry.issues ?? [];
|
|
812
|
+
const showPicker = entry.contentTypeId === null || changingType;
|
|
813
|
+
const selectedOption = entry.contentTypeOptions?.find(
|
|
814
|
+
(option) => option.id === entry.contentTypeId
|
|
815
|
+
);
|
|
816
|
+
const timeInput = (testId, value, key) => function TimeInput({
|
|
817
|
+
id,
|
|
818
|
+
describedBy
|
|
819
|
+
}) {
|
|
820
|
+
return /* @__PURE__ */ jsx5(
|
|
821
|
+
"input",
|
|
822
|
+
{
|
|
823
|
+
id,
|
|
824
|
+
type: "number",
|
|
825
|
+
className: "interlace-input",
|
|
826
|
+
inputMode: "decimal",
|
|
827
|
+
min: 0,
|
|
828
|
+
max: entry.videoDuration || void 0,
|
|
829
|
+
step: 0.1,
|
|
830
|
+
"aria-describedby": describedBy,
|
|
831
|
+
"data-testid": testId,
|
|
832
|
+
value: (value ?? 0).toFixed(1),
|
|
833
|
+
onChange: (e) => onTimeChange({ [key]: parseFloat(e.target.value) || 0 })
|
|
834
|
+
}
|
|
835
|
+
);
|
|
836
|
+
};
|
|
837
|
+
return /* @__PURE__ */ jsxs4(
|
|
748
838
|
"div",
|
|
749
839
|
{
|
|
750
840
|
className: "inspector-panel",
|
|
751
841
|
"data-testid": "inspector-panel",
|
|
752
|
-
tabIndex:
|
|
842
|
+
tabIndex: -1,
|
|
753
843
|
onKeyDown: handleKeyDown,
|
|
754
844
|
style: {
|
|
755
|
-
border: `1px solid ${COLORS.border}`,
|
|
756
|
-
borderRadius: RADIUS.md,
|
|
757
|
-
backgroundColor: COLORS.surfaceRaised,
|
|
758
|
-
padding: SPACE[3],
|
|
759
845
|
display: "flex",
|
|
760
846
|
flexDirection: "column",
|
|
761
|
-
gap: SPACE[
|
|
762
|
-
fontSize: TYPE.sm
|
|
847
|
+
gap: SPACE[4],
|
|
848
|
+
fontSize: TYPE.sm,
|
|
849
|
+
outline: "none"
|
|
763
850
|
},
|
|
764
851
|
children: [
|
|
765
|
-
/* @__PURE__ */
|
|
766
|
-
"
|
|
852
|
+
/* @__PURE__ */ jsxs4(
|
|
853
|
+
"div",
|
|
767
854
|
{
|
|
768
855
|
style: {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
color: COLORS.text
|
|
856
|
+
display: "flex",
|
|
857
|
+
alignItems: "center",
|
|
858
|
+
justifyContent: "space-between",
|
|
859
|
+
gap: SPACE[2]
|
|
774
860
|
},
|
|
775
|
-
children:
|
|
861
|
+
children: [
|
|
862
|
+
/* @__PURE__ */ jsx5(SectionHeading, { children: strings.inspectorHeading }),
|
|
863
|
+
/* @__PURE__ */ jsx5(
|
|
864
|
+
Button,
|
|
865
|
+
{
|
|
866
|
+
variant: "danger",
|
|
867
|
+
onClick: onDelete,
|
|
868
|
+
"data-testid": "inspector-panel-delete",
|
|
869
|
+
children: strings.deleteLabel
|
|
870
|
+
}
|
|
871
|
+
)
|
|
872
|
+
]
|
|
776
873
|
}
|
|
777
874
|
),
|
|
778
|
-
/* @__PURE__ */
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
875
|
+
issues.length > 0 ? /* @__PURE__ */ jsx5(IssueList, { title: strings.issuesHeading, issues }) : null,
|
|
876
|
+
/* @__PURE__ */ jsx5(Field, { label: strings.titleLabel, hint: strings.titleHint, children: ({ id, describedBy }) => /* @__PURE__ */ jsx5(
|
|
877
|
+
"input",
|
|
878
|
+
{
|
|
879
|
+
id,
|
|
880
|
+
type: "text",
|
|
881
|
+
className: "interlace-input",
|
|
882
|
+
"data-testid": "inspector-panel-title",
|
|
883
|
+
value: entry.title,
|
|
884
|
+
placeholder: strings.titlePlaceholder,
|
|
885
|
+
"aria-describedby": describedBy,
|
|
886
|
+
onChange: (e) => onTitleChange(e.target.value)
|
|
887
|
+
}
|
|
888
|
+
) }),
|
|
889
|
+
/* @__PURE__ */ jsxs4("div", { className: "interlace-field", children: [
|
|
890
|
+
/* @__PURE__ */ jsx5("span", { className: "interlace-label", id: `${entry.id}-type-label`, children: strings.hookTypeLabel }),
|
|
891
|
+
onHookTypeChange ? /* @__PURE__ */ jsx5(
|
|
892
|
+
"div",
|
|
782
893
|
{
|
|
783
|
-
|
|
784
|
-
"
|
|
785
|
-
value: entry.title,
|
|
786
|
-
onChange: (e) => onTitleChange(e.target.value),
|
|
787
|
-
"aria-label": strings.titleLabel,
|
|
894
|
+
role: "radiogroup",
|
|
895
|
+
"aria-labelledby": `${entry.id}-type-label`,
|
|
788
896
|
style: {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
897
|
+
display: "grid",
|
|
898
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(160px, 1fr))",
|
|
899
|
+
gap: SPACE[2]
|
|
900
|
+
},
|
|
901
|
+
children: [
|
|
902
|
+
[
|
|
903
|
+
"blocking",
|
|
904
|
+
strings.blockingTypeLabel,
|
|
905
|
+
strings.blockingTypeDescription
|
|
906
|
+
],
|
|
907
|
+
[
|
|
908
|
+
"non-blocking",
|
|
909
|
+
strings.nonBlockingTypeLabel,
|
|
910
|
+
strings.nonBlockingTypeDescription
|
|
911
|
+
]
|
|
912
|
+
].map(([value, label, description]) => /* @__PURE__ */ jsxs4(
|
|
913
|
+
"button",
|
|
914
|
+
{
|
|
915
|
+
type: "button",
|
|
916
|
+
role: "radio",
|
|
917
|
+
"aria-checked": entry.hookType === value,
|
|
918
|
+
className: "interlace-choice interlace-focusable",
|
|
919
|
+
"data-testid": `inspector-panel-type-${value}`,
|
|
920
|
+
onClick: () => {
|
|
921
|
+
if (entry.hookType !== value) onHookTypeChange(value);
|
|
922
|
+
},
|
|
923
|
+
style: { flexDirection: "column", gap: 2 },
|
|
924
|
+
children: [
|
|
925
|
+
/* @__PURE__ */ jsx5("strong", { style: { fontSize: TYPE.sm }, children: label }),
|
|
926
|
+
/* @__PURE__ */ jsx5("span", { style: { fontSize: TYPE.sm, color: COLORS.textMuted }, children: description })
|
|
927
|
+
]
|
|
928
|
+
},
|
|
929
|
+
value
|
|
930
|
+
))
|
|
795
931
|
}
|
|
796
|
-
)
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
strings.hookTypeLabel,
|
|
800
|
-
":",
|
|
801
|
-
" ",
|
|
802
|
-
/* @__PURE__ */ jsx4("strong", { "data-testid": "inspector-panel-type", children: isBlocking ? strings.blockingTypeLabel : strings.nonBlockingTypeLabel })
|
|
803
|
-
] }) }),
|
|
804
|
-
/* @__PURE__ */ jsx4("div", { style: { display: "flex", gap: 12, alignItems: "flex-end" }, children: isBlocking ? /* @__PURE__ */ jsxs3("label", { children: [
|
|
805
|
-
strings.timestampLabel,
|
|
806
|
-
/* @__PURE__ */ jsx4(
|
|
807
|
-
"input",
|
|
932
|
+
) : null,
|
|
933
|
+
/* @__PURE__ */ jsx5(
|
|
934
|
+
"span",
|
|
808
935
|
{
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
936
|
+
"data-testid": "inspector-panel-type",
|
|
937
|
+
style: onHookTypeChange ? {
|
|
938
|
+
position: "absolute",
|
|
939
|
+
width: 1,
|
|
940
|
+
height: 1,
|
|
941
|
+
overflow: "hidden",
|
|
942
|
+
clip: "rect(0 0 0 0)"
|
|
943
|
+
} : { fontWeight: 600 },
|
|
944
|
+
children: isBlocking ? strings.blockingTypeLabel : strings.nonBlockingTypeLabel
|
|
814
945
|
}
|
|
815
946
|
)
|
|
816
|
-
] })
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
947
|
+
] }),
|
|
948
|
+
/* @__PURE__ */ jsx5(
|
|
949
|
+
"div",
|
|
950
|
+
{
|
|
951
|
+
style: {
|
|
952
|
+
display: "grid",
|
|
953
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(140px, 1fr))",
|
|
954
|
+
gap: SPACE[3]
|
|
955
|
+
},
|
|
956
|
+
children: isBlocking ? /* @__PURE__ */ jsx5(Field, { label: strings.timestampLabel, children: timeInput(
|
|
957
|
+
"inspector-panel-timestamp",
|
|
958
|
+
entry.timestamp,
|
|
959
|
+
"timestamp"
|
|
960
|
+
) }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
961
|
+
/* @__PURE__ */ jsx5(Field, { label: strings.startLabel, children: timeInput("inspector-panel-start", entry.start, "start") }),
|
|
962
|
+
/* @__PURE__ */ jsx5(Field, { label: strings.endLabel, children: timeInput("inspector-panel-end", entry.end, "end") })
|
|
963
|
+
] })
|
|
964
|
+
}
|
|
965
|
+
),
|
|
966
|
+
placement && onPlacementChange ? /* @__PURE__ */ jsxs4(
|
|
967
|
+
"div",
|
|
968
|
+
{
|
|
969
|
+
className: "interlace-field",
|
|
970
|
+
role: "group",
|
|
971
|
+
"aria-label": strings.placementLabel,
|
|
972
|
+
children: [
|
|
973
|
+
/* @__PURE__ */ jsx5("span", { className: "interlace-label", children: strings.placementLabel }),
|
|
974
|
+
/* @__PURE__ */ jsx5(
|
|
975
|
+
PlacementInputs,
|
|
976
|
+
{
|
|
977
|
+
placement,
|
|
978
|
+
onPlacementChange
|
|
979
|
+
}
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ jsx5("p", { className: "interlace-hint", children: strings.placementHint })
|
|
982
|
+
]
|
|
983
|
+
}
|
|
984
|
+
) : null,
|
|
985
|
+
/* @__PURE__ */ jsxs4("div", { className: "interlace-field", children: [
|
|
986
|
+
/* @__PURE__ */ jsx5("span", { className: "interlace-label", children: strings.contentTypeLabel }),
|
|
987
|
+
showPicker ? /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
988
|
+
changingType ? /* @__PURE__ */ jsx5(
|
|
989
|
+
"p",
|
|
821
990
|
{
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
onChange: (e) => onTimeChange({ start: parseFloat(e.target.value) || 0 }),
|
|
826
|
-
style: INPUT_STYLE
|
|
991
|
+
className: "interlace-hint",
|
|
992
|
+
style: { color: COLORS.warningText },
|
|
993
|
+
children: strings.changeContentTypeWarning
|
|
827
994
|
}
|
|
828
|
-
)
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
strings.endLabel,
|
|
832
|
-
/* @__PURE__ */ jsx4(
|
|
833
|
-
"input",
|
|
995
|
+
) : null,
|
|
996
|
+
/* @__PURE__ */ jsx5(
|
|
997
|
+
ContentTypePicker,
|
|
834
998
|
{
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
999
|
+
registeredTypes: entry.registeredTypes,
|
|
1000
|
+
options: entry.contentTypeOptions,
|
|
1001
|
+
selectedType: entry.contentTypeId ?? null,
|
|
1002
|
+
label: strings.contentTypeLabel,
|
|
1003
|
+
onSelect: (typeId) => {
|
|
1004
|
+
setChangingType(false);
|
|
1005
|
+
if (typeId !== entry.contentTypeId) onContentTypeSelect(typeId);
|
|
1006
|
+
}
|
|
840
1007
|
}
|
|
841
|
-
)
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
placement && onPlacementChange ? /* @__PURE__ */ jsxs3("div", { children: [
|
|
845
|
-
/* @__PURE__ */ jsx4(
|
|
846
|
-
"div",
|
|
847
|
-
{
|
|
848
|
-
style: {
|
|
849
|
-
color: COLORS.textMuted,
|
|
850
|
-
marginBottom: SPACE[1],
|
|
851
|
-
fontWeight: 600
|
|
852
|
-
},
|
|
853
|
-
children: strings.placementLabel
|
|
854
|
-
}
|
|
855
|
-
),
|
|
856
|
-
/* @__PURE__ */ jsx4(
|
|
857
|
-
PlacementInputs,
|
|
858
|
-
{
|
|
859
|
-
placement,
|
|
860
|
-
onPlacementChange
|
|
861
|
-
}
|
|
862
|
-
)
|
|
863
|
-
] }) : null,
|
|
864
|
-
/* @__PURE__ */ jsxs3("div", { children: [
|
|
865
|
-
/* @__PURE__ */ jsx4(
|
|
1008
|
+
),
|
|
1009
|
+
changingType ? /* @__PURE__ */ jsx5("div", { children: /* @__PURE__ */ jsx5(Button, { variant: "ghost", onClick: () => setChangingType(false), children: strings.cancelChangeContentTypeLabel }) }) : null
|
|
1010
|
+
] }) : /* @__PURE__ */ jsxs4(
|
|
866
1011
|
"div",
|
|
867
1012
|
{
|
|
868
1013
|
style: {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
1014
|
+
display: "flex",
|
|
1015
|
+
alignItems: "center",
|
|
1016
|
+
justifyContent: "space-between",
|
|
1017
|
+
gap: SPACE[2],
|
|
1018
|
+
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
1019
|
+
border: `1px solid ${COLORS.border}`,
|
|
1020
|
+
borderRadius: RADIUS.md,
|
|
1021
|
+
background: COLORS.surface
|
|
872
1022
|
},
|
|
873
|
-
children:
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1023
|
+
children: [
|
|
1024
|
+
/* @__PURE__ */ jsxs4("span", { style: { display: "grid", gap: 2 }, children: [
|
|
1025
|
+
/* @__PURE__ */ jsx5("strong", { "data-testid": "inspector-panel-content-type", children: selectedOption?.label ?? entry.contentTypeId }),
|
|
1026
|
+
selectedOption?.description ? /* @__PURE__ */ jsx5("span", { style: { color: COLORS.textMuted }, children: selectedOption.description }) : null
|
|
1027
|
+
] }),
|
|
1028
|
+
/* @__PURE__ */ jsx5(
|
|
1029
|
+
Button,
|
|
1030
|
+
{
|
|
1031
|
+
variant: "ghost",
|
|
1032
|
+
onClick: () => setChangingType(true),
|
|
1033
|
+
"data-testid": "inspector-panel-change-type",
|
|
1034
|
+
children: strings.changeContentTypeLabel
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
]
|
|
882
1038
|
}
|
|
883
1039
|
)
|
|
884
|
-
] })
|
|
885
|
-
/* @__PURE__ */ jsx4("div", { style: { display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsx4(
|
|
886
|
-
"button",
|
|
887
|
-
{
|
|
888
|
-
type: "button",
|
|
889
|
-
onClick: onDelete,
|
|
890
|
-
"data-testid": "inspector-panel-delete",
|
|
891
|
-
style: {
|
|
892
|
-
padding: `${SPACE[1]}px ${SPACE[3]}px`,
|
|
893
|
-
backgroundColor: COLORS.errorBg,
|
|
894
|
-
border: `1px solid ${COLORS.errorBorder}`,
|
|
895
|
-
borderRadius: RADIUS.sm,
|
|
896
|
-
color: COLORS.errorText,
|
|
897
|
-
cursor: "pointer",
|
|
898
|
-
fontSize: TYPE.sm,
|
|
899
|
-
fontWeight: 600,
|
|
900
|
-
transition: "background-color 150ms ease"
|
|
901
|
-
},
|
|
902
|
-
children: strings.deleteLabel
|
|
903
|
-
}
|
|
904
|
-
) })
|
|
1040
|
+
] })
|
|
905
1041
|
]
|
|
906
1042
|
}
|
|
907
1043
|
);
|
|
908
1044
|
};
|
|
909
1045
|
|
|
910
1046
|
// src/components/keyframe-timeline.tsx
|
|
911
|
-
import { DEFAULT_STRINGS as DEFAULT_STRINGS2 } from "@interlacejs/core";
|
|
912
1047
|
import {
|
|
1048
|
+
DEFAULT_STRINGS as DEFAULT_STRINGS2,
|
|
1049
|
+
ensureInterlaceStyles as ensureInterlaceStyles2
|
|
1050
|
+
} from "@interlacejs/core";
|
|
1051
|
+
import React6, {
|
|
913
1052
|
useCallback as useCallback4,
|
|
914
|
-
useEffect as
|
|
1053
|
+
useEffect as useEffect4,
|
|
915
1054
|
useLayoutEffect,
|
|
916
1055
|
useMemo,
|
|
917
|
-
useRef as
|
|
1056
|
+
useRef as useRef6,
|
|
918
1057
|
useState as useState3
|
|
919
1058
|
} from "react";
|
|
920
|
-
import { jsx as
|
|
1059
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
921
1060
|
var DEFAULT_KEYFRAME_TIMELINE_STRINGS = {
|
|
922
1061
|
...DEFAULT_STRINGS2,
|
|
923
|
-
addBlockingLabel: "
|
|
924
|
-
addNonBlockingLabel: "
|
|
1062
|
+
addBlockingLabel: "Blocking hook",
|
|
1063
|
+
addNonBlockingLabel: "Non-blocking hook",
|
|
1064
|
+
addBlockingHint: "Add a hook that pauses the video at the playhead",
|
|
1065
|
+
addNonBlockingHint: "Add a hook that floats over the video from the playhead",
|
|
925
1066
|
zoomInLabel: "Zoom in",
|
|
926
1067
|
zoomOutLabel: "Zoom out",
|
|
927
1068
|
playLabel: "Play",
|
|
@@ -931,19 +1072,26 @@ var DEFAULT_KEYFRAME_TIMELINE_STRINGS = {
|
|
|
931
1072
|
rulerLabel: "Timeline ruler",
|
|
932
1073
|
trackLabel: "Hook track",
|
|
933
1074
|
blockingKeyframeLabel: "blocking at",
|
|
934
|
-
nonBlockingRangeLabel: "non-blocking from"
|
|
1075
|
+
nonBlockingRangeLabel: "non-blocking from",
|
|
1076
|
+
untitledLabel: "Untitled hook",
|
|
1077
|
+
needsAttentionLabel: "needs attention"
|
|
935
1078
|
};
|
|
936
1079
|
var MIN_ZOOM = 2;
|
|
937
1080
|
var MAX_ZOOM = 100;
|
|
938
1081
|
var DEFAULT_ZOOM = 8;
|
|
939
1082
|
var MIN_RANGE = 1;
|
|
940
|
-
var LANE_HEIGHT =
|
|
941
|
-
var MIN_LANE_HEIGHT = 14;
|
|
1083
|
+
var LANE_HEIGHT = 32;
|
|
942
1084
|
var TRACK_PADDING = 6;
|
|
943
|
-
var
|
|
1085
|
+
var MAX_VISIBLE_LANES = 4;
|
|
1086
|
+
var MAX_TRACK_HEIGHT = MAX_VISIBLE_LANES * LANE_HEIGHT + TRACK_PADDING;
|
|
944
1087
|
var RULER_HEIGHT = 24;
|
|
945
|
-
var
|
|
946
|
-
var
|
|
1088
|
+
var KEYFRAME_SIZE_PX = 14;
|
|
1089
|
+
var KEYFRAME_HIT_PX = 32;
|
|
1090
|
+
var LABEL_MAX_WIDTH_PX = 140;
|
|
1091
|
+
var LABEL_CHAR_PX = 7;
|
|
1092
|
+
var LABEL_GAP_PX = 8;
|
|
1093
|
+
var RANGE_EDGE_PX = 12;
|
|
1094
|
+
var RANGE_MIN_WIDTH_PX = RANGE_EDGE_PX * 2;
|
|
947
1095
|
function clampValue2(value, min, max) {
|
|
948
1096
|
return Math.max(min, Math.min(value, max));
|
|
949
1097
|
}
|
|
@@ -962,15 +1110,49 @@ function formatTick(seconds) {
|
|
|
962
1110
|
const s = seconds % 60;
|
|
963
1111
|
return s === 0 ? `${m}m` : `${m}m ${s}s`;
|
|
964
1112
|
}
|
|
965
|
-
function
|
|
966
|
-
return
|
|
1113
|
+
function estimateLabelWidth(label) {
|
|
1114
|
+
return Math.min(LABEL_MAX_WIDTH_PX, Math.ceil(label.length * LABEL_CHAR_PX));
|
|
967
1115
|
}
|
|
968
|
-
function extentOf(entry, zoom) {
|
|
1116
|
+
function extentOf(entry, zoom, label) {
|
|
969
1117
|
if (entry.hookType === "blocking") {
|
|
970
|
-
|
|
1118
|
+
const t = entry.timestamp ?? 0;
|
|
1119
|
+
const half = KEYFRAME_HIT_PX / 2;
|
|
1120
|
+
return [
|
|
1121
|
+
t - half / zoom,
|
|
1122
|
+
t + (half + estimateLabelWidth(label) + LABEL_GAP_PX) / zoom
|
|
1123
|
+
];
|
|
971
1124
|
}
|
|
972
|
-
const
|
|
973
|
-
|
|
1125
|
+
const start = entry.start ?? 0;
|
|
1126
|
+
const span = (entry.end ?? 0) - start;
|
|
1127
|
+
return [start, start + Math.max(RANGE_MIN_WIDTH_PX / zoom, span)];
|
|
1128
|
+
}
|
|
1129
|
+
function AttentionDot({ style }) {
|
|
1130
|
+
return /* @__PURE__ */ jsx6(
|
|
1131
|
+
"span",
|
|
1132
|
+
{
|
|
1133
|
+
"aria-hidden": "true",
|
|
1134
|
+
"data-testid": "timeline-attention",
|
|
1135
|
+
style: {
|
|
1136
|
+
display: "inline-flex",
|
|
1137
|
+
alignItems: "center",
|
|
1138
|
+
justifyContent: "center",
|
|
1139
|
+
boxSizing: "border-box",
|
|
1140
|
+
width: 14,
|
|
1141
|
+
height: 14,
|
|
1142
|
+
flexShrink: 0,
|
|
1143
|
+
borderRadius: RADIUS.pill,
|
|
1144
|
+
backgroundColor: COLORS.warningBg,
|
|
1145
|
+
border: `1px solid ${COLORS.warningBorder}`,
|
|
1146
|
+
color: COLORS.warningText,
|
|
1147
|
+
fontSize: TYPE.xs,
|
|
1148
|
+
fontWeight: 700,
|
|
1149
|
+
lineHeight: 1,
|
|
1150
|
+
pointerEvents: "none",
|
|
1151
|
+
...style
|
|
1152
|
+
},
|
|
1153
|
+
children: "!"
|
|
1154
|
+
}
|
|
1155
|
+
);
|
|
974
1156
|
}
|
|
975
1157
|
var KeyframeTimeline = ({
|
|
976
1158
|
entries,
|
|
@@ -987,12 +1169,20 @@ var KeyframeTimeline = ({
|
|
|
987
1169
|
strings: stringsOverride
|
|
988
1170
|
}) => {
|
|
989
1171
|
const strings = { ...DEFAULT_KEYFRAME_TIMELINE_STRINGS, ...stringsOverride };
|
|
1172
|
+
const untitledLabel = strings.untitledLabel ?? DEFAULT_KEYFRAME_TIMELINE_STRINGS.untitledLabel;
|
|
1173
|
+
const titleOf = useCallback4(
|
|
1174
|
+
(entry) => entry.title.trim() || untitledLabel,
|
|
1175
|
+
[untitledLabel]
|
|
1176
|
+
);
|
|
990
1177
|
const [zoom, setZoom] = useState3(DEFAULT_ZOOM);
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
const
|
|
1178
|
+
useEffect4(() => {
|
|
1179
|
+
ensureInterlaceStyles2();
|
|
1180
|
+
}, []);
|
|
1181
|
+
const dragRef = useRef6(null);
|
|
1182
|
+
const scrollRef = useRef6(null);
|
|
1183
|
+
const stripRef = useRef6(null);
|
|
1184
|
+
const userZoomedRef = useRef6(false);
|
|
1185
|
+
const propsRef = useRef6({ zoom, videoDuration, currentTime });
|
|
996
1186
|
propsRef.current = { zoom, videoDuration, currentTime };
|
|
997
1187
|
useLayoutEffect(() => {
|
|
998
1188
|
const el = scrollRef.current;
|
|
@@ -1057,7 +1247,7 @@ var KeyframeTimeline = ({
|
|
|
1057
1247
|
},
|
|
1058
1248
|
[]
|
|
1059
1249
|
);
|
|
1060
|
-
|
|
1250
|
+
useEffect4(() => {
|
|
1061
1251
|
return () => {
|
|
1062
1252
|
dragRef.current?.cleanup();
|
|
1063
1253
|
};
|
|
@@ -1130,19 +1320,49 @@ var KeyframeTimeline = ({
|
|
|
1130
1320
|
},
|
|
1131
1321
|
[beginDrag, onUpdateEntry]
|
|
1132
1322
|
);
|
|
1133
|
-
|
|
1323
|
+
const zoomAnchorRef = useRef6(null);
|
|
1324
|
+
useEffect4(() => {
|
|
1134
1325
|
const el = scrollRef.current;
|
|
1135
1326
|
if (!el) return;
|
|
1327
|
+
const toPixels = (delta, mode) => mode === 1 ? delta * 16 : mode === 2 ? delta * el.clientWidth : delta;
|
|
1136
1328
|
const onWheel = (e) => {
|
|
1329
|
+
const dx = toPixels(e.deltaX, e.deltaMode);
|
|
1330
|
+
const dy = toPixels(e.deltaY, e.deltaMode);
|
|
1331
|
+
const horizontal = e.shiftKey || Math.abs(dx) > Math.abs(dy);
|
|
1332
|
+
if (horizontal) {
|
|
1333
|
+
const pan = Math.abs(dx) > Math.abs(dy) ? dx : dy;
|
|
1334
|
+
if (pan === 0) return;
|
|
1335
|
+
e.preventDefault();
|
|
1336
|
+
el.scrollLeft += pan;
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
if (dy === 0) return;
|
|
1137
1340
|
e.preventDefault();
|
|
1138
1341
|
userZoomedRef.current = true;
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
)
|
|
1342
|
+
const strip = stripRef.current;
|
|
1343
|
+
const { zoom: currentZoom } = propsRef.current;
|
|
1344
|
+
if (strip && currentZoom > 0) {
|
|
1345
|
+
const left = strip.getBoundingClientRect().left;
|
|
1346
|
+
zoomAnchorRef.current = {
|
|
1347
|
+
time: (e.clientX - left) / currentZoom,
|
|
1348
|
+
clientX: e.clientX
|
|
1349
|
+
};
|
|
1350
|
+
}
|
|
1351
|
+
const steps = clampValue2(-dy / 100, -3, 3);
|
|
1352
|
+
setZoom((z) => clampValue2(z * Math.pow(1.2, steps), MIN_ZOOM, MAX_ZOOM));
|
|
1142
1353
|
};
|
|
1143
1354
|
el.addEventListener("wheel", onWheel, { passive: false });
|
|
1144
1355
|
return () => el.removeEventListener("wheel", onWheel);
|
|
1145
1356
|
}, []);
|
|
1357
|
+
useLayoutEffect(() => {
|
|
1358
|
+
const anchor = zoomAnchorRef.current;
|
|
1359
|
+
const el = scrollRef.current;
|
|
1360
|
+
const strip = stripRef.current;
|
|
1361
|
+
zoomAnchorRef.current = null;
|
|
1362
|
+
if (!anchor || !el || !strip) return;
|
|
1363
|
+
const left = strip.getBoundingClientRect().left;
|
|
1364
|
+
el.scrollLeft += left + anchor.time * zoom - anchor.clientX;
|
|
1365
|
+
}, [zoom]);
|
|
1146
1366
|
const handleZoom = useCallback4((direction) => {
|
|
1147
1367
|
userZoomedRef.current = true;
|
|
1148
1368
|
setZoom(
|
|
@@ -1237,12 +1457,13 @@ var KeyframeTimeline = ({
|
|
|
1237
1457
|
[onSeek]
|
|
1238
1458
|
);
|
|
1239
1459
|
const layout = useMemo(() => {
|
|
1240
|
-
const
|
|
1460
|
+
const extents = entries.map(
|
|
1461
|
+
(entry) => [entry, extentOf(entry, zoom, titleOf(entry))]
|
|
1462
|
+
);
|
|
1463
|
+
extents.sort((a, b) => a[1][0] - b[1][0]);
|
|
1241
1464
|
const laneEnds = [];
|
|
1242
1465
|
const lanes = /* @__PURE__ */ new Map();
|
|
1243
|
-
for (const entry of
|
|
1244
|
-
const start = anchorOf(entry);
|
|
1245
|
-
const end = start + extentOf(entry, zoom);
|
|
1466
|
+
for (const [entry, [start, end]] of extents) {
|
|
1246
1467
|
let lane = laneEnds.findIndex((laneEnd) => laneEnd <= start);
|
|
1247
1468
|
if (lane === -1) {
|
|
1248
1469
|
lane = laneEnds.length;
|
|
@@ -1253,25 +1474,19 @@ var KeyframeTimeline = ({
|
|
|
1253
1474
|
lanes.set(entry.id, lane);
|
|
1254
1475
|
}
|
|
1255
1476
|
return { lanes, laneCount: Math.max(laneEnds.length, 1) };
|
|
1256
|
-
}, [entries, zoom]);
|
|
1477
|
+
}, [entries, zoom, titleOf]);
|
|
1257
1478
|
const interval = tickInterval(zoom);
|
|
1258
1479
|
const ticks = [];
|
|
1259
1480
|
for (let t = 0; t <= videoDuration; t += interval) {
|
|
1260
1481
|
ticks.push(Math.round(t * 100) / 100);
|
|
1261
1482
|
}
|
|
1262
1483
|
const playheadPx = currentTime * zoom;
|
|
1263
|
-
const laneHeight = clampValue2(
|
|
1264
|
-
Math.floor(
|
|
1265
|
-
(TRACK_HEIGHT_BUDGET - TRACK_PADDING) / Math.max(1, layout.laneCount)
|
|
1266
|
-
),
|
|
1267
|
-
MIN_LANE_HEIGHT,
|
|
1268
|
-
LANE_HEIGHT
|
|
1269
|
-
);
|
|
1270
1484
|
const trackHeight = Math.max(
|
|
1271
1485
|
48,
|
|
1272
|
-
layout.laneCount *
|
|
1486
|
+
layout.laneCount * LANE_HEIGHT + TRACK_PADDING
|
|
1273
1487
|
);
|
|
1274
|
-
|
|
1488
|
+
const ariaLabelOf = (entry, base) => entry.needsAttention ? `${base}, ${entry.attentionLabel ?? strings.needsAttentionLabel ?? DEFAULT_KEYFRAME_TIMELINE_STRINGS.needsAttentionLabel}` : base;
|
|
1489
|
+
return /* @__PURE__ */ jsxs5(
|
|
1275
1490
|
"div",
|
|
1276
1491
|
{
|
|
1277
1492
|
className: "keyframe-timeline",
|
|
@@ -1286,7 +1501,7 @@ var KeyframeTimeline = ({
|
|
|
1286
1501
|
gap: SPACE[2]
|
|
1287
1502
|
},
|
|
1288
1503
|
children: [
|
|
1289
|
-
/* @__PURE__ */
|
|
1504
|
+
/* @__PURE__ */ jsxs5(
|
|
1290
1505
|
"div",
|
|
1291
1506
|
{
|
|
1292
1507
|
"data-testid": "keyframe-timeline-controls",
|
|
@@ -1297,133 +1512,97 @@ var KeyframeTimeline = ({
|
|
|
1297
1512
|
flexWrap: "wrap"
|
|
1298
1513
|
},
|
|
1299
1514
|
children: [
|
|
1300
|
-
/* @__PURE__ */
|
|
1515
|
+
onTogglePlay && /* @__PURE__ */ jsx6(
|
|
1301
1516
|
"button",
|
|
1302
1517
|
{
|
|
1303
1518
|
type: "button",
|
|
1519
|
+
className: "interlace-btn interlace-btn--ghost interlace-btn--icon",
|
|
1304
1520
|
onClick: onTogglePlay,
|
|
1305
1521
|
"data-testid": "keyframe-timeline-play",
|
|
1306
1522
|
"aria-label": isPlaying ? strings.pauseLabel : strings.playLabel,
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
backgroundColor: COLORS.accent,
|
|
1310
|
-
color: COLORS.white,
|
|
1311
|
-
border: "none",
|
|
1312
|
-
borderRadius: RADIUS.sm,
|
|
1313
|
-
cursor: "pointer",
|
|
1314
|
-
fontSize: TYPE.sm,
|
|
1315
|
-
fontWeight: 600,
|
|
1316
|
-
transition: "background-color 150ms ease"
|
|
1317
|
-
},
|
|
1318
|
-
children: isPlaying ? strings.pauseLabel : strings.playLabel
|
|
1523
|
+
title: isPlaying ? strings.pauseLabel : strings.playLabel,
|
|
1524
|
+
children: /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: isPlaying ? "\u275A\u275A" : "\u25B6" })
|
|
1319
1525
|
}
|
|
1320
1526
|
),
|
|
1321
|
-
/* @__PURE__ */
|
|
1527
|
+
/* @__PURE__ */ jsxs5(
|
|
1322
1528
|
"button",
|
|
1323
1529
|
{
|
|
1324
1530
|
type: "button",
|
|
1531
|
+
className: "interlace-btn interlace-btn--secondary",
|
|
1325
1532
|
onClick: () => onAddEntry("blocking"),
|
|
1326
1533
|
"data-testid": "keyframe-timeline-add-blocking",
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
borderRadius: RADIUS.sm,
|
|
1333
|
-
cursor: "pointer",
|
|
1334
|
-
fontSize: TYPE.sm,
|
|
1335
|
-
fontWeight: 600,
|
|
1336
|
-
transition: "background-color 150ms ease"
|
|
1337
|
-
},
|
|
1338
|
-
children: strings.addBlockingLabel
|
|
1534
|
+
title: strings.addBlockingHint,
|
|
1535
|
+
children: [
|
|
1536
|
+
/* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: "+" }),
|
|
1537
|
+
strings.addBlockingLabel
|
|
1538
|
+
]
|
|
1339
1539
|
}
|
|
1340
1540
|
),
|
|
1341
|
-
/* @__PURE__ */
|
|
1541
|
+
/* @__PURE__ */ jsxs5(
|
|
1342
1542
|
"button",
|
|
1343
1543
|
{
|
|
1344
1544
|
type: "button",
|
|
1545
|
+
className: "interlace-btn interlace-btn--secondary",
|
|
1345
1546
|
onClick: () => onAddEntry("non-blocking"),
|
|
1346
1547
|
"data-testid": "keyframe-timeline-add-non-blocking",
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
borderRadius: RADIUS.sm,
|
|
1353
|
-
cursor: "pointer",
|
|
1354
|
-
fontSize: TYPE.sm,
|
|
1355
|
-
fontWeight: 600,
|
|
1356
|
-
transition: "background-color 150ms ease"
|
|
1357
|
-
},
|
|
1358
|
-
children: strings.addNonBlockingLabel
|
|
1548
|
+
title: strings.addNonBlockingHint,
|
|
1549
|
+
children: [
|
|
1550
|
+
/* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: "+" }),
|
|
1551
|
+
strings.addNonBlockingLabel
|
|
1552
|
+
]
|
|
1359
1553
|
}
|
|
1360
1554
|
),
|
|
1361
|
-
/* @__PURE__ */
|
|
1362
|
-
/* @__PURE__ */
|
|
1555
|
+
/* @__PURE__ */ jsx6("div", { style: { flex: 1 } }),
|
|
1556
|
+
/* @__PURE__ */ jsx6(
|
|
1363
1557
|
"button",
|
|
1364
1558
|
{
|
|
1365
1559
|
type: "button",
|
|
1560
|
+
className: "interlace-btn interlace-btn--secondary interlace-btn--icon",
|
|
1366
1561
|
onClick: () => handleZoom(-1),
|
|
1367
1562
|
"data-testid": "keyframe-timeline-zoom-out",
|
|
1368
1563
|
"aria-label": strings.zoomOutLabel,
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
backgroundColor: COLORS.surface,
|
|
1372
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
1373
|
-
borderRadius: RADIUS.sm,
|
|
1374
|
-
cursor: "pointer",
|
|
1375
|
-
fontSize: TYPE.sm,
|
|
1376
|
-
color: COLORS.text,
|
|
1377
|
-
transition: "background-color 150ms ease"
|
|
1378
|
-
},
|
|
1379
|
-
children: "\u2212"
|
|
1564
|
+
title: strings.zoomOutLabel,
|
|
1565
|
+
children: /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: "\u2212" })
|
|
1380
1566
|
}
|
|
1381
1567
|
),
|
|
1382
|
-
/* @__PURE__ */
|
|
1568
|
+
/* @__PURE__ */ jsx6(
|
|
1383
1569
|
"button",
|
|
1384
1570
|
{
|
|
1385
1571
|
type: "button",
|
|
1572
|
+
className: "interlace-btn interlace-btn--secondary interlace-btn--icon",
|
|
1386
1573
|
onClick: () => handleZoom(1),
|
|
1387
1574
|
"data-testid": "keyframe-timeline-zoom-in",
|
|
1388
1575
|
"aria-label": strings.zoomInLabel,
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
backgroundColor: COLORS.surface,
|
|
1392
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
1393
|
-
borderRadius: RADIUS.sm,
|
|
1394
|
-
cursor: "pointer",
|
|
1395
|
-
fontSize: TYPE.sm,
|
|
1396
|
-
color: COLORS.text,
|
|
1397
|
-
transition: "background-color 150ms ease"
|
|
1398
|
-
},
|
|
1399
|
-
children: "+"
|
|
1576
|
+
title: strings.zoomInLabel,
|
|
1577
|
+
children: /* @__PURE__ */ jsx6("span", { "aria-hidden": "true", children: "+" })
|
|
1400
1578
|
}
|
|
1401
1579
|
)
|
|
1402
1580
|
]
|
|
1403
1581
|
}
|
|
1404
1582
|
),
|
|
1405
|
-
/* @__PURE__ */
|
|
1583
|
+
/* @__PURE__ */ jsx6(
|
|
1406
1584
|
"div",
|
|
1407
1585
|
{
|
|
1408
1586
|
ref: scrollRef,
|
|
1409
1587
|
"data-testid": "keyframe-timeline-scroll",
|
|
1410
1588
|
style: {
|
|
1411
1589
|
overflowX: "auto",
|
|
1412
|
-
overflowY: "
|
|
1590
|
+
overflowY: "auto",
|
|
1413
1591
|
position: "relative",
|
|
1414
|
-
maxHeight: RULER_HEIGHT +
|
|
1592
|
+
maxHeight: RULER_HEIGHT + MAX_TRACK_HEIGHT
|
|
1415
1593
|
},
|
|
1416
|
-
children: /* @__PURE__ */
|
|
1594
|
+
children: /* @__PURE__ */ jsxs5(
|
|
1417
1595
|
"div",
|
|
1418
1596
|
{
|
|
1419
1597
|
ref: stripRef,
|
|
1420
1598
|
"data-testid": "keyframe-timeline-strip",
|
|
1421
1599
|
style: { position: "relative", width: stripWidth, minWidth: "100%" },
|
|
1422
1600
|
children: [
|
|
1423
|
-
/* @__PURE__ */
|
|
1601
|
+
/* @__PURE__ */ jsx6(
|
|
1424
1602
|
"div",
|
|
1425
1603
|
{
|
|
1426
1604
|
role: "slider",
|
|
1605
|
+
className: "interlace-focusable",
|
|
1427
1606
|
"aria-label": strings.rulerLabel,
|
|
1428
1607
|
"aria-valuemin": 0,
|
|
1429
1608
|
"aria-valuemax": Math.round(videoDuration),
|
|
@@ -1436,15 +1615,17 @@ var KeyframeTimeline = ({
|
|
|
1436
1615
|
},
|
|
1437
1616
|
onKeyDown: handlePlayheadKeyDown,
|
|
1438
1617
|
style: {
|
|
1439
|
-
position: "
|
|
1440
|
-
|
|
1618
|
+
position: "sticky",
|
|
1619
|
+
top: 0,
|
|
1620
|
+
zIndex: 2,
|
|
1621
|
+
height: RULER_HEIGHT,
|
|
1441
1622
|
backgroundColor: COLORS.surfaceRaised,
|
|
1442
1623
|
borderBottom: `1px solid ${COLORS.border}`,
|
|
1443
1624
|
cursor: "pointer",
|
|
1444
1625
|
userSelect: "none",
|
|
1445
1626
|
touchAction: "none"
|
|
1446
1627
|
},
|
|
1447
|
-
children: ticks.map((t) => /* @__PURE__ */
|
|
1628
|
+
children: ticks.map((t) => /* @__PURE__ */ jsx6(
|
|
1448
1629
|
"div",
|
|
1449
1630
|
{
|
|
1450
1631
|
"data-testid": `keyframe-timeline-tick-${t}`,
|
|
@@ -1457,7 +1638,7 @@ var KeyframeTimeline = ({
|
|
|
1457
1638
|
paddingLeft: SPACE[1],
|
|
1458
1639
|
fontSize: TYPE.xs,
|
|
1459
1640
|
color: COLORS.textMuted,
|
|
1460
|
-
lineHeight:
|
|
1641
|
+
lineHeight: `${RULER_HEIGHT}px`,
|
|
1461
1642
|
whiteSpace: "nowrap"
|
|
1462
1643
|
},
|
|
1463
1644
|
children: formatTick(t)
|
|
@@ -1466,7 +1647,7 @@ var KeyframeTimeline = ({
|
|
|
1466
1647
|
))
|
|
1467
1648
|
}
|
|
1468
1649
|
),
|
|
1469
|
-
/* @__PURE__ */
|
|
1650
|
+
/* @__PURE__ */ jsx6(
|
|
1470
1651
|
"div",
|
|
1471
1652
|
{
|
|
1472
1653
|
role: "listbox",
|
|
@@ -1480,7 +1661,7 @@ var KeyframeTimeline = ({
|
|
|
1480
1661
|
position: "relative",
|
|
1481
1662
|
height: trackHeight
|
|
1482
1663
|
},
|
|
1483
|
-
children: entries.length === 0 ? /* @__PURE__ */
|
|
1664
|
+
children: entries.length === 0 ? /* @__PURE__ */ jsx6(
|
|
1484
1665
|
"p",
|
|
1485
1666
|
{
|
|
1486
1667
|
"data-testid": "keyframe-timeline-empty",
|
|
@@ -1495,64 +1676,126 @@ var KeyframeTimeline = ({
|
|
|
1495
1676
|
) : entries.map((entry) => {
|
|
1496
1677
|
const selected = entry.id === selectedId;
|
|
1497
1678
|
const accent = COLORS.accent;
|
|
1679
|
+
const title = titleOf(entry);
|
|
1498
1680
|
const lane = layout.lanes.get(entry.id) ?? 0;
|
|
1499
|
-
const laneTop =
|
|
1681
|
+
const laneTop = TRACK_PADDING / 2 + lane * LANE_HEIGHT;
|
|
1500
1682
|
if (entry.hookType === "blocking") {
|
|
1501
1683
|
const px = (entry.timestamp ?? 0) * zoom;
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1684
|
+
const half = KEYFRAME_HIT_PX / 2;
|
|
1685
|
+
return /* @__PURE__ */ jsxs5(React6.Fragment, { children: [
|
|
1686
|
+
/* @__PURE__ */ jsxs5(
|
|
1687
|
+
"button",
|
|
1688
|
+
{
|
|
1689
|
+
type: "button",
|
|
1690
|
+
className: "interlace-focusable",
|
|
1691
|
+
"data-testid": "timeline-keyframe",
|
|
1692
|
+
"data-content-id": entry.id,
|
|
1693
|
+
"aria-label": ariaLabelOf(
|
|
1694
|
+
entry,
|
|
1695
|
+
`${title} \u2014 ${strings.blockingKeyframeLabel} ${formatTick(Math.round(entry.timestamp ?? 0))}`
|
|
1696
|
+
),
|
|
1697
|
+
onClick: () => onSelectEntry(entry.id),
|
|
1698
|
+
onKeyDown: handleKeyframeKeyDown(entry),
|
|
1699
|
+
onPointerDown: beginKeyframeDrag(
|
|
1700
|
+
entry.id,
|
|
1701
|
+
entry.timestamp ?? 0
|
|
1702
|
+
),
|
|
1703
|
+
style: {
|
|
1704
|
+
position: "absolute",
|
|
1705
|
+
left: px - half,
|
|
1706
|
+
top: laneTop,
|
|
1707
|
+
width: KEYFRAME_HIT_PX,
|
|
1708
|
+
height: KEYFRAME_HIT_PX,
|
|
1709
|
+
display: "flex",
|
|
1710
|
+
alignItems: "center",
|
|
1711
|
+
justifyContent: "center",
|
|
1712
|
+
padding: 0,
|
|
1713
|
+
border: "none",
|
|
1714
|
+
borderRadius: RADIUS.sm,
|
|
1715
|
+
backgroundColor: "transparent",
|
|
1716
|
+
cursor: "grab",
|
|
1717
|
+
touchAction: "none"
|
|
1718
|
+
},
|
|
1719
|
+
children: [
|
|
1720
|
+
/* @__PURE__ */ jsx6(
|
|
1721
|
+
"span",
|
|
1722
|
+
{
|
|
1723
|
+
"aria-hidden": "true",
|
|
1724
|
+
"data-testid": "timeline-keyframe-diamond",
|
|
1725
|
+
style: {
|
|
1726
|
+
boxSizing: "border-box",
|
|
1727
|
+
width: KEYFRAME_SIZE_PX,
|
|
1728
|
+
height: KEYFRAME_SIZE_PX,
|
|
1729
|
+
transform: "rotate(45deg)",
|
|
1730
|
+
backgroundColor: selected ? accent : COLORS.surface,
|
|
1731
|
+
border: `2px solid ${accent}`,
|
|
1732
|
+
borderRadius: 2,
|
|
1733
|
+
boxShadow: selected ? SHADOWS.sm : "none",
|
|
1734
|
+
pointerEvents: "none"
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
),
|
|
1738
|
+
entry.needsAttention && /* @__PURE__ */ jsx6(
|
|
1739
|
+
AttentionDot,
|
|
1740
|
+
{
|
|
1741
|
+
style: { position: "absolute", top: 0, right: 0 }
|
|
1742
|
+
}
|
|
1743
|
+
)
|
|
1744
|
+
]
|
|
1745
|
+
}
|
|
1746
|
+
),
|
|
1747
|
+
/* @__PURE__ */ jsx6(
|
|
1748
|
+
"span",
|
|
1749
|
+
{
|
|
1750
|
+
"aria-hidden": "true",
|
|
1751
|
+
"data-testid": "timeline-keyframe-label",
|
|
1752
|
+
"data-content-id": entry.id,
|
|
1753
|
+
title,
|
|
1754
|
+
onClick: () => onSelectEntry(entry.id),
|
|
1755
|
+
style: {
|
|
1756
|
+
position: "absolute",
|
|
1757
|
+
left: px + half,
|
|
1758
|
+
top: laneTop,
|
|
1759
|
+
maxWidth: LABEL_MAX_WIDTH_PX,
|
|
1760
|
+
height: KEYFRAME_HIT_PX,
|
|
1761
|
+
lineHeight: `${KEYFRAME_HIT_PX}px`,
|
|
1762
|
+
overflow: "hidden",
|
|
1763
|
+
textOverflow: "ellipsis",
|
|
1764
|
+
whiteSpace: "nowrap",
|
|
1765
|
+
fontSize: TYPE.xs,
|
|
1766
|
+
color: selected ? COLORS.accent : COLORS.text,
|
|
1767
|
+
fontWeight: selected ? 700 : 400,
|
|
1768
|
+
fontStyle: entry.title.trim() ? "normal" : "italic",
|
|
1769
|
+
cursor: "pointer",
|
|
1770
|
+
userSelect: "none"
|
|
1771
|
+
},
|
|
1772
|
+
children: title
|
|
1773
|
+
}
|
|
1774
|
+
)
|
|
1775
|
+
] }, entry.id);
|
|
1549
1776
|
}
|
|
1550
1777
|
const startPx = (entry.start ?? 0) * zoom;
|
|
1551
1778
|
const widthPx = Math.max(
|
|
1552
1779
|
((entry.end ?? 0) - (entry.start ?? 0)) * zoom,
|
|
1553
|
-
|
|
1780
|
+
RANGE_MIN_WIDTH_PX
|
|
1554
1781
|
);
|
|
1555
|
-
|
|
1782
|
+
const edgeStyle = (side) => ({
|
|
1783
|
+
width: RANGE_EDGE_PX,
|
|
1784
|
+
flexShrink: 0,
|
|
1785
|
+
alignSelf: "stretch",
|
|
1786
|
+
display: "flex",
|
|
1787
|
+
justifyContent: side === "start" ? "flex-start" : "flex-end",
|
|
1788
|
+
cursor: "ew-resize",
|
|
1789
|
+
touchAction: "none"
|
|
1790
|
+
});
|
|
1791
|
+
const edgeGrip = /* @__PURE__ */ jsx6(
|
|
1792
|
+
"span",
|
|
1793
|
+
{
|
|
1794
|
+
"aria-hidden": "true",
|
|
1795
|
+
style: { width: 4, backgroundColor: COLORS.accent }
|
|
1796
|
+
}
|
|
1797
|
+
);
|
|
1798
|
+
return /* @__PURE__ */ jsxs5(
|
|
1556
1799
|
"div",
|
|
1557
1800
|
{
|
|
1558
1801
|
"data-testid": "timeline-range",
|
|
@@ -1561,8 +1804,8 @@ var KeyframeTimeline = ({
|
|
|
1561
1804
|
position: "absolute",
|
|
1562
1805
|
left: startPx,
|
|
1563
1806
|
width: widthPx,
|
|
1564
|
-
top: laneTop,
|
|
1565
|
-
height:
|
|
1807
|
+
top: laneTop + 4,
|
|
1808
|
+
height: LANE_HEIGHT - 8,
|
|
1566
1809
|
backgroundColor: selected ? COLORS.accentLight : COLORS.accentLighter,
|
|
1567
1810
|
border: `2px solid ${COLORS.accent}`,
|
|
1568
1811
|
borderRadius: RADIUS.sm,
|
|
@@ -1573,11 +1816,11 @@ var KeyframeTimeline = ({
|
|
|
1573
1816
|
touchAction: "none"
|
|
1574
1817
|
},
|
|
1575
1818
|
children: [
|
|
1576
|
-
/* @__PURE__ */
|
|
1819
|
+
/* @__PURE__ */ jsx6(
|
|
1577
1820
|
"div",
|
|
1578
1821
|
{
|
|
1579
1822
|
role: "separator",
|
|
1580
|
-
"aria-label": `${
|
|
1823
|
+
"aria-label": `${title} \u2014 resize start`,
|
|
1581
1824
|
"data-testid": "timeline-range-start",
|
|
1582
1825
|
onPointerDown: beginRangeDrag(
|
|
1583
1826
|
entry.id,
|
|
@@ -1585,22 +1828,22 @@ var KeyframeTimeline = ({
|
|
|
1585
1828
|
entry.start ?? 0,
|
|
1586
1829
|
entry.end ?? 0
|
|
1587
1830
|
),
|
|
1588
|
-
style:
|
|
1589
|
-
|
|
1590
|
-
alignSelf: "stretch",
|
|
1591
|
-
cursor: "ew-resize",
|
|
1592
|
-
backgroundColor: COLORS.accent,
|
|
1593
|
-
touchAction: "none"
|
|
1594
|
-
}
|
|
1831
|
+
style: edgeStyle("start"),
|
|
1832
|
+
children: edgeGrip
|
|
1595
1833
|
}
|
|
1596
1834
|
),
|
|
1597
|
-
/* @__PURE__ */
|
|
1835
|
+
/* @__PURE__ */ jsxs5(
|
|
1598
1836
|
"button",
|
|
1599
1837
|
{
|
|
1600
1838
|
type: "button",
|
|
1839
|
+
className: "interlace-focusable",
|
|
1601
1840
|
"data-testid": "timeline-keyframe",
|
|
1602
1841
|
"data-content-id": entry.id,
|
|
1603
|
-
"aria-label":
|
|
1842
|
+
"aria-label": ariaLabelOf(
|
|
1843
|
+
entry,
|
|
1844
|
+
`${title} \u2014 ${strings.nonBlockingRangeLabel} ${formatTick(Math.round(entry.start ?? 0))} to ${formatTick(Math.round(entry.end ?? 0))}`
|
|
1845
|
+
),
|
|
1846
|
+
title,
|
|
1604
1847
|
onClick: () => onSelectEntry(entry.id),
|
|
1605
1848
|
onKeyDown: handleKeyframeKeyDown(entry),
|
|
1606
1849
|
onPointerDown: beginRangeDrag(
|
|
@@ -1611,7 +1854,11 @@ var KeyframeTimeline = ({
|
|
|
1611
1854
|
),
|
|
1612
1855
|
style: {
|
|
1613
1856
|
flex: 1,
|
|
1857
|
+
minWidth: 0,
|
|
1614
1858
|
alignSelf: "stretch",
|
|
1859
|
+
display: "flex",
|
|
1860
|
+
alignItems: "center",
|
|
1861
|
+
gap: SPACE[1],
|
|
1615
1862
|
backgroundColor: "transparent",
|
|
1616
1863
|
border: "none",
|
|
1617
1864
|
cursor: "grab",
|
|
@@ -1619,20 +1866,31 @@ var KeyframeTimeline = ({
|
|
|
1619
1866
|
color: COLORS.text,
|
|
1620
1867
|
padding: `0 ${SPACE[1]}px`,
|
|
1621
1868
|
textAlign: "left",
|
|
1622
|
-
whiteSpace: "nowrap",
|
|
1623
|
-
overflow: "hidden",
|
|
1624
|
-
textOverflow: "ellipsis",
|
|
1625
1869
|
fontWeight: selected ? 700 : 400,
|
|
1870
|
+
fontStyle: entry.title.trim() ? "normal" : "italic",
|
|
1626
1871
|
touchAction: "none"
|
|
1627
1872
|
},
|
|
1628
|
-
children:
|
|
1873
|
+
children: [
|
|
1874
|
+
entry.needsAttention && /* @__PURE__ */ jsx6(AttentionDot, {}),
|
|
1875
|
+
/* @__PURE__ */ jsx6(
|
|
1876
|
+
"span",
|
|
1877
|
+
{
|
|
1878
|
+
style: {
|
|
1879
|
+
overflow: "hidden",
|
|
1880
|
+
textOverflow: "ellipsis",
|
|
1881
|
+
whiteSpace: "nowrap"
|
|
1882
|
+
},
|
|
1883
|
+
children: title
|
|
1884
|
+
}
|
|
1885
|
+
)
|
|
1886
|
+
]
|
|
1629
1887
|
}
|
|
1630
1888
|
),
|
|
1631
|
-
/* @__PURE__ */
|
|
1889
|
+
/* @__PURE__ */ jsx6(
|
|
1632
1890
|
"div",
|
|
1633
1891
|
{
|
|
1634
1892
|
role: "separator",
|
|
1635
|
-
"aria-label": `${
|
|
1893
|
+
"aria-label": `${title} \u2014 resize end`,
|
|
1636
1894
|
"data-testid": "timeline-range-end",
|
|
1637
1895
|
onPointerDown: beginRangeDrag(
|
|
1638
1896
|
entry.id,
|
|
@@ -1640,13 +1898,8 @@ var KeyframeTimeline = ({
|
|
|
1640
1898
|
entry.start ?? 0,
|
|
1641
1899
|
entry.end ?? 0
|
|
1642
1900
|
),
|
|
1643
|
-
style:
|
|
1644
|
-
|
|
1645
|
-
alignSelf: "stretch",
|
|
1646
|
-
cursor: "ew-resize",
|
|
1647
|
-
backgroundColor: COLORS.accent,
|
|
1648
|
-
touchAction: "none"
|
|
1649
|
-
}
|
|
1901
|
+
style: edgeStyle("end"),
|
|
1902
|
+
children: edgeGrip
|
|
1650
1903
|
}
|
|
1651
1904
|
)
|
|
1652
1905
|
]
|
|
@@ -1656,7 +1909,7 @@ var KeyframeTimeline = ({
|
|
|
1656
1909
|
})
|
|
1657
1910
|
}
|
|
1658
1911
|
),
|
|
1659
|
-
/* @__PURE__ */
|
|
1912
|
+
/* @__PURE__ */ jsx6(
|
|
1660
1913
|
"div",
|
|
1661
1914
|
{
|
|
1662
1915
|
"data-testid": "keyframe-timeline-playhead",
|
|
@@ -1666,13 +1919,15 @@ var KeyframeTimeline = ({
|
|
|
1666
1919
|
top: 0,
|
|
1667
1920
|
bottom: 0,
|
|
1668
1921
|
width: 0,
|
|
1922
|
+
zIndex: 3,
|
|
1669
1923
|
borderLeft: `2px solid ${COLORS.accent}`,
|
|
1670
1924
|
pointerEvents: "none"
|
|
1671
1925
|
},
|
|
1672
|
-
children: /* @__PURE__ */
|
|
1926
|
+
children: /* @__PURE__ */ jsx6(
|
|
1673
1927
|
"div",
|
|
1674
1928
|
{
|
|
1675
1929
|
role: "slider",
|
|
1930
|
+
className: "interlace-focusable",
|
|
1676
1931
|
"aria-label": strings.playheadLabel,
|
|
1677
1932
|
"aria-valuemin": 0,
|
|
1678
1933
|
"aria-valuemax": Math.round(videoDuration),
|
|
@@ -1714,8 +1969,8 @@ import {
|
|
|
1714
1969
|
} from "@interlacejs/core";
|
|
1715
1970
|
import { InteractiveVideoPlayer } from "@interlacejs/player";
|
|
1716
1971
|
import { NativeVideoAdapter } from "@interlacejs/native-adapter";
|
|
1717
|
-
import { useCallback as useCallback5, useEffect as
|
|
1718
|
-
import { jsx as
|
|
1972
|
+
import { useCallback as useCallback5, useEffect as useEffect5, useRef as useRef7, useState as useState4 } from "react";
|
|
1973
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1719
1974
|
var DEFAULT_PREVIEW_MODAL_STRINGS = {
|
|
1720
1975
|
...DEFAULT_STRINGS3,
|
|
1721
1976
|
title: "Preview",
|
|
@@ -1731,16 +1986,16 @@ function PreviewModal({
|
|
|
1731
1986
|
onError
|
|
1732
1987
|
}) {
|
|
1733
1988
|
const strings = { ...DEFAULT_PREVIEW_MODAL_STRINGS, ...stringsOverride };
|
|
1734
|
-
const videoRef =
|
|
1735
|
-
const closeButtonRef =
|
|
1736
|
-
const previouslyFocusedRef =
|
|
1737
|
-
const onErrorRef =
|
|
1989
|
+
const videoRef = useRef7(null);
|
|
1990
|
+
const closeButtonRef = useRef7(null);
|
|
1991
|
+
const previouslyFocusedRef = useRef7(null);
|
|
1992
|
+
const onErrorRef = useRef7(onError);
|
|
1738
1993
|
onErrorRef.current = onError;
|
|
1739
|
-
const onCloseRef =
|
|
1994
|
+
const onCloseRef = useRef7(onClose);
|
|
1740
1995
|
onCloseRef.current = onClose;
|
|
1741
1996
|
const [adapter, setAdapter] = useState4(null);
|
|
1742
1997
|
const [aspectRatio, setAspectRatio] = useState4(null);
|
|
1743
|
-
|
|
1998
|
+
useEffect5(() => {
|
|
1744
1999
|
if (!isOpen) {
|
|
1745
2000
|
setAdapter(null);
|
|
1746
2001
|
return;
|
|
@@ -1767,7 +2022,7 @@ function PreviewModal({
|
|
|
1767
2022
|
setAdapter(null);
|
|
1768
2023
|
};
|
|
1769
2024
|
}, [isOpen, videoSrc]);
|
|
1770
|
-
|
|
2025
|
+
useEffect5(() => {
|
|
1771
2026
|
if (!isOpen) return;
|
|
1772
2027
|
previouslyFocusedRef.current = globalThis.document?.activeElement ?? null;
|
|
1773
2028
|
closeButtonRef.current?.focus();
|
|
@@ -1778,7 +2033,7 @@ function PreviewModal({
|
|
|
1778
2033
|
}
|
|
1779
2034
|
};
|
|
1780
2035
|
}, [isOpen]);
|
|
1781
|
-
|
|
2036
|
+
useEffect5(() => {
|
|
1782
2037
|
if (!isOpen) return;
|
|
1783
2038
|
const handleKey = (e) => {
|
|
1784
2039
|
if (e.key === "Escape") onCloseRef.current();
|
|
@@ -1803,7 +2058,7 @@ function PreviewModal({
|
|
|
1803
2058
|
);
|
|
1804
2059
|
if (!isOpen) return null;
|
|
1805
2060
|
const containerAspectRatio = aspectRatio ?? 16 / 9;
|
|
1806
|
-
return /* @__PURE__ */
|
|
2061
|
+
return /* @__PURE__ */ jsx7(
|
|
1807
2062
|
"div",
|
|
1808
2063
|
{
|
|
1809
2064
|
className: "preview-modal-backdrop",
|
|
@@ -1822,7 +2077,7 @@ function PreviewModal({
|
|
|
1822
2077
|
alignItems: "center",
|
|
1823
2078
|
justifyContent: "center"
|
|
1824
2079
|
},
|
|
1825
|
-
children: /* @__PURE__ */
|
|
2080
|
+
children: /* @__PURE__ */ jsxs6(
|
|
1826
2081
|
"div",
|
|
1827
2082
|
{
|
|
1828
2083
|
className: "preview-modal",
|
|
@@ -1844,7 +2099,7 @@ function PreviewModal({
|
|
|
1844
2099
|
boxShadow: "0 16px 48px rgba(0, 0, 0, 0.35)"
|
|
1845
2100
|
},
|
|
1846
2101
|
children: [
|
|
1847
|
-
/* @__PURE__ */
|
|
2102
|
+
/* @__PURE__ */ jsxs6(
|
|
1848
2103
|
"div",
|
|
1849
2104
|
{
|
|
1850
2105
|
style: {
|
|
@@ -1854,7 +2109,7 @@ function PreviewModal({
|
|
|
1854
2109
|
color: COLORS.white
|
|
1855
2110
|
},
|
|
1856
2111
|
children: [
|
|
1857
|
-
/* @__PURE__ */
|
|
2112
|
+
/* @__PURE__ */ jsx7(
|
|
1858
2113
|
"h3",
|
|
1859
2114
|
{
|
|
1860
2115
|
style: {
|
|
@@ -1866,7 +2121,7 @@ function PreviewModal({
|
|
|
1866
2121
|
children: strings.title
|
|
1867
2122
|
}
|
|
1868
2123
|
),
|
|
1869
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ jsx7(
|
|
1870
2125
|
"button",
|
|
1871
2126
|
{
|
|
1872
2127
|
ref: closeButtonRef,
|
|
@@ -1874,15 +2129,11 @@ function PreviewModal({
|
|
|
1874
2129
|
onClick: onClose,
|
|
1875
2130
|
"data-testid": "preview-modal-close",
|
|
1876
2131
|
"aria-label": strings.closeLabel,
|
|
2132
|
+
className: "interlace-btn",
|
|
1877
2133
|
style: {
|
|
1878
|
-
padding: `${SPACE[1]}px ${SPACE[3]}px`,
|
|
1879
2134
|
backgroundColor: "transparent",
|
|
1880
|
-
border:
|
|
1881
|
-
color: COLORS.white
|
|
1882
|
-
borderRadius: RADIUS.sm,
|
|
1883
|
-
cursor: "pointer",
|
|
1884
|
-
fontSize: TYPE.sm,
|
|
1885
|
-
transition: "background-color 150ms ease, border-color 150ms ease"
|
|
2135
|
+
border: "1px solid rgba(255, 255, 255, 0.4)",
|
|
2136
|
+
color: COLORS.white
|
|
1886
2137
|
},
|
|
1887
2138
|
children: strings.closeLabel
|
|
1888
2139
|
}
|
|
@@ -1890,7 +2141,7 @@ function PreviewModal({
|
|
|
1890
2141
|
]
|
|
1891
2142
|
}
|
|
1892
2143
|
),
|
|
1893
|
-
/* @__PURE__ */
|
|
2144
|
+
/* @__PURE__ */ jsxs6(
|
|
1894
2145
|
"div",
|
|
1895
2146
|
{
|
|
1896
2147
|
className: "preview-modal-content",
|
|
@@ -1902,13 +2153,13 @@ function PreviewModal({
|
|
|
1902
2153
|
backgroundColor: "#000"
|
|
1903
2154
|
},
|
|
1904
2155
|
children: [
|
|
1905
|
-
/* @__PURE__ */
|
|
2156
|
+
/* @__PURE__ */ jsx7(
|
|
1906
2157
|
"div",
|
|
1907
2158
|
{
|
|
1908
2159
|
className: "preview-modal-video-container",
|
|
1909
2160
|
"data-testid": "preview-modal-video-container",
|
|
1910
2161
|
style: { width: "100%", height: "100%" },
|
|
1911
|
-
children: /* @__PURE__ */
|
|
2162
|
+
children: /* @__PURE__ */ jsx7(
|
|
1912
2163
|
"video",
|
|
1913
2164
|
{
|
|
1914
2165
|
ref: videoRef,
|
|
@@ -1926,7 +2177,7 @@ function PreviewModal({
|
|
|
1926
2177
|
)
|
|
1927
2178
|
}
|
|
1928
2179
|
),
|
|
1929
|
-
adapter ? /* @__PURE__ */
|
|
2180
|
+
adapter ? /* @__PURE__ */ jsx7(
|
|
1930
2181
|
"div",
|
|
1931
2182
|
{
|
|
1932
2183
|
className: "preview-modal-player-container",
|
|
@@ -1939,7 +2190,7 @@ function PreviewModal({
|
|
|
1939
2190
|
height: "100%",
|
|
1940
2191
|
pointerEvents: "none"
|
|
1941
2192
|
},
|
|
1942
|
-
children: /* @__PURE__ */
|
|
2193
|
+
children: /* @__PURE__ */ jsx7(
|
|
1943
2194
|
InteractiveVideoPlayer,
|
|
1944
2195
|
{
|
|
1945
2196
|
adapter,
|
|
@@ -1949,7 +2200,7 @@ function PreviewModal({
|
|
|
1949
2200
|
}
|
|
1950
2201
|
)
|
|
1951
2202
|
}
|
|
1952
|
-
) : /* @__PURE__ */
|
|
2203
|
+
) : /* @__PURE__ */ jsx7(
|
|
1953
2204
|
"div",
|
|
1954
2205
|
{
|
|
1955
2206
|
"data-testid": "preview-modal-loading",
|
|
@@ -1980,8 +2231,8 @@ function PreviewModal({
|
|
|
1980
2231
|
|
|
1981
2232
|
// src/components/video-source-input.tsx
|
|
1982
2233
|
import { DEFAULT_STRINGS as DEFAULT_STRINGS4 } from "@interlacejs/core";
|
|
1983
|
-
import { useCallback as useCallback6, useEffect as
|
|
1984
|
-
import { jsx as
|
|
2234
|
+
import { useCallback as useCallback6, useEffect as useEffect6, useRef as useRef8, useState as useState5 } from "react";
|
|
2235
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1985
2236
|
var DEFAULT_VIDEO_SOURCE_INPUT_STRINGS = {
|
|
1986
2237
|
...DEFAULT_STRINGS4,
|
|
1987
2238
|
uploadLabel: "Upload a video file",
|
|
@@ -2006,12 +2257,12 @@ function VideoSourceInput({
|
|
|
2006
2257
|
const strings = { ...DEFAULT_VIDEO_SOURCE_INPUT_STRINGS, ...stringsOverride };
|
|
2007
2258
|
const [urlDraft, setUrlDraft] = useState5(value?.src ?? "");
|
|
2008
2259
|
const [uploadState, setUploadState] = useState5({ kind: "idle" });
|
|
2009
|
-
const fileInputRef =
|
|
2010
|
-
const uploadTokenRef =
|
|
2011
|
-
|
|
2260
|
+
const fileInputRef = useRef8(null);
|
|
2261
|
+
const uploadTokenRef = useRef8(0);
|
|
2262
|
+
useEffect6(() => {
|
|
2012
2263
|
setUrlDraft(value?.src ?? "");
|
|
2013
2264
|
}, [value?.src]);
|
|
2014
|
-
|
|
2265
|
+
useEffect6(() => {
|
|
2015
2266
|
return () => {
|
|
2016
2267
|
uploadTokenRef.current += 1;
|
|
2017
2268
|
};
|
|
@@ -2052,215 +2303,163 @@ function VideoSourceInput({
|
|
|
2052
2303
|
const hasError = uploadState.kind === "error";
|
|
2053
2304
|
const isDisabled = disabled || isUploading;
|
|
2054
2305
|
const applyDisabled = isDisabled || urlDraft.trim().length === 0;
|
|
2055
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ jsxs7(
|
|
2056
2307
|
"div",
|
|
2057
2308
|
{
|
|
2058
2309
|
className: "video-source-input",
|
|
2059
2310
|
style: {
|
|
2060
2311
|
display: "flex",
|
|
2061
2312
|
flexDirection: "column",
|
|
2062
|
-
gap:
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
borderRadius: `${RADIUS.md}px`,
|
|
2066
|
-
backgroundColor: COLORS.surfaceRaised
|
|
2313
|
+
gap: SPACE[4],
|
|
2314
|
+
fontFamily: FONTS.body,
|
|
2315
|
+
color: COLORS.text
|
|
2067
2316
|
},
|
|
2068
2317
|
children: [
|
|
2069
|
-
value?.src ? /* @__PURE__ */
|
|
2318
|
+
value?.src ? /* @__PURE__ */ jsxs7(
|
|
2070
2319
|
"div",
|
|
2071
2320
|
{
|
|
2072
2321
|
style: {
|
|
2073
|
-
padding: `${SPACE[
|
|
2074
|
-
backgroundColor: COLORS.
|
|
2322
|
+
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
2323
|
+
backgroundColor: COLORS.surfaceRaised,
|
|
2075
2324
|
border: `1px solid ${COLORS.border}`,
|
|
2076
|
-
borderRadius:
|
|
2325
|
+
borderRadius: RADIUS.sm,
|
|
2077
2326
|
fontSize: TYPE.sm,
|
|
2078
|
-
|
|
2327
|
+
overflowWrap: "anywhere"
|
|
2079
2328
|
},
|
|
2080
2329
|
children: [
|
|
2081
|
-
/* @__PURE__ */
|
|
2330
|
+
/* @__PURE__ */ jsxs7("span", { style: { color: COLORS.textMuted }, children: [
|
|
2082
2331
|
strings.currentSourceLabel,
|
|
2083
2332
|
":"
|
|
2084
2333
|
] }),
|
|
2085
2334
|
" ",
|
|
2086
|
-
/* @__PURE__ */
|
|
2335
|
+
/* @__PURE__ */ jsx8("code", { "data-testid": "video-source-input-current-src", children: value.src })
|
|
2087
2336
|
]
|
|
2088
2337
|
}
|
|
2089
|
-
) : /* @__PURE__ */
|
|
2090
|
-
|
|
2338
|
+
) : /* @__PURE__ */ jsx8("p", { "data-testid": "video-source-input-empty", className: "interlace-hint", children: strings.noVideoSelectedLabel }),
|
|
2339
|
+
/* @__PURE__ */ jsxs7(
|
|
2340
|
+
"div",
|
|
2091
2341
|
{
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2342
|
+
style: {
|
|
2343
|
+
display: "flex",
|
|
2344
|
+
flexDirection: "column",
|
|
2345
|
+
alignItems: "center",
|
|
2346
|
+
gap: SPACE[2],
|
|
2347
|
+
padding: `${SPACE[5]}px ${SPACE[4]}px`,
|
|
2348
|
+
border: `2px dashed ${COLORS.borderStrong}`,
|
|
2349
|
+
borderRadius: RADIUS.md,
|
|
2350
|
+
backgroundColor: COLORS.surfaceRaised,
|
|
2351
|
+
textAlign: "center"
|
|
2352
|
+
},
|
|
2353
|
+
children: [
|
|
2354
|
+
/* @__PURE__ */ jsx8(SectionHeading, { children: strings.uploadLabel }),
|
|
2355
|
+
/* @__PURE__ */ jsx8(
|
|
2356
|
+
"input",
|
|
2357
|
+
{
|
|
2358
|
+
ref: fileInputRef,
|
|
2359
|
+
type: "file",
|
|
2360
|
+
accept: "video/*",
|
|
2361
|
+
onChange: handleFileSelected,
|
|
2362
|
+
disabled: isDisabled,
|
|
2363
|
+
"data-testid": "video-source-input-file",
|
|
2364
|
+
style: { display: "none" }
|
|
2365
|
+
}
|
|
2366
|
+
),
|
|
2367
|
+
/* @__PURE__ */ jsx8(
|
|
2368
|
+
Button,
|
|
2369
|
+
{
|
|
2370
|
+
variant: "primary",
|
|
2371
|
+
onClick: () => fileInputRef.current?.click(),
|
|
2372
|
+
disabled: isDisabled,
|
|
2373
|
+
"data-testid": "video-source-input-file-button",
|
|
2374
|
+
children: isUploading ? `${strings.uploadingLabel} (${uploadState.fileName})` : strings.uploadButtonLabel
|
|
2375
|
+
}
|
|
2376
|
+
),
|
|
2377
|
+
isUploading ? /* @__PURE__ */ jsx8(
|
|
2378
|
+
"span",
|
|
2379
|
+
{
|
|
2380
|
+
"data-testid": "video-source-input-uploading",
|
|
2381
|
+
className: "interlace-hint",
|
|
2382
|
+
"aria-live": "polite",
|
|
2383
|
+
children: strings.uploadingLabel
|
|
2384
|
+
}
|
|
2385
|
+
) : null,
|
|
2386
|
+
hasError ? /* @__PURE__ */ jsxs7(
|
|
2387
|
+
"div",
|
|
2388
|
+
{
|
|
2389
|
+
"data-testid": "video-source-input-error",
|
|
2390
|
+
role: "alert",
|
|
2391
|
+
style: {
|
|
2392
|
+
display: "flex",
|
|
2393
|
+
alignItems: "center",
|
|
2394
|
+
flexWrap: "wrap",
|
|
2395
|
+
gap: SPACE[2],
|
|
2396
|
+
color: COLORS.errorText,
|
|
2397
|
+
backgroundColor: COLORS.errorBg,
|
|
2398
|
+
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
2399
|
+
borderRadius: RADIUS.sm,
|
|
2400
|
+
border: `1px solid ${COLORS.errorBorder}`,
|
|
2401
|
+
fontSize: TYPE.sm
|
|
2402
|
+
},
|
|
2403
|
+
children: [
|
|
2404
|
+
/* @__PURE__ */ jsxs7("span", { children: [
|
|
2405
|
+
/* @__PURE__ */ jsx8("strong", { children: strings.uploadFailedLabel }),
|
|
2406
|
+
" ",
|
|
2407
|
+
/* @__PURE__ */ jsx8("span", { children: uploadState.message })
|
|
2408
|
+
] }),
|
|
2409
|
+
/* @__PURE__ */ jsx8(
|
|
2410
|
+
Button,
|
|
2411
|
+
{
|
|
2412
|
+
variant: "danger",
|
|
2413
|
+
onClick: handleRetryUpload,
|
|
2414
|
+
"data-testid": "video-source-input-retry",
|
|
2415
|
+
children: strings.retryLabel
|
|
2416
|
+
}
|
|
2417
|
+
)
|
|
2418
|
+
]
|
|
2419
|
+
}
|
|
2420
|
+
) : null
|
|
2421
|
+
]
|
|
2095
2422
|
}
|
|
2096
2423
|
),
|
|
2097
|
-
/* @__PURE__ */
|
|
2098
|
-
/* @__PURE__ */
|
|
2099
|
-
"h4",
|
|
2100
|
-
{
|
|
2101
|
-
style: {
|
|
2102
|
-
margin: `0 0 ${SPACE[2]}px 0`,
|
|
2103
|
-
fontSize: TYPE.md,
|
|
2104
|
-
fontWeight: 600,
|
|
2105
|
-
color: COLORS.text
|
|
2106
|
-
},
|
|
2107
|
-
children: strings.uploadLabel
|
|
2108
|
-
}
|
|
2109
|
-
),
|
|
2110
|
-
/* @__PURE__ */ jsx7(
|
|
2424
|
+
/* @__PURE__ */ jsx8(Field, { label: strings.urlLabel, children: ({ id }) => /* @__PURE__ */ jsxs7("div", { style: { display: "flex", gap: SPACE[2], flexWrap: "wrap" }, children: [
|
|
2425
|
+
/* @__PURE__ */ jsx8(
|
|
2111
2426
|
"input",
|
|
2112
2427
|
{
|
|
2113
|
-
|
|
2114
|
-
type: "
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
style: { display: "none" }
|
|
2120
|
-
}
|
|
2121
|
-
),
|
|
2122
|
-
/* @__PURE__ */ jsx7(
|
|
2123
|
-
"button",
|
|
2124
|
-
{
|
|
2125
|
-
type: "button",
|
|
2126
|
-
onClick: () => fileInputRef.current?.click(),
|
|
2428
|
+
id,
|
|
2429
|
+
type: "url",
|
|
2430
|
+
className: "interlace-input",
|
|
2431
|
+
value: urlDraft,
|
|
2432
|
+
onChange: (e) => setUrlDraft(e.target.value),
|
|
2433
|
+
placeholder: strings.urlPlaceholder,
|
|
2127
2434
|
disabled: isDisabled,
|
|
2128
|
-
"data-testid": "video-source-input-
|
|
2129
|
-
style: {
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
fontSize: TYPE.md,
|
|
2137
|
-
fontWeight: 600,
|
|
2138
|
-
transition: "background-color 150ms ease"
|
|
2139
|
-
},
|
|
2140
|
-
children: isUploading ? `${strings.uploadingLabel} (${uploadState.fileName})` : strings.uploadButtonLabel
|
|
2435
|
+
"data-testid": "video-source-input-url",
|
|
2436
|
+
style: { flex: "1 1 240px", width: "auto" },
|
|
2437
|
+
onKeyDown: (e) => {
|
|
2438
|
+
if (e.key === "Enter" && !applyDisabled) {
|
|
2439
|
+
e.preventDefault();
|
|
2440
|
+
handleApplyUrl();
|
|
2441
|
+
}
|
|
2442
|
+
}
|
|
2141
2443
|
}
|
|
2142
2444
|
),
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
{
|
|
2146
|
-
"data-testid": "video-source-input-uploading",
|
|
2147
|
-
style: { marginLeft: `${SPACE[2]}px`, color: COLORS.textMuted, fontSize: TYPE.sm },
|
|
2148
|
-
"aria-live": "polite",
|
|
2149
|
-
children: strings.uploadingLabel
|
|
2150
|
-
}
|
|
2151
|
-
) : null,
|
|
2152
|
-
hasError ? /* @__PURE__ */ jsxs6(
|
|
2153
|
-
"div",
|
|
2154
|
-
{
|
|
2155
|
-
"data-testid": "video-source-input-error",
|
|
2156
|
-
role: "alert",
|
|
2157
|
-
style: {
|
|
2158
|
-
marginTop: `${SPACE[2]}px`,
|
|
2159
|
-
color: COLORS.errorText,
|
|
2160
|
-
backgroundColor: COLORS.errorBg,
|
|
2161
|
-
padding: `${SPACE[2]}px`,
|
|
2162
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
2163
|
-
border: `1px solid ${COLORS.errorBorder}`,
|
|
2164
|
-
fontSize: TYPE.sm
|
|
2165
|
-
},
|
|
2166
|
-
children: [
|
|
2167
|
-
/* @__PURE__ */ jsx7("strong", { children: strings.uploadFailedLabel }),
|
|
2168
|
-
" ",
|
|
2169
|
-
/* @__PURE__ */ jsx7("span", { children: uploadState.message }),
|
|
2170
|
-
/* @__PURE__ */ jsx7(
|
|
2171
|
-
"button",
|
|
2172
|
-
{
|
|
2173
|
-
type: "button",
|
|
2174
|
-
onClick: handleRetryUpload,
|
|
2175
|
-
"data-testid": "video-source-input-retry",
|
|
2176
|
-
style: {
|
|
2177
|
-
marginLeft: `${SPACE[2]}px`,
|
|
2178
|
-
padding: `${SPACE[1]}px ${SPACE[2]}px`,
|
|
2179
|
-
backgroundColor: COLORS.surface,
|
|
2180
|
-
border: `1px solid ${COLORS.errorBorder}`,
|
|
2181
|
-
color: COLORS.errorText,
|
|
2182
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
2183
|
-
cursor: "pointer",
|
|
2184
|
-
fontSize: TYPE.xs,
|
|
2185
|
-
fontWeight: 600
|
|
2186
|
-
},
|
|
2187
|
-
children: strings.retryLabel
|
|
2188
|
-
}
|
|
2189
|
-
)
|
|
2190
|
-
]
|
|
2191
|
-
}
|
|
2192
|
-
) : null
|
|
2193
|
-
] }),
|
|
2194
|
-
/* @__PURE__ */ jsxs6("div", { children: [
|
|
2195
|
-
/* @__PURE__ */ jsx7(
|
|
2196
|
-
"label",
|
|
2445
|
+
/* @__PURE__ */ jsx8(
|
|
2446
|
+
Button,
|
|
2197
2447
|
{
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
color: COLORS.text
|
|
2204
|
-
},
|
|
2205
|
-
children: strings.urlLabel
|
|
2448
|
+
variant: "secondary",
|
|
2449
|
+
onClick: handleApplyUrl,
|
|
2450
|
+
disabled: applyDisabled,
|
|
2451
|
+
"data-testid": "video-source-input-apply",
|
|
2452
|
+
children: strings.applyUrlLabel
|
|
2206
2453
|
}
|
|
2207
|
-
)
|
|
2208
|
-
|
|
2209
|
-
/* @__PURE__ */ jsx7(
|
|
2210
|
-
"input",
|
|
2211
|
-
{
|
|
2212
|
-
type: "url",
|
|
2213
|
-
value: urlDraft,
|
|
2214
|
-
onChange: (e) => setUrlDraft(e.target.value),
|
|
2215
|
-
placeholder: strings.urlPlaceholder,
|
|
2216
|
-
disabled: isDisabled,
|
|
2217
|
-
"data-testid": "video-source-input-url",
|
|
2218
|
-
style: {
|
|
2219
|
-
flex: 1,
|
|
2220
|
-
padding: `${SPACE[2]}px ${SPACE[3]}px`,
|
|
2221
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
2222
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
2223
|
-
fontSize: TYPE.md,
|
|
2224
|
-
color: COLORS.text
|
|
2225
|
-
},
|
|
2226
|
-
onKeyDown: (e) => {
|
|
2227
|
-
if (e.key === "Enter" && !applyDisabled) {
|
|
2228
|
-
e.preventDefault();
|
|
2229
|
-
handleApplyUrl();
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
}
|
|
2233
|
-
),
|
|
2234
|
-
/* @__PURE__ */ jsx7(
|
|
2235
|
-
"button",
|
|
2236
|
-
{
|
|
2237
|
-
type: "button",
|
|
2238
|
-
onClick: handleApplyUrl,
|
|
2239
|
-
disabled: applyDisabled,
|
|
2240
|
-
"data-testid": "video-source-input-apply",
|
|
2241
|
-
style: {
|
|
2242
|
-
padding: `${SPACE[2]}px ${SPACE[4]}px`,
|
|
2243
|
-
backgroundColor: applyDisabled ? COLORS.borderStrong : COLORS.accent,
|
|
2244
|
-
color: COLORS.white,
|
|
2245
|
-
border: "none",
|
|
2246
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
2247
|
-
cursor: applyDisabled ? "not-allowed" : "pointer",
|
|
2248
|
-
fontSize: TYPE.md,
|
|
2249
|
-
fontWeight: 600,
|
|
2250
|
-
transition: "background-color 150ms ease"
|
|
2251
|
-
},
|
|
2252
|
-
children: strings.applyUrlLabel
|
|
2253
|
-
}
|
|
2254
|
-
)
|
|
2255
|
-
] })
|
|
2256
|
-
] })
|
|
2454
|
+
)
|
|
2455
|
+
] }) })
|
|
2257
2456
|
]
|
|
2258
2457
|
}
|
|
2259
2458
|
);
|
|
2260
2459
|
}
|
|
2261
2460
|
|
|
2262
2461
|
// src/components/interlace-editor.tsx
|
|
2263
|
-
import { jsx as
|
|
2462
|
+
import { jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2264
2463
|
var DEFAULT_EDITOR_STRINGS = {
|
|
2265
2464
|
...DEFAULT_STRINGS5,
|
|
2266
2465
|
videoSourceInputTitle: "Add a video",
|
|
@@ -2269,7 +2468,7 @@ var DEFAULT_EDITOR_STRINGS = {
|
|
|
2269
2468
|
replaceVideoLabel: "Replace video",
|
|
2270
2469
|
replaceCancelLabel: "Cancel replace",
|
|
2271
2470
|
saveLabel: "Save",
|
|
2272
|
-
noItemSelectedLabel: "Select
|
|
2471
|
+
noItemSelectedLabel: "Select a hook on the timeline to edit it, or add one at the playhead.",
|
|
2273
2472
|
placementLabel: "Placement",
|
|
2274
2473
|
timelineHeading: "Hooks",
|
|
2275
2474
|
addContentHeading: "Add content",
|
|
@@ -2277,9 +2476,27 @@ var DEFAULT_EDITOR_STRINGS = {
|
|
|
2277
2476
|
contentEditorHeading: "Content",
|
|
2278
2477
|
editContentLabel: "Edit content",
|
|
2279
2478
|
loadErrorTitle: "Could not load the document",
|
|
2280
|
-
durationUnknownLabel: "Duration unknown"
|
|
2479
|
+
durationUnknownLabel: "Duration unknown",
|
|
2480
|
+
durationLabel: "Duration",
|
|
2481
|
+
unsavedChangesLabel: "Unsaved changes",
|
|
2482
|
+
savedLabel: "All changes saved",
|
|
2483
|
+
hooksNeedAttentionLabel: "{count} need attention",
|
|
2484
|
+
saveBlockedTitle: "Fix these before saving",
|
|
2485
|
+
goToHookLabel: "Go to hook",
|
|
2486
|
+
needsTitleIssue: "Add a title",
|
|
2487
|
+
needsContentTypeIssue: "Choose a content type",
|
|
2488
|
+
untitledHookLabel: "Untitled hook",
|
|
2489
|
+
noHookSelectedTitle: "No hook selected"
|
|
2281
2490
|
};
|
|
2282
2491
|
var DEFAULT_PLACEMENT = { x: 50, y: 50, width: 20, height: 20 };
|
|
2492
|
+
var WIDE_LAYOUT_MIN_WIDTH = 900;
|
|
2493
|
+
function formatDuration(seconds) {
|
|
2494
|
+
const total = Math.max(0, Math.round(seconds));
|
|
2495
|
+
const h = Math.floor(total / 3600);
|
|
2496
|
+
const m = Math.floor(total % 3600 / 60);
|
|
2497
|
+
const s = String(total % 60).padStart(2, "0");
|
|
2498
|
+
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${s}` : `${m}:${s}`;
|
|
2499
|
+
}
|
|
2283
2500
|
function makeDefaultData(contentTypeId) {
|
|
2284
2501
|
if (contentTypeId === "quiz" || contentTypeId === "quiz-editor") {
|
|
2285
2502
|
return {
|
|
@@ -2358,11 +2575,9 @@ function EditorVideoToolbar({
|
|
|
2358
2575
|
duration,
|
|
2359
2576
|
strings,
|
|
2360
2577
|
onReplaceVideo,
|
|
2361
|
-
onOpenPreview,
|
|
2362
|
-
theme,
|
|
2363
2578
|
hint
|
|
2364
2579
|
}) {
|
|
2365
|
-
return /* @__PURE__ */
|
|
2580
|
+
return /* @__PURE__ */ jsxs8(
|
|
2366
2581
|
"div",
|
|
2367
2582
|
{
|
|
2368
2583
|
"data-testid": "interlace-editor-video-toolbar",
|
|
@@ -2370,66 +2585,38 @@ function EditorVideoToolbar({
|
|
|
2370
2585
|
display: "flex",
|
|
2371
2586
|
justifyContent: "space-between",
|
|
2372
2587
|
alignItems: "center",
|
|
2373
|
-
|
|
2588
|
+
gap: SPACE[3],
|
|
2589
|
+
flexWrap: "wrap",
|
|
2590
|
+
padding: `${SPACE[2]}px 0 0`,
|
|
2374
2591
|
fontSize: TYPE.sm,
|
|
2375
|
-
color:
|
|
2592
|
+
color: COLORS.textMuted
|
|
2376
2593
|
},
|
|
2377
2594
|
children: [
|
|
2378
|
-
/* @__PURE__ */
|
|
2595
|
+
/* @__PURE__ */ jsxs8(
|
|
2379
2596
|
"span",
|
|
2380
2597
|
{
|
|
2381
2598
|
style: {
|
|
2382
2599
|
display: "flex",
|
|
2383
2600
|
alignItems: "center",
|
|
2384
|
-
gap:
|
|
2601
|
+
gap: SPACE[3],
|
|
2602
|
+
flexWrap: "wrap",
|
|
2603
|
+
minWidth: 0
|
|
2385
2604
|
},
|
|
2386
2605
|
children: [
|
|
2387
|
-
/* @__PURE__ */
|
|
2388
|
-
hint ? /* @__PURE__ */
|
|
2606
|
+
/* @__PURE__ */ jsx9("span", { "data-testid": "interlace-editor-video-duration", children: duration === void 0 || !Number.isFinite(duration) ? strings.durationUnknownLabel : `${strings.durationLabel} ${formatDuration(duration)}` }),
|
|
2607
|
+
hint ? /* @__PURE__ */ jsx9("span", { "data-testid": "interlace-editor-selection-hint", children: hint }) : null
|
|
2389
2608
|
]
|
|
2390
2609
|
}
|
|
2391
2610
|
),
|
|
2392
|
-
/* @__PURE__ */
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
backgroundColor: "transparent",
|
|
2402
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
2403
|
-
borderRadius: RADIUS.sm,
|
|
2404
|
-
cursor: "pointer",
|
|
2405
|
-
fontSize: TYPE.sm,
|
|
2406
|
-
color: COLORS.text,
|
|
2407
|
-
transition: "background-color 150ms ease, border-color 150ms ease"
|
|
2408
|
-
},
|
|
2409
|
-
children: strings.replaceVideoLabel
|
|
2410
|
-
}
|
|
2411
|
-
),
|
|
2412
|
-
/* @__PURE__ */ jsx8(
|
|
2413
|
-
"button",
|
|
2414
|
-
{
|
|
2415
|
-
type: "button",
|
|
2416
|
-
onClick: onOpenPreview,
|
|
2417
|
-
"data-testid": "interlace-editor-open-preview",
|
|
2418
|
-
style: {
|
|
2419
|
-
padding: `${SPACE[1]}px ${SPACE[3]}px`,
|
|
2420
|
-
backgroundColor: theme?.accentColor ?? COLORS.accent,
|
|
2421
|
-
color: COLORS.white,
|
|
2422
|
-
border: "none",
|
|
2423
|
-
borderRadius: RADIUS.sm,
|
|
2424
|
-
cursor: "pointer",
|
|
2425
|
-
fontSize: TYPE.sm,
|
|
2426
|
-
fontWeight: 600,
|
|
2427
|
-
transition: "background-color 150ms ease"
|
|
2428
|
-
},
|
|
2429
|
-
children: strings.previewLabel
|
|
2430
|
-
}
|
|
2431
|
-
)
|
|
2432
|
-
] })
|
|
2611
|
+
/* @__PURE__ */ jsx9(
|
|
2612
|
+
Button,
|
|
2613
|
+
{
|
|
2614
|
+
variant: "ghost",
|
|
2615
|
+
onClick: onReplaceVideo,
|
|
2616
|
+
"data-testid": "interlace-editor-replace-video",
|
|
2617
|
+
children: strings.replaceVideoLabel
|
|
2618
|
+
}
|
|
2619
|
+
)
|
|
2433
2620
|
]
|
|
2434
2621
|
}
|
|
2435
2622
|
);
|
|
@@ -2442,6 +2629,7 @@ function InterlaceEditor({
|
|
|
2442
2629
|
onDirtyChange,
|
|
2443
2630
|
strings: stringsOverride,
|
|
2444
2631
|
theme,
|
|
2632
|
+
className,
|
|
2445
2633
|
onError
|
|
2446
2634
|
}) {
|
|
2447
2635
|
const strings = { ...DEFAULT_EDITOR_STRINGS, ...stringsOverride };
|
|
@@ -2458,32 +2646,39 @@ function InterlaceEditor({
|
|
|
2458
2646
|
document?.video?.duration ?? 0
|
|
2459
2647
|
);
|
|
2460
2648
|
const [selectedItemId, setSelectedItemId] = useState6(null);
|
|
2461
|
-
const [
|
|
2649
|
+
const [pendingHooks, setPendingHooks] = useState6([]);
|
|
2650
|
+
const updatePendingHook = useCallback7(
|
|
2651
|
+
(id, update) => {
|
|
2652
|
+
setPendingHooks(
|
|
2653
|
+
(prev) => prev.map((pending) => pending.id === id ? update(pending) : pending)
|
|
2654
|
+
);
|
|
2655
|
+
},
|
|
2656
|
+
[]
|
|
2657
|
+
);
|
|
2462
2658
|
const [loadVersion, setLoadVersion] = useState6(0);
|
|
2463
2659
|
const [replaceMode, setReplaceMode] = useState6(false);
|
|
2464
2660
|
const [previewOpen, setPreviewOpen] = useState6(false);
|
|
2465
2661
|
const [currentTime, setCurrentTime] = useState6(0);
|
|
2466
|
-
const
|
|
2467
|
-
const
|
|
2468
|
-
const registryRef = useRef8(contentTypeRegistry);
|
|
2662
|
+
const nextIdRef = useRef9(1);
|
|
2663
|
+
const registryRef = useRef9(contentTypeRegistry);
|
|
2469
2664
|
registryRef.current = contentTypeRegistry;
|
|
2470
|
-
const loadedInitialDocRef =
|
|
2665
|
+
const loadedInitialDocRef = useRef9(
|
|
2471
2666
|
null
|
|
2472
2667
|
);
|
|
2473
|
-
const videoRef =
|
|
2474
|
-
const lastDurationForSrcRef =
|
|
2475
|
-
const pendingSeekRef =
|
|
2476
|
-
|
|
2668
|
+
const videoRef = useRef9(null);
|
|
2669
|
+
const lastDurationForSrcRef = useRef9(null);
|
|
2670
|
+
const pendingSeekRef = useRef9(null);
|
|
2671
|
+
useEffect7(() => {
|
|
2477
2672
|
if (!document) {
|
|
2478
2673
|
if (loadedInitialDocRef.current !== null) {
|
|
2479
2674
|
loadedInitialDocRef.current = null;
|
|
2480
|
-
|
|
2675
|
+
setPendingHooks([]);
|
|
2481
2676
|
}
|
|
2482
2677
|
return;
|
|
2483
2678
|
}
|
|
2484
2679
|
if (loadedInitialDocRef.current === document) return;
|
|
2485
2680
|
loadedInitialDocRef.current = document;
|
|
2486
|
-
|
|
2681
|
+
setPendingHooks([]);
|
|
2487
2682
|
setLoadVersion((v) => v + 1);
|
|
2488
2683
|
const { validationErrors, warnings } = loadDocument(
|
|
2489
2684
|
document,
|
|
@@ -2498,7 +2693,7 @@ function InterlaceEditor({
|
|
|
2498
2693
|
onError?.(new Error(warning));
|
|
2499
2694
|
}
|
|
2500
2695
|
}, [document, loadDocument, onError, strings.loadErrorTitle]);
|
|
2501
|
-
|
|
2696
|
+
useEffect7(() => {
|
|
2502
2697
|
const last = lastDurationForSrcRef.current;
|
|
2503
2698
|
if (!last) return;
|
|
2504
2699
|
if (last.src !== state.videoSrc) return;
|
|
@@ -2511,9 +2706,10 @@ function InterlaceEditor({
|
|
|
2511
2706
|
() => state.items.find((item) => item.content.getId() === selectedItemId) ?? null,
|
|
2512
2707
|
[state.items, selectedItemId]
|
|
2513
2708
|
);
|
|
2514
|
-
const
|
|
2515
|
-
const
|
|
2516
|
-
const
|
|
2709
|
+
const selectedPendingHook = selectedStoreItem ? null : pendingHooks.find((pending) => pending.id === selectedItemId) ?? null;
|
|
2710
|
+
const isPendingSelected = selectedPendingHook !== null;
|
|
2711
|
+
const selectedHook = isPendingSelected ? selectedPendingHook.hook : selectedStoreItem?.hook ?? null;
|
|
2712
|
+
const selectedTitle = isPendingSelected ? selectedPendingHook.title : selectedStoreItem?.content.getTitle() ?? null;
|
|
2517
2713
|
const selectedContentTypeId = isPendingSelected ? null : selectedStoreItem?.content.getContentTypeId() ?? null;
|
|
2518
2714
|
const selectedContent = selectedStoreItem?.content ?? null;
|
|
2519
2715
|
const selectedData = useMemo2(
|
|
@@ -2524,43 +2720,87 @@ function InterlaceEditor({
|
|
|
2524
2720
|
() => contentTypeRegistry.getAll().map((ct) => ct.getId()),
|
|
2525
2721
|
[contentTypeRegistry]
|
|
2526
2722
|
);
|
|
2723
|
+
const contentTypeOptions = useMemo2(
|
|
2724
|
+
() => contentTypeRegistry.getAll().map((ct) => ({
|
|
2725
|
+
id: ct.getId(),
|
|
2726
|
+
label: ct.getDisplayName?.() ?? ct.getId(),
|
|
2727
|
+
description: ct.getDescription?.()
|
|
2728
|
+
})),
|
|
2729
|
+
[contentTypeRegistry]
|
|
2730
|
+
);
|
|
2731
|
+
const { needsTitleIssue, needsContentTypeIssue } = strings;
|
|
2732
|
+
const hookIssues = useMemo2(() => {
|
|
2733
|
+
const issues = /* @__PURE__ */ new Map();
|
|
2734
|
+
for (const pending of pendingHooks) {
|
|
2735
|
+
issues.set(pending.id, [
|
|
2736
|
+
...pending.title.trim() ? [] : [needsTitleIssue],
|
|
2737
|
+
needsContentTypeIssue
|
|
2738
|
+
]);
|
|
2739
|
+
}
|
|
2740
|
+
for (const item of state.items) {
|
|
2741
|
+
const list = [];
|
|
2742
|
+
if (!item.content.getTitle().trim()) list.push(needsTitleIssue);
|
|
2743
|
+
const contentType = contentTypeRegistry.get(
|
|
2744
|
+
item.content.getContentTypeId()
|
|
2745
|
+
);
|
|
2746
|
+
try {
|
|
2747
|
+
list.push(...contentType?.validate?.(item.content.getData()) ?? []);
|
|
2748
|
+
} catch (err) {
|
|
2749
|
+
list.push(err instanceof Error ? err.message : String(err));
|
|
2750
|
+
}
|
|
2751
|
+
if (list.length > 0) issues.set(item.content.getId(), list);
|
|
2752
|
+
}
|
|
2753
|
+
return issues;
|
|
2754
|
+
}, [
|
|
2755
|
+
pendingHooks,
|
|
2756
|
+
state.items,
|
|
2757
|
+
contentTypeRegistry,
|
|
2758
|
+
needsTitleIssue,
|
|
2759
|
+
needsContentTypeIssue
|
|
2760
|
+
]);
|
|
2527
2761
|
const timelineEntries = useMemo2(() => {
|
|
2528
2762
|
const fromStore = state.items.map((item) => {
|
|
2529
|
-
const
|
|
2530
|
-
if (
|
|
2763
|
+
const hook = item.hook;
|
|
2764
|
+
if (hook.type === "blocking") {
|
|
2531
2765
|
return {
|
|
2532
2766
|
id: item.content.getId(),
|
|
2533
2767
|
title: item.content.getTitle(),
|
|
2534
2768
|
hookType: "blocking",
|
|
2535
|
-
timestamp:
|
|
2769
|
+
timestamp: hook.timestamp
|
|
2536
2770
|
};
|
|
2537
2771
|
}
|
|
2538
2772
|
return {
|
|
2539
2773
|
id: item.content.getId(),
|
|
2540
2774
|
title: item.content.getTitle(),
|
|
2541
2775
|
hookType: "non-blocking",
|
|
2542
|
-
start:
|
|
2543
|
-
end:
|
|
2776
|
+
start: hook.start,
|
|
2777
|
+
end: hook.end
|
|
2544
2778
|
};
|
|
2545
2779
|
});
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
id: pendingHook.id,
|
|
2552
|
-
title: pendingHook.title,
|
|
2780
|
+
const fromPending = pendingHooks.map((pending) => {
|
|
2781
|
+
const hook = pending.hook;
|
|
2782
|
+
return hook.type === "blocking" ? {
|
|
2783
|
+
id: pending.id,
|
|
2784
|
+
title: pending.title,
|
|
2553
2785
|
hookType: "blocking",
|
|
2554
2786
|
timestamp: hook.timestamp
|
|
2555
2787
|
} : {
|
|
2556
|
-
id:
|
|
2557
|
-
title:
|
|
2788
|
+
id: pending.id,
|
|
2789
|
+
title: pending.title,
|
|
2558
2790
|
hookType: "non-blocking",
|
|
2559
2791
|
start: hook.start,
|
|
2560
2792
|
end: hook.end
|
|
2561
|
-
}
|
|
2562
|
-
|
|
2563
|
-
|
|
2793
|
+
};
|
|
2794
|
+
});
|
|
2795
|
+
return [...fromStore, ...fromPending].map((entry) => {
|
|
2796
|
+
const issues = hookIssues.get(entry.id) ?? [];
|
|
2797
|
+
return {
|
|
2798
|
+
...entry,
|
|
2799
|
+
needsAttention: issues.length > 0,
|
|
2800
|
+
attentionLabel: issues.length > 0 ? issues.join(", ") : void 0
|
|
2801
|
+
};
|
|
2802
|
+
});
|
|
2803
|
+
}, [state.items, pendingHooks, hookIssues]);
|
|
2564
2804
|
const previewDocument = useMemo2(() => {
|
|
2565
2805
|
if (!state.videoSrc) {
|
|
2566
2806
|
return { video: { src: "" }, items: [] };
|
|
@@ -2589,7 +2829,7 @@ function InterlaceEditor({
|
|
|
2589
2829
|
}),
|
|
2590
2830
|
[previewDocument]
|
|
2591
2831
|
);
|
|
2592
|
-
const baselineRef =
|
|
2832
|
+
const baselineRef = useRef9(
|
|
2593
2833
|
null
|
|
2594
2834
|
);
|
|
2595
2835
|
if (baselineRef.current?.version !== loadVersion) {
|
|
@@ -2597,9 +2837,9 @@ function InterlaceEditor({
|
|
|
2597
2837
|
}
|
|
2598
2838
|
const [saved, setSaved] = useState6(null);
|
|
2599
2839
|
const baselineSnapshot = saved?.version === loadVersion ? saved.snapshot : baselineRef.current.snapshot;
|
|
2600
|
-
const isDirty = authoredSnapshot !== baselineSnapshot ||
|
|
2601
|
-
const lastReportedDirtyRef =
|
|
2602
|
-
|
|
2840
|
+
const isDirty = authoredSnapshot !== baselineSnapshot || pendingHooks.length > 0;
|
|
2841
|
+
const lastReportedDirtyRef = useRef9(null);
|
|
2842
|
+
useEffect7(() => {
|
|
2603
2843
|
if (lastReportedDirtyRef.current === isDirty) return;
|
|
2604
2844
|
lastReportedDirtyRef.current = isDirty;
|
|
2605
2845
|
onDirtyChange?.(isDirty);
|
|
@@ -2608,7 +2848,7 @@ function InterlaceEditor({
|
|
|
2608
2848
|
(id) => {
|
|
2609
2849
|
setSelectedItemId(id);
|
|
2610
2850
|
const item = state.items.find((it) => it.content.getId() === id);
|
|
2611
|
-
const hook = item ? item.content.getHook() :
|
|
2851
|
+
const hook = item ? item.content.getHook() : pendingHooks.find((pending) => pending.id === id)?.hook ?? null;
|
|
2612
2852
|
if (!hook) return;
|
|
2613
2853
|
const target = hook.type === "blocking" ? hook.timestamp : hook.start;
|
|
2614
2854
|
if (!Number.isFinite(target)) return;
|
|
@@ -2624,7 +2864,7 @@ function InterlaceEditor({
|
|
|
2624
2864
|
}
|
|
2625
2865
|
setCurrentTime(Math.max(0, target));
|
|
2626
2866
|
},
|
|
2627
|
-
[state.items,
|
|
2867
|
+
[state.items, pendingHooks, setCurrentTime]
|
|
2628
2868
|
);
|
|
2629
2869
|
const handleDeselect = useCallback7(() => {
|
|
2630
2870
|
setSelectedItemId(null);
|
|
@@ -2633,28 +2873,27 @@ function InterlaceEditor({
|
|
|
2633
2873
|
(hookType) => {
|
|
2634
2874
|
const id = `pending-${nextIdRef.current++}`;
|
|
2635
2875
|
const hook = makeHook(hookType, currentTime, state.videoDuration);
|
|
2636
|
-
|
|
2876
|
+
setPendingHooks((prev) => [...prev, { id, title: "", hook }]);
|
|
2637
2877
|
setSelectedItemId(id);
|
|
2638
2878
|
},
|
|
2639
2879
|
[currentTime, state.videoDuration]
|
|
2640
2880
|
);
|
|
2641
2881
|
const handleDeleteEntry = useCallback7(
|
|
2642
2882
|
(id) => {
|
|
2643
|
-
if (
|
|
2644
|
-
|
|
2883
|
+
if (pendingHooks.some((pending) => pending.id === id)) {
|
|
2884
|
+
setPendingHooks((prev) => prev.filter((pending) => pending.id !== id));
|
|
2645
2885
|
setSelectedItemId((prev) => prev === id ? null : prev);
|
|
2646
2886
|
return;
|
|
2647
2887
|
}
|
|
2648
2888
|
removeItem(id);
|
|
2649
2889
|
setSelectedItemId((prev) => prev === id ? null : prev);
|
|
2650
2890
|
},
|
|
2651
|
-
[
|
|
2891
|
+
[pendingHooks, removeItem]
|
|
2652
2892
|
);
|
|
2653
2893
|
const handleUpdateEntry = useCallback7(
|
|
2654
2894
|
(id, updates) => {
|
|
2655
|
-
if (
|
|
2656
|
-
|
|
2657
|
-
if (!prev || prev.id !== id) return prev;
|
|
2895
|
+
if (pendingHooks.some((pending) => pending.id === id)) {
|
|
2896
|
+
updatePendingHook(id, (prev) => {
|
|
2658
2897
|
const hook2 = prev.hook;
|
|
2659
2898
|
const nextHook = hook2.type === "blocking" ? { ...hook2, timestamp: updates.timestamp ?? hook2.timestamp } : {
|
|
2660
2899
|
...hook2,
|
|
@@ -2694,15 +2933,22 @@ function InterlaceEditor({
|
|
|
2694
2933
|
hook
|
|
2695
2934
|
});
|
|
2696
2935
|
},
|
|
2697
|
-
[
|
|
2936
|
+
[
|
|
2937
|
+
pendingHooks,
|
|
2938
|
+
updatePendingHook,
|
|
2939
|
+
state.items,
|
|
2940
|
+
contentTypeRegistry,
|
|
2941
|
+
updateItem
|
|
2942
|
+
]
|
|
2698
2943
|
);
|
|
2699
2944
|
const handlePlacementChange = useCallback7(
|
|
2700
2945
|
(nextPlacement) => {
|
|
2701
2946
|
if (!selectedItemId) return;
|
|
2702
|
-
if (
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2947
|
+
if (pendingHooks.some((pending) => pending.id === selectedItemId)) {
|
|
2948
|
+
updatePendingHook(selectedItemId, (prev) => ({
|
|
2949
|
+
...prev,
|
|
2950
|
+
hook: { ...prev.hook, placement: nextPlacement }
|
|
2951
|
+
}));
|
|
2706
2952
|
return;
|
|
2707
2953
|
}
|
|
2708
2954
|
const current = state.items.find(
|
|
@@ -2721,7 +2967,14 @@ function InterlaceEditor({
|
|
|
2721
2967
|
hook: nextHook
|
|
2722
2968
|
});
|
|
2723
2969
|
},
|
|
2724
|
-
[
|
|
2970
|
+
[
|
|
2971
|
+
selectedItemId,
|
|
2972
|
+
pendingHooks,
|
|
2973
|
+
updatePendingHook,
|
|
2974
|
+
state.items,
|
|
2975
|
+
contentTypeRegistry,
|
|
2976
|
+
updateItem
|
|
2977
|
+
]
|
|
2725
2978
|
);
|
|
2726
2979
|
const handleContentChange = useCallback7(
|
|
2727
2980
|
(newData) => {
|
|
@@ -2752,17 +3005,18 @@ function InterlaceEditor({
|
|
|
2752
3005
|
if (!selectedItemId) return;
|
|
2753
3006
|
const contentType = contentTypeRegistry.get(typeId);
|
|
2754
3007
|
if (!contentType) return;
|
|
2755
|
-
|
|
3008
|
+
const pending = pendingHooks.find((p) => p.id === selectedItemId);
|
|
3009
|
+
if (pending) {
|
|
2756
3010
|
const id = `hook-${nextIdRef.current++}`;
|
|
2757
3011
|
const item = buildContentInstance(
|
|
2758
3012
|
id,
|
|
2759
|
-
|
|
3013
|
+
pending.title,
|
|
2760
3014
|
contentType,
|
|
2761
|
-
|
|
3015
|
+
pending.hook,
|
|
2762
3016
|
makeDefaultData(contentType.getId())
|
|
2763
3017
|
);
|
|
2764
|
-
addItem({ content: item, hook:
|
|
2765
|
-
|
|
3018
|
+
addItem({ content: item, hook: pending.hook });
|
|
3019
|
+
setPendingHooks((prev) => prev.filter((p) => p.id !== pending.id));
|
|
2766
3020
|
setSelectedItemId(id);
|
|
2767
3021
|
return;
|
|
2768
3022
|
}
|
|
@@ -2781,7 +3035,7 @@ function InterlaceEditor({
|
|
|
2781
3035
|
updateItem(selectedItemId, { content: rebuilt, hook: current.hook });
|
|
2782
3036
|
},
|
|
2783
3037
|
[
|
|
2784
|
-
|
|
3038
|
+
pendingHooks,
|
|
2785
3039
|
selectedItemId,
|
|
2786
3040
|
contentTypeRegistry,
|
|
2787
3041
|
addItem,
|
|
@@ -2792,21 +3046,23 @@ function InterlaceEditor({
|
|
|
2792
3046
|
const handleTimeChange = useCallback7(
|
|
2793
3047
|
(updates) => {
|
|
2794
3048
|
if (!selectedItemId) return;
|
|
2795
|
-
const
|
|
2796
|
-
const hook =
|
|
3049
|
+
const pending = pendingHooks.find((p) => p.id === selectedItemId);
|
|
3050
|
+
const hook = pending ? pending.hook : state.items.find((it) => it.content.getId() === selectedItemId)?.hook;
|
|
2797
3051
|
if (!hook) return;
|
|
2798
3052
|
const clamped = clampTimeUpdates(hook, updates, state.videoDuration);
|
|
2799
|
-
if (
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
3053
|
+
if (pending) {
|
|
3054
|
+
updatePendingHook(selectedItemId, (prev) => ({
|
|
3055
|
+
...prev,
|
|
3056
|
+
hook: { ...prev.hook, ...clamped }
|
|
3057
|
+
}));
|
|
2803
3058
|
return;
|
|
2804
3059
|
}
|
|
2805
3060
|
handleUpdateEntry(selectedItemId, clamped);
|
|
2806
3061
|
},
|
|
2807
3062
|
[
|
|
2808
3063
|
selectedItemId,
|
|
2809
|
-
|
|
3064
|
+
pendingHooks,
|
|
3065
|
+
updatePendingHook,
|
|
2810
3066
|
state.items,
|
|
2811
3067
|
state.videoDuration,
|
|
2812
3068
|
handleUpdateEntry
|
|
@@ -2818,10 +3074,10 @@ function InterlaceEditor({
|
|
|
2818
3074
|
const duration = next.duration ?? preserveDuration;
|
|
2819
3075
|
setVideoMetadata(next.src, duration);
|
|
2820
3076
|
setReplaceMode(false);
|
|
2821
|
-
|
|
3077
|
+
setPendingHooks([]);
|
|
2822
3078
|
setPreviewOpen(false);
|
|
2823
3079
|
},
|
|
2824
|
-
[setVideoMetadata,
|
|
3080
|
+
[setVideoMetadata, state.videoSrc, state.videoDuration]
|
|
2825
3081
|
);
|
|
2826
3082
|
const handleReplaceVideo = useCallback7(() => {
|
|
2827
3083
|
setReplaceMode(true);
|
|
@@ -2849,30 +3105,13 @@ function InterlaceEditor({
|
|
|
2849
3105
|
}
|
|
2850
3106
|
setCurrentTime(t);
|
|
2851
3107
|
}, []);
|
|
2852
|
-
const handleTogglePlay = useCallback7(() => {
|
|
2853
|
-
const video = videoRef.current;
|
|
2854
|
-
if (!video) return;
|
|
2855
|
-
if (video.paused) {
|
|
2856
|
-
try {
|
|
2857
|
-
const p = video.play();
|
|
2858
|
-
p?.catch?.(() => {
|
|
2859
|
-
});
|
|
2860
|
-
} catch {
|
|
2861
|
-
}
|
|
2862
|
-
} else {
|
|
2863
|
-
try {
|
|
2864
|
-
video.pause();
|
|
2865
|
-
} catch {
|
|
2866
|
-
}
|
|
2867
|
-
}
|
|
2868
|
-
}, []);
|
|
2869
3108
|
const handleOpenPreview = useCallback7(() => {
|
|
2870
3109
|
setPreviewOpen(true);
|
|
2871
3110
|
}, []);
|
|
2872
3111
|
const handleClosePreview = useCallback7(() => {
|
|
2873
3112
|
setPreviewOpen(false);
|
|
2874
3113
|
}, []);
|
|
2875
|
-
|
|
3114
|
+
useEffect7(() => {
|
|
2876
3115
|
if (previewOpen && videoRef.current) {
|
|
2877
3116
|
try {
|
|
2878
3117
|
videoRef.current.pause();
|
|
@@ -2900,350 +3139,461 @@ function InterlaceEditor({
|
|
|
2900
3139
|
},
|
|
2901
3140
|
[state.videoSrc, setVideoMetadata]
|
|
2902
3141
|
);
|
|
3142
|
+
const [saveAttempted, setSaveAttempted] = useState6(false);
|
|
2903
3143
|
const handleSave = useCallback7(() => {
|
|
2904
|
-
|
|
3144
|
+
if (hookIssues.size > 0) {
|
|
3145
|
+
setSaveAttempted(true);
|
|
3146
|
+
return;
|
|
3147
|
+
}
|
|
3148
|
+
setSaveAttempted(false);
|
|
3149
|
+
onSave(serialize());
|
|
2905
3150
|
setSaved({ version: loadVersion, snapshot: authoredSnapshot });
|
|
2906
|
-
}, [onSave, serialize, authoredSnapshot, loadVersion]);
|
|
3151
|
+
}, [hookIssues, onSave, serialize, authoredSnapshot, loadVersion]);
|
|
3152
|
+
const handleHookTypeChange = useCallback7(
|
|
3153
|
+
(hookType) => {
|
|
3154
|
+
if (!selectedItemId || !selectedHook) return;
|
|
3155
|
+
if (selectedHook.type === hookType) return;
|
|
3156
|
+
const anchor = selectedHook.type === "blocking" ? selectedHook.timestamp : selectedHook.start;
|
|
3157
|
+
const nextHook = {
|
|
3158
|
+
...makeHook(hookType, anchor, state.videoDuration),
|
|
3159
|
+
placement: selectedHook.placement
|
|
3160
|
+
};
|
|
3161
|
+
if (pendingHooks.some((pending) => pending.id === selectedItemId)) {
|
|
3162
|
+
updatePendingHook(selectedItemId, (prev) => ({
|
|
3163
|
+
...prev,
|
|
3164
|
+
hook: nextHook
|
|
3165
|
+
}));
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
const current = state.items.find(
|
|
3169
|
+
(item) => item.content.getId() === selectedItemId
|
|
3170
|
+
);
|
|
3171
|
+
if (!current) return;
|
|
3172
|
+
const contentType = contentTypeRegistry.get(
|
|
3173
|
+
current.content.getContentTypeId()
|
|
3174
|
+
);
|
|
3175
|
+
if (!contentType) return;
|
|
3176
|
+
updateItem(selectedItemId, {
|
|
3177
|
+
content: rebuildContentInstance(current.content, contentType, {
|
|
3178
|
+
hook: nextHook
|
|
3179
|
+
}),
|
|
3180
|
+
hook: nextHook
|
|
3181
|
+
});
|
|
3182
|
+
},
|
|
3183
|
+
[
|
|
3184
|
+
selectedItemId,
|
|
3185
|
+
selectedHook,
|
|
3186
|
+
state.videoDuration,
|
|
3187
|
+
state.items,
|
|
3188
|
+
pendingHooks,
|
|
3189
|
+
updatePendingHook,
|
|
3190
|
+
contentTypeRegistry,
|
|
3191
|
+
updateItem
|
|
3192
|
+
]
|
|
3193
|
+
);
|
|
3194
|
+
const rootRef = useRef9(null);
|
|
3195
|
+
const [isWide, setIsWide] = useState6(false);
|
|
3196
|
+
useEffect7(() => {
|
|
3197
|
+
const el = rootRef.current;
|
|
3198
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
3199
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
3200
|
+
if (entry) setIsWide(entry.contentRect.width >= WIDE_LAYOUT_MIN_WIDTH);
|
|
3201
|
+
});
|
|
3202
|
+
observer.observe(el);
|
|
3203
|
+
return () => observer.disconnect();
|
|
3204
|
+
}, [showSourceStep]);
|
|
3205
|
+
useInterlaceStyles();
|
|
3206
|
+
const rootClassName = ["interlace-editor", className].filter(Boolean).join(" ");
|
|
2907
3207
|
const rootStyle = {
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
3208
|
+
...themeToCssVariables(theme),
|
|
3209
|
+
boxSizing: "border-box",
|
|
3210
|
+
padding: SPACE[4],
|
|
3211
|
+
borderRadius: RADIUS.lg,
|
|
3212
|
+
border: `1px solid ${COLORS.border}`,
|
|
3213
|
+
backgroundColor: COLORS.surface,
|
|
3214
|
+
color: COLORS.text,
|
|
3215
|
+
fontFamily: FONTS.body,
|
|
3216
|
+
fontSize: TYPE.base - 1
|
|
2911
3217
|
};
|
|
2912
|
-
const
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
backgroundColor:
|
|
2918
|
-
|
|
3218
|
+
const panelStyle = {
|
|
3219
|
+
boxSizing: "border-box",
|
|
3220
|
+
padding: SPACE[4],
|
|
3221
|
+
borderRadius: RADIUS.md,
|
|
3222
|
+
border: `1px solid ${COLORS.border}`,
|
|
3223
|
+
backgroundColor: COLORS.surfaceRaised,
|
|
3224
|
+
minWidth: 0
|
|
2919
3225
|
};
|
|
2920
3226
|
if (showSourceStep) {
|
|
2921
|
-
return /* @__PURE__ */
|
|
3227
|
+
return /* @__PURE__ */ jsxs8("div", { ref: rootRef, className: rootClassName, style: rootStyle, children: [
|
|
3228
|
+
/* @__PURE__ */ jsxs8(
|
|
3229
|
+
"div",
|
|
3230
|
+
{
|
|
3231
|
+
style: {
|
|
3232
|
+
display: "flex",
|
|
3233
|
+
justifyContent: "space-between",
|
|
3234
|
+
alignItems: "center",
|
|
3235
|
+
gap: SPACE[3],
|
|
3236
|
+
marginBottom: SPACE[4]
|
|
3237
|
+
},
|
|
3238
|
+
children: [
|
|
3239
|
+
/* @__PURE__ */ jsx9(
|
|
3240
|
+
"h2",
|
|
3241
|
+
{
|
|
3242
|
+
style: {
|
|
3243
|
+
margin: 0,
|
|
3244
|
+
fontFamily: FONTS.display,
|
|
3245
|
+
fontSize: TYPE.lg,
|
|
3246
|
+
fontWeight: 600
|
|
3247
|
+
},
|
|
3248
|
+
children: strings.videoSourceInputTitle
|
|
3249
|
+
}
|
|
3250
|
+
),
|
|
3251
|
+
replaceMode ? /* @__PURE__ */ jsx9(
|
|
3252
|
+
Button,
|
|
3253
|
+
{
|
|
3254
|
+
variant: "secondary",
|
|
3255
|
+
onClick: handleCancelReplace,
|
|
3256
|
+
"data-testid": "interlace-editor-cancel-replace",
|
|
3257
|
+
children: strings.replaceCancelLabel
|
|
3258
|
+
}
|
|
3259
|
+
) : null
|
|
3260
|
+
]
|
|
3261
|
+
}
|
|
3262
|
+
),
|
|
3263
|
+
/* @__PURE__ */ jsx9(
|
|
3264
|
+
VideoSourceInput,
|
|
3265
|
+
{
|
|
3266
|
+
value: {
|
|
3267
|
+
src: state.videoSrc || void 0,
|
|
3268
|
+
duration: state.videoDuration || void 0
|
|
3269
|
+
},
|
|
3270
|
+
onChange: handleVideoSourceChange,
|
|
3271
|
+
onUpload,
|
|
3272
|
+
onError,
|
|
3273
|
+
strings: strings.videoSource
|
|
3274
|
+
}
|
|
3275
|
+
)
|
|
3276
|
+
] });
|
|
3277
|
+
}
|
|
3278
|
+
const issueCount = hookIssues.size;
|
|
3279
|
+
const hookLabel = (id) => {
|
|
3280
|
+
const entry = timelineEntries.find((e) => e.id === id);
|
|
3281
|
+
if (!entry) return strings.untitledHookLabel;
|
|
3282
|
+
const time = entry.hookType === "blocking" ? entry.timestamp : entry.start;
|
|
3283
|
+
const name = entry.title.trim() || strings.untitledHookLabel;
|
|
3284
|
+
return `${name} (${formatDuration(time ?? 0)})`;
|
|
3285
|
+
};
|
|
3286
|
+
const statusText = isDirty ? strings.unsavedChangesLabel : saved?.version === loadVersion ? strings.savedLabel : null;
|
|
3287
|
+
const videoSection = /* @__PURE__ */ jsxs8("section", { className: "interlace-editor-video", style: { minWidth: 0 }, children: [
|
|
3288
|
+
/* @__PURE__ */ jsxs8(
|
|
2922
3289
|
"div",
|
|
2923
3290
|
{
|
|
2924
|
-
|
|
3291
|
+
"data-testid": "interlace-editor-video",
|
|
2925
3292
|
style: {
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3293
|
+
position: "relative",
|
|
3294
|
+
borderRadius: RADIUS.md,
|
|
3295
|
+
overflow: "hidden",
|
|
3296
|
+
backgroundColor: COLORS.black
|
|
2930
3297
|
},
|
|
2931
3298
|
children: [
|
|
2932
|
-
/* @__PURE__ */
|
|
2933
|
-
"
|
|
3299
|
+
/* @__PURE__ */ jsx9(
|
|
3300
|
+
"video",
|
|
2934
3301
|
{
|
|
3302
|
+
ref: videoRef,
|
|
3303
|
+
src: state.videoSrc,
|
|
3304
|
+
controls: true,
|
|
3305
|
+
preload: "metadata",
|
|
3306
|
+
onLoadedMetadata: (e) => handlePreviewLoadedMetadata(e.currentTarget.duration),
|
|
3307
|
+
onTimeUpdate: handleTimeUpdate,
|
|
3308
|
+
"data-testid": "interlace-editor-preview-video",
|
|
2935
3309
|
style: {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
}
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
"h2",
|
|
2944
|
-
{
|
|
2945
|
-
style: {
|
|
2946
|
-
margin: 0,
|
|
2947
|
-
fontFamily: FONTS.display,
|
|
2948
|
-
fontSize: TYPE.lg,
|
|
2949
|
-
fontWeight: 600
|
|
2950
|
-
},
|
|
2951
|
-
children: strings.videoSourceInputTitle
|
|
2952
|
-
}
|
|
2953
|
-
),
|
|
2954
|
-
replaceMode ? /* @__PURE__ */ jsx8(
|
|
2955
|
-
"button",
|
|
2956
|
-
{
|
|
2957
|
-
type: "button",
|
|
2958
|
-
onClick: handleCancelReplace,
|
|
2959
|
-
"data-testid": "interlace-editor-cancel-replace",
|
|
2960
|
-
style: {
|
|
2961
|
-
padding: `${SPACE[1]}px ${SPACE[3]}px`,
|
|
2962
|
-
backgroundColor: COLORS.surface,
|
|
2963
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
2964
|
-
borderRadius: RADIUS.sm,
|
|
2965
|
-
cursor: "pointer",
|
|
2966
|
-
fontSize: TYPE.sm,
|
|
2967
|
-
color: COLORS.text,
|
|
2968
|
-
transition: "background-color 150ms ease"
|
|
2969
|
-
},
|
|
2970
|
-
children: strings.replaceCancelLabel
|
|
2971
|
-
}
|
|
2972
|
-
) : null
|
|
2973
|
-
]
|
|
2974
|
-
}
|
|
3310
|
+
width: "100%",
|
|
3311
|
+
height: "auto",
|
|
3312
|
+
display: "block",
|
|
3313
|
+
backgroundColor: COLORS.black
|
|
3314
|
+
}
|
|
3315
|
+
},
|
|
3316
|
+
state.videoSrc
|
|
2975
3317
|
),
|
|
2976
|
-
/* @__PURE__ */
|
|
2977
|
-
|
|
3318
|
+
selectedHook ? /* @__PURE__ */ jsx9(
|
|
3319
|
+
PlacementEditor,
|
|
2978
3320
|
{
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
duration: state.videoDuration || void 0
|
|
2982
|
-
},
|
|
2983
|
-
onChange: handleVideoSourceChange,
|
|
2984
|
-
onUpload,
|
|
2985
|
-
onError,
|
|
2986
|
-
strings: strings.videoSource
|
|
3321
|
+
placement: selectedHook.placement,
|
|
3322
|
+
onPlacementChange: handlePlacementChange
|
|
2987
3323
|
}
|
|
2988
|
-
)
|
|
3324
|
+
) : null
|
|
2989
3325
|
]
|
|
2990
3326
|
}
|
|
2991
|
-
)
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
3327
|
+
),
|
|
3328
|
+
/* @__PURE__ */ jsx9(
|
|
3329
|
+
EditorVideoToolbar,
|
|
3330
|
+
{
|
|
3331
|
+
duration: state.videoDuration || void 0,
|
|
3332
|
+
strings,
|
|
3333
|
+
onReplaceVideo: handleReplaceVideo,
|
|
3334
|
+
hint: selectedHook || isWide ? void 0 : strings.noItemSelectedLabel
|
|
3335
|
+
}
|
|
3336
|
+
)
|
|
3337
|
+
] });
|
|
3338
|
+
const timelineSection = /* @__PURE__ */ jsxs8("section", { className: "interlace-editor-timeline", style: { minWidth: 0 }, children: [
|
|
3339
|
+
/* @__PURE__ */ jsx9(SectionHeading, { style: { marginBottom: SPACE[2] }, children: strings.timelineHeading }),
|
|
3340
|
+
/* @__PURE__ */ jsx9(
|
|
3341
|
+
KeyframeTimeline,
|
|
3342
|
+
{
|
|
3343
|
+
entries: timelineEntries,
|
|
3344
|
+
selectedId: selectedItemId ?? void 0,
|
|
3345
|
+
videoDuration: state.videoDuration || 0,
|
|
3346
|
+
currentTime,
|
|
3347
|
+
onSeek: handleTimelineSeek,
|
|
3348
|
+
onSelectEntry: handleSelectEntry,
|
|
3349
|
+
onUpdateEntry: handleUpdateEntry,
|
|
3350
|
+
onDeleteEntry: handleDeleteEntry,
|
|
3351
|
+
onAddEntry: handleAddEntry,
|
|
3352
|
+
onDeselect: handleDeselect
|
|
3353
|
+
}
|
|
3354
|
+
)
|
|
3355
|
+
] });
|
|
3356
|
+
const hookSection = selectedItemId && selectedHook ? /* @__PURE__ */ jsxs8(
|
|
3357
|
+
"section",
|
|
2995
3358
|
{
|
|
2996
|
-
className: "interlace-editor",
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
borderRadius: 8,
|
|
3001
|
-
border: "1px solid"
|
|
3002
|
-
},
|
|
3359
|
+
className: "interlace-editor-hook",
|
|
3360
|
+
"data-testid": "interlace-editor-hook",
|
|
3361
|
+
"aria-label": strings.hookHeading,
|
|
3362
|
+
style: panelStyle,
|
|
3003
3363
|
children: [
|
|
3004
|
-
/* @__PURE__ */
|
|
3005
|
-
|
|
3364
|
+
/* @__PURE__ */ jsx9(
|
|
3365
|
+
InspectorPanel,
|
|
3006
3366
|
{
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3367
|
+
entry: {
|
|
3368
|
+
id: selectedItemId,
|
|
3369
|
+
title: selectedTitle ?? "",
|
|
3370
|
+
hookType: selectedHook.type,
|
|
3371
|
+
timestamp: selectedHook.type === "blocking" ? selectedHook.timestamp : void 0,
|
|
3372
|
+
start: selectedHook.type === "non-blocking" ? selectedHook.start : void 0,
|
|
3373
|
+
end: selectedHook.type === "non-blocking" ? selectedHook.end : void 0,
|
|
3374
|
+
videoDuration: state.videoDuration || 0,
|
|
3375
|
+
contentTypeId: selectedContentTypeId,
|
|
3376
|
+
registeredTypes: registeredTypeIds,
|
|
3377
|
+
contentTypeOptions,
|
|
3378
|
+
issues: hookIssues.get(selectedItemId)
|
|
3012
3379
|
},
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
fontSize: TYPE.lg,
|
|
3021
|
-
fontWeight: 600
|
|
3022
|
-
},
|
|
3023
|
-
children: strings.previewTitle
|
|
3024
|
-
}
|
|
3025
|
-
),
|
|
3026
|
-
/* @__PURE__ */ jsx8(
|
|
3027
|
-
"button",
|
|
3028
|
-
{
|
|
3029
|
-
type: "button",
|
|
3030
|
-
onClick: handleSave,
|
|
3031
|
-
"data-testid": "interlace-editor-save",
|
|
3032
|
-
style: {
|
|
3033
|
-
...saveButtonStyle,
|
|
3034
|
-
padding: `${SPACE[2]}px ${SPACE[4]}px`,
|
|
3035
|
-
border: "none",
|
|
3036
|
-
borderRadius: RADIUS.sm,
|
|
3037
|
-
cursor: "pointer",
|
|
3038
|
-
fontSize: TYPE.md,
|
|
3039
|
-
fontWeight: 600,
|
|
3040
|
-
boxShadow: SHADOWS.sm,
|
|
3041
|
-
transition: "background-color 150ms ease"
|
|
3042
|
-
},
|
|
3043
|
-
children: strings.saveLabel
|
|
3044
|
-
}
|
|
3045
|
-
)
|
|
3046
|
-
]
|
|
3380
|
+
onTitleChange: (title) => handleUpdateEntry(selectedItemId, { title }),
|
|
3381
|
+
onTimeChange: handleTimeChange,
|
|
3382
|
+
onHookTypeChange: handleHookTypeChange,
|
|
3383
|
+
onContentTypeSelect: handleContentTypeSelect,
|
|
3384
|
+
placement: selectedHook.placement,
|
|
3385
|
+
onPlacementChange: handlePlacementChange,
|
|
3386
|
+
onDelete: () => handleDeleteEntry(selectedItemId)
|
|
3047
3387
|
}
|
|
3048
3388
|
),
|
|
3049
|
-
/* @__PURE__ */
|
|
3050
|
-
"
|
|
3051
|
-
{
|
|
3052
|
-
className: "interlace-editor-video",
|
|
3053
|
-
style: {
|
|
3054
|
-
width: "100%",
|
|
3055
|
-
maxWidth: 720,
|
|
3056
|
-
margin: "0 auto"
|
|
3057
|
-
},
|
|
3058
|
-
children: [
|
|
3059
|
-
/* @__PURE__ */ jsxs7(
|
|
3060
|
-
"div",
|
|
3061
|
-
{
|
|
3062
|
-
"data-testid": "interlace-editor-video",
|
|
3063
|
-
style: { position: "relative" },
|
|
3064
|
-
children: [
|
|
3065
|
-
/* @__PURE__ */ jsx8(
|
|
3066
|
-
"video",
|
|
3067
|
-
{
|
|
3068
|
-
ref: videoRef,
|
|
3069
|
-
src: state.videoSrc,
|
|
3070
|
-
controls: true,
|
|
3071
|
-
preload: "metadata",
|
|
3072
|
-
onLoadedMetadata: (e) => handlePreviewLoadedMetadata(e.currentTarget.duration),
|
|
3073
|
-
onTimeUpdate: handleTimeUpdate,
|
|
3074
|
-
onPlay: () => setIsPlaying(true),
|
|
3075
|
-
onPause: () => setIsPlaying(false),
|
|
3076
|
-
"data-testid": "interlace-editor-preview-video",
|
|
3077
|
-
style: {
|
|
3078
|
-
width: "100%",
|
|
3079
|
-
height: "auto",
|
|
3080
|
-
display: "block",
|
|
3081
|
-
backgroundColor: "#000"
|
|
3082
|
-
}
|
|
3083
|
-
},
|
|
3084
|
-
state.videoSrc
|
|
3085
|
-
),
|
|
3086
|
-
selectedHook ? /* @__PURE__ */ jsx8(
|
|
3087
|
-
PlacementEditor,
|
|
3088
|
-
{
|
|
3089
|
-
placement: selectedHook.placement,
|
|
3090
|
-
onPlacementChange: handlePlacementChange
|
|
3091
|
-
}
|
|
3092
|
-
) : null
|
|
3093
|
-
]
|
|
3094
|
-
}
|
|
3095
|
-
),
|
|
3096
|
-
/* @__PURE__ */ jsx8(
|
|
3097
|
-
EditorVideoToolbar,
|
|
3098
|
-
{
|
|
3099
|
-
duration: state.videoDuration || void 0,
|
|
3100
|
-
strings,
|
|
3101
|
-
onReplaceVideo: handleReplaceVideo,
|
|
3102
|
-
onOpenPreview: handleOpenPreview,
|
|
3103
|
-
theme,
|
|
3104
|
-
hint: selectedHook ? void 0 : strings.noItemSelectedLabel
|
|
3105
|
-
}
|
|
3106
|
-
)
|
|
3107
|
-
]
|
|
3108
|
-
}
|
|
3109
|
-
),
|
|
3110
|
-
/* @__PURE__ */ jsx8(
|
|
3111
|
-
PreviewModal,
|
|
3112
|
-
{
|
|
3113
|
-
isOpen: previewOpen,
|
|
3114
|
-
videoSrc: state.videoSrc,
|
|
3115
|
-
document: previewDocument,
|
|
3116
|
-
contentTypeRegistry,
|
|
3117
|
-
onClose: handleClosePreview,
|
|
3118
|
-
onError,
|
|
3119
|
-
strings: strings.previewModal
|
|
3120
|
-
}
|
|
3121
|
-
),
|
|
3122
|
-
/* @__PURE__ */ jsxs7(
|
|
3123
|
-
"section",
|
|
3389
|
+
selectedContentTypeId ? /* @__PURE__ */ jsxs8(
|
|
3390
|
+
"div",
|
|
3124
3391
|
{
|
|
3125
|
-
className: "interlace-editor-timeline",
|
|
3126
3392
|
style: {
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
borderRadius: 8,
|
|
3131
|
-
border: "1px solid"
|
|
3393
|
+
marginTop: SPACE[4],
|
|
3394
|
+
paddingTop: SPACE[4],
|
|
3395
|
+
borderTop: `1px solid ${COLORS.border}`
|
|
3132
3396
|
},
|
|
3133
3397
|
children: [
|
|
3134
|
-
/* @__PURE__ */
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
style: {
|
|
3138
|
-
marginTop: 0,
|
|
3139
|
-
fontFamily: FONTS.display,
|
|
3140
|
-
fontSize: TYPE.md,
|
|
3141
|
-
fontWeight: 600
|
|
3142
|
-
},
|
|
3143
|
-
children: strings.timelineHeading
|
|
3144
|
-
}
|
|
3145
|
-
),
|
|
3146
|
-
/* @__PURE__ */ jsx8(
|
|
3147
|
-
KeyframeTimeline,
|
|
3398
|
+
/* @__PURE__ */ jsx9(SectionHeading, { style: { marginBottom: SPACE[3] }, children: strings.contentEditorHeading }),
|
|
3399
|
+
/* @__PURE__ */ jsx9(
|
|
3400
|
+
ContentTypeEditor,
|
|
3148
3401
|
{
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
isPlaying,
|
|
3154
|
-
onSeek: handleTimelineSeek,
|
|
3155
|
-
onTogglePlay: handleTogglePlay,
|
|
3156
|
-
onSelectEntry: handleSelectEntry,
|
|
3157
|
-
onUpdateEntry: handleUpdateEntry,
|
|
3158
|
-
onDeleteEntry: handleDeleteEntry,
|
|
3159
|
-
onAddEntry: handleAddEntry,
|
|
3160
|
-
onDeselect: handleDeselect
|
|
3402
|
+
contentTypeId: selectedContentTypeId,
|
|
3403
|
+
registry: contentTypeRegistry,
|
|
3404
|
+
data: selectedData,
|
|
3405
|
+
onChange: handleContentChange
|
|
3161
3406
|
}
|
|
3162
3407
|
)
|
|
3163
3408
|
]
|
|
3164
3409
|
}
|
|
3165
|
-
),
|
|
3166
|
-
selectedItemId && selectedHook ? /* @__PURE__ */ jsxs7(
|
|
3167
|
-
"section",
|
|
3168
|
-
{
|
|
3169
|
-
className: "interlace-editor-hook",
|
|
3170
|
-
"data-testid": "interlace-editor-hook",
|
|
3171
|
-
style: {
|
|
3172
|
-
...surfaceStyle,
|
|
3173
|
-
marginTop: 16,
|
|
3174
|
-
padding: 16,
|
|
3175
|
-
borderRadius: 8,
|
|
3176
|
-
border: "1px solid"
|
|
3177
|
-
},
|
|
3178
|
-
children: [
|
|
3179
|
-
/* @__PURE__ */ jsx8(
|
|
3180
|
-
"h3",
|
|
3181
|
-
{
|
|
3182
|
-
style: {
|
|
3183
|
-
marginTop: 0,
|
|
3184
|
-
fontFamily: FONTS.display,
|
|
3185
|
-
fontSize: TYPE.md,
|
|
3186
|
-
fontWeight: 600
|
|
3187
|
-
},
|
|
3188
|
-
children: strings.hookHeading
|
|
3189
|
-
}
|
|
3190
|
-
),
|
|
3191
|
-
/* @__PURE__ */ jsx8(
|
|
3192
|
-
InspectorPanel,
|
|
3193
|
-
{
|
|
3194
|
-
entry: {
|
|
3195
|
-
id: selectedItemId,
|
|
3196
|
-
title: selectedTitle ?? "",
|
|
3197
|
-
hookType: selectedHook.type,
|
|
3198
|
-
timestamp: selectedHook.type === "blocking" ? selectedHook.timestamp : void 0,
|
|
3199
|
-
start: selectedHook.type === "non-blocking" ? selectedHook.start : void 0,
|
|
3200
|
-
end: selectedHook.type === "non-blocking" ? selectedHook.end : void 0,
|
|
3201
|
-
videoDuration: state.videoDuration || 0,
|
|
3202
|
-
contentTypeId: selectedContentTypeId,
|
|
3203
|
-
registeredTypes: registeredTypeIds
|
|
3204
|
-
},
|
|
3205
|
-
onTitleChange: (title) => handleUpdateEntry(selectedItemId, { title }),
|
|
3206
|
-
onTimeChange: handleTimeChange,
|
|
3207
|
-
onContentTypeSelect: handleContentTypeSelect,
|
|
3208
|
-
placement: selectedHook.placement,
|
|
3209
|
-
onPlacementChange: handlePlacementChange,
|
|
3210
|
-
onDelete: () => handleDeleteEntry(selectedItemId)
|
|
3211
|
-
}
|
|
3212
|
-
),
|
|
3213
|
-
selectedContentTypeId ? /* @__PURE__ */ jsxs7("div", { style: { marginTop: 12 }, children: [
|
|
3214
|
-
/* @__PURE__ */ jsx8(
|
|
3215
|
-
"h4",
|
|
3216
|
-
{
|
|
3217
|
-
style: {
|
|
3218
|
-
margin: `0 0 ${SPACE[1]}px 0`,
|
|
3219
|
-
fontSize: TYPE.sm,
|
|
3220
|
-
color: theme?.mutedTextColor ?? COLORS.textMuted,
|
|
3221
|
-
fontWeight: 600
|
|
3222
|
-
},
|
|
3223
|
-
children: strings.contentEditorHeading
|
|
3224
|
-
}
|
|
3225
|
-
),
|
|
3226
|
-
/* @__PURE__ */ jsx8(
|
|
3227
|
-
ContentTypeEditor,
|
|
3228
|
-
{
|
|
3229
|
-
contentTypeId: selectedContentTypeId,
|
|
3230
|
-
registry: contentTypeRegistry,
|
|
3231
|
-
data: selectedData,
|
|
3232
|
-
onChange: handleContentChange
|
|
3233
|
-
}
|
|
3234
|
-
)
|
|
3235
|
-
] }) : null
|
|
3236
|
-
]
|
|
3237
|
-
}
|
|
3238
3410
|
) : null
|
|
3239
3411
|
]
|
|
3240
3412
|
}
|
|
3241
|
-
)
|
|
3413
|
+
) : isWide ? /* @__PURE__ */ jsxs8(
|
|
3414
|
+
"section",
|
|
3415
|
+
{
|
|
3416
|
+
className: "interlace-editor-hook",
|
|
3417
|
+
"data-testid": "interlace-editor-no-hook",
|
|
3418
|
+
style: {
|
|
3419
|
+
...panelStyle,
|
|
3420
|
+
display: "flex",
|
|
3421
|
+
flexDirection: "column",
|
|
3422
|
+
gap: SPACE[2],
|
|
3423
|
+
justifyContent: "center",
|
|
3424
|
+
alignItems: "center",
|
|
3425
|
+
textAlign: "center",
|
|
3426
|
+
minHeight: 200,
|
|
3427
|
+
borderStyle: "dashed"
|
|
3428
|
+
},
|
|
3429
|
+
children: [
|
|
3430
|
+
/* @__PURE__ */ jsx9(SectionHeading, { children: strings.noHookSelectedTitle }),
|
|
3431
|
+
/* @__PURE__ */ jsx9("p", { className: "interlace-hint", style: { maxWidth: 280 }, children: strings.noItemSelectedLabel })
|
|
3432
|
+
]
|
|
3433
|
+
}
|
|
3434
|
+
) : null;
|
|
3435
|
+
return /* @__PURE__ */ jsxs8("div", { ref: rootRef, className: rootClassName, style: rootStyle, children: [
|
|
3436
|
+
/* @__PURE__ */ jsxs8(
|
|
3437
|
+
"header",
|
|
3438
|
+
{
|
|
3439
|
+
style: {
|
|
3440
|
+
display: "flex",
|
|
3441
|
+
justifyContent: "space-between",
|
|
3442
|
+
alignItems: "center",
|
|
3443
|
+
gap: SPACE[3],
|
|
3444
|
+
flexWrap: "wrap",
|
|
3445
|
+
marginBottom: SPACE[4]
|
|
3446
|
+
},
|
|
3447
|
+
children: [
|
|
3448
|
+
/* @__PURE__ */ jsxs8(
|
|
3449
|
+
"div",
|
|
3450
|
+
{
|
|
3451
|
+
role: "status",
|
|
3452
|
+
"aria-live": "polite",
|
|
3453
|
+
"data-testid": "interlace-editor-status",
|
|
3454
|
+
style: {
|
|
3455
|
+
display: "flex",
|
|
3456
|
+
alignItems: "center",
|
|
3457
|
+
gap: SPACE[2],
|
|
3458
|
+
flexWrap: "wrap",
|
|
3459
|
+
color: COLORS.textMuted,
|
|
3460
|
+
fontSize: TYPE.sm
|
|
3461
|
+
},
|
|
3462
|
+
children: [
|
|
3463
|
+
statusText ? /* @__PURE__ */ jsx9("span", { children: statusText }) : null,
|
|
3464
|
+
issueCount > 0 ? /* @__PURE__ */ jsx9("span", { className: "interlace-badge interlace-badge--warning", children: strings.hooksNeedAttentionLabel.replace(
|
|
3465
|
+
"{count}",
|
|
3466
|
+
String(issueCount)
|
|
3467
|
+
) }) : null
|
|
3468
|
+
]
|
|
3469
|
+
}
|
|
3470
|
+
),
|
|
3471
|
+
/* @__PURE__ */ jsxs8("div", { style: { display: "flex", gap: SPACE[2] }, children: [
|
|
3472
|
+
/* @__PURE__ */ jsx9(
|
|
3473
|
+
Button,
|
|
3474
|
+
{
|
|
3475
|
+
variant: "secondary",
|
|
3476
|
+
onClick: handleOpenPreview,
|
|
3477
|
+
"data-testid": "interlace-editor-open-preview",
|
|
3478
|
+
children: strings.previewLabel
|
|
3479
|
+
}
|
|
3480
|
+
),
|
|
3481
|
+
/* @__PURE__ */ jsx9(
|
|
3482
|
+
Button,
|
|
3483
|
+
{
|
|
3484
|
+
variant: "primary",
|
|
3485
|
+
onClick: handleSave,
|
|
3486
|
+
"data-testid": "interlace-editor-save",
|
|
3487
|
+
children: strings.saveLabel
|
|
3488
|
+
}
|
|
3489
|
+
)
|
|
3490
|
+
] })
|
|
3491
|
+
]
|
|
3492
|
+
}
|
|
3493
|
+
),
|
|
3494
|
+
saveAttempted && issueCount > 0 ? /* @__PURE__ */ jsx9(
|
|
3495
|
+
"div",
|
|
3496
|
+
{
|
|
3497
|
+
style: { marginBottom: SPACE[4] },
|
|
3498
|
+
"data-testid": "interlace-editor-save-issues",
|
|
3499
|
+
children: /* @__PURE__ */ jsx9(
|
|
3500
|
+
IssueList,
|
|
3501
|
+
{
|
|
3502
|
+
title: strings.saveBlockedTitle,
|
|
3503
|
+
issues: [...hookIssues.entries()].map(([id, issues]) => /* @__PURE__ */ jsxs8(
|
|
3504
|
+
"span",
|
|
3505
|
+
{
|
|
3506
|
+
style: {
|
|
3507
|
+
display: "inline-flex",
|
|
3508
|
+
gap: SPACE[2],
|
|
3509
|
+
alignItems: "baseline",
|
|
3510
|
+
flexWrap: "wrap"
|
|
3511
|
+
},
|
|
3512
|
+
children: [
|
|
3513
|
+
/* @__PURE__ */ jsxs8("span", { children: [
|
|
3514
|
+
/* @__PURE__ */ jsx9("strong", { children: hookLabel(id) }),
|
|
3515
|
+
": ",
|
|
3516
|
+
issues.join(", ")
|
|
3517
|
+
] }),
|
|
3518
|
+
/* @__PURE__ */ jsx9(
|
|
3519
|
+
"button",
|
|
3520
|
+
{
|
|
3521
|
+
type: "button",
|
|
3522
|
+
className: "interlace-focusable",
|
|
3523
|
+
onClick: () => handleSelectEntry(id),
|
|
3524
|
+
style: {
|
|
3525
|
+
padding: 0,
|
|
3526
|
+
border: "none",
|
|
3527
|
+
background: "none",
|
|
3528
|
+
color: "inherit",
|
|
3529
|
+
textDecoration: "underline",
|
|
3530
|
+
cursor: "pointer",
|
|
3531
|
+
font: "inherit"
|
|
3532
|
+
},
|
|
3533
|
+
children: strings.goToHookLabel
|
|
3534
|
+
}
|
|
3535
|
+
)
|
|
3536
|
+
]
|
|
3537
|
+
},
|
|
3538
|
+
id
|
|
3539
|
+
))
|
|
3540
|
+
}
|
|
3541
|
+
)
|
|
3542
|
+
}
|
|
3543
|
+
) : null,
|
|
3544
|
+
/* @__PURE__ */ jsx9(
|
|
3545
|
+
PreviewModal,
|
|
3546
|
+
{
|
|
3547
|
+
isOpen: previewOpen,
|
|
3548
|
+
videoSrc: state.videoSrc,
|
|
3549
|
+
document: previewDocument,
|
|
3550
|
+
contentTypeRegistry,
|
|
3551
|
+
onClose: handleClosePreview,
|
|
3552
|
+
onError,
|
|
3553
|
+
strings: strings.previewModal
|
|
3554
|
+
}
|
|
3555
|
+
),
|
|
3556
|
+
isWide ? /* @__PURE__ */ jsxs8(
|
|
3557
|
+
"div",
|
|
3558
|
+
{
|
|
3559
|
+
"data-testid": "interlace-editor-layout-wide",
|
|
3560
|
+
style: {
|
|
3561
|
+
display: "grid",
|
|
3562
|
+
gridTemplateColumns: "minmax(0, 3fr) minmax(320px, 2fr)",
|
|
3563
|
+
gap: SPACE[4],
|
|
3564
|
+
alignItems: "start"
|
|
3565
|
+
},
|
|
3566
|
+
children: [
|
|
3567
|
+
/* @__PURE__ */ jsxs8(
|
|
3568
|
+
"div",
|
|
3569
|
+
{
|
|
3570
|
+
style: {
|
|
3571
|
+
display: "grid",
|
|
3572
|
+
gap: SPACE[4],
|
|
3573
|
+
position: "sticky",
|
|
3574
|
+
top: SPACE[4],
|
|
3575
|
+
minWidth: 0
|
|
3576
|
+
},
|
|
3577
|
+
children: [
|
|
3578
|
+
videoSection,
|
|
3579
|
+
timelineSection
|
|
3580
|
+
]
|
|
3581
|
+
}
|
|
3582
|
+
),
|
|
3583
|
+
hookSection
|
|
3584
|
+
]
|
|
3585
|
+
}
|
|
3586
|
+
) : /* @__PURE__ */ jsxs8("div", { style: { display: "grid", gap: SPACE[4] }, children: [
|
|
3587
|
+
/* @__PURE__ */ jsx9("div", { style: { width: "100%", maxWidth: 720, margin: "0 auto" }, children: videoSection }),
|
|
3588
|
+
timelineSection,
|
|
3589
|
+
hookSection
|
|
3590
|
+
] })
|
|
3591
|
+
] });
|
|
3242
3592
|
}
|
|
3243
3593
|
|
|
3244
3594
|
// src/components/content-type-editor-slot.tsx
|
|
3245
|
-
import { useRef as
|
|
3246
|
-
import { jsx as
|
|
3595
|
+
import { useRef as useRef10 } from "react";
|
|
3596
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3247
3597
|
function ContentTypeEditorSlot({
|
|
3248
3598
|
contentTypeId,
|
|
3249
3599
|
isOpen,
|
|
@@ -3253,7 +3603,7 @@ function ContentTypeEditorSlot({
|
|
|
3253
3603
|
data,
|
|
3254
3604
|
onChange
|
|
3255
3605
|
}) {
|
|
3256
|
-
const containerRef =
|
|
3606
|
+
const containerRef = useRef10(null);
|
|
3257
3607
|
useContentTypeEditorMount({
|
|
3258
3608
|
containerRef,
|
|
3259
3609
|
active: isOpen,
|
|
@@ -3266,7 +3616,7 @@ function ContentTypeEditorSlot({
|
|
|
3266
3616
|
if (!isOpen || !contentTypeId) {
|
|
3267
3617
|
return null;
|
|
3268
3618
|
}
|
|
3269
|
-
return /* @__PURE__ */
|
|
3619
|
+
return /* @__PURE__ */ jsx10(
|
|
3270
3620
|
"div",
|
|
3271
3621
|
{
|
|
3272
3622
|
className: "content-type-editor-slot",
|
|
@@ -3282,13 +3632,13 @@ function ContentTypeEditorSlot({
|
|
|
3282
3632
|
justifyContent: "center",
|
|
3283
3633
|
zIndex: 999
|
|
3284
3634
|
},
|
|
3285
|
-
children: /* @__PURE__ */
|
|
3635
|
+
children: /* @__PURE__ */ jsxs9(
|
|
3286
3636
|
"div",
|
|
3287
3637
|
{
|
|
3288
3638
|
className: "content-type-editor-container",
|
|
3289
3639
|
style: {
|
|
3290
3640
|
backgroundColor: COLORS.surface,
|
|
3291
|
-
borderRadius: `${RADIUS.lg}
|
|
3641
|
+
borderRadius: `${RADIUS.lg}`,
|
|
3292
3642
|
padding: `${SPACE[5]}px`,
|
|
3293
3643
|
maxWidth: "600px",
|
|
3294
3644
|
width: "90%",
|
|
@@ -3297,7 +3647,7 @@ function ContentTypeEditorSlot({
|
|
|
3297
3647
|
boxShadow: SHADOWS.md
|
|
3298
3648
|
},
|
|
3299
3649
|
children: [
|
|
3300
|
-
/* @__PURE__ */
|
|
3650
|
+
/* @__PURE__ */ jsxs9(
|
|
3301
3651
|
"h2",
|
|
3302
3652
|
{
|
|
3303
3653
|
className: "content-type-editor-title",
|
|
@@ -3313,19 +3663,19 @@ function ContentTypeEditorSlot({
|
|
|
3313
3663
|
]
|
|
3314
3664
|
}
|
|
3315
3665
|
),
|
|
3316
|
-
/* @__PURE__ */
|
|
3666
|
+
/* @__PURE__ */ jsx10(
|
|
3317
3667
|
"div",
|
|
3318
3668
|
{
|
|
3319
3669
|
className: "content-type-editor-body",
|
|
3320
3670
|
style: { margin: "16px 0", minHeight: "100px" },
|
|
3321
|
-
children: contentType ? /* @__PURE__ */
|
|
3671
|
+
children: contentType ? /* @__PURE__ */ jsx10("div", { ref: containerRef }) : /* @__PURE__ */ jsxs9("p", { style: { color: COLORS.textMuted }, children: [
|
|
3322
3672
|
'Content type "',
|
|
3323
3673
|
contentTypeId,
|
|
3324
3674
|
'" is not registered'
|
|
3325
3675
|
] })
|
|
3326
3676
|
}
|
|
3327
3677
|
),
|
|
3328
|
-
/* @__PURE__ */
|
|
3678
|
+
/* @__PURE__ */ jsxs9(
|
|
3329
3679
|
"div",
|
|
3330
3680
|
{
|
|
3331
3681
|
className: "content-type-editor-footer",
|
|
@@ -3336,43 +3686,24 @@ function ContentTypeEditorSlot({
|
|
|
3336
3686
|
marginTop: `${SPACE[5]}px`
|
|
3337
3687
|
},
|
|
3338
3688
|
children: [
|
|
3339
|
-
/* @__PURE__ */
|
|
3340
|
-
|
|
3689
|
+
/* @__PURE__ */ jsx10(
|
|
3690
|
+
Button,
|
|
3341
3691
|
{
|
|
3692
|
+
variant: "secondary",
|
|
3342
3693
|
className: "content-type-editor-cancel-button",
|
|
3343
3694
|
onClick: onClose,
|
|
3344
|
-
style: {
|
|
3345
|
-
padding: `${SPACE[2]}px ${SPACE[4]}px`,
|
|
3346
|
-
backgroundColor: COLORS.surfaceRaised,
|
|
3347
|
-
border: `1px solid ${COLORS.borderStrong}`,
|
|
3348
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
3349
|
-
cursor: "pointer",
|
|
3350
|
-
fontSize: TYPE.md,
|
|
3351
|
-
color: COLORS.text,
|
|
3352
|
-
transition: "background-color 150ms ease"
|
|
3353
|
-
},
|
|
3354
3695
|
children: "Cancel"
|
|
3355
3696
|
}
|
|
3356
3697
|
),
|
|
3357
|
-
/* @__PURE__ */
|
|
3358
|
-
|
|
3698
|
+
/* @__PURE__ */ jsx10(
|
|
3699
|
+
Button,
|
|
3359
3700
|
{
|
|
3701
|
+
variant: "primary",
|
|
3360
3702
|
className: "content-type-editor-save-button",
|
|
3361
3703
|
onClick: () => {
|
|
3362
3704
|
onSave?.(data);
|
|
3363
3705
|
onClose();
|
|
3364
3706
|
},
|
|
3365
|
-
style: {
|
|
3366
|
-
padding: `${SPACE[2]}px ${SPACE[4]}px`,
|
|
3367
|
-
backgroundColor: COLORS.accent,
|
|
3368
|
-
color: COLORS.white,
|
|
3369
|
-
border: "none",
|
|
3370
|
-
borderRadius: `${RADIUS.sm}px`,
|
|
3371
|
-
cursor: "pointer",
|
|
3372
|
-
fontSize: TYPE.md,
|
|
3373
|
-
fontWeight: 600,
|
|
3374
|
-
transition: "background-color 150ms ease"
|
|
3375
|
-
},
|
|
3376
3707
|
children: "Save"
|
|
3377
3708
|
}
|
|
3378
3709
|
)
|