@tbib-image-viewer/react 0.1.5 → 0.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/dist/index.css +74 -33
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +11 -23
- package/dist/index.d.ts +11 -23
- package/dist/index.js +577 -975
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +548 -942
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -3
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/components/ImageViewer.tsx
|
|
2
|
-
import { useState as useState4, useRef as
|
|
3
|
-
import { FontAwesomeIcon as
|
|
2
|
+
import { useState as useState4, useRef as useRef3, useEffect, useCallback as useCallback3, useMemo as useMemo2, Suspense, lazy } from "react";
|
|
3
|
+
import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
|
|
4
4
|
import {
|
|
5
|
-
faSpinner
|
|
5
|
+
faSpinner,
|
|
6
6
|
faRotateRight as faRotateRight2
|
|
7
7
|
} from "@fortawesome/free-solid-svg-icons";
|
|
8
8
|
import { faExclamationTriangle } from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
|
|
@@ -14,13 +14,13 @@ import {
|
|
|
14
14
|
} from "@tbib-image-viewer/core";
|
|
15
15
|
|
|
16
16
|
// src/components/ImageToolbar.tsx
|
|
17
|
-
import
|
|
18
|
-
import { FontAwesomeIcon
|
|
17
|
+
import { useState } from "react";
|
|
18
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
19
19
|
import {
|
|
20
20
|
faHand,
|
|
21
21
|
faPen,
|
|
22
22
|
faHighlighter,
|
|
23
|
-
|
|
23
|
+
faWandMagicSparkles,
|
|
24
24
|
faEraser,
|
|
25
25
|
faRotateLeft,
|
|
26
26
|
faRotateRight,
|
|
@@ -30,190 +30,16 @@ import {
|
|
|
30
30
|
faExpand,
|
|
31
31
|
faRotate,
|
|
32
32
|
faXmark,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
faEyeDropper
|
|
36
|
-
} from "@fortawesome/free-solid-svg-icons";
|
|
37
|
-
|
|
38
|
-
// src/components/DownloadMenu.tsx
|
|
39
|
-
import { useState, useRef, useEffect } from "react";
|
|
40
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
41
|
-
import {
|
|
33
|
+
faUpRightAndDownLeftFromCenter,
|
|
34
|
+
faDownLeftAndUpRightToCenter,
|
|
35
|
+
faEyeDropper,
|
|
42
36
|
faDownload,
|
|
43
37
|
faImage,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
faChevronDown
|
|
38
|
+
faFileCode,
|
|
39
|
+
faPenToSquare
|
|
47
40
|
} from "@fortawesome/free-solid-svg-icons";
|
|
41
|
+
import { InkToolbar } from "@tbib-ink/react";
|
|
48
42
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
49
|
-
var DownloadMenu = ({
|
|
50
|
-
onDownloadAnnotated,
|
|
51
|
-
onDownloadClean,
|
|
52
|
-
onExportJson
|
|
53
|
-
}) => {
|
|
54
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
55
|
-
const [isExporting, setIsExporting] = useState(false);
|
|
56
|
-
const [popoverPos, setPopoverPos] = useState({ top: 0, right: 0 });
|
|
57
|
-
const containerRef = useRef(null);
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
if (isOpen && containerRef.current) {
|
|
60
|
-
const rect = containerRef.current.getBoundingClientRect();
|
|
61
|
-
setPopoverPos({
|
|
62
|
-
top: rect.bottom + 8,
|
|
63
|
-
right: Math.max(12, window.innerWidth - rect.right)
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
}, [isOpen]);
|
|
67
|
-
useEffect(() => {
|
|
68
|
-
const handleOutsideClick = (e) => {
|
|
69
|
-
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
70
|
-
setIsOpen(false);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
if (isOpen) {
|
|
74
|
-
document.addEventListener("mousedown", handleOutsideClick);
|
|
75
|
-
document.addEventListener("touchstart", handleOutsideClick);
|
|
76
|
-
}
|
|
77
|
-
return () => {
|
|
78
|
-
document.removeEventListener("mousedown", handleOutsideClick);
|
|
79
|
-
document.removeEventListener("touchstart", handleOutsideClick);
|
|
80
|
-
};
|
|
81
|
-
}, [isOpen]);
|
|
82
|
-
const handleAnnotated = async () => {
|
|
83
|
-
if (isExporting) return;
|
|
84
|
-
setIsExporting(true);
|
|
85
|
-
try {
|
|
86
|
-
await onDownloadAnnotated();
|
|
87
|
-
} finally {
|
|
88
|
-
setIsExporting(false);
|
|
89
|
-
setIsOpen(false);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const handleClean = async () => {
|
|
93
|
-
if (isExporting) return;
|
|
94
|
-
setIsExporting(true);
|
|
95
|
-
try {
|
|
96
|
-
await onDownloadClean();
|
|
97
|
-
} finally {
|
|
98
|
-
setIsExporting(false);
|
|
99
|
-
setIsOpen(false);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return /* @__PURE__ */ jsxs(
|
|
103
|
-
"div",
|
|
104
|
-
{
|
|
105
|
-
ref: containerRef,
|
|
106
|
-
style: {
|
|
107
|
-
position: "relative",
|
|
108
|
-
display: "inline-flex",
|
|
109
|
-
alignItems: "center"
|
|
110
|
-
},
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ jsx(
|
|
113
|
-
"button",
|
|
114
|
-
{
|
|
115
|
-
type: "button",
|
|
116
|
-
className: "tbib-iv-btn",
|
|
117
|
-
title: "Download Annotated Image (1-Click PNG)",
|
|
118
|
-
"aria-label": "Download Image",
|
|
119
|
-
disabled: isExporting,
|
|
120
|
-
onClick: handleAnnotated,
|
|
121
|
-
style: {
|
|
122
|
-
borderTopRightRadius: 0,
|
|
123
|
-
borderBottomRightRadius: 0,
|
|
124
|
-
paddingRight: "6px"
|
|
125
|
-
},
|
|
126
|
-
children: /* @__PURE__ */ jsx(
|
|
127
|
-
FontAwesomeIcon,
|
|
128
|
-
{
|
|
129
|
-
icon: isExporting ? faSpinner : faDownload,
|
|
130
|
-
className: isExporting ? "fa-spin" : "",
|
|
131
|
-
style: { fontSize: "14px" }
|
|
132
|
-
}
|
|
133
|
-
)
|
|
134
|
-
}
|
|
135
|
-
),
|
|
136
|
-
/* @__PURE__ */ jsx(
|
|
137
|
-
"button",
|
|
138
|
-
{
|
|
139
|
-
type: "button",
|
|
140
|
-
className: "tbib-iv-btn",
|
|
141
|
-
title: "More Download Options",
|
|
142
|
-
"aria-label": "More Download Options",
|
|
143
|
-
disabled: isExporting,
|
|
144
|
-
onClick: () => setIsOpen((prev) => !prev),
|
|
145
|
-
style: {
|
|
146
|
-
borderTopLeftRadius: 0,
|
|
147
|
-
borderBottomLeftRadius: 0,
|
|
148
|
-
paddingLeft: "4px",
|
|
149
|
-
paddingRight: "6px",
|
|
150
|
-
minWidth: "20px",
|
|
151
|
-
borderLeft: "1px solid var(--tbib-iv-border)"
|
|
152
|
-
},
|
|
153
|
-
children: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
|
|
154
|
-
}
|
|
155
|
-
),
|
|
156
|
-
isOpen && /* @__PURE__ */ jsxs(
|
|
157
|
-
"div",
|
|
158
|
-
{
|
|
159
|
-
className: "tbib-iv-popover",
|
|
160
|
-
style: {
|
|
161
|
-
position: "fixed",
|
|
162
|
-
top: `${popoverPos.top}px`,
|
|
163
|
-
right: `${popoverPos.right}px`,
|
|
164
|
-
flexDirection: "column",
|
|
165
|
-
minWidth: "210px",
|
|
166
|
-
zIndex: 9999
|
|
167
|
-
},
|
|
168
|
-
children: [
|
|
169
|
-
/* @__PURE__ */ jsxs(
|
|
170
|
-
"button",
|
|
171
|
-
{
|
|
172
|
-
type: "button",
|
|
173
|
-
className: "tbib-iv-btn",
|
|
174
|
-
style: {
|
|
175
|
-
width: "100%",
|
|
176
|
-
justifyContent: "flex-start",
|
|
177
|
-
gap: "10px",
|
|
178
|
-
padding: "8px 10px",
|
|
179
|
-
fontSize: "12px"
|
|
180
|
-
},
|
|
181
|
-
onClick: handleAnnotated,
|
|
182
|
-
children: [
|
|
183
|
-
/* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
|
|
184
|
-
/* @__PURE__ */ jsx("span", { children: "Annotated Image (PNG)" })
|
|
185
|
-
]
|
|
186
|
-
}
|
|
187
|
-
),
|
|
188
|
-
/* @__PURE__ */ jsxs(
|
|
189
|
-
"button",
|
|
190
|
-
{
|
|
191
|
-
type: "button",
|
|
192
|
-
className: "tbib-iv-btn",
|
|
193
|
-
style: {
|
|
194
|
-
width: "100%",
|
|
195
|
-
justifyContent: "flex-start",
|
|
196
|
-
gap: "10px",
|
|
197
|
-
padding: "8px 10px",
|
|
198
|
-
fontSize: "12px"
|
|
199
|
-
},
|
|
200
|
-
onClick: handleClean,
|
|
201
|
-
children: [
|
|
202
|
-
/* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faImage, style: { fontSize: "13px" } }),
|
|
203
|
-
/* @__PURE__ */ jsx("span", { children: "Clean Image (Original)" })
|
|
204
|
-
]
|
|
205
|
-
}
|
|
206
|
-
)
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
)
|
|
210
|
-
]
|
|
211
|
-
}
|
|
212
|
-
);
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
// src/components/ImageToolbar.tsx
|
|
216
|
-
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
217
43
|
var PRESET_COLORS = [
|
|
218
44
|
"#ef4444",
|
|
219
45
|
// Red
|
|
@@ -233,11 +59,46 @@ var PRESET_COLORS = [
|
|
|
233
59
|
// Black
|
|
234
60
|
];
|
|
235
61
|
var THICKNESS_OPTIONS = [
|
|
236
|
-
{ label: "
|
|
237
|
-
{ label: "
|
|
238
|
-
{ label: "
|
|
239
|
-
{ label: "
|
|
62
|
+
{ label: "Fin", value: 2 },
|
|
63
|
+
{ label: "Moyen", value: 4 },
|
|
64
|
+
{ label: "\xC9pais", value: 7 },
|
|
65
|
+
{ label: "Gras", value: 12 }
|
|
240
66
|
];
|
|
67
|
+
var TOOLS = [
|
|
68
|
+
{ id: "hand", label: "Main", icon: faHand, shortcut: "H" },
|
|
69
|
+
{ id: "pen", label: "Stylo", icon: faPen, shortcut: "P", hasOptions: true },
|
|
70
|
+
{ id: "highlighter", label: "Surligneur", icon: faHighlighter, shortcut: "S", hasOptions: true },
|
|
71
|
+
{ id: "eraser", label: "Gomme", icon: faEraser, shortcut: "E" },
|
|
72
|
+
{ id: "laser", label: "Laser", icon: faWandMagicSparkles, shortcut: "L", hasOptions: true }
|
|
73
|
+
];
|
|
74
|
+
var panelStyle = {
|
|
75
|
+
display: "flex",
|
|
76
|
+
flexDirection: "column",
|
|
77
|
+
gap: 10,
|
|
78
|
+
padding: 12,
|
|
79
|
+
width: "min(296px, calc(100vw - 24px))",
|
|
80
|
+
background: "var(--tbi-surface)",
|
|
81
|
+
border: "1px solid var(--tbi-border)",
|
|
82
|
+
borderRadius: 16,
|
|
83
|
+
boxShadow: "var(--tbi-shadow)",
|
|
84
|
+
color: "var(--tbi-fg)"
|
|
85
|
+
};
|
|
86
|
+
var chipStyle = (active) => ({
|
|
87
|
+
display: "inline-flex",
|
|
88
|
+
alignItems: "center",
|
|
89
|
+
justifyContent: "center",
|
|
90
|
+
gap: 6,
|
|
91
|
+
padding: "7px 0",
|
|
92
|
+
flex: 1,
|
|
93
|
+
borderRadius: 10,
|
|
94
|
+
border: `1px solid ${active ? "color-mix(in oklch, var(--tbi-primary) 40%, transparent)" : "var(--tbi-border)"}`,
|
|
95
|
+
background: active ? "color-mix(in oklch, var(--tbi-primary) 15%, transparent)" : "var(--tbi-surface-2)",
|
|
96
|
+
color: active ? "var(--tbi-primary)" : "var(--tbi-fg)",
|
|
97
|
+
font: "inherit",
|
|
98
|
+
fontSize: 11,
|
|
99
|
+
fontWeight: 700,
|
|
100
|
+
cursor: "pointer"
|
|
101
|
+
});
|
|
241
102
|
var ImageToolbar = ({
|
|
242
103
|
activeTool,
|
|
243
104
|
onToolChange,
|
|
@@ -262,311 +123,198 @@ var ImageToolbar = ({
|
|
|
262
123
|
isFullscreen,
|
|
263
124
|
onToggleFullscreen,
|
|
264
125
|
currentIndex,
|
|
265
|
-
totalImages
|
|
126
|
+
totalImages,
|
|
127
|
+
theme = "dark"
|
|
266
128
|
}) => {
|
|
267
|
-
const
|
|
268
|
-
const
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
scrollLeft: toolbarRef.current.scrollLeft
|
|
278
|
-
};
|
|
279
|
-
};
|
|
280
|
-
const handleToolbarTouchMove = (e) => {
|
|
281
|
-
if (!toolbarTouchState.current.isDown || !toolbarRef.current) return;
|
|
282
|
-
const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
|
|
283
|
-
toolbarRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
|
|
284
|
-
};
|
|
285
|
-
const handleToolbarTouchEnd = () => {
|
|
286
|
-
toolbarTouchState.current.isDown = false;
|
|
287
|
-
};
|
|
288
|
-
const handleSubtoolbarTouchStart = (e) => {
|
|
289
|
-
if (!subtoolbarRef.current) return;
|
|
290
|
-
subtoolbarTouchState.current = {
|
|
291
|
-
isDown: true,
|
|
292
|
-
startX: e.touches[0].clientX,
|
|
293
|
-
scrollLeft: subtoolbarRef.current.scrollLeft
|
|
294
|
-
};
|
|
295
|
-
};
|
|
296
|
-
const handleSubtoolbarTouchMove = (e) => {
|
|
297
|
-
if (!subtoolbarTouchState.current.isDown || !subtoolbarRef.current) return;
|
|
298
|
-
const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
|
|
299
|
-
subtoolbarRef.current.scrollLeft = subtoolbarTouchState.current.scrollLeft - dx;
|
|
300
|
-
};
|
|
301
|
-
const handleSubtoolbarTouchEnd = () => {
|
|
302
|
-
subtoolbarTouchState.current.isDown = false;
|
|
129
|
+
const [downloadOpen, setDownloadOpen] = useState(false);
|
|
130
|
+
const [downloading, setDownloading] = useState(false);
|
|
131
|
+
const runDownload = async (fn) => {
|
|
132
|
+
setDownloadOpen(false);
|
|
133
|
+
setDownloading(true);
|
|
134
|
+
try {
|
|
135
|
+
await fn();
|
|
136
|
+
} finally {
|
|
137
|
+
setDownloading(false);
|
|
138
|
+
}
|
|
303
139
|
};
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
)
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
type: "button",
|
|
350
|
-
className: `tbib-iv-btn ${activeTool === "highlighter" ? "tbib-iv-btn-active" : ""}`,
|
|
351
|
-
onClick: () => onToolChange("highlighter"),
|
|
352
|
-
title: "Highlighter (Semi-transparent)",
|
|
353
|
-
"aria-label": "Highlighter Tool",
|
|
354
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faHighlighter })
|
|
355
|
-
}
|
|
356
|
-
),
|
|
357
|
-
/* @__PURE__ */ jsx2(
|
|
358
|
-
"button",
|
|
359
|
-
{
|
|
360
|
-
type: "button",
|
|
361
|
-
className: `tbib-iv-btn ${activeTool === "laser" ? "tbib-iv-btn-active" : ""}`,
|
|
362
|
-
onClick: () => onToolChange("laser"),
|
|
363
|
-
title: "Laser Pointer (Glowing WebGL trail)",
|
|
364
|
-
"aria-label": "Laser Pointer",
|
|
365
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faCrosshairs })
|
|
366
|
-
}
|
|
367
|
-
),
|
|
368
|
-
/* @__PURE__ */ jsx2(
|
|
369
|
-
"button",
|
|
370
|
-
{
|
|
371
|
-
type: "button",
|
|
372
|
-
className: `tbib-iv-btn ${activeTool === "eraser" ? "tbib-iv-btn-active" : ""}`,
|
|
373
|
-
onClick: () => onToolChange("eraser"),
|
|
374
|
-
title: "Eraser (Erase strokes on tap)",
|
|
375
|
-
"aria-label": "Eraser Tool",
|
|
376
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faEraser })
|
|
377
|
-
}
|
|
378
|
-
),
|
|
379
|
-
/* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
|
|
380
|
-
/* @__PURE__ */ jsx2(
|
|
381
|
-
"button",
|
|
382
|
-
{
|
|
383
|
-
type: "button",
|
|
384
|
-
className: "tbib-iv-btn",
|
|
385
|
-
disabled: !canUndo,
|
|
386
|
-
onClick: onUndo,
|
|
387
|
-
title: "Undo (Ctrl+Z)",
|
|
388
|
-
"aria-label": "Undo",
|
|
389
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotateLeft })
|
|
390
|
-
}
|
|
391
|
-
),
|
|
392
|
-
/* @__PURE__ */ jsx2(
|
|
393
|
-
"button",
|
|
394
|
-
{
|
|
395
|
-
type: "button",
|
|
396
|
-
className: "tbib-iv-btn",
|
|
397
|
-
disabled: !canRedo,
|
|
398
|
-
onClick: onRedo,
|
|
399
|
-
title: "Redo (Ctrl+Y)",
|
|
400
|
-
"aria-label": "Redo",
|
|
401
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotateRight })
|
|
402
|
-
}
|
|
403
|
-
),
|
|
404
|
-
/* @__PURE__ */ jsx2(
|
|
405
|
-
"button",
|
|
406
|
-
{
|
|
407
|
-
type: "button",
|
|
408
|
-
className: "tbib-iv-btn",
|
|
409
|
-
onClick: onClear,
|
|
410
|
-
title: "Clear Slide Annotations",
|
|
411
|
-
"aria-label": "Clear All",
|
|
412
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faTrashCan })
|
|
413
|
-
}
|
|
414
|
-
),
|
|
415
|
-
/* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
|
|
416
|
-
/* @__PURE__ */ jsx2(
|
|
417
|
-
"button",
|
|
418
|
-
{
|
|
419
|
-
type: "button",
|
|
420
|
-
className: "tbib-iv-btn",
|
|
421
|
-
onClick: onZoomOut,
|
|
422
|
-
title: "Zoom Out (-)",
|
|
423
|
-
"aria-label": "Zoom Out",
|
|
424
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faMagnifyingGlassMinus })
|
|
425
|
-
}
|
|
426
|
-
),
|
|
427
|
-
/* @__PURE__ */ jsxs2("span", { className: "tbib-iv-tabular", title: "Current Zoom Scale", children: [
|
|
428
|
-
Math.round(zoomScale * 100),
|
|
429
|
-
"%"
|
|
430
|
-
] }),
|
|
431
|
-
/* @__PURE__ */ jsx2(
|
|
432
|
-
"button",
|
|
433
|
-
{
|
|
434
|
-
type: "button",
|
|
435
|
-
className: "tbib-iv-btn",
|
|
436
|
-
onClick: onZoomIn,
|
|
437
|
-
title: "Zoom In (+)",
|
|
438
|
-
"aria-label": "Zoom In",
|
|
439
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faMagnifyingGlassPlus })
|
|
440
|
-
}
|
|
441
|
-
),
|
|
442
|
-
/* @__PURE__ */ jsx2(
|
|
443
|
-
"button",
|
|
444
|
-
{
|
|
445
|
-
type: "button",
|
|
446
|
-
className: "tbib-iv-btn",
|
|
447
|
-
onClick: onZoomReset,
|
|
448
|
-
title: "Reset Fit to Screen (0)",
|
|
449
|
-
"aria-label": "Reset Zoom",
|
|
450
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faExpand })
|
|
451
|
-
}
|
|
452
|
-
),
|
|
453
|
-
/* @__PURE__ */ jsx2(
|
|
454
|
-
"button",
|
|
455
|
-
{
|
|
456
|
-
type: "button",
|
|
457
|
-
className: "tbib-iv-btn",
|
|
458
|
-
onClick: onRotate,
|
|
459
|
-
title: "Rotate 90\xB0 Clockwise",
|
|
460
|
-
"aria-label": "Rotate Image",
|
|
461
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: faRotate })
|
|
462
|
-
}
|
|
463
|
-
),
|
|
464
|
-
/* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
|
|
465
|
-
/* @__PURE__ */ jsx2(
|
|
466
|
-
DownloadMenu,
|
|
467
|
-
{
|
|
468
|
-
onDownloadAnnotated,
|
|
469
|
-
onDownloadClean,
|
|
470
|
-
onExportJson
|
|
471
|
-
}
|
|
472
|
-
),
|
|
473
|
-
onToggleFullscreen && /* @__PURE__ */ jsx2(
|
|
474
|
-
"button",
|
|
475
|
-
{
|
|
476
|
-
type: "button",
|
|
477
|
-
className: "tbib-iv-btn",
|
|
478
|
-
onClick: onToggleFullscreen,
|
|
479
|
-
title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
|
|
480
|
-
"aria-label": "Toggle Fullscreen",
|
|
481
|
-
children: /* @__PURE__ */ jsx2(FontAwesomeIcon2, { icon: isFullscreen ? faCompressAlt : faExpandAlt })
|
|
482
|
-
}
|
|
483
|
-
),
|
|
484
|
-
onClose && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
485
|
-
/* @__PURE__ */ jsx2("div", { className: "tbib-iv-divider" }),
|
|
486
|
-
/* @__PURE__ */ jsx2(
|
|
487
|
-
"button",
|
|
140
|
+
const zoomPct = Math.round(zoomScale * 100);
|
|
141
|
+
const actions = [
|
|
142
|
+
{ id: "undo", label: "Annuler", icon: faRotateLeft, disabled: !canUndo, onSelect: onUndo },
|
|
143
|
+
{ id: "redo", label: "R\xE9tablir", icon: faRotateRight, disabled: !canRedo, onSelect: onRedo },
|
|
144
|
+
{ id: "clear", label: "Tout effacer", icon: faTrashCan, placement: "sheet", onSelect: onClear },
|
|
145
|
+
{ id: "zoom-out", label: "Zoom arri\xE8re", icon: faMagnifyingGlassMinus, onSelect: onZoomOut },
|
|
146
|
+
{ id: "zoom-in", label: "Zoom avant", icon: faMagnifyingGlassPlus, onSelect: onZoomIn },
|
|
147
|
+
{ id: "zoom-reset", label: `Ajuster (${zoomPct}%)`, icon: faExpand, onSelect: onZoomReset },
|
|
148
|
+
{ id: "rotate", label: "Pivoter", icon: faRotate, onSelect: onRotate },
|
|
149
|
+
{
|
|
150
|
+
id: "download",
|
|
151
|
+
label: "T\xE9l\xE9charger",
|
|
152
|
+
icon: faDownload,
|
|
153
|
+
primary: true,
|
|
154
|
+
busy: downloading,
|
|
155
|
+
active: downloadOpen,
|
|
156
|
+
onSelect: () => setDownloadOpen((v) => !v)
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
if (onToggleFullscreen) {
|
|
160
|
+
actions.push({
|
|
161
|
+
id: "fullscreen",
|
|
162
|
+
label: isFullscreen ? "Quitter le plein \xE9cran" : "Plein \xE9cran",
|
|
163
|
+
icon: isFullscreen ? faDownLeftAndUpRightToCenter : faUpRightAndDownLeftFromCenter,
|
|
164
|
+
active: isFullscreen,
|
|
165
|
+
onSelect: onToggleFullscreen
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (onClose) {
|
|
169
|
+
actions.push({ id: "close", label: "Fermer", icon: faXmark, placement: "bar", onSelect: onClose });
|
|
170
|
+
}
|
|
171
|
+
const renderToolOptions = (toolId) => {
|
|
172
|
+
const showThickness = toolId === "pen" || toolId === "highlighter";
|
|
173
|
+
return /* @__PURE__ */ jsxs("div", { style: panelStyle, role: "group", "aria-label": "Options de l'outil", children: [
|
|
174
|
+
showThickness && /* @__PURE__ */ jsx("div", { style: { display: "flex", gap: 6 }, children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ jsxs(
|
|
175
|
+
"button",
|
|
176
|
+
{
|
|
177
|
+
type: "button",
|
|
178
|
+
"aria-pressed": strokeWidth === opt.value,
|
|
179
|
+
style: chipStyle(strokeWidth === opt.value),
|
|
180
|
+
onClick: () => onStrokeWidthChange(opt.value),
|
|
181
|
+
title: `${opt.label} (${opt.value}px)`,
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ jsx(
|
|
184
|
+
"span",
|
|
488
185
|
{
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
186
|
+
"aria-hidden": "true",
|
|
187
|
+
style: {
|
|
188
|
+
width: Math.min(opt.value * 1.4, 11),
|
|
189
|
+
height: Math.min(opt.value * 1.4, 11),
|
|
190
|
+
borderRadius: 999,
|
|
191
|
+
background: "currentColor"
|
|
192
|
+
}
|
|
496
193
|
}
|
|
497
|
-
)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
"div",
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
role: "region",
|
|
508
|
-
"aria-label": "Tool customization",
|
|
509
|
-
onTouchStart: handleSubtoolbarTouchStart,
|
|
510
|
-
onTouchMove: handleSubtoolbarTouchMove,
|
|
511
|
-
onTouchEnd: handleSubtoolbarTouchEnd,
|
|
512
|
-
children: [
|
|
513
|
-
activeTool !== "laser" && /* @__PURE__ */ jsx2("div", { className: "tbib-iv-thickness-group", children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ jsxs2(
|
|
194
|
+
),
|
|
195
|
+
opt.label
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
opt.value
|
|
199
|
+
)) }),
|
|
200
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" }, children: [
|
|
201
|
+
PRESET_COLORS.map((c) => {
|
|
202
|
+
const selected = color.toLowerCase() === c.toLowerCase();
|
|
203
|
+
return /* @__PURE__ */ jsx(
|
|
514
204
|
"button",
|
|
515
205
|
{
|
|
516
206
|
type: "button",
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
backgroundColor: "currentColor"
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
),
|
|
533
|
-
/* @__PURE__ */ jsx2("span", { children: opt.label })
|
|
534
|
-
]
|
|
207
|
+
"aria-label": `Couleur ${c}`,
|
|
208
|
+
"aria-pressed": selected,
|
|
209
|
+
onClick: () => onColorChange(c),
|
|
210
|
+
style: {
|
|
211
|
+
width: 24,
|
|
212
|
+
height: 24,
|
|
213
|
+
borderRadius: 999,
|
|
214
|
+
background: c,
|
|
215
|
+
cursor: "pointer",
|
|
216
|
+
border: "1px solid var(--tbi-border)",
|
|
217
|
+
boxShadow: selected ? "0 0 0 2px var(--tbi-surface), 0 0 0 4px var(--tbi-primary)" : "none"
|
|
218
|
+
}
|
|
535
219
|
},
|
|
536
|
-
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/* @__PURE__ */
|
|
558
|
-
/* @__PURE__ */
|
|
220
|
+
c
|
|
221
|
+
);
|
|
222
|
+
}),
|
|
223
|
+
/* @__PURE__ */ jsxs(
|
|
224
|
+
"label",
|
|
225
|
+
{
|
|
226
|
+
title: "Couleur personnalis\xE9e",
|
|
227
|
+
style: {
|
|
228
|
+
position: "relative",
|
|
229
|
+
width: 24,
|
|
230
|
+
height: 24,
|
|
231
|
+
borderRadius: 999,
|
|
232
|
+
display: "inline-flex",
|
|
233
|
+
alignItems: "center",
|
|
234
|
+
justifyContent: "center",
|
|
235
|
+
border: "1px dashed var(--tbi-border)",
|
|
236
|
+
color: "var(--tbi-muted)",
|
|
237
|
+
cursor: "pointer",
|
|
238
|
+
overflow: "hidden"
|
|
239
|
+
},
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsx(FontAwesomeIcon, { icon: faEyeDropper, style: { width: 11, height: 11 } }),
|
|
242
|
+
/* @__PURE__ */ jsx(
|
|
559
243
|
"input",
|
|
560
244
|
{
|
|
561
245
|
type: "color",
|
|
562
246
|
value: color,
|
|
563
247
|
onChange: (e) => onColorChange(e.target.value),
|
|
564
|
-
|
|
565
|
-
"
|
|
248
|
+
"aria-label": "Couleur personnalis\xE9e",
|
|
249
|
+
style: { position: "absolute", inset: 0, opacity: 0, cursor: "pointer" }
|
|
566
250
|
}
|
|
567
251
|
)
|
|
568
|
-
]
|
|
569
|
-
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
] })
|
|
256
|
+
] });
|
|
257
|
+
};
|
|
258
|
+
const downloadPanel = downloadOpen ? /* @__PURE__ */ jsx("div", { style: { ...panelStyle, width: "min(260px, calc(100vw - 24px))", gap: 6 }, role: "menu", "aria-label": "T\xE9l\xE9charger", children: [
|
|
259
|
+
{ id: "annotated", label: "Image annot\xE9e (PNG)", icon: faPenToSquare, run: onDownloadAnnotated },
|
|
260
|
+
{ id: "clean", label: "Image originale", icon: faImage, run: onDownloadClean },
|
|
261
|
+
...onExportJson ? [{ id: "json", label: "Annotations (JSON)", icon: faFileCode, run: onExportJson }] : []
|
|
262
|
+
].map((o) => /* @__PURE__ */ jsxs(
|
|
263
|
+
"button",
|
|
264
|
+
{
|
|
265
|
+
type: "button",
|
|
266
|
+
role: "menuitem",
|
|
267
|
+
onClick: () => void runDownload(o.run),
|
|
268
|
+
style: { ...chipStyle(false), justifyContent: "flex-start", padding: "10px 12px", fontSize: 12, gap: 10 },
|
|
269
|
+
children: [
|
|
270
|
+
/* @__PURE__ */ jsx(FontAwesomeIcon, { icon: o.icon, style: { width: 13, height: 13 } }),
|
|
271
|
+
o.label
|
|
272
|
+
]
|
|
273
|
+
},
|
|
274
|
+
o.id
|
|
275
|
+
)) }) : null;
|
|
276
|
+
return /* @__PURE__ */ jsxs("div", { className: "tbib-iv-toolbar-wrapper", children: [
|
|
277
|
+
/* @__PURE__ */ jsx(
|
|
278
|
+
InkToolbar,
|
|
279
|
+
{
|
|
280
|
+
theme,
|
|
281
|
+
style: { pointerEvents: "auto" },
|
|
282
|
+
ariaLabel: "Outils de l'image",
|
|
283
|
+
tools: TOOLS,
|
|
284
|
+
activeTool,
|
|
285
|
+
onToolSelect: (id) => {
|
|
286
|
+
setDownloadOpen(false);
|
|
287
|
+
onToolChange(id);
|
|
288
|
+
},
|
|
289
|
+
activeColor: color,
|
|
290
|
+
actions,
|
|
291
|
+
compactTools: ["hand", "pen", "highlighter", "eraser"],
|
|
292
|
+
compactActions: ["undo", "close"],
|
|
293
|
+
renderToolOptions,
|
|
294
|
+
panel: downloadPanel
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ jsxs(
|
|
298
|
+
"span",
|
|
299
|
+
{
|
|
300
|
+
className: "tbi-root",
|
|
301
|
+
"data-theme": theme,
|
|
302
|
+
style: {
|
|
303
|
+
pointerEvents: "none",
|
|
304
|
+
padding: "3px 10px",
|
|
305
|
+
borderRadius: 999,
|
|
306
|
+
fontSize: 11,
|
|
307
|
+
fontWeight: 700,
|
|
308
|
+
fontVariantNumeric: "tabular-nums",
|
|
309
|
+
background: "var(--tbi-surface)",
|
|
310
|
+
border: "1px solid var(--tbi-border)",
|
|
311
|
+
color: "var(--tbi-muted)"
|
|
312
|
+
},
|
|
313
|
+
"aria-label": `Image ${currentIndex + 1} sur ${totalImages}`,
|
|
314
|
+
children: [
|
|
315
|
+
currentIndex + 1,
|
|
316
|
+
" / ",
|
|
317
|
+
totalImages
|
|
570
318
|
]
|
|
571
319
|
}
|
|
572
320
|
)
|
|
@@ -574,12 +322,12 @@ var ImageToolbar = ({
|
|
|
574
322
|
};
|
|
575
323
|
|
|
576
324
|
// src/components/AnnotationCanvas.tsx
|
|
577
|
-
import { useRef
|
|
325
|
+
import { useRef, useState as useState2, useCallback, useMemo } from "react";
|
|
578
326
|
import {
|
|
579
327
|
pointsToSvgPath,
|
|
580
328
|
hexToRgba
|
|
581
329
|
} from "@tbib-image-viewer/core";
|
|
582
|
-
import { jsx as
|
|
330
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
583
331
|
var AnnotationCanvas = ({
|
|
584
332
|
width,
|
|
585
333
|
height,
|
|
@@ -594,13 +342,13 @@ var AnnotationCanvas = ({
|
|
|
594
342
|
onPinchPan
|
|
595
343
|
}) => {
|
|
596
344
|
const [currentPoints, setCurrentPoints] = useState2(null);
|
|
597
|
-
const isDrawingRef =
|
|
598
|
-
const svgRef =
|
|
599
|
-
const activePointersRef =
|
|
600
|
-
const pinchStartDistRef =
|
|
601
|
-
const pinchStartScaleRef =
|
|
602
|
-
const pinchLastMidpointRef =
|
|
603
|
-
const isMultiTouchRef =
|
|
345
|
+
const isDrawingRef = useRef(false);
|
|
346
|
+
const svgRef = useRef(null);
|
|
347
|
+
const activePointersRef = useRef(/* @__PURE__ */ new Map());
|
|
348
|
+
const pinchStartDistRef = useRef(null);
|
|
349
|
+
const pinchStartScaleRef = useRef(1);
|
|
350
|
+
const pinchLastMidpointRef = useRef(null);
|
|
351
|
+
const isMultiTouchRef = useRef(false);
|
|
604
352
|
const isDrawableTool = activeTool === "pen" || activeTool === "highlighter";
|
|
605
353
|
const isEraser = activeTool === "eraser";
|
|
606
354
|
const getNormalizedPoint = useCallback(
|
|
@@ -720,7 +468,7 @@ var AnnotationCanvas = ({
|
|
|
720
468
|
return pointsToSvgPath(currentPoints, width, height);
|
|
721
469
|
}, [currentPoints, width, height]);
|
|
722
470
|
const pointerEventsStyle = isDrawableTool || isEraser ? "auto" : "none";
|
|
723
|
-
return /* @__PURE__ */
|
|
471
|
+
return /* @__PURE__ */ jsxs2(
|
|
724
472
|
"svg",
|
|
725
473
|
{
|
|
726
474
|
ref: svgRef,
|
|
@@ -738,11 +486,11 @@ var AnnotationCanvas = ({
|
|
|
738
486
|
onPointerUp: handlePointerUp,
|
|
739
487
|
onPointerCancel: handlePointerUp,
|
|
740
488
|
children: [
|
|
741
|
-
/* @__PURE__ */
|
|
489
|
+
/* @__PURE__ */ jsx2("defs", { children: /* @__PURE__ */ jsx2("filter", { id: "highlighter-blend", children: /* @__PURE__ */ jsx2("feBlend", { mode: "multiply" }) }) }),
|
|
742
490
|
strokes.map((stroke) => {
|
|
743
491
|
const d = pointsToSvgPath(stroke.points, width, height);
|
|
744
492
|
const isHighlighter = stroke.tool === "highlighter";
|
|
745
|
-
return /* @__PURE__ */
|
|
493
|
+
return /* @__PURE__ */ jsx2(
|
|
746
494
|
"path",
|
|
747
495
|
{
|
|
748
496
|
d,
|
|
@@ -753,365 +501,39 @@ var AnnotationCanvas = ({
|
|
|
753
501
|
strokeLinejoin: "round",
|
|
754
502
|
style: {
|
|
755
503
|
mixBlendMode: isHighlighter ? "multiply" : "normal",
|
|
756
|
-
pointerEvents: "none"
|
|
757
|
-
}
|
|
758
|
-
},
|
|
759
|
-
stroke.id
|
|
760
|
-
);
|
|
761
|
-
}),
|
|
762
|
-
currentPathD && /* @__PURE__ */
|
|
763
|
-
"path",
|
|
764
|
-
{
|
|
765
|
-
d: currentPathD,
|
|
766
|
-
fill: "none",
|
|
767
|
-
stroke: activeTool === "highlighter" ? hexToRgba(color, 0.35) : color,
|
|
768
|
-
strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
|
|
769
|
-
strokeLinecap: "round",
|
|
770
|
-
strokeLinejoin: "round",
|
|
771
|
-
style: {
|
|
772
|
-
mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
|
|
773
|
-
pointerEvents: "none"
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
)
|
|
777
|
-
]
|
|
778
|
-
}
|
|
779
|
-
);
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
// src/components/LaserCursorLayer.tsx
|
|
783
|
-
import { useEffect as useEffect2, useRef as useRef3 } from "react";
|
|
784
|
-
import { Mesh, Program, Renderer, Triangle } from "ogl";
|
|
785
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
786
|
-
var MAX_POINTS = 64;
|
|
787
|
-
var VERTEX_SHADER = `
|
|
788
|
-
attribute vec2 position;
|
|
789
|
-
attribute vec2 uv;
|
|
790
|
-
varying vec2 vUv;
|
|
791
|
-
|
|
792
|
-
void main() {
|
|
793
|
-
vUv = uv;
|
|
794
|
-
gl_Position = vec4(position, 0.0, 1.0);
|
|
795
|
-
}
|
|
796
|
-
`;
|
|
797
|
-
var FRAGMENT_SHADER = `
|
|
798
|
-
precision highp float;
|
|
799
|
-
|
|
800
|
-
#define MAX_POINTS 64
|
|
801
|
-
|
|
802
|
-
uniform vec2 uResolution;
|
|
803
|
-
uniform vec2 uPoints[MAX_POINTS];
|
|
804
|
-
uniform float uPointCount;
|
|
805
|
-
uniform vec3 uColor;
|
|
806
|
-
uniform vec3 uSecondaryColor;
|
|
807
|
-
uniform float uTrailWidth;
|
|
808
|
-
uniform float uTaper;
|
|
809
|
-
uniform float uGlowIntensity;
|
|
810
|
-
uniform float uGlowSpread;
|
|
811
|
-
uniform float uHotspot;
|
|
812
|
-
uniform float uBrightness;
|
|
813
|
-
uniform float uOpacity;
|
|
814
|
-
uniform float uPulseSpeed;
|
|
815
|
-
uniform float uNoiseStrength;
|
|
816
|
-
uniform float uTime;
|
|
817
|
-
uniform float uFade;
|
|
818
|
-
|
|
819
|
-
varying vec2 vUv;
|
|
820
|
-
|
|
821
|
-
float sRGB(float x) {
|
|
822
|
-
if (x <= 0.00031308) return 12.92 * x;
|
|
823
|
-
return 1.055 * pow(x, 1.0 / 2.4) - 0.055;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
float hash(vec2 p) {
|
|
827
|
-
return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453123);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
float filmGrain(vec2 p, float time) {
|
|
831
|
-
float frame = time * 18.0;
|
|
832
|
-
float frameIndex = mod(floor(frame), 256.0);
|
|
833
|
-
float nextFrameIndex = mod(frameIndex + 1.0, 256.0);
|
|
834
|
-
float blend = fract(frame);
|
|
835
|
-
blend = blend * blend * (3.0 - 2.0 * blend);
|
|
836
|
-
vec2 pixel = floor(p);
|
|
837
|
-
float current = hash(pixel + vec2(frameIndex * 17.0, frameIndex * 31.0));
|
|
838
|
-
float next = hash(pixel + vec2(nextFrameIndex * 17.0, nextFrameIndex * 31.0));
|
|
839
|
-
return mix(current, next, blend) * 2.0 - 1.0;
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
void main() {
|
|
843
|
-
vec2 pixel = vUv * uResolution;
|
|
844
|
-
float denominator = max(uPointCount - 1.0, 1.0);
|
|
845
|
-
float strongest = 0.0;
|
|
846
|
-
float strongestCore = 0.0;
|
|
847
|
-
float colorWeight = 0.0;
|
|
848
|
-
vec3 colorSum = vec3(0.0);
|
|
849
|
-
|
|
850
|
-
for (int i = 0; i < MAX_POINTS - 1; i++) {
|
|
851
|
-
float index = float(i);
|
|
852
|
-
vec2 start = uPoints[i];
|
|
853
|
-
vec2 end = uPoints[i + 1];
|
|
854
|
-
vec2 toPixel = pixel - start;
|
|
855
|
-
vec2 segment = end - start;
|
|
856
|
-
float along = clamp(dot(toPixel, segment) / max(dot(segment, segment), 0.0001), 0.0, 1.0);
|
|
857
|
-
float progress = clamp((index + along) / denominator, 0.0, 1.0);
|
|
858
|
-
float life = pow(max(1.0 - progress, 0.0), mix(0.55, 1.25, uTaper));
|
|
859
|
-
float width = uTrailWidth * mix(1.0, 0.25, pow(progress, mix(0.55, 1.6, uTaper)));
|
|
860
|
-
float distanceToTrail = length(toPixel - segment * along);
|
|
861
|
-
float falloff = max(width * (0.8 + uGlowSpread * 1.4), 0.5);
|
|
862
|
-
float beam = min(1.0, (falloff * falloff) / (distanceToTrail * distanceToTrail + falloff * falloff));
|
|
863
|
-
float core = exp(-pow(distanceToTrail / max(width, 0.5), 2.0) * 2.5);
|
|
864
|
-
float pulseAmount = min(abs(uPulseSpeed), 1.0);
|
|
865
|
-
float pulse = 1.0 + sin(uTime * uPulseSpeed * 3.0 - progress * 11.0) * 0.16 * pulseAmount;
|
|
866
|
-
float intensity = (core + beam * uGlowIntensity * 0.55) * life * pulse;
|
|
867
|
-
vec3 segmentColor = mix(uColor, uSecondaryColor, progress);
|
|
868
|
-
|
|
869
|
-
strongest = max(strongest, intensity);
|
|
870
|
-
strongestCore = max(strongestCore, core * life);
|
|
871
|
-
colorSum += segmentColor * intensity;
|
|
872
|
-
colorWeight += intensity;
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
float grain = filmGrain(pixel, uTime);
|
|
876
|
-
float noiseAmount = (1.0 - exp(-uNoiseStrength * 2.2)) * 0.4;
|
|
877
|
-
float alpha = clamp(strongest * uOpacity * uFade, 0.0, 1.0);
|
|
878
|
-
if (alpha < 0.0005) discard;
|
|
879
|
-
|
|
880
|
-
vec3 color = colorSum / max(colorWeight, 0.0001);
|
|
881
|
-
color = mix(color, vec3(1.0), smoothstep(0.25, 0.95, strongestCore) * uHotspot);
|
|
882
|
-
float luminance = sRGB(clamp(strongest * uBrightness, 0.0, 1.0));
|
|
883
|
-
luminance *= 1.0 + grain * noiseAmount;
|
|
884
|
-
vec3 additiveColor = color * luminance;
|
|
885
|
-
float normalAlpha = clamp(strongest * uBrightness * uOpacity * uFade, 0.0, 1.0);
|
|
886
|
-
vec3 normalColor = mix(color, vec3(1.0), smoothstep(0.45, 1.0, strongestCore) * uHotspot * 0.35);
|
|
887
|
-
gl_FragColor = vec4(mix(additiveColor, normalColor, 1.0), mix(alpha, normalAlpha, 1.0));
|
|
888
|
-
}
|
|
889
|
-
`;
|
|
890
|
-
function hexToRgb(hex) {
|
|
891
|
-
let value = (hex || "").replace("#", "").trim();
|
|
892
|
-
if (value.length === 3) {
|
|
893
|
-
value = value.split("").map((c) => c + c).join("");
|
|
894
|
-
}
|
|
895
|
-
const parsed = Number.parseInt(value || "ff0000", 16);
|
|
896
|
-
return [
|
|
897
|
-
(parsed >> 16 & 255) / 255,
|
|
898
|
-
(parsed >> 8 & 255) / 255,
|
|
899
|
-
(parsed & 255) / 255
|
|
900
|
-
];
|
|
901
|
-
}
|
|
902
|
-
var LaserCursorLayer = ({
|
|
903
|
-
color = "#ef4444",
|
|
904
|
-
secondaryColor = "#ef4444",
|
|
905
|
-
trailLength = 29,
|
|
906
|
-
trailWidth = 8,
|
|
907
|
-
trailTaper = 0.22,
|
|
908
|
-
followSpeed = 1.5,
|
|
909
|
-
glowIntensity = 1.9,
|
|
910
|
-
glowSpread = 0.1,
|
|
911
|
-
hotspot = 0.5,
|
|
912
|
-
brightness = 1.25,
|
|
913
|
-
opacity = 1,
|
|
914
|
-
pulseSpeed = 0.8,
|
|
915
|
-
noiseStrength = 0.035,
|
|
916
|
-
idleFade = true,
|
|
917
|
-
idleTimeout = 700,
|
|
918
|
-
fadeDuration = 1500,
|
|
919
|
-
enabled = true,
|
|
920
|
-
className = "",
|
|
921
|
-
style,
|
|
922
|
-
...rest
|
|
923
|
-
}) => {
|
|
924
|
-
const containerRef = useRef3(null);
|
|
925
|
-
const canvasRef = useRef3(null);
|
|
926
|
-
useEffect2(() => {
|
|
927
|
-
const container = containerRef.current;
|
|
928
|
-
const canvas = canvasRef.current;
|
|
929
|
-
if (!container || !canvas || !enabled) return;
|
|
930
|
-
let renderer = null;
|
|
931
|
-
try {
|
|
932
|
-
renderer = new Renderer({
|
|
933
|
-
canvas,
|
|
934
|
-
alpha: true,
|
|
935
|
-
dpr: Math.min(window.devicePixelRatio || 1, 1.5)
|
|
936
|
-
});
|
|
937
|
-
} catch {
|
|
938
|
-
return;
|
|
939
|
-
}
|
|
940
|
-
const gl = renderer.gl;
|
|
941
|
-
gl.clearColor(0, 0, 0, 0);
|
|
942
|
-
const pointData = Array(MAX_POINTS * 2).fill(0);
|
|
943
|
-
const points = Array.from({ length: MAX_POINTS }, () => ({ x: 0, y: 0 }));
|
|
944
|
-
const target = { x: 0, y: 0 };
|
|
945
|
-
const head = { x: 0, y: 0 };
|
|
946
|
-
let program;
|
|
947
|
-
let mesh;
|
|
948
|
-
try {
|
|
949
|
-
program = new Program(gl, {
|
|
950
|
-
vertex: VERTEX_SHADER,
|
|
951
|
-
fragment: FRAGMENT_SHADER,
|
|
952
|
-
uniforms: {
|
|
953
|
-
uResolution: { value: [1, 1] },
|
|
954
|
-
uPoints: { value: pointData },
|
|
955
|
-
uPointCount: { value: trailLength },
|
|
956
|
-
uColor: { value: hexToRgb(color) },
|
|
957
|
-
uSecondaryColor: { value: hexToRgb(secondaryColor) },
|
|
958
|
-
uTrailWidth: { value: trailWidth },
|
|
959
|
-
uTaper: { value: trailTaper },
|
|
960
|
-
uGlowIntensity: { value: glowIntensity },
|
|
961
|
-
uGlowSpread: { value: glowSpread },
|
|
962
|
-
uHotspot: { value: hotspot },
|
|
963
|
-
uBrightness: { value: brightness },
|
|
964
|
-
uOpacity: { value: opacity },
|
|
965
|
-
uPulseSpeed: { value: pulseSpeed },
|
|
966
|
-
uNoiseStrength: { value: noiseStrength },
|
|
967
|
-
uTime: { value: 0 },
|
|
968
|
-
uFade: { value: 0 }
|
|
969
|
-
},
|
|
970
|
-
transparent: true,
|
|
971
|
-
depthTest: false,
|
|
972
|
-
depthWrite: false
|
|
973
|
-
});
|
|
974
|
-
mesh = new Mesh(gl, { geometry: new Triangle(gl), program });
|
|
975
|
-
} catch {
|
|
976
|
-
return;
|
|
977
|
-
}
|
|
978
|
-
let width = 0;
|
|
979
|
-
let height = 0;
|
|
980
|
-
let isHovered = false;
|
|
981
|
-
let lastMoveTime = 0;
|
|
982
|
-
let animationId;
|
|
983
|
-
const resize = () => {
|
|
984
|
-
const rect = container.getBoundingClientRect();
|
|
985
|
-
const newWidth = Math.floor(rect.width);
|
|
986
|
-
const newHeight = Math.floor(rect.height);
|
|
987
|
-
if (newWidth <= 0 || newHeight <= 0) return;
|
|
988
|
-
if (newWidth === width && newHeight === height) return;
|
|
989
|
-
width = newWidth;
|
|
990
|
-
height = newHeight;
|
|
991
|
-
renderer?.setSize(width, height);
|
|
992
|
-
program.uniforms.uResolution.value = [width, height];
|
|
993
|
-
};
|
|
994
|
-
resize();
|
|
995
|
-
const resizeObserver = new ResizeObserver(resize);
|
|
996
|
-
resizeObserver.observe(container);
|
|
997
|
-
const onPointerMove = (e) => {
|
|
998
|
-
const rect = container.getBoundingClientRect();
|
|
999
|
-
target.x = e.clientX - rect.left;
|
|
1000
|
-
target.y = rect.height - (e.clientY - rect.top);
|
|
1001
|
-
lastMoveTime = performance.now();
|
|
1002
|
-
isHovered = true;
|
|
1003
|
-
};
|
|
1004
|
-
const onPointerLeave = () => {
|
|
1005
|
-
isHovered = false;
|
|
1006
|
-
};
|
|
1007
|
-
container.addEventListener("pointermove", onPointerMove);
|
|
1008
|
-
container.addEventListener("pointerleave", onPointerLeave);
|
|
1009
|
-
let lastTime = performance.now();
|
|
1010
|
-
const render = (now) => {
|
|
1011
|
-
animationId = requestAnimationFrame(render);
|
|
1012
|
-
const dt = Math.min((now - lastTime) / 1e3, 0.1);
|
|
1013
|
-
lastTime = now;
|
|
1014
|
-
const speed = followSpeed * 20;
|
|
1015
|
-
head.x += (target.x - head.x) * Math.min(dt * speed, 1);
|
|
1016
|
-
head.y += (target.y - head.y) * Math.min(dt * speed, 1);
|
|
1017
|
-
for (let i = MAX_POINTS - 1; i > 0; i--) {
|
|
1018
|
-
points[i].x = points[i - 1].x;
|
|
1019
|
-
points[i].y = points[i - 1].y;
|
|
1020
|
-
}
|
|
1021
|
-
points[0].x = head.x;
|
|
1022
|
-
points[0].y = head.y;
|
|
1023
|
-
for (let i = 0; i < MAX_POINTS; i++) {
|
|
1024
|
-
pointData[i * 2] = points[i].x;
|
|
1025
|
-
pointData[i * 2 + 1] = points[i].y;
|
|
1026
|
-
}
|
|
1027
|
-
program.uniforms.uTime.value = now * 1e-3;
|
|
1028
|
-
let fade = 1;
|
|
1029
|
-
if (idleFade) {
|
|
1030
|
-
const idleTime = now - lastMoveTime;
|
|
1031
|
-
if (!isHovered || idleTime > idleTimeout) {
|
|
1032
|
-
const fadeProgress = Math.min(Math.max((idleTime - idleTimeout) / fadeDuration, 0), 1);
|
|
1033
|
-
fade = 1 - fadeProgress;
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
program.uniforms.uFade.value = fade;
|
|
1037
|
-
if (fade > 1e-3) {
|
|
1038
|
-
renderer?.render({ scene: mesh });
|
|
1039
|
-
} else {
|
|
1040
|
-
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
1041
|
-
}
|
|
1042
|
-
};
|
|
1043
|
-
animationId = requestAnimationFrame(render);
|
|
1044
|
-
return () => {
|
|
1045
|
-
cancelAnimationFrame(animationId);
|
|
1046
|
-
resizeObserver.disconnect();
|
|
1047
|
-
container.removeEventListener("pointermove", onPointerMove);
|
|
1048
|
-
container.removeEventListener("pointerleave", onPointerLeave);
|
|
1049
|
-
};
|
|
1050
|
-
}, [
|
|
1051
|
-
color,
|
|
1052
|
-
secondaryColor,
|
|
1053
|
-
trailLength,
|
|
1054
|
-
trailWidth,
|
|
1055
|
-
trailTaper,
|
|
1056
|
-
followSpeed,
|
|
1057
|
-
glowIntensity,
|
|
1058
|
-
glowSpread,
|
|
1059
|
-
hotspot,
|
|
1060
|
-
brightness,
|
|
1061
|
-
opacity,
|
|
1062
|
-
pulseSpeed,
|
|
1063
|
-
noiseStrength,
|
|
1064
|
-
idleFade,
|
|
1065
|
-
idleTimeout,
|
|
1066
|
-
fadeDuration,
|
|
1067
|
-
enabled
|
|
1068
|
-
]);
|
|
1069
|
-
return /* @__PURE__ */ jsx4(
|
|
1070
|
-
"div",
|
|
1071
|
-
{
|
|
1072
|
-
ref: containerRef,
|
|
1073
|
-
className: `tbib-iv-laser-layer ${className}`,
|
|
1074
|
-
style: {
|
|
1075
|
-
position: "absolute",
|
|
1076
|
-
top: 0,
|
|
1077
|
-
left: 0,
|
|
1078
|
-
width: "100%",
|
|
1079
|
-
height: "100%",
|
|
1080
|
-
pointerEvents: "auto",
|
|
1081
|
-
touchAction: "none",
|
|
1082
|
-
cursor: "crosshair",
|
|
1083
|
-
zIndex: 30,
|
|
1084
|
-
overflow: "hidden",
|
|
1085
|
-
...style
|
|
1086
|
-
},
|
|
1087
|
-
...rest,
|
|
1088
|
-
children: /* @__PURE__ */ jsx4(
|
|
1089
|
-
"canvas",
|
|
1090
|
-
{
|
|
1091
|
-
ref: canvasRef,
|
|
1092
|
-
className: "tbib-iv-laser-canvas",
|
|
1093
|
-
style: {
|
|
1094
|
-
position: "absolute",
|
|
1095
|
-
top: 0,
|
|
1096
|
-
left: 0,
|
|
1097
|
-
width: "100%",
|
|
1098
|
-
height: "100%",
|
|
1099
|
-
display: "block",
|
|
1100
|
-
pointerEvents: "none"
|
|
504
|
+
pointerEvents: "none"
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
stroke.id
|
|
508
|
+
);
|
|
509
|
+
}),
|
|
510
|
+
currentPathD && /* @__PURE__ */ jsx2(
|
|
511
|
+
"path",
|
|
512
|
+
{
|
|
513
|
+
d: currentPathD,
|
|
514
|
+
fill: "none",
|
|
515
|
+
stroke: activeTool === "highlighter" ? hexToRgba(color, 0.35) : color,
|
|
516
|
+
strokeWidth: activeTool === "highlighter" ? strokeWidth * 2.5 : strokeWidth,
|
|
517
|
+
strokeLinecap: "round",
|
|
518
|
+
strokeLinejoin: "round",
|
|
519
|
+
style: {
|
|
520
|
+
mixBlendMode: activeTool === "highlighter" ? "multiply" : "normal",
|
|
521
|
+
pointerEvents: "none"
|
|
522
|
+
}
|
|
1101
523
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
524
|
+
)
|
|
525
|
+
]
|
|
1104
526
|
}
|
|
1105
527
|
);
|
|
1106
528
|
};
|
|
1107
529
|
|
|
1108
530
|
// src/hooks/useImageTransform.ts
|
|
1109
|
-
import { useState as useState3, useCallback as useCallback2, useRef as
|
|
531
|
+
import { useState as useState3, useCallback as useCallback2, useRef as useRef2 } from "react";
|
|
1110
532
|
import { clampScale, DEFAULT_TRANSFORM } from "@tbib-image-viewer/core";
|
|
1111
533
|
function useImageTransform() {
|
|
1112
534
|
const [transform, setTransform] = useState3(DEFAULT_TRANSFORM);
|
|
1113
|
-
const pinchStartDistRef =
|
|
1114
|
-
const pinchStartScaleRef =
|
|
535
|
+
const pinchStartDistRef = useRef2(null);
|
|
536
|
+
const pinchStartScaleRef = useRef2(1);
|
|
1115
537
|
const zoomIn = useCallback2(() => {
|
|
1116
538
|
setTransform((prev) => ({
|
|
1117
539
|
...prev,
|
|
@@ -1195,7 +617,8 @@ function useImageTransform() {
|
|
|
1195
617
|
}
|
|
1196
618
|
|
|
1197
619
|
// src/components/ImageViewer.tsx
|
|
1198
|
-
import { jsx as
|
|
620
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
621
|
+
var LaserCursorLayer = lazy(() => import("@tbib-ink/react/laser"));
|
|
1199
622
|
var ImageViewer = ({
|
|
1200
623
|
src,
|
|
1201
624
|
alt = "Medical illustration",
|
|
@@ -1217,7 +640,7 @@ var ImageViewer = ({
|
|
|
1217
640
|
const [activeTool, setActiveTool] = useState4(initialTool);
|
|
1218
641
|
const [color, setColor] = useState4(initialColor);
|
|
1219
642
|
const [strokeWidth, setStrokeWidth] = useState4(initialStrokeWidth);
|
|
1220
|
-
const storeRef =
|
|
643
|
+
const storeRef = useRef3(
|
|
1221
644
|
new AnnotationStore(
|
|
1222
645
|
initialAnnotations ? [{ slideId: effectiveSlideId, strokes: initialAnnotations }] : void 0
|
|
1223
646
|
)
|
|
@@ -1227,8 +650,8 @@ var ImageViewer = ({
|
|
|
1227
650
|
);
|
|
1228
651
|
const [canUndo, setCanUndo] = useState4(false);
|
|
1229
652
|
const [canRedo, setCanRedo] = useState4(false);
|
|
1230
|
-
const containerRef =
|
|
1231
|
-
const imgRef =
|
|
653
|
+
const containerRef = useRef3(null);
|
|
654
|
+
const imgRef = useRef3(null);
|
|
1232
655
|
const [imgSize, setImgSize] = useState4({ width: 800, height: 600 });
|
|
1233
656
|
const [imageStatus, setImageStatus] = useState4("loading");
|
|
1234
657
|
const [reloadKey, setReloadKey] = useState4(0);
|
|
@@ -1238,7 +661,7 @@ var ImageViewer = ({
|
|
|
1238
661
|
const sep = src.includes("?") ? "&" : "?";
|
|
1239
662
|
return `${src}${sep}_reload=${reloadKey}`;
|
|
1240
663
|
}, [src, reloadKey]);
|
|
1241
|
-
|
|
664
|
+
useEffect(() => {
|
|
1242
665
|
setImageStatus("loading");
|
|
1243
666
|
if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
|
|
1244
667
|
setImgSize({
|
|
@@ -1261,9 +684,9 @@ var ImageViewer = ({
|
|
|
1261
684
|
handleTouchMove,
|
|
1262
685
|
handleTouchEnd
|
|
1263
686
|
} = useImageTransform();
|
|
1264
|
-
const isDraggingRef =
|
|
1265
|
-
const lastMousePosRef =
|
|
1266
|
-
|
|
687
|
+
const isDraggingRef = useRef3(false);
|
|
688
|
+
const lastMousePosRef = useRef3({ x: 0, y: 0 });
|
|
689
|
+
useEffect(() => {
|
|
1267
690
|
const store = storeRef.current;
|
|
1268
691
|
const unsubscribe = store.subscribe((id, updated) => {
|
|
1269
692
|
if (id === effectiveSlideId) {
|
|
@@ -1336,7 +759,7 @@ var ImageViewer = ({
|
|
|
1336
759
|
const handleStagePointerUp = (e) => {
|
|
1337
760
|
isDraggingRef.current = false;
|
|
1338
761
|
};
|
|
1339
|
-
|
|
762
|
+
useEffect(() => {
|
|
1340
763
|
const handleKeyDown = (e) => {
|
|
1341
764
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
|
|
1342
765
|
e.preventDefault();
|
|
@@ -1389,14 +812,14 @@ var ImageViewer = ({
|
|
|
1389
812
|
link.click();
|
|
1390
813
|
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
1391
814
|
};
|
|
1392
|
-
return /* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ jsxs3(
|
|
1393
816
|
"div",
|
|
1394
817
|
{
|
|
1395
818
|
ref: containerRef,
|
|
1396
819
|
className: `tbib-iv-container ${theme === "light" ? "tbib-iv-light" : ""} ${className}`,
|
|
1397
820
|
style,
|
|
1398
821
|
children: [
|
|
1399
|
-
showToolbar && /* @__PURE__ */
|
|
822
|
+
showToolbar && /* @__PURE__ */ jsx3(
|
|
1400
823
|
ImageToolbar,
|
|
1401
824
|
{
|
|
1402
825
|
activeTool,
|
|
@@ -1417,10 +840,11 @@ var ImageViewer = ({
|
|
|
1417
840
|
onRotate: rotateClockwise,
|
|
1418
841
|
onDownloadAnnotated: handleDownloadAnnotated,
|
|
1419
842
|
onDownloadClean: handleDownloadClean,
|
|
1420
|
-
onExportJson: handleExportJson
|
|
843
|
+
onExportJson: handleExportJson,
|
|
844
|
+
theme: theme === "light" ? "light" : "dark"
|
|
1421
845
|
}
|
|
1422
846
|
),
|
|
1423
|
-
/* @__PURE__ */
|
|
847
|
+
/* @__PURE__ */ jsxs3(
|
|
1424
848
|
"div",
|
|
1425
849
|
{
|
|
1426
850
|
className: "tbib-iv-stage",
|
|
@@ -1436,7 +860,7 @@ var ImageViewer = ({
|
|
|
1436
860
|
cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
|
|
1437
861
|
},
|
|
1438
862
|
children: [
|
|
1439
|
-
/* @__PURE__ */
|
|
863
|
+
/* @__PURE__ */ jsxs3(
|
|
1440
864
|
"div",
|
|
1441
865
|
{
|
|
1442
866
|
className: "tbib-iv-stage-inner",
|
|
@@ -1445,7 +869,7 @@ var ImageViewer = ({
|
|
|
1445
869
|
transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
|
|
1446
870
|
},
|
|
1447
871
|
children: [
|
|
1448
|
-
/* @__PURE__ */
|
|
872
|
+
/* @__PURE__ */ jsx3(
|
|
1449
873
|
"img",
|
|
1450
874
|
{
|
|
1451
875
|
ref: imgRef,
|
|
@@ -1458,7 +882,7 @@ var ImageViewer = ({
|
|
|
1458
882
|
},
|
|
1459
883
|
`${src}-${reloadKey}`
|
|
1460
884
|
),
|
|
1461
|
-
enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */
|
|
885
|
+
enableAnnotations && imageStatus === "loaded" && /* @__PURE__ */ jsx3(
|
|
1462
886
|
AnnotationCanvas,
|
|
1463
887
|
{
|
|
1464
888
|
width: imgSize.width,
|
|
@@ -1477,28 +901,28 @@ var ImageViewer = ({
|
|
|
1477
901
|
]
|
|
1478
902
|
}
|
|
1479
903
|
),
|
|
1480
|
-
imageStatus === "loading" && /* @__PURE__ */
|
|
1481
|
-
/* @__PURE__ */
|
|
1482
|
-
/* @__PURE__ */
|
|
904
|
+
imageStatus === "loading" && /* @__PURE__ */ jsxs3("div", { className: "tbib-iv-status-overlay", children: [
|
|
905
|
+
/* @__PURE__ */ jsx3("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faSpinner, spin: true, className: "tbib-iv-spinner-icon" }) }),
|
|
906
|
+
/* @__PURE__ */ jsx3("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
|
|
1483
907
|
] }),
|
|
1484
|
-
imageStatus === "error" && /* @__PURE__ */
|
|
1485
|
-
/* @__PURE__ */
|
|
1486
|
-
/* @__PURE__ */
|
|
1487
|
-
/* @__PURE__ */
|
|
1488
|
-
/* @__PURE__ */
|
|
1489
|
-
/* @__PURE__ */
|
|
908
|
+
imageStatus === "error" && /* @__PURE__ */ jsxs3("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
|
|
909
|
+
/* @__PURE__ */ jsx3("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faExclamationTriangle }) }),
|
|
910
|
+
/* @__PURE__ */ jsx3("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
|
|
911
|
+
/* @__PURE__ */ jsx3("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
|
|
912
|
+
/* @__PURE__ */ jsxs3("div", { className: "tbib-iv-error-actions", children: [
|
|
913
|
+
/* @__PURE__ */ jsxs3(
|
|
1490
914
|
"button",
|
|
1491
915
|
{
|
|
1492
916
|
type: "button",
|
|
1493
917
|
className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
|
|
1494
918
|
onClick: handleReload,
|
|
1495
919
|
children: [
|
|
1496
|
-
/* @__PURE__ */
|
|
1497
|
-
/* @__PURE__ */
|
|
920
|
+
/* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faRotateRight2 }),
|
|
921
|
+
/* @__PURE__ */ jsx3("span", { children: "R\xE9essayer" })
|
|
1498
922
|
]
|
|
1499
923
|
}
|
|
1500
924
|
),
|
|
1501
|
-
src && /* @__PURE__ */
|
|
925
|
+
src && /* @__PURE__ */ jsxs3(
|
|
1502
926
|
"a",
|
|
1503
927
|
{
|
|
1504
928
|
href: src,
|
|
@@ -1506,14 +930,14 @@ var ImageViewer = ({
|
|
|
1506
930
|
rel: "noopener noreferrer",
|
|
1507
931
|
className: "tbib-iv-btn tbib-iv-open-btn",
|
|
1508
932
|
children: [
|
|
1509
|
-
/* @__PURE__ */
|
|
1510
|
-
/* @__PURE__ */
|
|
933
|
+
/* @__PURE__ */ jsx3(FontAwesomeIcon2, { icon: faExternalLinkAlt }),
|
|
934
|
+
/* @__PURE__ */ jsx3("span", { children: "Lien direct" })
|
|
1511
935
|
]
|
|
1512
936
|
}
|
|
1513
937
|
)
|
|
1514
938
|
] })
|
|
1515
939
|
] }),
|
|
1516
|
-
enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */
|
|
940
|
+
enableLaser && activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx3(Suspense, { fallback: null, children: /* @__PURE__ */ jsx3(LaserCursorLayer, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
|
|
1517
941
|
]
|
|
1518
942
|
}
|
|
1519
943
|
),
|
|
@@ -1524,12 +948,12 @@ var ImageViewer = ({
|
|
|
1524
948
|
};
|
|
1525
949
|
|
|
1526
950
|
// src/components/ImageGalleryLightbox.tsx
|
|
1527
|
-
import { useState as useState5, useRef as
|
|
1528
|
-
import { FontAwesomeIcon as
|
|
951
|
+
import { useState as useState5, useRef as useRef5, useEffect as useEffect2, useCallback as useCallback5, useMemo as useMemo3, Suspense as Suspense2, lazy as lazy2 } from "react";
|
|
952
|
+
import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
|
|
1529
953
|
import {
|
|
1530
954
|
faChevronLeft,
|
|
1531
955
|
faChevronRight,
|
|
1532
|
-
faSpinner as
|
|
956
|
+
faSpinner as faSpinner2,
|
|
1533
957
|
faRotateRight as faRotateRight3
|
|
1534
958
|
} from "@fortawesome/free-solid-svg-icons";
|
|
1535
959
|
import { faExclamationTriangle as faExclamationTriangle2 } from "@fortawesome/free-solid-svg-icons/faExclamationTriangle";
|
|
@@ -1541,21 +965,21 @@ import {
|
|
|
1541
965
|
} from "@tbib-image-viewer/core";
|
|
1542
966
|
|
|
1543
967
|
// src/components/ThumbnailStrip.tsx
|
|
1544
|
-
import { jsx as
|
|
968
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
1545
969
|
var ThumbnailStrip = ({
|
|
1546
970
|
items,
|
|
1547
971
|
activeIndex,
|
|
1548
972
|
onSelect
|
|
1549
973
|
}) => {
|
|
1550
974
|
if (items.length <= 1) return null;
|
|
1551
|
-
return /* @__PURE__ */
|
|
975
|
+
return /* @__PURE__ */ jsx4("div", { className: "tbib-iv-thumbnail-strip", children: items.map((item, idx) => /* @__PURE__ */ jsx4(
|
|
1552
976
|
"button",
|
|
1553
977
|
{
|
|
1554
978
|
type: "button",
|
|
1555
979
|
className: `tbib-iv-thumbnail-item ${idx === activeIndex ? "tbib-iv-thumbnail-item-active" : ""}`,
|
|
1556
980
|
onClick: () => onSelect(idx),
|
|
1557
981
|
title: item.title || `Image ${idx + 1}`,
|
|
1558
|
-
children: /* @__PURE__ */
|
|
982
|
+
children: /* @__PURE__ */ jsx4(
|
|
1559
983
|
"img",
|
|
1560
984
|
{
|
|
1561
985
|
src: item.thumbnailSrc || item.src,
|
|
@@ -1570,10 +994,10 @@ var ThumbnailStrip = ({
|
|
|
1570
994
|
};
|
|
1571
995
|
|
|
1572
996
|
// src/hooks/useSwipeGesture.ts
|
|
1573
|
-
import { useRef as
|
|
997
|
+
import { useRef as useRef4, useCallback as useCallback4 } from "react";
|
|
1574
998
|
function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
|
|
1575
|
-
const touchStartXRef =
|
|
1576
|
-
const touchStartYRef =
|
|
999
|
+
const touchStartXRef = useRef4(null);
|
|
1000
|
+
const touchStartYRef = useRef4(null);
|
|
1577
1001
|
const onTouchStart = useCallback4((e) => {
|
|
1578
1002
|
if (!enabled || e.touches.length !== 1) return;
|
|
1579
1003
|
touchStartXRef.current = e.touches[0].clientX;
|
|
@@ -1602,7 +1026,8 @@ function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
|
|
|
1602
1026
|
}
|
|
1603
1027
|
|
|
1604
1028
|
// src/components/ImageGalleryLightbox.tsx
|
|
1605
|
-
import { jsx as
|
|
1029
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1030
|
+
var LaserCursorLayer2 = lazy2(() => import("@tbib-ink/react/laser"));
|
|
1606
1031
|
var ImageGalleryLightbox = ({
|
|
1607
1032
|
items,
|
|
1608
1033
|
activeIndex = 0,
|
|
@@ -1621,12 +1046,12 @@ var ImageGalleryLightbox = ({
|
|
|
1621
1046
|
const [color, setColor] = useState5(initialColor);
|
|
1622
1047
|
const [strokeWidth, setStrokeWidth] = useState5(4);
|
|
1623
1048
|
const [isFullscreen, setIsFullscreen] = useState5(false);
|
|
1624
|
-
|
|
1049
|
+
useEffect2(() => {
|
|
1625
1050
|
setCurrentIndex(activeIndex);
|
|
1626
1051
|
}, [activeIndex]);
|
|
1627
1052
|
const currentItem = items[currentIndex] || items[0];
|
|
1628
1053
|
const slideId = currentItem?.id || currentItem?.src || `slide-${currentIndex}`;
|
|
1629
|
-
const storeRef =
|
|
1054
|
+
const storeRef = useRef5(new AnnotationStore2(initialAnnotations));
|
|
1630
1055
|
const [strokes, setStrokes] = useState5([]);
|
|
1631
1056
|
const [canUndo, setCanUndo] = useState5(false);
|
|
1632
1057
|
const [canRedo, setCanRedo] = useState5(false);
|
|
@@ -1643,21 +1068,21 @@ var ImageGalleryLightbox = ({
|
|
|
1643
1068
|
handleTouchMove,
|
|
1644
1069
|
handleTouchEnd
|
|
1645
1070
|
} = useImageTransform();
|
|
1646
|
-
|
|
1071
|
+
useEffect2(() => {
|
|
1647
1072
|
resetTransform();
|
|
1648
1073
|
}, [currentIndex, resetTransform]);
|
|
1649
|
-
const imgRef =
|
|
1074
|
+
const imgRef = useRef5(null);
|
|
1650
1075
|
const [imgSize, setImgSize] = useState5({ width: 800, height: 600 });
|
|
1651
1076
|
const [imageStatus, setImageStatus] = useState5("loading");
|
|
1652
1077
|
const [reloadKey, setReloadKey] = useState5(0);
|
|
1653
|
-
const containerRef =
|
|
1078
|
+
const containerRef = useRef5(null);
|
|
1654
1079
|
const effectiveSrc = useMemo3(() => {
|
|
1655
1080
|
if (!currentItem?.src) return "";
|
|
1656
1081
|
if (reloadKey === 0) return currentItem.src;
|
|
1657
1082
|
const sep = currentItem.src.includes("?") ? "&" : "?";
|
|
1658
1083
|
return `${currentItem.src}${sep}_reload=${reloadKey}`;
|
|
1659
1084
|
}, [currentItem?.src, reloadKey]);
|
|
1660
|
-
|
|
1085
|
+
useEffect2(() => {
|
|
1661
1086
|
setImageStatus("loading");
|
|
1662
1087
|
setReloadKey(0);
|
|
1663
1088
|
if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
|
|
@@ -1683,9 +1108,9 @@ var ImageGalleryLightbox = ({
|
|
|
1683
1108
|
setImageStatus("loading");
|
|
1684
1109
|
setReloadKey((prev) => prev + 1);
|
|
1685
1110
|
};
|
|
1686
|
-
const isDraggingRef =
|
|
1687
|
-
const lastMousePosRef =
|
|
1688
|
-
|
|
1111
|
+
const isDraggingRef = useRef5(false);
|
|
1112
|
+
const lastMousePosRef = useRef5({ x: 0, y: 0 });
|
|
1113
|
+
useEffect2(() => {
|
|
1689
1114
|
const store = storeRef.current;
|
|
1690
1115
|
const updateStrokes = () => {
|
|
1691
1116
|
const s = store.getStrokes(slideId);
|
|
@@ -1729,7 +1154,7 @@ var ImageGalleryLightbox = ({
|
|
|
1729
1154
|
handleTouchEnd();
|
|
1730
1155
|
onSwipeTouchEnd(e);
|
|
1731
1156
|
};
|
|
1732
|
-
|
|
1157
|
+
useEffect2(() => {
|
|
1733
1158
|
if (!isOpen) return;
|
|
1734
1159
|
const handleKeyDown = (e) => {
|
|
1735
1160
|
if (e.key === "Escape") {
|
|
@@ -1830,7 +1255,7 @@ var ImageGalleryLightbox = ({
|
|
|
1830
1255
|
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
1831
1256
|
};
|
|
1832
1257
|
if (!isOpen || !currentItem) return null;
|
|
1833
|
-
return /* @__PURE__ */
|
|
1258
|
+
return /* @__PURE__ */ jsxs4(
|
|
1834
1259
|
"div",
|
|
1835
1260
|
{
|
|
1836
1261
|
ref: containerRef,
|
|
@@ -1839,7 +1264,7 @@ var ImageGalleryLightbox = ({
|
|
|
1839
1264
|
"aria-modal": "true",
|
|
1840
1265
|
"aria-label": "Image Lightbox Gallery",
|
|
1841
1266
|
children: [
|
|
1842
|
-
/* @__PURE__ */
|
|
1267
|
+
/* @__PURE__ */ jsx5(
|
|
1843
1268
|
ImageToolbar,
|
|
1844
1269
|
{
|
|
1845
1270
|
activeTool,
|
|
@@ -1861,6 +1286,7 @@ var ImageGalleryLightbox = ({
|
|
|
1861
1286
|
onDownloadAnnotated: handleDownloadAnnotated,
|
|
1862
1287
|
onDownloadClean: handleDownloadClean,
|
|
1863
1288
|
onExportJson: handleExportJson,
|
|
1289
|
+
theme: theme === "light" ? "light" : "dark",
|
|
1864
1290
|
onClose,
|
|
1865
1291
|
isFullscreen,
|
|
1866
1292
|
onToggleFullscreen: toggleFullscreen,
|
|
@@ -1868,7 +1294,7 @@ var ImageGalleryLightbox = ({
|
|
|
1868
1294
|
totalImages: items.length
|
|
1869
1295
|
}
|
|
1870
1296
|
),
|
|
1871
|
-
currentIndex > 0 && /* @__PURE__ */
|
|
1297
|
+
currentIndex > 0 && /* @__PURE__ */ jsx5(
|
|
1872
1298
|
"button",
|
|
1873
1299
|
{
|
|
1874
1300
|
type: "button",
|
|
@@ -1876,10 +1302,10 @@ var ImageGalleryLightbox = ({
|
|
|
1876
1302
|
onClick: goToPrev,
|
|
1877
1303
|
title: "Previous Image (Arrow Left)",
|
|
1878
1304
|
"aria-label": "Previous image",
|
|
1879
|
-
children: /* @__PURE__ */
|
|
1305
|
+
children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faChevronLeft })
|
|
1880
1306
|
}
|
|
1881
1307
|
),
|
|
1882
|
-
currentIndex < items.length - 1 && /* @__PURE__ */
|
|
1308
|
+
currentIndex < items.length - 1 && /* @__PURE__ */ jsx5(
|
|
1883
1309
|
"button",
|
|
1884
1310
|
{
|
|
1885
1311
|
type: "button",
|
|
@@ -1887,10 +1313,10 @@ var ImageGalleryLightbox = ({
|
|
|
1887
1313
|
onClick: goToNext,
|
|
1888
1314
|
title: "Next Image (Arrow Right)",
|
|
1889
1315
|
"aria-label": "Next image",
|
|
1890
|
-
children: /* @__PURE__ */
|
|
1316
|
+
children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faChevronRight })
|
|
1891
1317
|
}
|
|
1892
1318
|
),
|
|
1893
|
-
/* @__PURE__ */
|
|
1319
|
+
/* @__PURE__ */ jsxs4(
|
|
1894
1320
|
"div",
|
|
1895
1321
|
{
|
|
1896
1322
|
className: "tbib-iv-stage",
|
|
@@ -1906,7 +1332,7 @@ var ImageGalleryLightbox = ({
|
|
|
1906
1332
|
cursor: activeTool === "hand" ? isDraggingRef.current ? "grabbing" : "grab" : "default"
|
|
1907
1333
|
},
|
|
1908
1334
|
children: [
|
|
1909
|
-
/* @__PURE__ */
|
|
1335
|
+
/* @__PURE__ */ jsxs4(
|
|
1910
1336
|
"div",
|
|
1911
1337
|
{
|
|
1912
1338
|
className: "tbib-iv-stage-inner",
|
|
@@ -1915,7 +1341,7 @@ var ImageGalleryLightbox = ({
|
|
|
1915
1341
|
transition: isDraggingRef.current ? "none" : "transform 0.05s ease-out"
|
|
1916
1342
|
},
|
|
1917
1343
|
children: [
|
|
1918
|
-
/* @__PURE__ */
|
|
1344
|
+
/* @__PURE__ */ jsx5(
|
|
1919
1345
|
"img",
|
|
1920
1346
|
{
|
|
1921
1347
|
ref: imgRef,
|
|
@@ -1928,7 +1354,7 @@ var ImageGalleryLightbox = ({
|
|
|
1928
1354
|
},
|
|
1929
1355
|
`${slideId}-${reloadKey}`
|
|
1930
1356
|
),
|
|
1931
|
-
imageStatus === "loaded" && /* @__PURE__ */
|
|
1357
|
+
imageStatus === "loaded" && /* @__PURE__ */ jsx5(
|
|
1932
1358
|
AnnotationCanvas,
|
|
1933
1359
|
{
|
|
1934
1360
|
width: imgSize.width,
|
|
@@ -1947,28 +1373,28 @@ var ImageGalleryLightbox = ({
|
|
|
1947
1373
|
]
|
|
1948
1374
|
}
|
|
1949
1375
|
),
|
|
1950
|
-
imageStatus === "loading" && /* @__PURE__ */
|
|
1951
|
-
/* @__PURE__ */
|
|
1952
|
-
/* @__PURE__ */
|
|
1376
|
+
imageStatus === "loading" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay", children: [
|
|
1377
|
+
/* @__PURE__ */ jsx5("div", { className: "tbib-iv-spinner", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faSpinner2, spin: true, className: "tbib-iv-spinner-icon" }) }),
|
|
1378
|
+
/* @__PURE__ */ jsx5("span", { className: "tbib-iv-status-text", children: "Chargement de l'illustration..." })
|
|
1953
1379
|
] }),
|
|
1954
|
-
imageStatus === "error" && /* @__PURE__ */
|
|
1955
|
-
/* @__PURE__ */
|
|
1956
|
-
/* @__PURE__ */
|
|
1957
|
-
/* @__PURE__ */
|
|
1958
|
-
/* @__PURE__ */
|
|
1959
|
-
/* @__PURE__ */
|
|
1380
|
+
imageStatus === "error" && /* @__PURE__ */ jsxs4("div", { className: "tbib-iv-status-overlay tbib-iv-error-card", children: [
|
|
1381
|
+
/* @__PURE__ */ jsx5("div", { className: "tbib-iv-error-icon", children: /* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExclamationTriangle2 }) }),
|
|
1382
|
+
/* @__PURE__ */ jsx5("h3", { className: "tbib-iv-error-title", children: "Impossible de charger l'image" }),
|
|
1383
|
+
/* @__PURE__ */ jsx5("p", { className: "tbib-iv-error-desc", children: "Le fichier est temporairement inaccessible ou une erreur r\xE9seau est survenue." }),
|
|
1384
|
+
/* @__PURE__ */ jsxs4("div", { className: "tbib-iv-error-actions", children: [
|
|
1385
|
+
/* @__PURE__ */ jsxs4(
|
|
1960
1386
|
"button",
|
|
1961
1387
|
{
|
|
1962
1388
|
type: "button",
|
|
1963
1389
|
className: "tbib-iv-btn tbib-iv-btn-primary tbib-iv-retry-btn",
|
|
1964
1390
|
onClick: handleReload,
|
|
1965
1391
|
children: [
|
|
1966
|
-
/* @__PURE__ */
|
|
1967
|
-
/* @__PURE__ */
|
|
1392
|
+
/* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faRotateRight3 }),
|
|
1393
|
+
/* @__PURE__ */ jsx5("span", { children: "R\xE9essayer" })
|
|
1968
1394
|
]
|
|
1969
1395
|
}
|
|
1970
1396
|
),
|
|
1971
|
-
currentItem?.src && /* @__PURE__ */
|
|
1397
|
+
currentItem?.src && /* @__PURE__ */ jsxs4(
|
|
1972
1398
|
"a",
|
|
1973
1399
|
{
|
|
1974
1400
|
href: currentItem.src,
|
|
@@ -1976,18 +1402,18 @@ var ImageGalleryLightbox = ({
|
|
|
1976
1402
|
rel: "noopener noreferrer",
|
|
1977
1403
|
className: "tbib-iv-btn tbib-iv-open-btn",
|
|
1978
1404
|
children: [
|
|
1979
|
-
/* @__PURE__ */
|
|
1980
|
-
/* @__PURE__ */
|
|
1405
|
+
/* @__PURE__ */ jsx5(FontAwesomeIcon3, { icon: faExternalLinkAlt2 }),
|
|
1406
|
+
/* @__PURE__ */ jsx5("span", { children: "Lien direct" })
|
|
1981
1407
|
]
|
|
1982
1408
|
}
|
|
1983
1409
|
)
|
|
1984
1410
|
] })
|
|
1985
1411
|
] }),
|
|
1986
|
-
activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */
|
|
1412
|
+
activeTool === "laser" && imageStatus === "loaded" && /* @__PURE__ */ jsx5(Suspense2, { fallback: null, children: /* @__PURE__ */ jsx5(LaserCursorLayer2, { color, secondaryColor: color, enabled: activeTool === "laser" }) })
|
|
1987
1413
|
]
|
|
1988
1414
|
}
|
|
1989
1415
|
),
|
|
1990
|
-
showThumbnails && /* @__PURE__ */
|
|
1416
|
+
showThumbnails && /* @__PURE__ */ jsx5(
|
|
1991
1417
|
ThumbnailStrip,
|
|
1992
1418
|
{
|
|
1993
1419
|
items,
|
|
@@ -2003,11 +1429,14 @@ var ImageGalleryLightbox = ({
|
|
|
2003
1429
|
);
|
|
2004
1430
|
};
|
|
2005
1431
|
|
|
1432
|
+
// src/components/LaserCursorLayer.tsx
|
|
1433
|
+
import { LaserCursorLayer as LaserCursorLayer3 } from "@tbib-ink/react/laser";
|
|
1434
|
+
|
|
2006
1435
|
// src/components/ColorPicker.tsx
|
|
2007
|
-
import { useState as useState6, useRef as
|
|
2008
|
-
import { FontAwesomeIcon as
|
|
1436
|
+
import { useState as useState6, useRef as useRef6, useEffect as useEffect3 } from "react";
|
|
1437
|
+
import { FontAwesomeIcon as FontAwesomeIcon4 } from "@fortawesome/react-fontawesome";
|
|
2009
1438
|
import { faPalette } from "@fortawesome/free-solid-svg-icons";
|
|
2010
|
-
import { jsx as
|
|
1439
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2011
1440
|
var PRESET_COLORS2 = [
|
|
2012
1441
|
"#ef4444",
|
|
2013
1442
|
// Red (Danger / Anatomy landmark)
|
|
@@ -2028,8 +1457,8 @@ var PRESET_COLORS2 = [
|
|
|
2028
1457
|
];
|
|
2029
1458
|
var ColorPicker = ({ color, onChange }) => {
|
|
2030
1459
|
const [isOpen, setIsOpen] = useState6(false);
|
|
2031
|
-
const containerRef =
|
|
2032
|
-
|
|
1460
|
+
const containerRef = useRef6(null);
|
|
1461
|
+
useEffect3(() => {
|
|
2033
1462
|
const handleOutsideClick = (e) => {
|
|
2034
1463
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2035
1464
|
setIsOpen(false);
|
|
@@ -2042,8 +1471,8 @@ var ColorPicker = ({ color, onChange }) => {
|
|
|
2042
1471
|
document.removeEventListener("mousedown", handleOutsideClick);
|
|
2043
1472
|
};
|
|
2044
1473
|
}, [isOpen]);
|
|
2045
|
-
return /* @__PURE__ */
|
|
2046
|
-
/* @__PURE__ */
|
|
1474
|
+
return /* @__PURE__ */ jsxs5("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
|
|
1475
|
+
/* @__PURE__ */ jsxs5(
|
|
2047
1476
|
"button",
|
|
2048
1477
|
{
|
|
2049
1478
|
type: "button",
|
|
@@ -2051,7 +1480,7 @@ var ColorPicker = ({ color, onChange }) => {
|
|
|
2051
1480
|
title: "Annotation Color",
|
|
2052
1481
|
onClick: () => setIsOpen((prev) => !prev),
|
|
2053
1482
|
children: [
|
|
2054
|
-
/* @__PURE__ */
|
|
1483
|
+
/* @__PURE__ */ jsx6(
|
|
2055
1484
|
"span",
|
|
2056
1485
|
{
|
|
2057
1486
|
style: {
|
|
@@ -2065,11 +1494,11 @@ var ColorPicker = ({ color, onChange }) => {
|
|
|
2065
1494
|
}
|
|
2066
1495
|
}
|
|
2067
1496
|
),
|
|
2068
|
-
/* @__PURE__ */
|
|
1497
|
+
/* @__PURE__ */ jsx6(FontAwesomeIcon4, { icon: faPalette, style: { fontSize: "12px", opacity: 0.8 } })
|
|
2069
1498
|
]
|
|
2070
1499
|
}
|
|
2071
1500
|
),
|
|
2072
|
-
isOpen && /* @__PURE__ */
|
|
1501
|
+
isOpen && /* @__PURE__ */ jsx6("div", { className: "tbib-iv-popover", children: PRESET_COLORS2.map((c) => /* @__PURE__ */ jsx6(
|
|
2073
1502
|
"button",
|
|
2074
1503
|
{
|
|
2075
1504
|
type: "button",
|
|
@@ -2087,8 +1516,8 @@ var ColorPicker = ({ color, onChange }) => {
|
|
|
2087
1516
|
};
|
|
2088
1517
|
|
|
2089
1518
|
// src/components/StrokeWidthPicker.tsx
|
|
2090
|
-
import { useState as useState7, useRef as
|
|
2091
|
-
import { jsx as
|
|
1519
|
+
import { useState as useState7, useRef as useRef7, useEffect as useEffect4 } from "react";
|
|
1520
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2092
1521
|
var WIDTH_OPTIONS = [
|
|
2093
1522
|
{ label: "Fine (2px)", value: 2, iconSize: "6px" },
|
|
2094
1523
|
{ label: "Medium (4px)", value: 4, iconSize: "10px" },
|
|
@@ -2100,8 +1529,8 @@ var StrokeWidthPicker = ({
|
|
|
2100
1529
|
onChange
|
|
2101
1530
|
}) => {
|
|
2102
1531
|
const [isOpen, setIsOpen] = useState7(false);
|
|
2103
|
-
const containerRef =
|
|
2104
|
-
|
|
1532
|
+
const containerRef = useRef7(null);
|
|
1533
|
+
useEffect4(() => {
|
|
2105
1534
|
const handleOutsideClick = (e) => {
|
|
2106
1535
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2107
1536
|
setIsOpen(false);
|
|
@@ -2115,15 +1544,15 @@ var StrokeWidthPicker = ({
|
|
|
2115
1544
|
};
|
|
2116
1545
|
}, [isOpen]);
|
|
2117
1546
|
const currentOption = WIDTH_OPTIONS.find((o) => o.value === strokeWidth) || WIDTH_OPTIONS[1];
|
|
2118
|
-
return /* @__PURE__ */
|
|
2119
|
-
/* @__PURE__ */
|
|
1547
|
+
return /* @__PURE__ */ jsxs6("div", { ref: containerRef, style: { position: "relative", display: "inline-block" }, children: [
|
|
1548
|
+
/* @__PURE__ */ jsx7(
|
|
2120
1549
|
"button",
|
|
2121
1550
|
{
|
|
2122
1551
|
type: "button",
|
|
2123
1552
|
className: "tbib-iv-btn",
|
|
2124
1553
|
title: "Stroke Thickness",
|
|
2125
1554
|
onClick: () => setIsOpen((prev) => !prev),
|
|
2126
|
-
children: /* @__PURE__ */
|
|
1555
|
+
children: /* @__PURE__ */ jsx7(
|
|
2127
1556
|
"span",
|
|
2128
1557
|
{
|
|
2129
1558
|
style: {
|
|
@@ -2133,7 +1562,7 @@ var StrokeWidthPicker = ({
|
|
|
2133
1562
|
width: "16px",
|
|
2134
1563
|
height: "16px"
|
|
2135
1564
|
},
|
|
2136
|
-
children: /* @__PURE__ */
|
|
1565
|
+
children: /* @__PURE__ */ jsx7(
|
|
2137
1566
|
"span",
|
|
2138
1567
|
{
|
|
2139
1568
|
style: {
|
|
@@ -2148,7 +1577,7 @@ var StrokeWidthPicker = ({
|
|
|
2148
1577
|
)
|
|
2149
1578
|
}
|
|
2150
1579
|
),
|
|
2151
|
-
isOpen && /* @__PURE__ */
|
|
1580
|
+
isOpen && /* @__PURE__ */ jsx7(
|
|
2152
1581
|
"div",
|
|
2153
1582
|
{
|
|
2154
1583
|
className: "tbib-iv-popover",
|
|
@@ -2157,7 +1586,7 @@ var StrokeWidthPicker = ({
|
|
|
2157
1586
|
minWidth: "120px",
|
|
2158
1587
|
padding: "4px"
|
|
2159
1588
|
},
|
|
2160
|
-
children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */
|
|
1589
|
+
children: WIDTH_OPTIONS.map((opt) => /* @__PURE__ */ jsxs6(
|
|
2161
1590
|
"button",
|
|
2162
1591
|
{
|
|
2163
1592
|
type: "button",
|
|
@@ -2174,7 +1603,7 @@ var StrokeWidthPicker = ({
|
|
|
2174
1603
|
setIsOpen(false);
|
|
2175
1604
|
},
|
|
2176
1605
|
children: [
|
|
2177
|
-
/* @__PURE__ */
|
|
1606
|
+
/* @__PURE__ */ jsx7(
|
|
2178
1607
|
"span",
|
|
2179
1608
|
{
|
|
2180
1609
|
style: {
|
|
@@ -2186,7 +1615,7 @@ var StrokeWidthPicker = ({
|
|
|
2186
1615
|
}
|
|
2187
1616
|
}
|
|
2188
1617
|
),
|
|
2189
|
-
/* @__PURE__ */
|
|
1618
|
+
/* @__PURE__ */ jsx7("span", { children: opt.label })
|
|
2190
1619
|
]
|
|
2191
1620
|
},
|
|
2192
1621
|
opt.value
|
|
@@ -2195,6 +1624,183 @@ var StrokeWidthPicker = ({
|
|
|
2195
1624
|
)
|
|
2196
1625
|
] });
|
|
2197
1626
|
};
|
|
1627
|
+
|
|
1628
|
+
// src/components/DownloadMenu.tsx
|
|
1629
|
+
import { useState as useState8, useRef as useRef8, useEffect as useEffect5 } from "react";
|
|
1630
|
+
import { FontAwesomeIcon as FontAwesomeIcon5 } from "@fortawesome/react-fontawesome";
|
|
1631
|
+
import {
|
|
1632
|
+
faDownload as faDownload2,
|
|
1633
|
+
faImage as faImage2,
|
|
1634
|
+
faPaintBrush,
|
|
1635
|
+
faSpinner as faSpinner3,
|
|
1636
|
+
faChevronDown
|
|
1637
|
+
} from "@fortawesome/free-solid-svg-icons";
|
|
1638
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1639
|
+
var DownloadMenu = ({
|
|
1640
|
+
onDownloadAnnotated,
|
|
1641
|
+
onDownloadClean,
|
|
1642
|
+
onExportJson
|
|
1643
|
+
}) => {
|
|
1644
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
1645
|
+
const [isExporting, setIsExporting] = useState8(false);
|
|
1646
|
+
const [popoverPos, setPopoverPos] = useState8({ top: 0, right: 0 });
|
|
1647
|
+
const containerRef = useRef8(null);
|
|
1648
|
+
useEffect5(() => {
|
|
1649
|
+
if (isOpen && containerRef.current) {
|
|
1650
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1651
|
+
setPopoverPos({
|
|
1652
|
+
top: rect.bottom + 8,
|
|
1653
|
+
right: Math.max(12, window.innerWidth - rect.right)
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
}, [isOpen]);
|
|
1657
|
+
useEffect5(() => {
|
|
1658
|
+
const handleOutsideClick = (e) => {
|
|
1659
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1660
|
+
setIsOpen(false);
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
if (isOpen) {
|
|
1664
|
+
document.addEventListener("mousedown", handleOutsideClick);
|
|
1665
|
+
document.addEventListener("touchstart", handleOutsideClick);
|
|
1666
|
+
}
|
|
1667
|
+
return () => {
|
|
1668
|
+
document.removeEventListener("mousedown", handleOutsideClick);
|
|
1669
|
+
document.removeEventListener("touchstart", handleOutsideClick);
|
|
1670
|
+
};
|
|
1671
|
+
}, [isOpen]);
|
|
1672
|
+
const handleAnnotated = async () => {
|
|
1673
|
+
if (isExporting) return;
|
|
1674
|
+
setIsExporting(true);
|
|
1675
|
+
try {
|
|
1676
|
+
await onDownloadAnnotated();
|
|
1677
|
+
} finally {
|
|
1678
|
+
setIsExporting(false);
|
|
1679
|
+
setIsOpen(false);
|
|
1680
|
+
}
|
|
1681
|
+
};
|
|
1682
|
+
const handleClean = async () => {
|
|
1683
|
+
if (isExporting) return;
|
|
1684
|
+
setIsExporting(true);
|
|
1685
|
+
try {
|
|
1686
|
+
await onDownloadClean();
|
|
1687
|
+
} finally {
|
|
1688
|
+
setIsExporting(false);
|
|
1689
|
+
setIsOpen(false);
|
|
1690
|
+
}
|
|
1691
|
+
};
|
|
1692
|
+
return /* @__PURE__ */ jsxs7(
|
|
1693
|
+
"div",
|
|
1694
|
+
{
|
|
1695
|
+
ref: containerRef,
|
|
1696
|
+
style: {
|
|
1697
|
+
position: "relative",
|
|
1698
|
+
display: "inline-flex",
|
|
1699
|
+
alignItems: "center"
|
|
1700
|
+
},
|
|
1701
|
+
children: [
|
|
1702
|
+
/* @__PURE__ */ jsx8(
|
|
1703
|
+
"button",
|
|
1704
|
+
{
|
|
1705
|
+
type: "button",
|
|
1706
|
+
className: "tbib-iv-btn",
|
|
1707
|
+
title: "Download Annotated Image (1-Click PNG)",
|
|
1708
|
+
"aria-label": "Download Image",
|
|
1709
|
+
disabled: isExporting,
|
|
1710
|
+
onClick: handleAnnotated,
|
|
1711
|
+
style: {
|
|
1712
|
+
borderTopRightRadius: 0,
|
|
1713
|
+
borderBottomRightRadius: 0,
|
|
1714
|
+
paddingRight: "6px"
|
|
1715
|
+
},
|
|
1716
|
+
children: /* @__PURE__ */ jsx8(
|
|
1717
|
+
FontAwesomeIcon5,
|
|
1718
|
+
{
|
|
1719
|
+
icon: isExporting ? faSpinner3 : faDownload2,
|
|
1720
|
+
className: isExporting ? "fa-spin" : "",
|
|
1721
|
+
style: { fontSize: "14px" }
|
|
1722
|
+
}
|
|
1723
|
+
)
|
|
1724
|
+
}
|
|
1725
|
+
),
|
|
1726
|
+
/* @__PURE__ */ jsx8(
|
|
1727
|
+
"button",
|
|
1728
|
+
{
|
|
1729
|
+
type: "button",
|
|
1730
|
+
className: "tbib-iv-btn",
|
|
1731
|
+
title: "More Download Options",
|
|
1732
|
+
"aria-label": "More Download Options",
|
|
1733
|
+
disabled: isExporting,
|
|
1734
|
+
onClick: () => setIsOpen((prev) => !prev),
|
|
1735
|
+
style: {
|
|
1736
|
+
borderTopLeftRadius: 0,
|
|
1737
|
+
borderBottomLeftRadius: 0,
|
|
1738
|
+
paddingLeft: "4px",
|
|
1739
|
+
paddingRight: "6px",
|
|
1740
|
+
minWidth: "20px",
|
|
1741
|
+
borderLeft: "1px solid var(--tbib-iv-border)"
|
|
1742
|
+
},
|
|
1743
|
+
children: /* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faChevronDown, style: { fontSize: "10px", opacity: 0.8 } })
|
|
1744
|
+
}
|
|
1745
|
+
),
|
|
1746
|
+
isOpen && /* @__PURE__ */ jsxs7(
|
|
1747
|
+
"div",
|
|
1748
|
+
{
|
|
1749
|
+
className: "tbib-iv-popover",
|
|
1750
|
+
style: {
|
|
1751
|
+
position: "fixed",
|
|
1752
|
+
top: `${popoverPos.top}px`,
|
|
1753
|
+
right: `${popoverPos.right}px`,
|
|
1754
|
+
flexDirection: "column",
|
|
1755
|
+
minWidth: "210px",
|
|
1756
|
+
zIndex: 9999
|
|
1757
|
+
},
|
|
1758
|
+
children: [
|
|
1759
|
+
/* @__PURE__ */ jsxs7(
|
|
1760
|
+
"button",
|
|
1761
|
+
{
|
|
1762
|
+
type: "button",
|
|
1763
|
+
className: "tbib-iv-btn",
|
|
1764
|
+
style: {
|
|
1765
|
+
width: "100%",
|
|
1766
|
+
justifyContent: "flex-start",
|
|
1767
|
+
gap: "10px",
|
|
1768
|
+
padding: "8px 10px",
|
|
1769
|
+
fontSize: "12px"
|
|
1770
|
+
},
|
|
1771
|
+
onClick: handleAnnotated,
|
|
1772
|
+
children: [
|
|
1773
|
+
/* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faPaintBrush, style: { fontSize: "13px", color: "var(--tbib-iv-accent)" } }),
|
|
1774
|
+
/* @__PURE__ */ jsx8("span", { children: "Annotated Image (PNG)" })
|
|
1775
|
+
]
|
|
1776
|
+
}
|
|
1777
|
+
),
|
|
1778
|
+
/* @__PURE__ */ jsxs7(
|
|
1779
|
+
"button",
|
|
1780
|
+
{
|
|
1781
|
+
type: "button",
|
|
1782
|
+
className: "tbib-iv-btn",
|
|
1783
|
+
style: {
|
|
1784
|
+
width: "100%",
|
|
1785
|
+
justifyContent: "flex-start",
|
|
1786
|
+
gap: "10px",
|
|
1787
|
+
padding: "8px 10px",
|
|
1788
|
+
fontSize: "12px"
|
|
1789
|
+
},
|
|
1790
|
+
onClick: handleClean,
|
|
1791
|
+
children: [
|
|
1792
|
+
/* @__PURE__ */ jsx8(FontAwesomeIcon5, { icon: faImage2, style: { fontSize: "13px" } }),
|
|
1793
|
+
/* @__PURE__ */ jsx8("span", { children: "Clean Image (Original)" })
|
|
1794
|
+
]
|
|
1795
|
+
}
|
|
1796
|
+
)
|
|
1797
|
+
]
|
|
1798
|
+
}
|
|
1799
|
+
)
|
|
1800
|
+
]
|
|
1801
|
+
}
|
|
1802
|
+
);
|
|
1803
|
+
};
|
|
2198
1804
|
export {
|
|
2199
1805
|
AnnotationCanvas,
|
|
2200
1806
|
ColorPicker,
|
|
@@ -2202,7 +1808,7 @@ export {
|
|
|
2202
1808
|
ImageGalleryLightbox,
|
|
2203
1809
|
ImageToolbar,
|
|
2204
1810
|
ImageViewer,
|
|
2205
|
-
LaserCursorLayer,
|
|
1811
|
+
LaserCursorLayer3 as LaserCursorLayer,
|
|
2206
1812
|
StrokeWidthPicker,
|
|
2207
1813
|
ThumbnailStrip,
|
|
2208
1814
|
useImageTransform,
|