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