@arbidocs/blocks 0.5.123 → 0.5.124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ClippingMediaViewer-IEIBT74X.cjs → ClippingMediaViewer-ZFEX5A3U.cjs} +11 -10
- package/dist/ClippingMediaViewer-ZFEX5A3U.cjs.map +1 -0
- package/dist/{ClippingPdfViewer-OGYLMVCE.cjs → ClippingPdfViewer-3LRTEPHV.cjs} +45 -11
- package/dist/ClippingPdfViewer-3LRTEPHV.cjs.map +1 -0
- package/dist/ConnectedNativeDocxComparison-QKHCYD6W.cjs +1 -1
- package/dist/{ConnectedPresentation-5DOJ35XL.cjs → ConnectedPresentation-OV2KBOLK.cjs} +27 -153
- package/dist/ConnectedPresentation-OV2KBOLK.cjs.map +1 -0
- package/dist/{ConnectedSlidesTab-7YMEDGUU.cjs → ConnectedSlidesTab-LUAGZ6FD.cjs} +29 -27
- package/dist/ConnectedSlidesTab-LUAGZ6FD.cjs.map +1 -0
- package/dist/ConnectedStreamedWordArtifact-AG62232A.cjs +1 -1
- package/dist/{FilesViewerDialog-2QCCRWF2.cjs → FilesViewerDialog-JWKNJLWG.cjs} +12 -9
- package/dist/FilesViewerDialog-JWKNJLWG.cjs.map +1 -0
- package/dist/SpotlightStrip-ED22UYTM.cjs +398 -0
- package/dist/SpotlightStrip-ED22UYTM.cjs.map +1 -0
- package/dist/agents/index.cjs +176 -176
- package/dist/{chunk-46P7IDBX.cjs → chunk-3IH55CDE.cjs} +3 -3
- package/dist/chunk-3IH55CDE.cjs.map +1 -0
- package/dist/chunk-3ZZZO4F7.cjs +145 -0
- package/dist/chunk-3ZZZO4F7.cjs.map +1 -0
- package/dist/{chunk-WFMWKPGY.cjs → chunk-ADPRIBSH.cjs} +9 -33
- package/dist/chunk-ADPRIBSH.cjs.map +1 -0
- package/dist/{chunk-JD2HX2BR.cjs → chunk-BX6G2ZCI.cjs} +58 -86
- package/dist/chunk-BX6G2ZCI.cjs.map +1 -0
- package/dist/{chunk-NQML7IUC.cjs → chunk-CQQQIZU4.cjs} +3 -3
- package/dist/{chunk-NQML7IUC.cjs.map → chunk-CQQQIZU4.cjs.map} +1 -1
- package/dist/{chunk-SNPK3R3O.cjs → chunk-EMRY62HS.cjs} +5 -5
- package/dist/{chunk-SNPK3R3O.cjs.map → chunk-EMRY62HS.cjs.map} +1 -1
- package/dist/{chunk-DWMWEALB.cjs → chunk-H236SNEV.cjs} +143 -1634
- package/dist/chunk-H236SNEV.cjs.map +1 -0
- package/dist/chunk-JITYC4OS.cjs +66 -0
- package/dist/chunk-JITYC4OS.cjs.map +1 -0
- package/dist/chunk-JY7UUZQG.cjs +1513 -0
- package/dist/chunk-JY7UUZQG.cjs.map +1 -0
- package/dist/chunk-MVXHTAJ4.cjs +111 -0
- package/dist/chunk-MVXHTAJ4.cjs.map +1 -0
- package/dist/{chunk-4TTX6ZNS.cjs → chunk-ORNLCBNE.cjs} +24 -2
- package/dist/chunk-ORNLCBNE.cjs.map +1 -0
- package/dist/{chunk-L4CIFLCU.cjs → chunk-QG2U2JGX.cjs} +4 -4
- package/dist/{chunk-L4CIFLCU.cjs.map → chunk-QG2U2JGX.cjs.map} +1 -1
- package/dist/chunk-WVZLAAIZ.cjs +31 -0
- package/dist/chunk-WVZLAAIZ.cjs.map +1 -0
- package/dist/{chunk-WV7BCGCK.cjs → chunk-XGM4VVNV.cjs} +19 -19
- package/dist/{chunk-WV7BCGCK.cjs.map → chunk-XGM4VVNV.cjs.map} +1 -1
- package/dist/chunk-ZZZITHGK.cjs +119 -0
- package/dist/chunk-ZZZITHGK.cjs.map +1 -0
- package/dist/connect/docx.cjs +1 -1
- package/dist/connect/index.cjs +175 -175
- package/dist/connect/viewer.cjs +10 -7
- package/dist/connection/presentation/ClippingMediaViewer.js +3 -3
- package/dist/connection/presentation/ClippingMediaViewer.js.map +2 -2
- package/dist/connection/presentation/ClippingPdfViewer.d.ts +4 -3
- package/dist/connection/presentation/ClippingPdfViewer.js +48 -9
- package/dist/connection/presentation/ClippingPdfViewer.js.map +2 -2
- package/dist/connection/presentation/SpotlightLayer.d.ts +5 -0
- package/dist/connection/presentation/SpotlightLayer.js +19 -0
- package/dist/connection/presentation/SpotlightLayer.js.map +7 -0
- package/dist/connection/presentation/SpotlightStrip.d.ts +10 -0
- package/dist/connection/presentation/SpotlightStrip.js +237 -0
- package/dist/connection/presentation/SpotlightStrip.js.map +7 -0
- package/dist/connection/presentation/useViewerClipping.d.ts +4 -3
- package/dist/connection/presentation/useViewerClipping.js +8 -4
- package/dist/connection/presentation/useViewerClipping.js.map +2 -2
- package/dist/connection/viewer/ConnectedDocumentViewer.js +1 -1
- package/dist/connection/viewer/ConnectedDocumentViewer.js.map +2 -2
- package/dist/connection/viewer/pdf/passageHighlights.d.ts +5 -0
- package/dist/connection/viewer/pdf/passageHighlights.js +14 -1
- package/dist/connection/viewer/pdf/passageHighlights.js.map +2 -2
- package/dist/connection/viewer/useCleanView.d.ts +3 -1
- package/dist/connection/viewer/useCleanView.js +6 -3
- package/dist/connection/viewer/useCleanView.js.map +2 -2
- package/dist/document-tools/DocumentToolButtons.js +1 -1
- package/dist/document-tools/DocumentToolButtons.js.map +1 -1
- package/dist/document-tools/index.cjs +13 -13
- package/dist/embed/index.cjs +2 -2
- package/dist/index.cjs +239 -239
- package/dist/presentation/ClipCaptureOverlay.d.ts +7 -3
- package/dist/presentation/ClipCaptureOverlay.js +43 -14
- package/dist/presentation/ClipCaptureOverlay.js.map +2 -2
- package/dist/presentation/PresentControls.d.ts +8 -0
- package/dist/presentation/PresentControls.js +1 -0
- package/dist/presentation/PresentControls.js.map +2 -2
- package/dist/presentation/PresentationStage.d.ts +10 -2
- package/dist/presentation/PresentationStage.js +6 -3
- package/dist/presentation/PresentationStage.js.map +2 -2
- package/dist/presentation/PresenterView.js +1 -22
- package/dist/presentation/PresenterView.js.map +2 -2
- package/dist/presentation/SpotlightView.d.ts +19 -0
- package/dist/presentation/SpotlightView.js +180 -0
- package/dist/presentation/SpotlightView.js.map +7 -0
- package/dist/presentation/passage-clip.d.ts +17 -0
- package/dist/presentation/passage-clip.js +25 -0
- package/dist/presentation/passage-clip.js.map +7 -0
- package/dist/presentation/spotlight.d.ts +58 -0
- package/dist/presentation/spotlight.js +110 -0
- package/dist/presentation/spotlight.js.map +7 -0
- package/dist/presentation/store.d.ts +5 -0
- package/dist/presentation/store.js +19 -0
- package/dist/presentation/store.js.map +2 -2
- package/dist/presentation/usePointerActive.d.ts +2 -0
- package/dist/presentation/usePointerActive.js +28 -0
- package/dist/presentation/usePointerActive.js.map +7 -0
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +12 -12
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ClippingMediaViewer-IEIBT74X.cjs.map +0 -1
- package/dist/ClippingPdfViewer-OGYLMVCE.cjs.map +0 -1
- package/dist/ConnectedPresentation-5DOJ35XL.cjs.map +0 -1
- package/dist/ConnectedSlidesTab-7YMEDGUU.cjs.map +0 -1
- package/dist/FilesViewerDialog-2QCCRWF2.cjs.map +0 -1
- package/dist/chunk-46P7IDBX.cjs.map +0 -1
- package/dist/chunk-4TTX6ZNS.cjs.map +0 -1
- package/dist/chunk-DWMWEALB.cjs.map +0 -1
- package/dist/chunk-JD2HX2BR.cjs.map +0 -1
- package/dist/chunk-WFMWKPGY.cjs.map +0 -1
- package/dist/chunk-XK4TVJKD.cjs +0 -73
- package/dist/chunk-XK4TVJKD.cjs.map +0 -1
|
@@ -0,0 +1,1513 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkWOOOMTTA_cjs = require('./chunk-WOOOMTTA.cjs');
|
|
5
|
+
var chunk5GCCUXMT_cjs = require('./chunk-5GCCUXMT.cjs');
|
|
6
|
+
var chunkADPRIBSH_cjs = require('./chunk-ADPRIBSH.cjs');
|
|
7
|
+
var chunkORNLCBNE_cjs = require('./chunk-ORNLCBNE.cjs');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var viewers = require('@arbidocs/react/viewers');
|
|
10
|
+
var ui = require('@arbidocs/react/ui');
|
|
11
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
+
var lucideReact = require('lucide-react');
|
|
13
|
+
|
|
14
|
+
function cropStyle(rect) {
|
|
15
|
+
return {
|
|
16
|
+
position: "absolute",
|
|
17
|
+
width: `${100 / rect.w}%`,
|
|
18
|
+
height: `${100 / rect.h}%`,
|
|
19
|
+
left: `${-rect.x / rect.w * 100}%`,
|
|
20
|
+
top: `${-rect.y / rect.h * 100}%`,
|
|
21
|
+
maxWidth: "none"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function MediaClip({
|
|
25
|
+
clip,
|
|
26
|
+
className,
|
|
27
|
+
live
|
|
28
|
+
}) {
|
|
29
|
+
const url = chunkWOOOMTTA_cjs.useObjectUrl(clip.source);
|
|
30
|
+
const videoRef = react.useRef(null);
|
|
31
|
+
react.useEffect(() => {
|
|
32
|
+
const video = videoRef.current;
|
|
33
|
+
if (!video) return;
|
|
34
|
+
const toStart = () => {
|
|
35
|
+
video.currentTime = clip.start ?? 0;
|
|
36
|
+
};
|
|
37
|
+
if (video.readyState >= 1) toStart();
|
|
38
|
+
else video.addEventListener("loadedmetadata", toStart, { once: true });
|
|
39
|
+
return () => video.removeEventListener("loadedmetadata", toStart);
|
|
40
|
+
}, [clip.start, url]);
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
className: ui.cn("relative h-full w-full overflow-hidden bg-black", className),
|
|
45
|
+
"data-testid": `clip-image-${clip.id}`,
|
|
46
|
+
children: clip.kind === "video" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
47
|
+
"video",
|
|
48
|
+
{
|
|
49
|
+
ref: videoRef,
|
|
50
|
+
src: url,
|
|
51
|
+
muted: !live,
|
|
52
|
+
playsInline: true,
|
|
53
|
+
preload: "auto",
|
|
54
|
+
className: "pointer-events-none block select-none",
|
|
55
|
+
style: cropStyle(clip.rect),
|
|
56
|
+
...live ? { [chunkADPRIBSH_cjs.STAGE_VIDEO_ATTRIBUTE]: "" } : {}
|
|
57
|
+
}
|
|
58
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
59
|
+
"img",
|
|
60
|
+
{
|
|
61
|
+
src: url,
|
|
62
|
+
alt: clip.caption,
|
|
63
|
+
draggable: false,
|
|
64
|
+
className: "pointer-events-none block select-none",
|
|
65
|
+
style: cropStyle(clip.rect)
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
var WIDTH_STEP = 160;
|
|
72
|
+
var SETTLE_MS = 150;
|
|
73
|
+
var ClipImage = react.memo(function ClipImage2({
|
|
74
|
+
clip,
|
|
75
|
+
className,
|
|
76
|
+
live = false
|
|
77
|
+
}) {
|
|
78
|
+
return clip.kind === "pdf" ? /* @__PURE__ */ jsxRuntime.jsx(PdfClip, { clip, className }) : /* @__PURE__ */ jsxRuntime.jsx(MediaClip, { clip, className, live });
|
|
79
|
+
});
|
|
80
|
+
var sameRect = (a, b) => a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;
|
|
81
|
+
function PdfClip({ clip, className }) {
|
|
82
|
+
const canvasRef = react.useRef(null);
|
|
83
|
+
const [size, setSize] = react.useState({ width: 0, height: 0 });
|
|
84
|
+
const [rendered, setRendered] = react.useState(null);
|
|
85
|
+
const [failed, setFailed] = react.useState(false);
|
|
86
|
+
react.useEffect(() => {
|
|
87
|
+
const canvas = canvasRef.current;
|
|
88
|
+
const view = canvas?.ownerDocument.defaultView;
|
|
89
|
+
if (!canvas || !view) return;
|
|
90
|
+
const measure = () => {
|
|
91
|
+
const box = canvas.getBoundingClientRect();
|
|
92
|
+
const dpr = view.devicePixelRatio || 1;
|
|
93
|
+
const width = Math.max(1, Math.round(box.width * dpr));
|
|
94
|
+
const height = Math.max(1, Math.round(box.height * dpr));
|
|
95
|
+
setSize((s) => s.width === width && s.height === height ? s : { width, height });
|
|
96
|
+
};
|
|
97
|
+
measure();
|
|
98
|
+
const Observer = view.ResizeObserver ?? ResizeObserver;
|
|
99
|
+
const observer = new Observer(measure);
|
|
100
|
+
observer.observe(canvas);
|
|
101
|
+
return () => observer.disconnect();
|
|
102
|
+
}, []);
|
|
103
|
+
react.useLayoutEffect(() => {
|
|
104
|
+
const canvas = canvasRef.current;
|
|
105
|
+
const context = canvas?.getContext("2d");
|
|
106
|
+
if (!canvas || !context || !size.width) return;
|
|
107
|
+
if (canvas.width !== size.width) canvas.width = size.width;
|
|
108
|
+
if (canvas.height !== size.height) canvas.height = size.height;
|
|
109
|
+
context.fillStyle = "#fff";
|
|
110
|
+
context.fillRect(0, 0, size.width, size.height);
|
|
111
|
+
if (!rendered) return;
|
|
112
|
+
const { rect } = clip;
|
|
113
|
+
const sx = size.width / rect.w;
|
|
114
|
+
const sy = size.height / rect.h;
|
|
115
|
+
try {
|
|
116
|
+
context.drawImage(
|
|
117
|
+
rendered.image,
|
|
118
|
+
(rendered.rect.x - rect.x) * sx,
|
|
119
|
+
(rendered.rect.y - rect.y) * sy,
|
|
120
|
+
rendered.rect.w * sx,
|
|
121
|
+
rendered.rect.h * sy
|
|
122
|
+
);
|
|
123
|
+
} catch {
|
|
124
|
+
setRendered(null);
|
|
125
|
+
}
|
|
126
|
+
}, [size, rendered, clip]);
|
|
127
|
+
const wanted = Math.ceil(size.width / WIDTH_STEP) * WIDTH_STEP;
|
|
128
|
+
const stale = wanted > 0 && (!rendered || !sameRect(rendered.rect, clip.rect) || wanted > rendered.width || wanted < rendered.width / 2);
|
|
129
|
+
react.useEffect(() => {
|
|
130
|
+
if (!stale) return;
|
|
131
|
+
const controller = new AbortController();
|
|
132
|
+
const rect = clip.rect;
|
|
133
|
+
const timer = setTimeout(() => {
|
|
134
|
+
viewers.renderPdfRegion({
|
|
135
|
+
file: clip.source,
|
|
136
|
+
page: clip.page,
|
|
137
|
+
rect,
|
|
138
|
+
masks: clip.masks,
|
|
139
|
+
width: wanted,
|
|
140
|
+
signal: controller.signal
|
|
141
|
+
}).then((image) => {
|
|
142
|
+
if (controller.signal.aborted) return viewers.closePdfRegionImage(image);
|
|
143
|
+
setFailed(false);
|
|
144
|
+
setRendered({ image, rect, width: wanted });
|
|
145
|
+
}).catch(() => !controller.signal.aborted && setFailed(true));
|
|
146
|
+
}, SETTLE_MS);
|
|
147
|
+
return () => {
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
controller.abort();
|
|
150
|
+
};
|
|
151
|
+
}, [stale, wanted, clip.source, clip.page, clip.rect, clip.masks]);
|
|
152
|
+
const previous = react.useRef(null);
|
|
153
|
+
react.useEffect(() => {
|
|
154
|
+
if (previous.current && previous.current !== rendered) {
|
|
155
|
+
viewers.closePdfRegionImage(previous.current.image);
|
|
156
|
+
}
|
|
157
|
+
previous.current = rendered;
|
|
158
|
+
}, [rendered]);
|
|
159
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
className: ui.cn("relative h-full w-full overflow-hidden bg-white", className),
|
|
163
|
+
"data-testid": `clip-image-${clip.id}`,
|
|
164
|
+
children: [
|
|
165
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
166
|
+
"canvas",
|
|
167
|
+
{
|
|
168
|
+
ref: canvasRef,
|
|
169
|
+
className: "pointer-events-none block h-full w-full",
|
|
170
|
+
role: "img",
|
|
171
|
+
"aria-label": clip.caption,
|
|
172
|
+
"aria-busy": !rendered
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
failed && !rendered && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center p-2 text-center text-xs text-neutral-500", children: "Couldn't draw this clip" })
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
var PAN_STEP = 0.1;
|
|
181
|
+
var MAX_ZOOM = 800;
|
|
182
|
+
var HOLD_DELAY = 350;
|
|
183
|
+
var HOLD_EVERY = 90;
|
|
184
|
+
var BUTTON = "flex size-7 items-center justify-center rounded-full border border-border bg-background text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-30 pointer-coarse:size-11";
|
|
185
|
+
function HoldButton({
|
|
186
|
+
label,
|
|
187
|
+
disabled,
|
|
188
|
+
onStep,
|
|
189
|
+
className,
|
|
190
|
+
children
|
|
191
|
+
}) {
|
|
192
|
+
const timer = react.useRef(null);
|
|
193
|
+
const stop = () => {
|
|
194
|
+
if (timer.current) clearTimeout(timer.current);
|
|
195
|
+
timer.current = null;
|
|
196
|
+
};
|
|
197
|
+
react.useEffect(() => stop, []);
|
|
198
|
+
react.useEffect(() => {
|
|
199
|
+
if (disabled) stop();
|
|
200
|
+
}, [disabled]);
|
|
201
|
+
const start = (event) => {
|
|
202
|
+
event.stopPropagation();
|
|
203
|
+
if (disabled || event.button !== 0) return;
|
|
204
|
+
onStep();
|
|
205
|
+
const repeat = () => {
|
|
206
|
+
onStep();
|
|
207
|
+
timer.current = setTimeout(repeat, HOLD_EVERY);
|
|
208
|
+
};
|
|
209
|
+
timer.current = setTimeout(repeat, HOLD_DELAY);
|
|
210
|
+
};
|
|
211
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
212
|
+
"button",
|
|
213
|
+
{
|
|
214
|
+
type: "button",
|
|
215
|
+
className: ui.cn(BUTTON, className),
|
|
216
|
+
title: label,
|
|
217
|
+
"aria-label": label,
|
|
218
|
+
disabled,
|
|
219
|
+
onPointerDown: start,
|
|
220
|
+
onPointerUp: stop,
|
|
221
|
+
onPointerLeave: stop,
|
|
222
|
+
onPointerCancel: stop,
|
|
223
|
+
onClick: (event) => event.detail === 0 && onStep(),
|
|
224
|
+
children
|
|
225
|
+
}
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function ClipViewControls({ clip }) {
|
|
229
|
+
const { panClip, setClipZoom } = chunkORNLCBNE_cjs.usePresentation.getState();
|
|
230
|
+
const { rect } = clip;
|
|
231
|
+
const zoomBase = clip.zoomBase ?? rect.w;
|
|
232
|
+
const minZoom = Math.min(100, Math.floor(zoomBase / Math.min(1, rect.w / rect.h) * 100));
|
|
233
|
+
const pan = (dx, dy) => () => panClip(clip.id, dx * rect.w, dy * rect.h);
|
|
234
|
+
const zoom = Math.round(zoomBase / rect.w * 100);
|
|
235
|
+
const edge = 1e-6;
|
|
236
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
237
|
+
"div",
|
|
238
|
+
{
|
|
239
|
+
className: "flex flex-col items-center gap-2 p-1",
|
|
240
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
241
|
+
"data-testid": "clip-view-controls",
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-3 grid-rows-3 place-items-center gap-0.5", children: [
|
|
244
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
245
|
+
HoldButton,
|
|
246
|
+
{
|
|
247
|
+
label: "Show more above",
|
|
248
|
+
disabled: rect.y <= edge,
|
|
249
|
+
onStep: pan(0, -PAN_STEP),
|
|
250
|
+
className: "col-start-2 row-start-1",
|
|
251
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronUp, { className: "size-4" })
|
|
252
|
+
}
|
|
253
|
+
),
|
|
254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
255
|
+
HoldButton,
|
|
256
|
+
{
|
|
257
|
+
label: "Show more on the left",
|
|
258
|
+
disabled: rect.x <= edge,
|
|
259
|
+
onStep: pan(-PAN_STEP, 0),
|
|
260
|
+
className: "col-start-1 row-start-2",
|
|
261
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { className: "size-4" })
|
|
262
|
+
}
|
|
263
|
+
),
|
|
264
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
265
|
+
HoldButton,
|
|
266
|
+
{
|
|
267
|
+
label: "Show more on the right",
|
|
268
|
+
disabled: rect.x + rect.w >= 1 - edge,
|
|
269
|
+
onStep: pan(PAN_STEP, 0),
|
|
270
|
+
className: "col-start-3 row-start-2",
|
|
271
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "size-4" })
|
|
272
|
+
}
|
|
273
|
+
),
|
|
274
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
HoldButton,
|
|
276
|
+
{
|
|
277
|
+
label: "Show more below",
|
|
278
|
+
disabled: rect.y + rect.h >= 1 - edge,
|
|
279
|
+
onStep: pan(0, PAN_STEP),
|
|
280
|
+
className: "col-start-2 row-start-3",
|
|
281
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "size-4" })
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
] }),
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "clip-zoom-control", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
286
|
+
chunk5GCCUXMT_cjs.ZoomSlider,
|
|
287
|
+
{
|
|
288
|
+
value: zoom,
|
|
289
|
+
min: minZoom,
|
|
290
|
+
max: Math.max(MAX_ZOOM, zoom),
|
|
291
|
+
zoomOutStep: 25,
|
|
292
|
+
onChange: (value) => setClipZoom(clip.id, value),
|
|
293
|
+
label: "Zoom",
|
|
294
|
+
valueLabel: /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-testid": "clip-zoom", children: [
|
|
295
|
+
zoom,
|
|
296
|
+
"%"
|
|
297
|
+
] }),
|
|
298
|
+
className: "pointer-coarse:h-11",
|
|
299
|
+
sliderClassName: "w-28"
|
|
300
|
+
}
|
|
301
|
+
) })
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
var ACTION = "inline-flex size-7 items-center justify-center rounded text-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring pointer-coarse:size-11";
|
|
307
|
+
var SIZES = [
|
|
308
|
+
{ command: "fit", label: "Fit the slide", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-4" }) },
|
|
309
|
+
{ command: "fullWidth", label: "Full width", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoveHorizontal, { className: "size-4" }) },
|
|
310
|
+
{ command: "fullHeight", label: "Full height", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoveVertical, { className: "size-4" }) }
|
|
311
|
+
];
|
|
312
|
+
var ALIGNMENTS = [
|
|
313
|
+
{ alignment: "left", label: "Left", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignStartVertical, { className: "size-4" }) },
|
|
314
|
+
{ alignment: "centre", label: "Centre", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignCenterVertical, { className: "size-4" }) },
|
|
315
|
+
{ alignment: "right", label: "Right", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignEndVertical, { className: "size-4" }) },
|
|
316
|
+
{ alignment: "top", label: "Top", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignStartHorizontal, { className: "size-4" }) },
|
|
317
|
+
{ alignment: "middle", label: "Middle", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignCenterHorizontal, { className: "size-4" }) },
|
|
318
|
+
{ alignment: "bottom", label: "Bottom", icon: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignEndHorizontal, { className: "size-4" }) }
|
|
319
|
+
];
|
|
320
|
+
function Action({
|
|
321
|
+
label,
|
|
322
|
+
onClick,
|
|
323
|
+
children
|
|
324
|
+
}) {
|
|
325
|
+
return /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: ACTION, title: label, "aria-label": label, onClick, children });
|
|
326
|
+
}
|
|
327
|
+
function ClipActionBar({
|
|
328
|
+
clipId,
|
|
329
|
+
at,
|
|
330
|
+
onRemoved,
|
|
331
|
+
onEditImage,
|
|
332
|
+
onCropImage
|
|
333
|
+
}) {
|
|
334
|
+
const actions = chunkORNLCBNE_cjs.usePresentation.getState();
|
|
335
|
+
const clip = chunkORNLCBNE_cjs.usePresentation((state) => state.clips.find((entry) => entry.id === clipId));
|
|
336
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
role: "toolbar",
|
|
340
|
+
"aria-label": "Clip",
|
|
341
|
+
className: "absolute z-20 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
|
|
342
|
+
style: { left: `${at.x * 100}%`, top: `calc(${at.y * 100}% - 40px)` },
|
|
343
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
344
|
+
"data-testid": "clip-action-bar",
|
|
345
|
+
children: [
|
|
346
|
+
/* @__PURE__ */ jsxRuntime.jsx(Action, { label: "Fit the slide", onClick: () => actions.applyFrame(clipId, "fit"), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "size-4" }) }),
|
|
347
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
348
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: ACTION, title: "Align", "aria-label": "Align", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignCenterHorizontal, { className: "size-4" }) }) }),
|
|
349
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuContent, { align: "start", children: ALIGNMENTS.map(({ alignment, label, icon }) => /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.align(clipId, alignment), children: [
|
|
350
|
+
icon,
|
|
351
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: label })
|
|
352
|
+
] }, alignment)) })
|
|
353
|
+
] }),
|
|
354
|
+
clip && /* @__PURE__ */ jsxRuntime.jsxs(ui.Popover, { children: [
|
|
355
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
356
|
+
"button",
|
|
357
|
+
{
|
|
358
|
+
type: "button",
|
|
359
|
+
className: ACTION,
|
|
360
|
+
title: "View: scroll or zoom what the clip shows (or scroll over it)",
|
|
361
|
+
"aria-label": "View",
|
|
362
|
+
"data-testid": "clip-view-button",
|
|
363
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ZoomIn, { className: "size-4" })
|
|
364
|
+
}
|
|
365
|
+
) }),
|
|
366
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.PopoverContent, { align: "start", className: "w-auto p-2", children: /* @__PURE__ */ jsxRuntime.jsx(ClipViewControls, { clip }) })
|
|
367
|
+
] }),
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
370
|
+
"button",
|
|
371
|
+
{
|
|
372
|
+
type: "button",
|
|
373
|
+
className: ACTION,
|
|
374
|
+
title: "More",
|
|
375
|
+
"aria-label": "More",
|
|
376
|
+
"data-testid": "clip-more-menu",
|
|
377
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-4" })
|
|
378
|
+
}
|
|
379
|
+
) }),
|
|
380
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuContent, { align: "start", children: [
|
|
381
|
+
SIZES.filter(({ command }) => command !== "fit").map(({ command, label, icon }) => /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.applyFrame(clipId, command), children: [
|
|
382
|
+
icon,
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: label })
|
|
384
|
+
] }, command)),
|
|
385
|
+
onCropImage && /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: onCropImage, children: [
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Crop, { className: "size-4" }),
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Crop" })
|
|
388
|
+
] }),
|
|
389
|
+
onEditImage && /* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: onEditImage, children: [
|
|
390
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sparkles, { className: "size-4" }),
|
|
391
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Edit image" })
|
|
392
|
+
] }),
|
|
393
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuSeparator, {}),
|
|
394
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.bringToFront(clipId), children: [
|
|
395
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.BringToFront, { className: "size-4" }),
|
|
396
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Bring to front" })
|
|
397
|
+
] }),
|
|
398
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.sendToBack(clipId), children: [
|
|
399
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendToBack, { className: "size-4" }),
|
|
400
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Send to back" })
|
|
401
|
+
] })
|
|
402
|
+
] })
|
|
403
|
+
] }),
|
|
404
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-0.5 h-5 w-px bg-border" }),
|
|
405
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
406
|
+
"button",
|
|
407
|
+
{
|
|
408
|
+
type: "button",
|
|
409
|
+
className: ui.cn(ACTION, "text-destructive hover:bg-destructive/10"),
|
|
410
|
+
title: "Remove from slide (Delete)",
|
|
411
|
+
"aria-label": "Remove from slide",
|
|
412
|
+
onClick: () => {
|
|
413
|
+
actions.unplace(clipId);
|
|
414
|
+
onRemoved();
|
|
415
|
+
},
|
|
416
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" })
|
|
417
|
+
}
|
|
418
|
+
)
|
|
419
|
+
]
|
|
420
|
+
}
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
var boxStyle = (box) => ({
|
|
424
|
+
left: `${box.x * 100}%`,
|
|
425
|
+
top: `${box.y * 100}%`,
|
|
426
|
+
width: `${box.w * 100}%`,
|
|
427
|
+
height: `${box.h * 100}%`
|
|
428
|
+
});
|
|
429
|
+
var textStyle = (box, color) => ({
|
|
430
|
+
...boxStyle(box),
|
|
431
|
+
fontSize: `${box.size * 100}cqw`,
|
|
432
|
+
fontWeight: box.weight,
|
|
433
|
+
lineHeight: box.leading,
|
|
434
|
+
color,
|
|
435
|
+
letterSpacing: box.tone === "title" ? "-0.01em" : void 0
|
|
436
|
+
});
|
|
437
|
+
var PLACEHOLDER_COLOR = "rgba(255,255,255,0.32)";
|
|
438
|
+
function Text({
|
|
439
|
+
box,
|
|
440
|
+
lines,
|
|
441
|
+
accent,
|
|
442
|
+
placeholder,
|
|
443
|
+
onEdit,
|
|
444
|
+
testId
|
|
445
|
+
}) {
|
|
446
|
+
const empty = lines.length === 0;
|
|
447
|
+
if (empty && !placeholder) return null;
|
|
448
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
449
|
+
"div",
|
|
450
|
+
{
|
|
451
|
+
className: ui.cn(
|
|
452
|
+
"absolute flex flex-col overflow-hidden",
|
|
453
|
+
onEdit ? "pointer-events-auto cursor-text rounded-[0.3cqw] hover:outline hover:outline-1 hover:outline-white/25" : "pointer-events-none",
|
|
454
|
+
box.align === "center" && "text-center",
|
|
455
|
+
box.bullets && "gap-[0.6cqw]",
|
|
456
|
+
box.anchor === "middle" && "justify-center",
|
|
457
|
+
box.anchor === "bottom" && "justify-end"
|
|
458
|
+
),
|
|
459
|
+
style: textStyle(box, empty ? PLACEHOLDER_COLOR : chunkORNLCBNE_cjs.TEXT_COLORS[box.tone]),
|
|
460
|
+
onPointerDown: onEdit ? (event) => event.stopPropagation() : void 0,
|
|
461
|
+
onClick: onEdit,
|
|
462
|
+
"data-testid": testId,
|
|
463
|
+
children: (empty ? [placeholder] : lines).map(
|
|
464
|
+
(line, index) => box.bullets ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline gap-[0.8em]", children: [
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
466
|
+
"span",
|
|
467
|
+
{
|
|
468
|
+
"aria-hidden": true,
|
|
469
|
+
className: "inline-block size-[0.42em] shrink-0 -translate-y-[0.12em]",
|
|
470
|
+
style: { background: empty ? "currentColor" : accent }
|
|
471
|
+
}
|
|
472
|
+
),
|
|
473
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: line })
|
|
474
|
+
] }, index) : /* @__PURE__ */ jsxRuntime.jsx("div", { children: line }, index)
|
|
475
|
+
)
|
|
476
|
+
}
|
|
477
|
+
);
|
|
478
|
+
}
|
|
479
|
+
function TextField({
|
|
480
|
+
box,
|
|
481
|
+
value,
|
|
482
|
+
placeholder,
|
|
483
|
+
multiline,
|
|
484
|
+
onChange,
|
|
485
|
+
onDone,
|
|
486
|
+
testId
|
|
487
|
+
}) {
|
|
488
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
489
|
+
"textarea",
|
|
490
|
+
{
|
|
491
|
+
autoFocus: true,
|
|
492
|
+
value,
|
|
493
|
+
placeholder,
|
|
494
|
+
onChange: (event) => onChange(multiline ? event.target.value : event.target.value.replace(/\n/g, " ")),
|
|
495
|
+
onBlur: onDone,
|
|
496
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
497
|
+
onKeyDown: (event) => {
|
|
498
|
+
if (event.key === "Escape" || !multiline && event.key === "Enter") {
|
|
499
|
+
event.preventDefault();
|
|
500
|
+
event.currentTarget.blur();
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
className: ui.cn(
|
|
504
|
+
"pointer-events-auto absolute resize-none overflow-hidden rounded-[0.3cqw] bg-white/5 p-0 outline outline-1 outline-white/40 placeholder:text-white/30 focus:outline-white/60",
|
|
505
|
+
box.align === "center" && "text-center"
|
|
506
|
+
),
|
|
507
|
+
style: {
|
|
508
|
+
...textStyle(box, chunkORNLCBNE_cjs.TEXT_COLORS[box.tone]),
|
|
509
|
+
fontFamily: "inherit",
|
|
510
|
+
// Bulleted lines keep their indent while typed.
|
|
511
|
+
paddingLeft: box.bullets ? "1.22em" : void 0
|
|
512
|
+
},
|
|
513
|
+
"aria-label": placeholder,
|
|
514
|
+
"data-testid": testId
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
function Logo({ image, box }) {
|
|
519
|
+
const url = chunkWOOOMTTA_cjs.useObjectUrl(image);
|
|
520
|
+
if (!url) return null;
|
|
521
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
522
|
+
"img",
|
|
523
|
+
{
|
|
524
|
+
src: url,
|
|
525
|
+
alt: "",
|
|
526
|
+
className: "pointer-events-none absolute object-contain opacity-90",
|
|
527
|
+
style: { ...boxStyle(box), objectPosition: box.x < 0.5 ? "left bottom" : "right bottom" },
|
|
528
|
+
"data-testid": "stage-logo"
|
|
529
|
+
}
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
var SlideDecor = react.memo(function SlideDecor2({
|
|
533
|
+
slide,
|
|
534
|
+
theme,
|
|
535
|
+
labels,
|
|
536
|
+
logoImage,
|
|
537
|
+
editable,
|
|
538
|
+
editing,
|
|
539
|
+
dim
|
|
540
|
+
}) {
|
|
541
|
+
const [typing, setTyping] = react.useState(null);
|
|
542
|
+
const geometry = chunkORNLCBNE_cjs.slideGeometry(slide, { labels, logo: theme.logo?.corner ?? null });
|
|
543
|
+
const title = slide.caption.trim();
|
|
544
|
+
const titled = slide.layout === "title" || slide.layout === "section";
|
|
545
|
+
const info = chunkORNLCBNE_cjs.LAYOUT_INFO[slide.layout];
|
|
546
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cn("pointer-events-none absolute inset-0", dim && "opacity-30"), children: [
|
|
547
|
+
!geometry.title ? null : editing && typing === "title" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
548
|
+
TextField,
|
|
549
|
+
{
|
|
550
|
+
box: geometry.title,
|
|
551
|
+
value: slide.caption,
|
|
552
|
+
placeholder: "Title",
|
|
553
|
+
multiline: false,
|
|
554
|
+
onChange: editing.onTitle,
|
|
555
|
+
onDone: () => setTyping(null),
|
|
556
|
+
testId: "stage-slide-caption-input"
|
|
557
|
+
}
|
|
558
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
559
|
+
Text,
|
|
560
|
+
{
|
|
561
|
+
box: geometry.title,
|
|
562
|
+
lines: title ? [title] : [],
|
|
563
|
+
accent: chunkORNLCBNE_cjs.accentColor(theme.accent),
|
|
564
|
+
placeholder: editable && (titled || editing) ? "Click to add a title" : void 0,
|
|
565
|
+
onEdit: editing ? () => setTyping("title") : void 0,
|
|
566
|
+
testId: "stage-slide-caption"
|
|
567
|
+
}
|
|
568
|
+
),
|
|
569
|
+
geometry.rule && (title || editable && titled) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
"div",
|
|
571
|
+
{
|
|
572
|
+
className: "absolute",
|
|
573
|
+
style: { ...boxStyle(geometry.rule), background: chunkORNLCBNE_cjs.accentColor(theme.accent) }
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
geometry.text && (editing && typing === "text" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
577
|
+
TextField,
|
|
578
|
+
{
|
|
579
|
+
box: geometry.text,
|
|
580
|
+
value: slide.points,
|
|
581
|
+
placeholder: info.text ?? "",
|
|
582
|
+
multiline: true,
|
|
583
|
+
onChange: editing.onPoints,
|
|
584
|
+
onDone: () => setTyping(null),
|
|
585
|
+
testId: "stage-slide-points-input"
|
|
586
|
+
}
|
|
587
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
588
|
+
Text,
|
|
589
|
+
{
|
|
590
|
+
box: geometry.text,
|
|
591
|
+
lines: chunkORNLCBNE_cjs.textLines(slide.points),
|
|
592
|
+
accent: chunkORNLCBNE_cjs.accentColor(theme.accent),
|
|
593
|
+
placeholder: editable ? info.text : void 0,
|
|
594
|
+
onEdit: editing ? () => setTyping("text") : void 0,
|
|
595
|
+
testId: "stage-slide-points"
|
|
596
|
+
}
|
|
597
|
+
)),
|
|
598
|
+
geometry.logo && logoImage && /* @__PURE__ */ jsxRuntime.jsx(Logo, { image: logoImage, box: geometry.logo })
|
|
599
|
+
] });
|
|
600
|
+
});
|
|
601
|
+
var isEdge = (kind) => kind === "n" || kind === "e" || kind === "s" || kind === "w";
|
|
602
|
+
var EDGES = [
|
|
603
|
+
{ edge: "n", left: "50%", top: "0%", cursor: "ns-resize", label: "top" },
|
|
604
|
+
{ edge: "e", left: "100%", top: "50%", cursor: "ew-resize", label: "right" },
|
|
605
|
+
{ edge: "s", left: "50%", top: "100%", cursor: "ns-resize", label: "bottom" },
|
|
606
|
+
{ edge: "w", left: "0%", top: "50%", cursor: "ew-resize", label: "left" }
|
|
607
|
+
];
|
|
608
|
+
var CORNERS = [
|
|
609
|
+
{ corner: "nw", left: "0%", top: "0%", cursor: "nwse-resize" },
|
|
610
|
+
{ corner: "ne", left: "100%", top: "0%", cursor: "nesw-resize" },
|
|
611
|
+
{ corner: "sw", left: "0%", top: "100%", cursor: "nesw-resize" },
|
|
612
|
+
{ corner: "se", left: "100%", top: "100%", cursor: "nwse-resize" }
|
|
613
|
+
];
|
|
614
|
+
var EDGE_CSS = chunkORNLCBNE_cjs.clipEdgeCss();
|
|
615
|
+
var StageItem = react.memo(function StageItem2({
|
|
616
|
+
clip,
|
|
617
|
+
frame,
|
|
618
|
+
editable,
|
|
619
|
+
selected,
|
|
620
|
+
dim,
|
|
621
|
+
label,
|
|
622
|
+
host
|
|
623
|
+
}) {
|
|
624
|
+
const element = react.useRef(null);
|
|
625
|
+
const gesture = react.useRef(null);
|
|
626
|
+
const [reshape, setReshape] = react.useState(null);
|
|
627
|
+
const shown = reshape ? { ...clip, ...reshape.shape } : clip;
|
|
628
|
+
const box = reshape?.frame ?? frame;
|
|
629
|
+
const view = () => element.current?.ownerDocument.defaultView ?? window;
|
|
630
|
+
const apply = () => {
|
|
631
|
+
const g = gesture.current;
|
|
632
|
+
const el = element.current;
|
|
633
|
+
if (!g) return;
|
|
634
|
+
g.request = null;
|
|
635
|
+
const next = g.next;
|
|
636
|
+
if (!next || !el) return;
|
|
637
|
+
if (next.shape) {
|
|
638
|
+
setReshape({ frame: next.frame, shape: next.shape });
|
|
639
|
+
} else {
|
|
640
|
+
const dx = (next.frame.x - g.frame.x) * g.stage.width;
|
|
641
|
+
const dy = (next.frame.y - g.frame.y) * g.stage.height;
|
|
642
|
+
const scale = next.frame.w / g.frame.w;
|
|
643
|
+
el.style.transform = `translate3d(${dx}px, ${dy}px, 0) scale(${scale})`;
|
|
644
|
+
}
|
|
645
|
+
const key = next.guides.map((guide) => `${guide.axis}${guide.at}`).join();
|
|
646
|
+
if (key !== g.guidesKey) {
|
|
647
|
+
g.guidesKey = key;
|
|
648
|
+
host.guides(next.guides);
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
const start = (event, kind) => {
|
|
652
|
+
if (!editable || event.button !== 0) return;
|
|
653
|
+
const stage = host.stageBox();
|
|
654
|
+
if (!stage) return;
|
|
655
|
+
event.preventDefault();
|
|
656
|
+
event.stopPropagation();
|
|
657
|
+
host.select(clip.id);
|
|
658
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
659
|
+
gesture.current = {
|
|
660
|
+
kind,
|
|
661
|
+
pointer: { x: event.clientX, y: event.clientY },
|
|
662
|
+
frame,
|
|
663
|
+
shape: { rect: clip.rect, aspect: clip.aspect },
|
|
664
|
+
stage,
|
|
665
|
+
others: host.others(clip.id),
|
|
666
|
+
next: null,
|
|
667
|
+
request: null,
|
|
668
|
+
guidesKey: ""
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
const move = (event) => {
|
|
672
|
+
const g = gesture.current;
|
|
673
|
+
if (!g) return;
|
|
674
|
+
if (!g.next) {
|
|
675
|
+
host.dragging(true);
|
|
676
|
+
if (element.current) element.current.style.willChange = "transform";
|
|
677
|
+
}
|
|
678
|
+
const dx = (event.clientX - g.pointer.x) / g.stage.width;
|
|
679
|
+
const dy = (event.clientY - g.pointer.y) / g.stage.height;
|
|
680
|
+
const free = event.altKey;
|
|
681
|
+
if (isEdge(g.kind)) {
|
|
682
|
+
const result = chunkORNLCBNE_cjs.reshapeFrame(g.frame, g.shape, g.kind, dx, dy, g.others, free);
|
|
683
|
+
g.next = {
|
|
684
|
+
frame: result.frame,
|
|
685
|
+
shape: { rect: result.rect, aspect: result.aspect },
|
|
686
|
+
guides: result.guides
|
|
687
|
+
};
|
|
688
|
+
} else {
|
|
689
|
+
g.next = g.kind === "move" ? chunkORNLCBNE_cjs.moveFrame(g.frame, g.shape.aspect, dx, dy, g.others, free) : chunkORNLCBNE_cjs.resizeFrame(g.frame, g.shape.aspect, g.kind, dx, dy, g.others, free);
|
|
690
|
+
}
|
|
691
|
+
g.request ??= view().requestAnimationFrame(apply);
|
|
692
|
+
};
|
|
693
|
+
const end = () => {
|
|
694
|
+
const g = gesture.current;
|
|
695
|
+
gesture.current = null;
|
|
696
|
+
if (!g) return;
|
|
697
|
+
if (g.request !== null) view().cancelAnimationFrame(g.request);
|
|
698
|
+
const el = element.current;
|
|
699
|
+
if (el) {
|
|
700
|
+
el.style.transform = "";
|
|
701
|
+
el.style.willChange = "";
|
|
702
|
+
}
|
|
703
|
+
if (!g.next) return;
|
|
704
|
+
setReshape(null);
|
|
705
|
+
host.dragging(false);
|
|
706
|
+
host.guides([]);
|
|
707
|
+
host.commit(clip.id, g.next.frame, g.next.shape);
|
|
708
|
+
};
|
|
709
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
710
|
+
"div",
|
|
711
|
+
{
|
|
712
|
+
ref: element,
|
|
713
|
+
className: ui.cn(
|
|
714
|
+
"absolute origin-top-left",
|
|
715
|
+
// Lifted off the background (a picture that is part of the slide's design is not).
|
|
716
|
+
!clip.plain && "rounded-[0.6cqw] shadow-[0_0.5cqw_1.6cqw_rgba(0,0,0,0.5)]",
|
|
717
|
+
editable && "cursor-move touch-none",
|
|
718
|
+
selected && "outline outline-2 outline-offset-2 outline-primary",
|
|
719
|
+
dim && "opacity-30"
|
|
720
|
+
),
|
|
721
|
+
style: {
|
|
722
|
+
left: `${box.x * 100}%`,
|
|
723
|
+
top: `${box.y * 100}%`,
|
|
724
|
+
width: `${box.w * 100}%`,
|
|
725
|
+
height: `${chunkORNLCBNE_cjs.frameHeight(box, shown.aspect) * 100}%`
|
|
726
|
+
},
|
|
727
|
+
onPointerDown: (event) => start(event, "move"),
|
|
728
|
+
onPointerMove: move,
|
|
729
|
+
onPointerUp: end,
|
|
730
|
+
onPointerCancel: end,
|
|
731
|
+
"data-testid": `stage-item-${clip.id}`,
|
|
732
|
+
children: [
|
|
733
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cn("absolute inset-0 overflow-hidden", !clip.plain && "rounded-[0.6cqw]"), children: [
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsx(ClipImage, { clip: shown, live: !editable }),
|
|
735
|
+
clip.kind === "pdf" && !clip.plain && /* @__PURE__ */ jsxRuntime.jsx(
|
|
736
|
+
"div",
|
|
737
|
+
{
|
|
738
|
+
className: "pointer-events-none absolute inset-0",
|
|
739
|
+
style: { background: EDGE_CSS },
|
|
740
|
+
"data-testid": "stage-clip-edge"
|
|
741
|
+
}
|
|
742
|
+
),
|
|
743
|
+
!clip.plain && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pointer-events-none absolute inset-0 rounded-[0.6cqw] ring-1 ring-inset ring-white/15" })
|
|
744
|
+
] }),
|
|
745
|
+
label && !clip.plain && // Under the clip, in the room the layout keeps (CAPTION_SPACE): never over it.
|
|
746
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
747
|
+
"div",
|
|
748
|
+
{
|
|
749
|
+
className: "pointer-events-none absolute left-0 top-full mt-[0.5cqw] max-w-full truncate text-[1.7cqw] leading-tight",
|
|
750
|
+
style: { color: chunkORNLCBNE_cjs.TEXT_COLORS.muted },
|
|
751
|
+
children: label
|
|
752
|
+
}
|
|
753
|
+
),
|
|
754
|
+
selected && CORNERS.map(({ corner, left, top, cursor }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
755
|
+
"div",
|
|
756
|
+
{
|
|
757
|
+
className: "absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11",
|
|
758
|
+
style: { left, top, cursor, touchAction: "none" },
|
|
759
|
+
onPointerDown: (event) => start(event, corner),
|
|
760
|
+
"aria-label": `Resize from the ${corner} corner`,
|
|
761
|
+
"data-testid": `stage-item-resize-${corner}`,
|
|
762
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none size-3 rounded-full border-2 border-primary bg-background" })
|
|
763
|
+
},
|
|
764
|
+
corner
|
|
765
|
+
)),
|
|
766
|
+
selected && EDGES.map(({ edge, left, top, cursor, label: side }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
767
|
+
"div",
|
|
768
|
+
{
|
|
769
|
+
className: "absolute flex size-6 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11",
|
|
770
|
+
style: { left, top, cursor, touchAction: "none" },
|
|
771
|
+
onPointerDown: (event) => start(event, edge),
|
|
772
|
+
"aria-label": `Show more or less at the ${side}`,
|
|
773
|
+
title: "Drag to show more or less of the page",
|
|
774
|
+
"data-testid": `stage-item-reshape-${edge}`,
|
|
775
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
776
|
+
"span",
|
|
777
|
+
{
|
|
778
|
+
className: ui.cn(
|
|
779
|
+
"pointer-events-none rounded-full border-2 border-primary bg-background",
|
|
780
|
+
edge === "n" || edge === "s" ? "h-2 w-4" : "h-4 w-2"
|
|
781
|
+
)
|
|
782
|
+
}
|
|
783
|
+
)
|
|
784
|
+
},
|
|
785
|
+
edge
|
|
786
|
+
))
|
|
787
|
+
]
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
});
|
|
791
|
+
|
|
792
|
+
// src/presentation/box-style.ts
|
|
793
|
+
var cqw = (points) => `${chunkORNLCBNE_cjs.pointsToStage(points) * 100}cqw`;
|
|
794
|
+
function runStyle(run, font) {
|
|
795
|
+
return {
|
|
796
|
+
fontSize: cqw(run.size ?? chunkORNLCBNE_cjs.DEFAULT_TEXT_SIZE),
|
|
797
|
+
fontWeight: run.bold ? 700 : 400,
|
|
798
|
+
fontStyle: run.italic ? "italic" : void 0,
|
|
799
|
+
textDecoration: run.underline ? "underline" : void 0,
|
|
800
|
+
color: run.color ?? chunkORNLCBNE_cjs.TEXT_COLORS.body,
|
|
801
|
+
fontFamily: run.font ? `"${run.font}", ${font}` : font
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
var HANDLES = [
|
|
805
|
+
{ handle: "nw", left: "0%", top: "0%", cursor: "nwse-resize" },
|
|
806
|
+
{ handle: "n", left: "50%", top: "0%", cursor: "ns-resize" },
|
|
807
|
+
{ handle: "ne", left: "100%", top: "0%", cursor: "nesw-resize" },
|
|
808
|
+
{ handle: "e", left: "100%", top: "50%", cursor: "ew-resize" },
|
|
809
|
+
{ handle: "se", left: "100%", top: "100%", cursor: "nwse-resize" },
|
|
810
|
+
{ handle: "s", left: "50%", top: "100%", cursor: "ns-resize" },
|
|
811
|
+
{ handle: "sw", left: "0%", top: "100%", cursor: "nesw-resize" },
|
|
812
|
+
{ handle: "w", left: "0%", top: "50%", cursor: "ew-resize" }
|
|
813
|
+
];
|
|
814
|
+
var withAlpha = (hex, alpha = 1) => {
|
|
815
|
+
if (alpha >= 1) return hex;
|
|
816
|
+
const n = parseInt(hex.slice(1), 16);
|
|
817
|
+
return `rgba(${n >> 16 & 255}, ${n >> 8 & 255}, ${n & 255}, ${alpha})`;
|
|
818
|
+
};
|
|
819
|
+
function shapeStyle(box) {
|
|
820
|
+
const { frame } = box;
|
|
821
|
+
const line = box.line;
|
|
822
|
+
const shorter = Math.min(frame.w, frame.h * 1 / chunkORNLCBNE_cjs.STAGE_ASPECT);
|
|
823
|
+
return {
|
|
824
|
+
background: box.fill && box.shape !== "line" ? withAlpha(box.fill, box.fillAlpha) : void 0,
|
|
825
|
+
border: line && box.shape !== "line" ? `${cqw(line.width)} ${line.dash ? "dashed" : "solid"} ${line.color}` : void 0,
|
|
826
|
+
borderRadius: box.shape === "ellipse" ? "50%" : box.shape === "roundRect" ? `${shorter * 16.67}cqw` : void 0
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
function Paragraphs({
|
|
830
|
+
paragraphs,
|
|
831
|
+
font
|
|
832
|
+
}) {
|
|
833
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: paragraphs.map((paragraph, index) => {
|
|
834
|
+
const first = paragraph.runs[0];
|
|
835
|
+
const size = first?.size ?? chunkORNLCBNE_cjs.DEFAULT_TEXT_SIZE;
|
|
836
|
+
const indent = (paragraph.level ?? 0) * 0.5 * size;
|
|
837
|
+
const empty = !paragraph.runs.some((run) => run.text);
|
|
838
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
839
|
+
"div",
|
|
840
|
+
{
|
|
841
|
+
className: "whitespace-pre-wrap break-words",
|
|
842
|
+
style: {
|
|
843
|
+
textAlign: paragraph.align ?? "left",
|
|
844
|
+
lineHeight: 1.2,
|
|
845
|
+
paddingLeft: cqw(indent + (paragraph.bullet ? size * 0.9 : 0)),
|
|
846
|
+
textIndent: paragraph.bullet ? cqw(-size * 0.9) : void 0,
|
|
847
|
+
// An empty line keeps its height.
|
|
848
|
+
fontSize: cqw(size)
|
|
849
|
+
},
|
|
850
|
+
children: [
|
|
851
|
+
paragraph.bullet && /* @__PURE__ */ jsxRuntime.jsx(
|
|
852
|
+
"span",
|
|
853
|
+
{
|
|
854
|
+
style: {
|
|
855
|
+
...runStyle(first ?? { }, font),
|
|
856
|
+
display: "inline-block",
|
|
857
|
+
width: cqw(size * 0.9),
|
|
858
|
+
textIndent: 0
|
|
859
|
+
},
|
|
860
|
+
children: "\u2022"
|
|
861
|
+
}
|
|
862
|
+
),
|
|
863
|
+
empty ? "\u200B" : paragraph.runs.map((run, i) => /* @__PURE__ */ jsxRuntime.jsx("span", { style: runStyle(run, font), children: run.text }, i))
|
|
864
|
+
]
|
|
865
|
+
},
|
|
866
|
+
index
|
|
867
|
+
);
|
|
868
|
+
}) });
|
|
869
|
+
}
|
|
870
|
+
var StageBox = react.memo(function StageBox2({
|
|
871
|
+
box,
|
|
872
|
+
font,
|
|
873
|
+
editable,
|
|
874
|
+
selected,
|
|
875
|
+
host
|
|
876
|
+
}) {
|
|
877
|
+
const element = react.useRef(null);
|
|
878
|
+
const gesture = react.useRef(null);
|
|
879
|
+
const [typing, setTyping] = react.useState(false);
|
|
880
|
+
const [dragging, setDragging] = react.useState(false);
|
|
881
|
+
const { frame } = box;
|
|
882
|
+
const view = () => element.current?.ownerDocument.defaultView ?? window;
|
|
883
|
+
const apply = () => {
|
|
884
|
+
const g = gesture.current;
|
|
885
|
+
const el = element.current;
|
|
886
|
+
if (!g || !el) return;
|
|
887
|
+
g.request = null;
|
|
888
|
+
if (!g.next) return;
|
|
889
|
+
if (g.handle === "move") {
|
|
890
|
+
el.style.translate = `${(g.next.x - g.frame.x) * g.stage.width}px ${(g.next.y - g.frame.y) * g.stage.height}px`;
|
|
891
|
+
} else {
|
|
892
|
+
el.style.left = `${g.next.x * 100}%`;
|
|
893
|
+
el.style.top = `${g.next.y * 100}%`;
|
|
894
|
+
el.style.width = `${g.next.w * 100}%`;
|
|
895
|
+
el.style.height = `${g.next.h * 100}%`;
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
const start = (event, handle) => {
|
|
899
|
+
if (!editable || typing || event.button !== 0) return;
|
|
900
|
+
const stage = host.stageBox();
|
|
901
|
+
if (!stage) return;
|
|
902
|
+
event.preventDefault();
|
|
903
|
+
event.stopPropagation();
|
|
904
|
+
host.select(box.id);
|
|
905
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
906
|
+
gesture.current = {
|
|
907
|
+
handle,
|
|
908
|
+
pointer: { x: event.clientX, y: event.clientY },
|
|
909
|
+
frame,
|
|
910
|
+
stage,
|
|
911
|
+
next: null,
|
|
912
|
+
request: null,
|
|
913
|
+
wasSelected: selected
|
|
914
|
+
};
|
|
915
|
+
};
|
|
916
|
+
const move = (event) => {
|
|
917
|
+
const g = gesture.current;
|
|
918
|
+
if (!g) return;
|
|
919
|
+
const dx = (event.clientX - g.pointer.x) / g.stage.width;
|
|
920
|
+
const dy = (event.clientY - g.pointer.y) / g.stage.height;
|
|
921
|
+
if (!g.next) setDragging(true);
|
|
922
|
+
g.next = g.handle === "move" ? chunkORNLCBNE_cjs.moveBox(g.frame, dx, dy) : chunkORNLCBNE_cjs.stretchBox(g.frame, g.handle, dx, dy);
|
|
923
|
+
g.request ??= view().requestAnimationFrame(apply);
|
|
924
|
+
};
|
|
925
|
+
const end = () => {
|
|
926
|
+
const g = gesture.current;
|
|
927
|
+
gesture.current = null;
|
|
928
|
+
if (!g) return;
|
|
929
|
+
if (g.request !== null) view().cancelAnimationFrame(g.request);
|
|
930
|
+
if (!g.next) {
|
|
931
|
+
if (g.wasSelected && g.handle === "move" && hasText) setTyping(true);
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const el = element.current;
|
|
935
|
+
if (el) {
|
|
936
|
+
el.style.translate = "";
|
|
937
|
+
el.style.left = `${g.frame.x * 100}%`;
|
|
938
|
+
el.style.top = `${g.frame.y * 100}%`;
|
|
939
|
+
el.style.width = `${g.frame.w * 100}%`;
|
|
940
|
+
el.style.height = `${g.frame.h * 100}%`;
|
|
941
|
+
}
|
|
942
|
+
setDragging(false);
|
|
943
|
+
host.commit(box.id, g.next);
|
|
944
|
+
};
|
|
945
|
+
const hasText = box.shape !== "line";
|
|
946
|
+
const inset = cqw(box.inset ?? chunkORNLCBNE_cjs.DEFAULT_INSET);
|
|
947
|
+
const run = chunkORNLCBNE_cjs.firstRun(box);
|
|
948
|
+
const transform = box.rotation ? `rotate(${box.rotation}deg)` : void 0;
|
|
949
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
950
|
+
"div",
|
|
951
|
+
{
|
|
952
|
+
ref: element,
|
|
953
|
+
className: ui.cn(
|
|
954
|
+
"absolute",
|
|
955
|
+
editable ? "pointer-events-auto" : "pointer-events-none",
|
|
956
|
+
editable && !typing && "cursor-move touch-none",
|
|
957
|
+
editable && !selected && "hover:outline hover:outline-1 hover:outline-white/30",
|
|
958
|
+
selected && "outline outline-2 outline-offset-1 outline-primary"
|
|
959
|
+
),
|
|
960
|
+
style: {
|
|
961
|
+
left: `${frame.x * 100}%`,
|
|
962
|
+
top: `${frame.y * 100}%`,
|
|
963
|
+
width: `${frame.w * 100}%`,
|
|
964
|
+
height: `${frame.h * 100}%`,
|
|
965
|
+
transform,
|
|
966
|
+
willChange: dragging ? "translate" : void 0
|
|
967
|
+
},
|
|
968
|
+
onPointerDown: (event) => start(event, "move"),
|
|
969
|
+
onPointerMove: move,
|
|
970
|
+
onPointerUp: end,
|
|
971
|
+
onPointerCancel: end,
|
|
972
|
+
onDoubleClick: () => editable && hasText && setTyping(true),
|
|
973
|
+
onKeyDown: (event) => {
|
|
974
|
+
if (selected && !typing && event.key === "Enter" && hasText) {
|
|
975
|
+
event.preventDefault();
|
|
976
|
+
setTyping(true);
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
tabIndex: editable ? 0 : void 0,
|
|
980
|
+
"data-testid": `stage-box-${box.id}`,
|
|
981
|
+
children: [
|
|
982
|
+
box.shape === "line" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
983
|
+
"svg",
|
|
984
|
+
{
|
|
985
|
+
className: "absolute inset-0 size-full overflow-visible",
|
|
986
|
+
preserveAspectRatio: "none",
|
|
987
|
+
"aria-hidden": true,
|
|
988
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
989
|
+
"line",
|
|
990
|
+
{
|
|
991
|
+
x1: "0%",
|
|
992
|
+
y1: box.flipV ? "100%" : "0%",
|
|
993
|
+
x2: "100%",
|
|
994
|
+
y2: box.flipV ? "0%" : "100%",
|
|
995
|
+
stroke: box.line?.color ?? chunkORNLCBNE_cjs.TEXT_COLORS.body,
|
|
996
|
+
style: { strokeWidth: cqw(box.line?.width ?? 1) },
|
|
997
|
+
strokeDasharray: box.line?.dash ? "6 4" : void 0
|
|
998
|
+
}
|
|
999
|
+
)
|
|
1000
|
+
}
|
|
1001
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1002
|
+
"div",
|
|
1003
|
+
{
|
|
1004
|
+
className: ui.cn(
|
|
1005
|
+
"absolute inset-0 box-border flex flex-col overflow-hidden",
|
|
1006
|
+
box.anchor === "middle" && "justify-center",
|
|
1007
|
+
box.anchor === "bottom" && "justify-end"
|
|
1008
|
+
),
|
|
1009
|
+
style: { ...shapeStyle(box), padding: inset },
|
|
1010
|
+
children: typing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1011
|
+
"textarea",
|
|
1012
|
+
{
|
|
1013
|
+
autoFocus: true,
|
|
1014
|
+
defaultValue: chunkORNLCBNE_cjs.boxText(box),
|
|
1015
|
+
className: "pointer-events-auto w-full flex-1 resize-none bg-transparent p-0 outline-none",
|
|
1016
|
+
style: {
|
|
1017
|
+
...runStyle(run ?? { }, font),
|
|
1018
|
+
lineHeight: 1.2,
|
|
1019
|
+
textAlign: box.paragraphs[0]?.align ?? "left"
|
|
1020
|
+
},
|
|
1021
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1022
|
+
onBlur: (event) => {
|
|
1023
|
+
host.setText(box.id, event.currentTarget.value);
|
|
1024
|
+
setTyping(false);
|
|
1025
|
+
},
|
|
1026
|
+
onKeyDown: (event) => {
|
|
1027
|
+
event.stopPropagation();
|
|
1028
|
+
if (event.key === "Escape") event.currentTarget.blur();
|
|
1029
|
+
},
|
|
1030
|
+
"aria-label": "Text",
|
|
1031
|
+
"data-testid": "stage-box-text-input"
|
|
1032
|
+
}
|
|
1033
|
+
) : chunkORNLCBNE_cjs.boxText(box) || !editable ? /* @__PURE__ */ jsxRuntime.jsx(Paragraphs, { paragraphs: box.paragraphs, font }) : box.shape === "text" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1034
|
+
"span",
|
|
1035
|
+
{
|
|
1036
|
+
className: "text-white/40",
|
|
1037
|
+
style: { fontSize: cqw(run?.size ?? chunkORNLCBNE_cjs.DEFAULT_TEXT_SIZE) },
|
|
1038
|
+
children: "Double-click to type"
|
|
1039
|
+
}
|
|
1040
|
+
)
|
|
1041
|
+
}
|
|
1042
|
+
),
|
|
1043
|
+
selected && !typing && !dragging && HANDLES.filter(
|
|
1044
|
+
({ handle }) => box.shape !== "line" || handle === "e" || handle === "w" || handle === "n" || handle === "s"
|
|
1045
|
+
).map(({ handle, left, top, cursor }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1046
|
+
"div",
|
|
1047
|
+
{
|
|
1048
|
+
className: "absolute flex size-5 -translate-x-1/2 -translate-y-1/2 items-center justify-center pointer-coarse:size-11",
|
|
1049
|
+
style: { left, top, cursor, touchAction: "none" },
|
|
1050
|
+
onPointerDown: (event) => start(event, handle),
|
|
1051
|
+
"aria-label": `Resize from ${handle}`,
|
|
1052
|
+
"data-testid": `stage-box-resize-${handle}`,
|
|
1053
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pointer-events-none size-2.5 rounded-full border-2 border-primary bg-background" })
|
|
1054
|
+
},
|
|
1055
|
+
handle
|
|
1056
|
+
))
|
|
1057
|
+
]
|
|
1058
|
+
}
|
|
1059
|
+
);
|
|
1060
|
+
});
|
|
1061
|
+
var SIZE_STEPS = [8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 44, 54, 66, 80, 96];
|
|
1062
|
+
var nextSize = (size, up) => up ? SIZE_STEPS.find((step) => step > size + 0.5) ?? size : [...SIZE_STEPS].reverse().find((step) => step < size - 0.5) ?? size;
|
|
1063
|
+
var ALIGN_ICON = {
|
|
1064
|
+
left: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignLeft, { className: "size-4" }),
|
|
1065
|
+
center: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignCenter, { className: "size-4" }),
|
|
1066
|
+
right: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignRight, { className: "size-4" }),
|
|
1067
|
+
justify: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlignLeft, { className: "size-4" })
|
|
1068
|
+
};
|
|
1069
|
+
function ColorAction({
|
|
1070
|
+
label,
|
|
1071
|
+
value,
|
|
1072
|
+
onChange,
|
|
1073
|
+
children
|
|
1074
|
+
}) {
|
|
1075
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: ui.cn(ACTION, "relative cursor-pointer"), title: label, "aria-label": label, children: [
|
|
1076
|
+
children,
|
|
1077
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
|
+
"span",
|
|
1079
|
+
{
|
|
1080
|
+
className: "pointer-events-none absolute inset-x-1.5 bottom-0.5 h-0.5 rounded-full",
|
|
1081
|
+
style: { background: value }
|
|
1082
|
+
}
|
|
1083
|
+
),
|
|
1084
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1085
|
+
"input",
|
|
1086
|
+
{
|
|
1087
|
+
type: "color",
|
|
1088
|
+
value,
|
|
1089
|
+
onChange: (event) => onChange(event.target.value),
|
|
1090
|
+
className: "absolute inset-0 size-full cursor-pointer opacity-0",
|
|
1091
|
+
"aria-label": label
|
|
1092
|
+
}
|
|
1093
|
+
)
|
|
1094
|
+
] });
|
|
1095
|
+
}
|
|
1096
|
+
function BoxActionBar({ box, onRemoved }) {
|
|
1097
|
+
const actions = chunkORNLCBNE_cjs.usePresentation.getState();
|
|
1098
|
+
const run = chunkORNLCBNE_cjs.firstRun(box);
|
|
1099
|
+
const size = run?.size ?? chunkORNLCBNE_cjs.DEFAULT_TEXT_SIZE;
|
|
1100
|
+
const align = box.paragraphs[0]?.align ?? "left";
|
|
1101
|
+
const update = (change) => actions.updateBox(box.id, change);
|
|
1102
|
+
const text = box.shape !== "line";
|
|
1103
|
+
const top = Math.max(0, box.frame.y);
|
|
1104
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1105
|
+
"div",
|
|
1106
|
+
{
|
|
1107
|
+
role: "toolbar",
|
|
1108
|
+
"aria-label": "Text box",
|
|
1109
|
+
className: "absolute z-20 flex items-center gap-0.5 rounded-md border border-border bg-background p-0.5 shadow-md",
|
|
1110
|
+
style: {
|
|
1111
|
+
left: `${Math.min(Math.max(0, box.frame.x), 0.6) * 100}%`,
|
|
1112
|
+
top: `calc(${top * 100}% - 40px)`
|
|
1113
|
+
},
|
|
1114
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
1115
|
+
"data-testid": "box-action-bar",
|
|
1116
|
+
children: [
|
|
1117
|
+
text && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1119
|
+
Action,
|
|
1120
|
+
{
|
|
1121
|
+
label: "Smaller",
|
|
1122
|
+
onClick: () => update((b) => chunkORNLCBNE_cjs.styleRuns(b, (r) => ({ ...r, size: nextSize(r.size ?? size, false) }))),
|
|
1123
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AArrowDown, { className: "size-4" })
|
|
1124
|
+
}
|
|
1125
|
+
),
|
|
1126
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1127
|
+
"span",
|
|
1128
|
+
{
|
|
1129
|
+
className: "w-7 text-center text-xs tabular-nums text-muted-foreground",
|
|
1130
|
+
"data-testid": "box-text-size",
|
|
1131
|
+
children: Math.round(size)
|
|
1132
|
+
}
|
|
1133
|
+
),
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1135
|
+
Action,
|
|
1136
|
+
{
|
|
1137
|
+
label: "Larger",
|
|
1138
|
+
onClick: () => update((b) => chunkORNLCBNE_cjs.styleRuns(b, (r) => ({ ...r, size: nextSize(r.size ?? size, true) }))),
|
|
1139
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AArrowUp, { className: "size-4" })
|
|
1140
|
+
}
|
|
1141
|
+
),
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1143
|
+
Action,
|
|
1144
|
+
{
|
|
1145
|
+
label: "Bold",
|
|
1146
|
+
onClick: () => update((b) => chunkORNLCBNE_cjs.styleRuns(b, (r) => ({ ...r, bold: !run?.bold }))),
|
|
1147
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Bold, { className: ui.cn("size-4", run?.bold && "text-primary") })
|
|
1148
|
+
}
|
|
1149
|
+
),
|
|
1150
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1151
|
+
ColorAction,
|
|
1152
|
+
{
|
|
1153
|
+
label: "Text colour",
|
|
1154
|
+
value: run?.color ?? chunkORNLCBNE_cjs.TEXT_COLORS.body,
|
|
1155
|
+
onChange: (color) => update((b) => chunkORNLCBNE_cjs.styleRuns(b, (r) => ({ ...r, color }))),
|
|
1156
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Baseline, { className: "size-4" })
|
|
1157
|
+
}
|
|
1158
|
+
)
|
|
1159
|
+
] }),
|
|
1160
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1161
|
+
ColorAction,
|
|
1162
|
+
{
|
|
1163
|
+
label: box.shape === "line" ? "Line colour" : "Fill",
|
|
1164
|
+
value: (box.shape === "line" ? box.line?.color : box.fill) ?? "#ffffff",
|
|
1165
|
+
onChange: (color) => update(
|
|
1166
|
+
(b) => b.shape === "line" ? { ...b, line: { width: b.line?.width ?? 2, ...b.line, color } } : { ...b, fill: color, shape: b.shape === "text" ? "rect" : b.shape }
|
|
1167
|
+
),
|
|
1168
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PaintBucket, { className: "size-4" })
|
|
1169
|
+
}
|
|
1170
|
+
),
|
|
1171
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenu, { children: [
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
type: "button",
|
|
1176
|
+
className: ACTION,
|
|
1177
|
+
title: "More",
|
|
1178
|
+
"aria-label": "More",
|
|
1179
|
+
"data-testid": "box-more-menu",
|
|
1180
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MoreHorizontal, { className: "size-4" })
|
|
1181
|
+
}
|
|
1182
|
+
) }),
|
|
1183
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuContent, { align: "start", children: [
|
|
1184
|
+
text && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1185
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1186
|
+
ui.DropdownMenuCheckboxItem,
|
|
1187
|
+
{
|
|
1188
|
+
checked: !!run?.italic,
|
|
1189
|
+
onCheckedChange: () => update((b) => chunkORNLCBNE_cjs.styleRuns(b, (r) => ({ ...r, italic: !run?.italic }))),
|
|
1190
|
+
children: [
|
|
1191
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Italic, { className: "size-4" }),
|
|
1192
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Italic" })
|
|
1193
|
+
]
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
["left", "center", "right"].map((value) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1197
|
+
ui.DropdownMenuCheckboxItem,
|
|
1198
|
+
{
|
|
1199
|
+
checked: align === value,
|
|
1200
|
+
onCheckedChange: () => update((b) => ({
|
|
1201
|
+
...b,
|
|
1202
|
+
paragraphs: b.paragraphs.map((p) => ({ ...p, align: value }))
|
|
1203
|
+
})),
|
|
1204
|
+
children: [
|
|
1205
|
+
ALIGN_ICON[value],
|
|
1206
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: value === "left" ? "Align left" : value === "center" ? "Centre" : "Align right" })
|
|
1207
|
+
]
|
|
1208
|
+
},
|
|
1209
|
+
value
|
|
1210
|
+
)),
|
|
1211
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui.DropdownMenuSeparator, {})
|
|
1212
|
+
] }),
|
|
1213
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.restackBox(box.id, "front"), children: [
|
|
1214
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.BringToFront, { className: "size-4" }),
|
|
1215
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "In front of the clips" })
|
|
1216
|
+
] }),
|
|
1217
|
+
/* @__PURE__ */ jsxRuntime.jsxs(ui.DropdownMenuItem, { onSelect: () => actions.restackBox(box.id, "back"), children: [
|
|
1218
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.SendToBack, { className: "size-4" }),
|
|
1219
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-2", children: "Behind the clips" })
|
|
1220
|
+
] })
|
|
1221
|
+
] })
|
|
1222
|
+
] }),
|
|
1223
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1224
|
+
"button",
|
|
1225
|
+
{
|
|
1226
|
+
type: "button",
|
|
1227
|
+
className: ui.cn(ACTION, "text-destructive hover:bg-destructive/10"),
|
|
1228
|
+
title: "Delete (Delete)",
|
|
1229
|
+
"aria-label": "Delete",
|
|
1230
|
+
onClick: () => {
|
|
1231
|
+
actions.removeBox(box.id);
|
|
1232
|
+
onRemoved();
|
|
1233
|
+
},
|
|
1234
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { className: "size-4" })
|
|
1235
|
+
}
|
|
1236
|
+
)
|
|
1237
|
+
]
|
|
1238
|
+
}
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
var DRAG_THRESHOLD = 6;
|
|
1242
|
+
var DROP_ATTRIBUTE = "data-presentation-drop";
|
|
1243
|
+
function dropAt(doc, clipId, x, y) {
|
|
1244
|
+
const target = doc.elementFromPoint(x, y)?.closest(`[${DROP_ATTRIBUTE}]`);
|
|
1245
|
+
if (!target) return false;
|
|
1246
|
+
const state = chunkORNLCBNE_cjs.usePresentation.getState();
|
|
1247
|
+
if (target.getAttribute(DROP_ATTRIBUTE) === "slide") {
|
|
1248
|
+
const index2 = Number(target.getAttribute("data-slide-index"));
|
|
1249
|
+
if (!Number.isInteger(index2)) return false;
|
|
1250
|
+
state.goTo(index2);
|
|
1251
|
+
state.place(clipId);
|
|
1252
|
+
return true;
|
|
1253
|
+
}
|
|
1254
|
+
const index = Number(target.getAttribute("data-slide-index"));
|
|
1255
|
+
if (target.hasAttribute("data-slide-index") && Number.isInteger(index)) state.goTo(index);
|
|
1256
|
+
const box = target.getBoundingClientRect();
|
|
1257
|
+
state.place(clipId, { x: (x - box.left) / box.width, y: (y - box.top) / box.height });
|
|
1258
|
+
return true;
|
|
1259
|
+
}
|
|
1260
|
+
function useClipDrag(clipId, onTap) {
|
|
1261
|
+
const press = react.useRef(null);
|
|
1262
|
+
const [ghost, setGhost] = react.useState(null);
|
|
1263
|
+
const end = () => {
|
|
1264
|
+
press.current = null;
|
|
1265
|
+
setGhost(null);
|
|
1266
|
+
chunkORNLCBNE_cjs.usePresentation.getState().setDragging(null);
|
|
1267
|
+
};
|
|
1268
|
+
return {
|
|
1269
|
+
ghost,
|
|
1270
|
+
handlers: {
|
|
1271
|
+
onPointerDown: (event) => {
|
|
1272
|
+
if (event.button !== 0) return;
|
|
1273
|
+
press.current = { x: event.clientX, y: event.clientY, dragging: false };
|
|
1274
|
+
},
|
|
1275
|
+
onPointerMove: (event) => {
|
|
1276
|
+
const p = press.current;
|
|
1277
|
+
if (!p) return;
|
|
1278
|
+
if (!p.dragging) {
|
|
1279
|
+
if (Math.hypot(event.clientX - p.x, event.clientY - p.y) < DRAG_THRESHOLD) return;
|
|
1280
|
+
p.dragging = true;
|
|
1281
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1282
|
+
chunkORNLCBNE_cjs.usePresentation.getState().setDragging(clipId);
|
|
1283
|
+
}
|
|
1284
|
+
event.preventDefault();
|
|
1285
|
+
setGhost({ x: event.clientX, y: event.clientY });
|
|
1286
|
+
},
|
|
1287
|
+
onPointerUp: (event) => {
|
|
1288
|
+
const p = press.current;
|
|
1289
|
+
if (p?.dragging)
|
|
1290
|
+
dropAt(event.currentTarget.ownerDocument, clipId, event.clientX, event.clientY);
|
|
1291
|
+
else if (p) onTap();
|
|
1292
|
+
end();
|
|
1293
|
+
},
|
|
1294
|
+
onPointerCancel: end
|
|
1295
|
+
}
|
|
1296
|
+
};
|
|
1297
|
+
}
|
|
1298
|
+
var GuideLayer = react.memo(
|
|
1299
|
+
react.forwardRef(function GuideLayer2(_, ref) {
|
|
1300
|
+
const [guides, setGuides] = react.useState([]);
|
|
1301
|
+
react.useImperativeHandle(ref, () => ({ set: setGuides }), []);
|
|
1302
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: guides.map((guide) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1303
|
+
"div",
|
|
1304
|
+
{
|
|
1305
|
+
className: "pointer-events-none absolute z-10 bg-primary",
|
|
1306
|
+
style: guide.axis === "x" ? { left: `${guide.at * 100}%`, top: 0, bottom: 0, width: 1 } : { top: `${guide.at * 100}%`, left: 0, right: 0, height: 1 },
|
|
1307
|
+
"data-testid": `stage-guide-${guide.axis}`
|
|
1308
|
+
},
|
|
1309
|
+
`${guide.axis}-${guide.at}`
|
|
1310
|
+
)) });
|
|
1311
|
+
})
|
|
1312
|
+
);
|
|
1313
|
+
function PresentationStage({
|
|
1314
|
+
editable = false,
|
|
1315
|
+
slideIndex,
|
|
1316
|
+
show,
|
|
1317
|
+
selected = null,
|
|
1318
|
+
onSelect,
|
|
1319
|
+
onEditImage,
|
|
1320
|
+
onCropImage,
|
|
1321
|
+
textEditing,
|
|
1322
|
+
overlay,
|
|
1323
|
+
className
|
|
1324
|
+
}) {
|
|
1325
|
+
const index = chunkORNLCBNE_cjs.usePresentation((s) => slideIndex ?? s.current);
|
|
1326
|
+
const deckSlide = chunkORNLCBNE_cjs.usePresentation((s) => s.slides[index]);
|
|
1327
|
+
const deckClips = chunkORNLCBNE_cjs.usePresentation((s) => s.clips);
|
|
1328
|
+
const slide = show?.slide ?? deckSlide;
|
|
1329
|
+
const clips = show?.clips ?? deckClips;
|
|
1330
|
+
const blank = chunkORNLCBNE_cjs.usePresentation((s) => s.blank && !editable && !show);
|
|
1331
|
+
const captions = chunkORNLCBNE_cjs.usePresentation((s) => s.captions);
|
|
1332
|
+
const columnValues = chunkORNLCBNE_cjs.usePresentation((s) => s.columnValues);
|
|
1333
|
+
const theme = chunkORNLCBNE_cjs.usePresentation((s) => s.theme);
|
|
1334
|
+
const logoImage = chunkORNLCBNE_cjs.usePresentation((s) => s.logoImage);
|
|
1335
|
+
const media = chunkORNLCBNE_cjs.usePresentation((s) => s.media);
|
|
1336
|
+
const stageRef = react.useRef(null);
|
|
1337
|
+
const guideLayer = react.useRef(null);
|
|
1338
|
+
const dropping = chunkORNLCBNE_cjs.usePresentation((s) => editable && s.dragging !== null);
|
|
1339
|
+
const [dragging, setDragging] = react.useState(false);
|
|
1340
|
+
const latest = react.useRef({ slide, clips, index, onSelect });
|
|
1341
|
+
latest.current = { slide, clips, index, onSelect };
|
|
1342
|
+
const host = react.useMemo(
|
|
1343
|
+
() => ({
|
|
1344
|
+
stageBox: () => stageRef.current?.getBoundingClientRect() ?? null,
|
|
1345
|
+
others: (clipId) => {
|
|
1346
|
+
const { slide: current, clips: all } = latest.current;
|
|
1347
|
+
return (current?.items ?? []).filter((item) => item.clipId !== clipId).map((item) => ({
|
|
1348
|
+
frame: item.frame,
|
|
1349
|
+
aspect: all.find((clip) => clip.id === item.clipId)?.aspect ?? 1
|
|
1350
|
+
}));
|
|
1351
|
+
},
|
|
1352
|
+
select: (clipId) => {
|
|
1353
|
+
chunkORNLCBNE_cjs.usePresentation.getState().goTo(latest.current.index);
|
|
1354
|
+
latest.current.onSelect?.(clipId);
|
|
1355
|
+
},
|
|
1356
|
+
guides: (guides) => guideLayer.current?.set(guides),
|
|
1357
|
+
dragging: setDragging,
|
|
1358
|
+
commit: (clipId, frame, shape) => {
|
|
1359
|
+
const state = chunkORNLCBNE_cjs.usePresentation.getState();
|
|
1360
|
+
state.goTo(latest.current.index);
|
|
1361
|
+
if (shape) state.reshapeClip(clipId, frame, shape.rect, shape.aspect);
|
|
1362
|
+
else state.setFrame(clipId, frame);
|
|
1363
|
+
}
|
|
1364
|
+
}),
|
|
1365
|
+
[]
|
|
1366
|
+
);
|
|
1367
|
+
const boxHost = react.useMemo(
|
|
1368
|
+
() => ({
|
|
1369
|
+
stageBox: () => stageRef.current?.getBoundingClientRect() ?? null,
|
|
1370
|
+
select: (boxId) => {
|
|
1371
|
+
chunkORNLCBNE_cjs.usePresentation.getState().goTo(latest.current.index);
|
|
1372
|
+
latest.current.onSelect?.(boxId);
|
|
1373
|
+
},
|
|
1374
|
+
commit: (boxId, frame) => chunkORNLCBNE_cjs.usePresentation.getState().updateBox(boxId, (box) => ({ ...box, frame })),
|
|
1375
|
+
setText: (boxId, text) => chunkORNLCBNE_cjs.usePresentation.getState().setBoxText(boxId, text)
|
|
1376
|
+
}),
|
|
1377
|
+
[]
|
|
1378
|
+
);
|
|
1379
|
+
const font = chunkORNLCBNE_cjs.FONTS[theme.font].css;
|
|
1380
|
+
const boxes = slide?.boxes ?? [];
|
|
1381
|
+
const selectedBox = selected ? boxes.find((box) => box.id === selected) : void 0;
|
|
1382
|
+
const renderBoxes = (front) => boxes.filter((box) => !!box.front === front).map((box) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1383
|
+
StageBox,
|
|
1384
|
+
{
|
|
1385
|
+
box,
|
|
1386
|
+
font,
|
|
1387
|
+
editable,
|
|
1388
|
+
selected: editable && selected === box.id,
|
|
1389
|
+
host: boxHost
|
|
1390
|
+
},
|
|
1391
|
+
box.id
|
|
1392
|
+
));
|
|
1393
|
+
const clipOf = (id) => clips.find((clip) => clip.id === id);
|
|
1394
|
+
const selectedFrame = selected ? slide?.items.find((item) => item.clipId === selected)?.frame : void 0;
|
|
1395
|
+
react.useEffect(() => {
|
|
1396
|
+
const stage = stageRef.current;
|
|
1397
|
+
const view = stage?.ownerDocument.defaultView;
|
|
1398
|
+
if (!editable || !selected || !stage || !view) return;
|
|
1399
|
+
let sum = { x: 0, y: 0 };
|
|
1400
|
+
let request = null;
|
|
1401
|
+
const onWheel = (event) => {
|
|
1402
|
+
const item = event.target?.closest?.(
|
|
1403
|
+
`[data-testid="stage-item-${selected}"]`
|
|
1404
|
+
);
|
|
1405
|
+
const clip = chunkORNLCBNE_cjs.usePresentation.getState().clips.find((entry) => entry.id === selected);
|
|
1406
|
+
if (!item || !clip) return;
|
|
1407
|
+
event.preventDefault();
|
|
1408
|
+
const box = item.getBoundingClientRect();
|
|
1409
|
+
const horizontal = event.shiftKey && !event.deltaX;
|
|
1410
|
+
const deltaX = horizontal ? event.deltaY : event.deltaX;
|
|
1411
|
+
const deltaY = horizontal ? 0 : event.deltaY;
|
|
1412
|
+
sum = {
|
|
1413
|
+
x: sum.x + deltaX / box.width * clip.rect.w,
|
|
1414
|
+
y: sum.y + deltaY / box.height * clip.rect.h
|
|
1415
|
+
};
|
|
1416
|
+
request ??= view.requestAnimationFrame(() => {
|
|
1417
|
+
request = null;
|
|
1418
|
+
chunkORNLCBNE_cjs.usePresentation.getState().panClip(selected, sum.x, sum.y);
|
|
1419
|
+
sum = { x: 0, y: 0 };
|
|
1420
|
+
});
|
|
1421
|
+
};
|
|
1422
|
+
stage.addEventListener("wheel", onWheel, { passive: false });
|
|
1423
|
+
return () => {
|
|
1424
|
+
stage.removeEventListener("wheel", onWheel);
|
|
1425
|
+
if (request !== null) view.cancelAnimationFrame(request);
|
|
1426
|
+
};
|
|
1427
|
+
}, [editable, selected]);
|
|
1428
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1429
|
+
"div",
|
|
1430
|
+
{
|
|
1431
|
+
className: ui.cn("relative h-full w-full", !editable && "overflow-hidden bg-black", className),
|
|
1432
|
+
style: { containerType: "size" },
|
|
1433
|
+
"data-testid": editable ? "presentation-stage-editor" : "presentation-stage",
|
|
1434
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1435
|
+
"div",
|
|
1436
|
+
{
|
|
1437
|
+
ref: stageRef,
|
|
1438
|
+
className: ui.cn(
|
|
1439
|
+
"absolute inset-0 m-auto",
|
|
1440
|
+
editable ? "shadow-md" : "overflow-hidden",
|
|
1441
|
+
dropping && "outline outline-2 outline-offset-2 outline-primary"
|
|
1442
|
+
),
|
|
1443
|
+
style: {
|
|
1444
|
+
width: "min(100cqw, calc(100cqh * 16 / 9))",
|
|
1445
|
+
height: "min(100cqh, calc(100cqw * 9 / 16))",
|
|
1446
|
+
containerType: "inline-size",
|
|
1447
|
+
background: slide?.background ? chunkORNLCBNE_cjs.slideBackgroundCss(slide.background, media) : chunkORNLCBNE_cjs.backgroundCss(theme.background),
|
|
1448
|
+
fontFamily: chunkORNLCBNE_cjs.FONTS[theme.font].css
|
|
1449
|
+
},
|
|
1450
|
+
onPointerDown: () => {
|
|
1451
|
+
if (!editable) return;
|
|
1452
|
+
chunkORNLCBNE_cjs.usePresentation.getState().goTo(index);
|
|
1453
|
+
onSelect?.(null);
|
|
1454
|
+
},
|
|
1455
|
+
...editable ? { [DROP_ATTRIBUTE]: "stage", "data-slide-index": index } : {},
|
|
1456
|
+
"aria-label": `Slide ${index + 1}`,
|
|
1457
|
+
children: [
|
|
1458
|
+
blank && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 z-20 bg-black" }),
|
|
1459
|
+
slide && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1460
|
+
SlideDecor,
|
|
1461
|
+
{
|
|
1462
|
+
slide,
|
|
1463
|
+
theme,
|
|
1464
|
+
labels: captions,
|
|
1465
|
+
logoImage,
|
|
1466
|
+
editable,
|
|
1467
|
+
editing: textEditing
|
|
1468
|
+
}
|
|
1469
|
+
),
|
|
1470
|
+
renderBoxes(false),
|
|
1471
|
+
slide?.items.map((item) => {
|
|
1472
|
+
const clip = clipOf(item.clipId);
|
|
1473
|
+
if (!clip) return null;
|
|
1474
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1475
|
+
StageItem,
|
|
1476
|
+
{
|
|
1477
|
+
clip,
|
|
1478
|
+
frame: item.frame,
|
|
1479
|
+
editable,
|
|
1480
|
+
selected: editable && selected === clip.id,
|
|
1481
|
+
dim: false,
|
|
1482
|
+
label: captions ? chunkORNLCBNE_cjs.clipLabel(clip, columnValues) : "",
|
|
1483
|
+
host
|
|
1484
|
+
},
|
|
1485
|
+
clip.id
|
|
1486
|
+
);
|
|
1487
|
+
}),
|
|
1488
|
+
renderBoxes(true),
|
|
1489
|
+
editable && /* @__PURE__ */ jsxRuntime.jsx(GuideLayer, { ref: guideLayer }),
|
|
1490
|
+
editable && selectedFrame && selected && !dragging && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1491
|
+
ClipActionBar,
|
|
1492
|
+
{
|
|
1493
|
+
clipId: selected,
|
|
1494
|
+
at: selectedFrame,
|
|
1495
|
+
onRemoved: () => onSelect?.(null),
|
|
1496
|
+
onEditImage: onEditImage && clipOf(selected)?.kind === "image" ? () => onEditImage(selected) : void 0,
|
|
1497
|
+
onCropImage: onCropImage && clipOf(selected)?.kind === "image" ? () => onCropImage(selected) : void 0
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
editable && selectedBox && /* @__PURE__ */ jsxRuntime.jsx(BoxActionBar, { box: selectedBox, onRemoved: () => onSelect?.(null) }),
|
|
1501
|
+
overlay
|
|
1502
|
+
]
|
|
1503
|
+
}
|
|
1504
|
+
)
|
|
1505
|
+
}
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
|
|
1509
|
+
exports.ClipImage = ClipImage;
|
|
1510
|
+
exports.PresentationStage = PresentationStage;
|
|
1511
|
+
exports.useClipDrag = useClipDrag;
|
|
1512
|
+
//# sourceMappingURL=chunk-JY7UUZQG.cjs.map
|
|
1513
|
+
//# sourceMappingURL=chunk-JY7UUZQG.cjs.map
|