@tbib-image-viewer/react 0.1.4 → 0.1.6
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 +77 -33
- package/dist/index.css.map +1 -1
- package/dist/index.js +401 -334
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +294 -237
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -35,7 +45,7 @@ __export(index_exports, {
|
|
|
35
45
|
module.exports = __toCommonJS(index_exports);
|
|
36
46
|
|
|
37
47
|
// src/components/ImageViewer.tsx
|
|
38
|
-
var
|
|
48
|
+
var import_react6 = require("react");
|
|
39
49
|
var import_react_fontawesome3 = require("@fortawesome/react-fontawesome");
|
|
40
50
|
var import_free_solid_svg_icons3 = require("@fortawesome/free-solid-svg-icons");
|
|
41
51
|
var import_faExclamationTriangle = require("@fortawesome/free-solid-svg-icons/faExclamationTriangle");
|
|
@@ -43,6 +53,7 @@ var import_faExternalLinkAlt = require("@fortawesome/free-solid-svg-icons/faExte
|
|
|
43
53
|
var import_core3 = require("@tbib-image-viewer/core");
|
|
44
54
|
|
|
45
55
|
// src/components/ImageToolbar.tsx
|
|
56
|
+
var import_react2 = __toESM(require("react"));
|
|
46
57
|
var import_react_fontawesome2 = require("@fortawesome/react-fontawesome");
|
|
47
58
|
var import_free_solid_svg_icons2 = require("@fortawesome/free-solid-svg-icons");
|
|
48
59
|
|
|
@@ -270,256 +281,312 @@ var ImageToolbar = ({
|
|
|
270
281
|
totalImages
|
|
271
282
|
}) => {
|
|
272
283
|
const showSubtoolbar = activeTool === "pen" || activeTool === "highlighter" || activeTool === "laser";
|
|
284
|
+
const toolbarScrollRef = import_react2.default.useRef(null);
|
|
285
|
+
const subtoolbarScrollRef = import_react2.default.useRef(null);
|
|
286
|
+
const toolbarTouchState = import_react2.default.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
|
|
287
|
+
const subtoolbarTouchState = import_react2.default.useRef({ isDown: false, startX: 0, scrollLeft: 0 });
|
|
288
|
+
const handleToolbarTouchStart = (e) => {
|
|
289
|
+
if (!toolbarScrollRef.current) return;
|
|
290
|
+
toolbarTouchState.current = {
|
|
291
|
+
isDown: true,
|
|
292
|
+
startX: e.touches[0].clientX,
|
|
293
|
+
scrollLeft: toolbarScrollRef.current.scrollLeft
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
const handleToolbarTouchMove = (e) => {
|
|
297
|
+
if (!toolbarTouchState.current.isDown || !toolbarScrollRef.current) return;
|
|
298
|
+
const dx = e.touches[0].clientX - toolbarTouchState.current.startX;
|
|
299
|
+
toolbarScrollRef.current.scrollLeft = toolbarTouchState.current.scrollLeft - dx;
|
|
300
|
+
};
|
|
301
|
+
const handleToolbarTouchEnd = () => {
|
|
302
|
+
toolbarTouchState.current.isDown = false;
|
|
303
|
+
};
|
|
304
|
+
const handleSubtoolbarTouchStart = (e) => {
|
|
305
|
+
if (!subtoolbarScrollRef.current) return;
|
|
306
|
+
subtoolbarTouchState.current = {
|
|
307
|
+
isDown: true,
|
|
308
|
+
startX: e.touches[0].clientX,
|
|
309
|
+
scrollLeft: subtoolbarScrollRef.current.scrollLeft
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
const handleSubtoolbarTouchMove = (e) => {
|
|
313
|
+
if (!subtoolbarTouchState.current.isDown || !subtoolbarScrollRef.current) return;
|
|
314
|
+
const dx = e.touches[0].clientX - subtoolbarTouchState.current.startX;
|
|
315
|
+
subtoolbarScrollRef.current.scrollLeft = subtoolbarTouchState.current.scrollLeft - dx;
|
|
316
|
+
};
|
|
317
|
+
const handleSubtoolbarTouchEnd = () => {
|
|
318
|
+
subtoolbarTouchState.current.isDown = false;
|
|
319
|
+
};
|
|
273
320
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tbib-iv-toolbar-wrapper", children: [
|
|
274
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
"
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
className: "tbib-iv-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
"
|
|
453
|
-
style: { color: "#ef4444" },
|
|
454
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faXmark, style: { fontSize: "16px" } })
|
|
455
|
-
}
|
|
456
|
-
)
|
|
457
|
-
] })
|
|
458
|
-
] }),
|
|
459
|
-
showSubtoolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "tbib-iv-subtoolbar", role: "region", "aria-label": "Tool customization", children: [
|
|
460
|
-
activeTool !== "laser" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-thickness-group", children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
461
|
-
"button",
|
|
462
|
-
{
|
|
463
|
-
type: "button",
|
|
464
|
-
className: `tbib-iv-thickness-btn ${strokeWidth === opt.value ? "tbib-iv-thickness-active" : ""}`,
|
|
465
|
-
onClick: () => onStrokeWidthChange(opt.value),
|
|
466
|
-
title: `${opt.label} stroke (${opt.value}px)`,
|
|
467
|
-
children: [
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("header", { className: "tbib-iv-toolbar", role: "toolbar", "aria-label": "Image tools", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
ref: toolbarScrollRef,
|
|
325
|
+
className: "tbib-iv-toolbar-scroll",
|
|
326
|
+
onTouchStart: handleToolbarTouchStart,
|
|
327
|
+
onTouchMove: handleToolbarTouchMove,
|
|
328
|
+
onTouchEnd: handleToolbarTouchEnd,
|
|
329
|
+
children: [
|
|
330
|
+
currentIndex !== void 0 && totalImages !== void 0 && totalImages > 1 && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
331
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Image", children: [
|
|
332
|
+
currentIndex + 1,
|
|
333
|
+
" / ",
|
|
334
|
+
totalImages
|
|
335
|
+
] }),
|
|
336
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" })
|
|
337
|
+
] }),
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
339
|
+
"button",
|
|
340
|
+
{
|
|
341
|
+
type: "button",
|
|
342
|
+
className: `tbib-iv-btn ${activeTool === "hand" ? "tbib-iv-btn-active" : ""}`,
|
|
343
|
+
onClick: () => onToolChange("hand"),
|
|
344
|
+
title: "Pan & Move (1-finger / drag)",
|
|
345
|
+
"aria-label": "Hand Pan Tool",
|
|
346
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHand })
|
|
347
|
+
}
|
|
348
|
+
),
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
350
|
+
"button",
|
|
351
|
+
{
|
|
352
|
+
type: "button",
|
|
353
|
+
className: `tbib-iv-btn ${activeTool === "pen" ? "tbib-iv-btn-active" : ""}`,
|
|
354
|
+
onClick: () => onToolChange("pen"),
|
|
355
|
+
title: "Draw Pen",
|
|
356
|
+
"aria-label": "Pen Tool",
|
|
357
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faPen })
|
|
358
|
+
}
|
|
359
|
+
),
|
|
360
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
361
|
+
"button",
|
|
362
|
+
{
|
|
363
|
+
type: "button",
|
|
364
|
+
className: `tbib-iv-btn ${activeTool === "highlighter" ? "tbib-iv-btn-active" : ""}`,
|
|
365
|
+
onClick: () => onToolChange("highlighter"),
|
|
366
|
+
title: "Highlighter (Semi-transparent)",
|
|
367
|
+
"aria-label": "Highlighter Tool",
|
|
368
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faHighlighter })
|
|
369
|
+
}
|
|
370
|
+
),
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
372
|
+
"button",
|
|
373
|
+
{
|
|
374
|
+
type: "button",
|
|
375
|
+
className: `tbib-iv-btn ${activeTool === "laser" ? "tbib-iv-btn-active" : ""}`,
|
|
376
|
+
onClick: () => onToolChange("laser"),
|
|
377
|
+
title: "Laser Pointer (Glowing WebGL trail)",
|
|
378
|
+
"aria-label": "Laser Pointer",
|
|
379
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faCrosshairs })
|
|
380
|
+
}
|
|
381
|
+
),
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
383
|
+
"button",
|
|
384
|
+
{
|
|
385
|
+
type: "button",
|
|
386
|
+
className: `tbib-iv-btn ${activeTool === "eraser" ? "tbib-iv-btn-active" : ""}`,
|
|
387
|
+
onClick: () => onToolChange("eraser"),
|
|
388
|
+
title: "Eraser (Erase strokes on tap)",
|
|
389
|
+
"aria-label": "Eraser Tool",
|
|
390
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEraser })
|
|
391
|
+
}
|
|
392
|
+
),
|
|
393
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
|
|
394
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
395
|
+
"button",
|
|
396
|
+
{
|
|
397
|
+
type: "button",
|
|
398
|
+
className: "tbib-iv-btn",
|
|
399
|
+
disabled: !canUndo,
|
|
400
|
+
onClick: onUndo,
|
|
401
|
+
title: "Undo (Ctrl+Z)",
|
|
402
|
+
"aria-label": "Undo",
|
|
403
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateLeft })
|
|
404
|
+
}
|
|
405
|
+
),
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
407
|
+
"button",
|
|
408
|
+
{
|
|
409
|
+
type: "button",
|
|
410
|
+
className: "tbib-iv-btn",
|
|
411
|
+
disabled: !canRedo,
|
|
412
|
+
onClick: onRedo,
|
|
413
|
+
title: "Redo (Ctrl+Y)",
|
|
414
|
+
"aria-label": "Redo",
|
|
415
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotateRight })
|
|
416
|
+
}
|
|
417
|
+
),
|
|
418
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
419
|
+
"button",
|
|
420
|
+
{
|
|
421
|
+
type: "button",
|
|
422
|
+
className: "tbib-iv-btn",
|
|
423
|
+
onClick: onClear,
|
|
424
|
+
title: "Clear Slide Annotations",
|
|
425
|
+
"aria-label": "Clear All",
|
|
426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faTrashCan })
|
|
427
|
+
}
|
|
428
|
+
),
|
|
429
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
|
|
430
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
431
|
+
"button",
|
|
432
|
+
{
|
|
433
|
+
type: "button",
|
|
434
|
+
className: "tbib-iv-btn",
|
|
435
|
+
onClick: onZoomOut,
|
|
436
|
+
title: "Zoom Out (-)",
|
|
437
|
+
"aria-label": "Zoom Out",
|
|
438
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassMinus })
|
|
439
|
+
}
|
|
440
|
+
),
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "tbib-iv-tabular", title: "Current Zoom Scale", children: [
|
|
442
|
+
Math.round(zoomScale * 100),
|
|
443
|
+
"%"
|
|
444
|
+
] }),
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
446
|
+
"button",
|
|
447
|
+
{
|
|
448
|
+
type: "button",
|
|
449
|
+
className: "tbib-iv-btn",
|
|
450
|
+
onClick: onZoomIn,
|
|
451
|
+
title: "Zoom In (+)",
|
|
452
|
+
"aria-label": "Zoom In",
|
|
453
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faMagnifyingGlassPlus })
|
|
454
|
+
}
|
|
455
|
+
),
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
type: "button",
|
|
460
|
+
className: "tbib-iv-btn",
|
|
461
|
+
onClick: onZoomReset,
|
|
462
|
+
title: "Reset Fit to Screen (0)",
|
|
463
|
+
"aria-label": "Reset Zoom",
|
|
464
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faExpand })
|
|
465
|
+
}
|
|
466
|
+
),
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
type: "button",
|
|
471
|
+
className: "tbib-iv-btn",
|
|
472
|
+
onClick: onRotate,
|
|
473
|
+
title: "Rotate 90\xB0 Clockwise",
|
|
474
|
+
"aria-label": "Rotate Image",
|
|
475
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faRotate })
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
|
|
479
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
480
|
+
DownloadMenu,
|
|
481
|
+
{
|
|
482
|
+
onDownloadAnnotated,
|
|
483
|
+
onDownloadClean,
|
|
484
|
+
onExportJson
|
|
485
|
+
}
|
|
486
|
+
),
|
|
487
|
+
onToggleFullscreen && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
type: "button",
|
|
491
|
+
className: "tbib-iv-btn",
|
|
492
|
+
onClick: onToggleFullscreen,
|
|
493
|
+
title: isFullscreen ? "Exit Fullscreen" : "Enter Fullscreen",
|
|
494
|
+
"aria-label": "Toggle Fullscreen",
|
|
495
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: isFullscreen ? import_free_solid_svg_icons2.faCompressAlt : import_free_solid_svg_icons2.faExpandAlt })
|
|
496
|
+
}
|
|
497
|
+
),
|
|
498
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider" }),
|
|
468
500
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
469
|
-
"
|
|
501
|
+
"button",
|
|
470
502
|
{
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}
|
|
503
|
+
type: "button",
|
|
504
|
+
className: "tbib-iv-btn",
|
|
505
|
+
onClick: onClose,
|
|
506
|
+
title: "Close Viewer (Esc)",
|
|
507
|
+
"aria-label": "Close",
|
|
508
|
+
style: { color: "#ef4444" },
|
|
509
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faXmark, style: { fontSize: "16px" } })
|
|
478
510
|
}
|
|
479
|
-
)
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
511
|
+
)
|
|
512
|
+
] })
|
|
513
|
+
]
|
|
514
|
+
}
|
|
515
|
+
) }),
|
|
516
|
+
showSubtoolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-subtoolbar", role: "region", "aria-label": "Tool customization", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
517
|
+
"div",
|
|
518
|
+
{
|
|
519
|
+
ref: subtoolbarScrollRef,
|
|
520
|
+
className: "tbib-iv-subtoolbar-scroll",
|
|
521
|
+
onTouchStart: handleSubtoolbarTouchStart,
|
|
522
|
+
onTouchMove: handleSubtoolbarTouchMove,
|
|
523
|
+
onTouchEnd: handleSubtoolbarTouchEnd,
|
|
524
|
+
children: [
|
|
525
|
+
activeTool !== "laser" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-thickness-group", children: THICKNESS_OPTIONS.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
491
526
|
"button",
|
|
492
527
|
{
|
|
493
528
|
type: "button",
|
|
494
|
-
className: `tbib-iv-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
529
|
+
className: `tbib-iv-thickness-btn ${strokeWidth === opt.value ? "tbib-iv-thickness-active" : ""}`,
|
|
530
|
+
onClick: () => onStrokeWidthChange(opt.value),
|
|
531
|
+
title: `${opt.label} stroke (${opt.value}px)`,
|
|
532
|
+
children: [
|
|
533
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
534
|
+
"span",
|
|
535
|
+
{
|
|
536
|
+
style: {
|
|
537
|
+
display: "inline-block",
|
|
538
|
+
width: `${Math.min(opt.value * 1.5, 12)}px`,
|
|
539
|
+
height: `${Math.min(opt.value * 1.5, 12)}px`,
|
|
540
|
+
borderRadius: "50%",
|
|
541
|
+
backgroundColor: "currentColor"
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
),
|
|
545
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: opt.label })
|
|
546
|
+
]
|
|
499
547
|
},
|
|
500
|
-
|
|
501
|
-
)
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
548
|
+
opt.value
|
|
549
|
+
)) }),
|
|
550
|
+
activeTool === "laser" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: { fontSize: "11px", color: "var(--tbib-iv-text-muted)", fontStyle: "italic", paddingRight: "4px" }, children: "Laser Beam Color:" }),
|
|
551
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "tbib-iv-divider", style: { height: "16px", margin: "0 2px" } }),
|
|
552
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { display: "inline-flex", alignItems: "center", gap: "6px" }, children: [
|
|
553
|
+
PRESET_COLORS.map((c) => {
|
|
554
|
+
const isSelected = color.toLowerCase() === c.toLowerCase();
|
|
555
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
556
|
+
"button",
|
|
557
|
+
{
|
|
558
|
+
type: "button",
|
|
559
|
+
className: `tbib-iv-swatch-btn ${isSelected ? "tbib-iv-swatch-active" : ""}`,
|
|
560
|
+
style: { backgroundColor: c },
|
|
561
|
+
onClick: () => onColorChange(c),
|
|
562
|
+
title: `Select color: ${c}`,
|
|
563
|
+
"aria-label": `Color ${c}`
|
|
564
|
+
},
|
|
565
|
+
c
|
|
566
|
+
);
|
|
567
|
+
}),
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("label", { className: "tbib-iv-custom-color-btn", title: "Custom Color Picker", children: [
|
|
569
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_fontawesome2.FontAwesomeIcon, { icon: import_free_solid_svg_icons2.faEyeDropper, style: { fontSize: "10px", opacity: 0.8 } }),
|
|
570
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
571
|
+
"input",
|
|
572
|
+
{
|
|
573
|
+
type: "color",
|
|
574
|
+
value: color,
|
|
575
|
+
onChange: (e) => onColorChange(e.target.value),
|
|
576
|
+
className: "tbib-iv-custom-color-input",
|
|
577
|
+
"aria-label": "Custom color picker"
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
] })
|
|
581
|
+
] })
|
|
582
|
+
]
|
|
583
|
+
}
|
|
584
|
+
) })
|
|
518
585
|
] });
|
|
519
586
|
};
|
|
520
587
|
|
|
521
588
|
// src/components/AnnotationCanvas.tsx
|
|
522
|
-
var
|
|
589
|
+
var import_react3 = require("react");
|
|
523
590
|
var import_core = require("@tbib-image-viewer/core");
|
|
524
591
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
525
592
|
var AnnotationCanvas = ({
|
|
@@ -535,17 +602,17 @@ var AnnotationCanvas = ({
|
|
|
535
602
|
onPinchZoom,
|
|
536
603
|
onPinchPan
|
|
537
604
|
}) => {
|
|
538
|
-
const [currentPoints, setCurrentPoints] = (0,
|
|
539
|
-
const isDrawingRef = (0,
|
|
540
|
-
const svgRef = (0,
|
|
541
|
-
const activePointersRef = (0,
|
|
542
|
-
const pinchStartDistRef = (0,
|
|
543
|
-
const pinchStartScaleRef = (0,
|
|
544
|
-
const pinchLastMidpointRef = (0,
|
|
545
|
-
const isMultiTouchRef = (0,
|
|
605
|
+
const [currentPoints, setCurrentPoints] = (0, import_react3.useState)(null);
|
|
606
|
+
const isDrawingRef = (0, import_react3.useRef)(false);
|
|
607
|
+
const svgRef = (0, import_react3.useRef)(null);
|
|
608
|
+
const activePointersRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
|
|
609
|
+
const pinchStartDistRef = (0, import_react3.useRef)(null);
|
|
610
|
+
const pinchStartScaleRef = (0, import_react3.useRef)(1);
|
|
611
|
+
const pinchLastMidpointRef = (0, import_react3.useRef)(null);
|
|
612
|
+
const isMultiTouchRef = (0, import_react3.useRef)(false);
|
|
546
613
|
const isDrawableTool = activeTool === "pen" || activeTool === "highlighter";
|
|
547
614
|
const isEraser = activeTool === "eraser";
|
|
548
|
-
const getNormalizedPoint = (0,
|
|
615
|
+
const getNormalizedPoint = (0, import_react3.useCallback)(
|
|
549
616
|
(e) => {
|
|
550
617
|
const svg = svgRef.current;
|
|
551
618
|
if (!svg || width <= 0 || height <= 0) return null;
|
|
@@ -657,7 +724,7 @@ var AnnotationCanvas = ({
|
|
|
657
724
|
setCurrentPoints(null);
|
|
658
725
|
}
|
|
659
726
|
};
|
|
660
|
-
const currentPathD = (0,
|
|
727
|
+
const currentPathD = (0, import_react3.useMemo)(() => {
|
|
661
728
|
if (!currentPoints || currentPoints.length === 0) return "";
|
|
662
729
|
return (0, import_core.pointsToSvgPath)(currentPoints, width, height);
|
|
663
730
|
}, [currentPoints, width, height]);
|
|
@@ -722,7 +789,7 @@ var AnnotationCanvas = ({
|
|
|
722
789
|
};
|
|
723
790
|
|
|
724
791
|
// src/components/LaserCursorLayer.tsx
|
|
725
|
-
var
|
|
792
|
+
var import_react4 = require("react");
|
|
726
793
|
var import_ogl = require("ogl");
|
|
727
794
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
728
795
|
var MAX_POINTS = 64;
|
|
@@ -863,9 +930,9 @@ var LaserCursorLayer = ({
|
|
|
863
930
|
style,
|
|
864
931
|
...rest
|
|
865
932
|
}) => {
|
|
866
|
-
const containerRef = (0,
|
|
867
|
-
const canvasRef = (0,
|
|
868
|
-
(0,
|
|
933
|
+
const containerRef = (0, import_react4.useRef)(null);
|
|
934
|
+
const canvasRef = (0, import_react4.useRef)(null);
|
|
935
|
+
(0, import_react4.useEffect)(() => {
|
|
869
936
|
const container = containerRef.current;
|
|
870
937
|
const canvas = canvasRef.current;
|
|
871
938
|
if (!container || !canvas || !enabled) return;
|
|
@@ -1048,47 +1115,47 @@ var LaserCursorLayer = ({
|
|
|
1048
1115
|
};
|
|
1049
1116
|
|
|
1050
1117
|
// src/hooks/useImageTransform.ts
|
|
1051
|
-
var
|
|
1118
|
+
var import_react5 = require("react");
|
|
1052
1119
|
var import_core2 = require("@tbib-image-viewer/core");
|
|
1053
1120
|
function useImageTransform() {
|
|
1054
|
-
const [transform, setTransform] = (0,
|
|
1055
|
-
const pinchStartDistRef = (0,
|
|
1056
|
-
const pinchStartScaleRef = (0,
|
|
1057
|
-
const zoomIn = (0,
|
|
1121
|
+
const [transform, setTransform] = (0, import_react5.useState)(import_core2.DEFAULT_TRANSFORM);
|
|
1122
|
+
const pinchStartDistRef = (0, import_react5.useRef)(null);
|
|
1123
|
+
const pinchStartScaleRef = (0, import_react5.useRef)(1);
|
|
1124
|
+
const zoomIn = (0, import_react5.useCallback)(() => {
|
|
1058
1125
|
setTransform((prev) => ({
|
|
1059
1126
|
...prev,
|
|
1060
1127
|
scale: (0, import_core2.clampScale)(prev.scale * 1.25)
|
|
1061
1128
|
}));
|
|
1062
1129
|
}, []);
|
|
1063
|
-
const zoomOut = (0,
|
|
1130
|
+
const zoomOut = (0, import_react5.useCallback)(() => {
|
|
1064
1131
|
setTransform((prev) => ({
|
|
1065
1132
|
...prev,
|
|
1066
1133
|
scale: (0, import_core2.clampScale)(prev.scale / 1.25)
|
|
1067
1134
|
}));
|
|
1068
1135
|
}, []);
|
|
1069
|
-
const resetTransform = (0,
|
|
1136
|
+
const resetTransform = (0, import_react5.useCallback)(() => {
|
|
1070
1137
|
setTransform(import_core2.DEFAULT_TRANSFORM);
|
|
1071
1138
|
}, []);
|
|
1072
|
-
const rotateClockwise = (0,
|
|
1139
|
+
const rotateClockwise = (0, import_react5.useCallback)(() => {
|
|
1073
1140
|
setTransform((prev) => ({
|
|
1074
1141
|
...prev,
|
|
1075
1142
|
rotate: (prev.rotate + 90) % 360
|
|
1076
1143
|
}));
|
|
1077
1144
|
}, []);
|
|
1078
|
-
const panBy = (0,
|
|
1145
|
+
const panBy = (0, import_react5.useCallback)((dx, dy) => {
|
|
1079
1146
|
setTransform((prev) => ({
|
|
1080
1147
|
...prev,
|
|
1081
1148
|
translateX: prev.translateX + dx,
|
|
1082
1149
|
translateY: prev.translateY + dy
|
|
1083
1150
|
}));
|
|
1084
1151
|
}, []);
|
|
1085
|
-
const pinchZoomByRatio = (0,
|
|
1152
|
+
const pinchZoomByRatio = (0, import_react5.useCallback)((startScale, ratio) => {
|
|
1086
1153
|
setTransform((prev) => ({
|
|
1087
1154
|
...prev,
|
|
1088
1155
|
scale: (0, import_core2.clampScale)(startScale * ratio)
|
|
1089
1156
|
}));
|
|
1090
1157
|
}, []);
|
|
1091
|
-
const handleWheel = (0,
|
|
1158
|
+
const handleWheel = (0, import_react5.useCallback)((e) => {
|
|
1092
1159
|
e.preventDefault();
|
|
1093
1160
|
const factor = e.deltaY < 0 ? 1.15 : 1 / 1.15;
|
|
1094
1161
|
setTransform((prev) => ({
|
|
@@ -1096,7 +1163,7 @@ function useImageTransform() {
|
|
|
1096
1163
|
scale: (0, import_core2.clampScale)(prev.scale * factor)
|
|
1097
1164
|
}));
|
|
1098
1165
|
}, []);
|
|
1099
|
-
const handleTouchStart = (0,
|
|
1166
|
+
const handleTouchStart = (0, import_react5.useCallback)((e) => {
|
|
1100
1167
|
if (e.touches.length === 2) {
|
|
1101
1168
|
const t1 = e.touches[0];
|
|
1102
1169
|
const t2 = e.touches[1];
|
|
@@ -1105,7 +1172,7 @@ function useImageTransform() {
|
|
|
1105
1172
|
pinchStartScaleRef.current = transform.scale;
|
|
1106
1173
|
}
|
|
1107
1174
|
}, [transform.scale]);
|
|
1108
|
-
const handleTouchMove = (0,
|
|
1175
|
+
const handleTouchMove = (0, import_react5.useCallback)((e) => {
|
|
1109
1176
|
if (e.touches.length === 2 && pinchStartDistRef.current !== null) {
|
|
1110
1177
|
const t1 = e.touches[0];
|
|
1111
1178
|
const t2 = e.touches[1];
|
|
@@ -1117,7 +1184,7 @@ function useImageTransform() {
|
|
|
1117
1184
|
}));
|
|
1118
1185
|
}
|
|
1119
1186
|
}, []);
|
|
1120
|
-
const handleTouchEnd = (0,
|
|
1187
|
+
const handleTouchEnd = (0, import_react5.useCallback)(() => {
|
|
1121
1188
|
pinchStartDistRef.current = null;
|
|
1122
1189
|
}, []);
|
|
1123
1190
|
return {
|
|
@@ -1155,32 +1222,32 @@ var ImageViewer = ({
|
|
|
1155
1222
|
onAnnotationsChange,
|
|
1156
1223
|
children
|
|
1157
1224
|
}) => {
|
|
1158
|
-
const effectiveSlideId = (0,
|
|
1159
|
-
const [activeTool, setActiveTool] = (0,
|
|
1160
|
-
const [color, setColor] = (0,
|
|
1161
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
1162
|
-
const storeRef = (0,
|
|
1225
|
+
const effectiveSlideId = (0, import_react6.useMemo)(() => slideId || src, [slideId, src]);
|
|
1226
|
+
const [activeTool, setActiveTool] = (0, import_react6.useState)(initialTool);
|
|
1227
|
+
const [color, setColor] = (0, import_react6.useState)(initialColor);
|
|
1228
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react6.useState)(initialStrokeWidth);
|
|
1229
|
+
const storeRef = (0, import_react6.useRef)(
|
|
1163
1230
|
new import_core3.AnnotationStore(
|
|
1164
1231
|
initialAnnotations ? [{ slideId: effectiveSlideId, strokes: initialAnnotations }] : void 0
|
|
1165
1232
|
)
|
|
1166
1233
|
);
|
|
1167
|
-
const [strokes, setStrokes] = (0,
|
|
1234
|
+
const [strokes, setStrokes] = (0, import_react6.useState)(
|
|
1168
1235
|
() => storeRef.current.getStrokes(effectiveSlideId)
|
|
1169
1236
|
);
|
|
1170
|
-
const [canUndo, setCanUndo] = (0,
|
|
1171
|
-
const [canRedo, setCanRedo] = (0,
|
|
1172
|
-
const containerRef = (0,
|
|
1173
|
-
const imgRef = (0,
|
|
1174
|
-
const [imgSize, setImgSize] = (0,
|
|
1175
|
-
const [imageStatus, setImageStatus] = (0,
|
|
1176
|
-
const [reloadKey, setReloadKey] = (0,
|
|
1177
|
-
const effectiveSrc = (0,
|
|
1237
|
+
const [canUndo, setCanUndo] = (0, import_react6.useState)(false);
|
|
1238
|
+
const [canRedo, setCanRedo] = (0, import_react6.useState)(false);
|
|
1239
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
1240
|
+
const imgRef = (0, import_react6.useRef)(null);
|
|
1241
|
+
const [imgSize, setImgSize] = (0, import_react6.useState)({ width: 800, height: 600 });
|
|
1242
|
+
const [imageStatus, setImageStatus] = (0, import_react6.useState)("loading");
|
|
1243
|
+
const [reloadKey, setReloadKey] = (0, import_react6.useState)(0);
|
|
1244
|
+
const effectiveSrc = (0, import_react6.useMemo)(() => {
|
|
1178
1245
|
if (!src) return "";
|
|
1179
1246
|
if (reloadKey === 0) return src;
|
|
1180
1247
|
const sep = src.includes("?") ? "&" : "?";
|
|
1181
1248
|
return `${src}${sep}_reload=${reloadKey}`;
|
|
1182
1249
|
}, [src, reloadKey]);
|
|
1183
|
-
(0,
|
|
1250
|
+
(0, import_react6.useEffect)(() => {
|
|
1184
1251
|
setImageStatus("loading");
|
|
1185
1252
|
if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
|
|
1186
1253
|
setImgSize({
|
|
@@ -1203,9 +1270,9 @@ var ImageViewer = ({
|
|
|
1203
1270
|
handleTouchMove,
|
|
1204
1271
|
handleTouchEnd
|
|
1205
1272
|
} = useImageTransform();
|
|
1206
|
-
const isDraggingRef = (0,
|
|
1207
|
-
const lastMousePosRef = (0,
|
|
1208
|
-
(0,
|
|
1273
|
+
const isDraggingRef = (0, import_react6.useRef)(false);
|
|
1274
|
+
const lastMousePosRef = (0, import_react6.useRef)({ x: 0, y: 0 });
|
|
1275
|
+
(0, import_react6.useEffect)(() => {
|
|
1209
1276
|
const store = storeRef.current;
|
|
1210
1277
|
const unsubscribe = store.subscribe((id, updated) => {
|
|
1211
1278
|
if (id === effectiveSlideId) {
|
|
@@ -1235,13 +1302,13 @@ var ImageViewer = ({
|
|
|
1235
1302
|
setImageStatus("loading");
|
|
1236
1303
|
setReloadKey((prev) => prev + 1);
|
|
1237
1304
|
};
|
|
1238
|
-
const handleStrokeComplete = (0,
|
|
1305
|
+
const handleStrokeComplete = (0, import_react6.useCallback)(
|
|
1239
1306
|
(newStroke) => {
|
|
1240
1307
|
storeRef.current.addStroke(effectiveSlideId, newStroke);
|
|
1241
1308
|
},
|
|
1242
1309
|
[effectiveSlideId]
|
|
1243
1310
|
);
|
|
1244
|
-
const handleEraseStroke = (0,
|
|
1311
|
+
const handleEraseStroke = (0, import_react6.useCallback)(
|
|
1245
1312
|
(point) => {
|
|
1246
1313
|
storeRef.current.removeStrokesNear(
|
|
1247
1314
|
effectiveSlideId,
|
|
@@ -1253,13 +1320,13 @@ var ImageViewer = ({
|
|
|
1253
1320
|
},
|
|
1254
1321
|
[effectiveSlideId]
|
|
1255
1322
|
);
|
|
1256
|
-
const handleUndo = (0,
|
|
1323
|
+
const handleUndo = (0, import_react6.useCallback)(() => {
|
|
1257
1324
|
storeRef.current.undo(effectiveSlideId);
|
|
1258
1325
|
}, [effectiveSlideId]);
|
|
1259
|
-
const handleRedo = (0,
|
|
1326
|
+
const handleRedo = (0, import_react6.useCallback)(() => {
|
|
1260
1327
|
storeRef.current.redo(effectiveSlideId);
|
|
1261
1328
|
}, [effectiveSlideId]);
|
|
1262
|
-
const handleClear = (0,
|
|
1329
|
+
const handleClear = (0, import_react6.useCallback)(() => {
|
|
1263
1330
|
storeRef.current.clear(effectiveSlideId);
|
|
1264
1331
|
}, [effectiveSlideId]);
|
|
1265
1332
|
const handleStagePointerDown = (e) => {
|
|
@@ -1278,7 +1345,7 @@ var ImageViewer = ({
|
|
|
1278
1345
|
const handleStagePointerUp = (e) => {
|
|
1279
1346
|
isDraggingRef.current = false;
|
|
1280
1347
|
};
|
|
1281
|
-
(0,
|
|
1348
|
+
(0, import_react6.useEffect)(() => {
|
|
1282
1349
|
const handleKeyDown = (e) => {
|
|
1283
1350
|
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "z") {
|
|
1284
1351
|
e.preventDefault();
|
|
@@ -1466,7 +1533,7 @@ var ImageViewer = ({
|
|
|
1466
1533
|
};
|
|
1467
1534
|
|
|
1468
1535
|
// src/components/ImageGalleryLightbox.tsx
|
|
1469
|
-
var
|
|
1536
|
+
var import_react8 = require("react");
|
|
1470
1537
|
var import_react_fontawesome4 = require("@fortawesome/react-fontawesome");
|
|
1471
1538
|
var import_free_solid_svg_icons4 = require("@fortawesome/free-solid-svg-icons");
|
|
1472
1539
|
var import_faExclamationTriangle2 = require("@fortawesome/free-solid-svg-icons/faExclamationTriangle");
|
|
@@ -1503,16 +1570,16 @@ var ThumbnailStrip = ({
|
|
|
1503
1570
|
};
|
|
1504
1571
|
|
|
1505
1572
|
// src/hooks/useSwipeGesture.ts
|
|
1506
|
-
var
|
|
1573
|
+
var import_react7 = require("react");
|
|
1507
1574
|
function useSwipeGesture({ onSwipeLeft, onSwipeRight, enabled = true }) {
|
|
1508
|
-
const touchStartXRef = (0,
|
|
1509
|
-
const touchStartYRef = (0,
|
|
1510
|
-
const onTouchStart = (0,
|
|
1575
|
+
const touchStartXRef = (0, import_react7.useRef)(null);
|
|
1576
|
+
const touchStartYRef = (0, import_react7.useRef)(null);
|
|
1577
|
+
const onTouchStart = (0, import_react7.useCallback)((e) => {
|
|
1511
1578
|
if (!enabled || e.touches.length !== 1) return;
|
|
1512
1579
|
touchStartXRef.current = e.touches[0].clientX;
|
|
1513
1580
|
touchStartYRef.current = e.touches[0].clientY;
|
|
1514
1581
|
}, [enabled]);
|
|
1515
|
-
const onTouchEnd = (0,
|
|
1582
|
+
const onTouchEnd = (0, import_react7.useCallback)((e) => {
|
|
1516
1583
|
if (!enabled || touchStartXRef.current === null || touchStartYRef.current === null) return;
|
|
1517
1584
|
const touchEndX = e.changedTouches[0].clientX;
|
|
1518
1585
|
const touchEndY = e.changedTouches[0].clientY;
|
|
@@ -1549,20 +1616,20 @@ var ImageGalleryLightbox = ({
|
|
|
1549
1616
|
initialAnnotations,
|
|
1550
1617
|
onAnnotationsChange
|
|
1551
1618
|
}) => {
|
|
1552
|
-
const [currentIndex, setCurrentIndex] = (0,
|
|
1553
|
-
const [activeTool, setActiveTool] = (0,
|
|
1554
|
-
const [color, setColor] = (0,
|
|
1555
|
-
const [strokeWidth, setStrokeWidth] = (0,
|
|
1556
|
-
const [isFullscreen, setIsFullscreen] = (0,
|
|
1557
|
-
(0,
|
|
1619
|
+
const [currentIndex, setCurrentIndex] = (0, import_react8.useState)(activeIndex);
|
|
1620
|
+
const [activeTool, setActiveTool] = (0, import_react8.useState)(initialTool);
|
|
1621
|
+
const [color, setColor] = (0, import_react8.useState)(initialColor);
|
|
1622
|
+
const [strokeWidth, setStrokeWidth] = (0, import_react8.useState)(4);
|
|
1623
|
+
const [isFullscreen, setIsFullscreen] = (0, import_react8.useState)(false);
|
|
1624
|
+
(0, import_react8.useEffect)(() => {
|
|
1558
1625
|
setCurrentIndex(activeIndex);
|
|
1559
1626
|
}, [activeIndex]);
|
|
1560
1627
|
const currentItem = items[currentIndex] || items[0];
|
|
1561
1628
|
const slideId = currentItem?.id || currentItem?.src || `slide-${currentIndex}`;
|
|
1562
|
-
const storeRef = (0,
|
|
1563
|
-
const [strokes, setStrokes] = (0,
|
|
1564
|
-
const [canUndo, setCanUndo] = (0,
|
|
1565
|
-
const [canRedo, setCanRedo] = (0,
|
|
1629
|
+
const storeRef = (0, import_react8.useRef)(new import_core4.AnnotationStore(initialAnnotations));
|
|
1630
|
+
const [strokes, setStrokes] = (0, import_react8.useState)([]);
|
|
1631
|
+
const [canUndo, setCanUndo] = (0, import_react8.useState)(false);
|
|
1632
|
+
const [canRedo, setCanRedo] = (0, import_react8.useState)(false);
|
|
1566
1633
|
const {
|
|
1567
1634
|
transform,
|
|
1568
1635
|
zoomIn,
|
|
@@ -1576,21 +1643,21 @@ var ImageGalleryLightbox = ({
|
|
|
1576
1643
|
handleTouchMove,
|
|
1577
1644
|
handleTouchEnd
|
|
1578
1645
|
} = useImageTransform();
|
|
1579
|
-
(0,
|
|
1646
|
+
(0, import_react8.useEffect)(() => {
|
|
1580
1647
|
resetTransform();
|
|
1581
1648
|
}, [currentIndex, resetTransform]);
|
|
1582
|
-
const imgRef = (0,
|
|
1583
|
-
const [imgSize, setImgSize] = (0,
|
|
1584
|
-
const [imageStatus, setImageStatus] = (0,
|
|
1585
|
-
const [reloadKey, setReloadKey] = (0,
|
|
1586
|
-
const containerRef = (0,
|
|
1587
|
-
const effectiveSrc = (0,
|
|
1649
|
+
const imgRef = (0, import_react8.useRef)(null);
|
|
1650
|
+
const [imgSize, setImgSize] = (0, import_react8.useState)({ width: 800, height: 600 });
|
|
1651
|
+
const [imageStatus, setImageStatus] = (0, import_react8.useState)("loading");
|
|
1652
|
+
const [reloadKey, setReloadKey] = (0, import_react8.useState)(0);
|
|
1653
|
+
const containerRef = (0, import_react8.useRef)(null);
|
|
1654
|
+
const effectiveSrc = (0, import_react8.useMemo)(() => {
|
|
1588
1655
|
if (!currentItem?.src) return "";
|
|
1589
1656
|
if (reloadKey === 0) return currentItem.src;
|
|
1590
1657
|
const sep = currentItem.src.includes("?") ? "&" : "?";
|
|
1591
1658
|
return `${currentItem.src}${sep}_reload=${reloadKey}`;
|
|
1592
1659
|
}, [currentItem?.src, reloadKey]);
|
|
1593
|
-
(0,
|
|
1660
|
+
(0, import_react8.useEffect)(() => {
|
|
1594
1661
|
setImageStatus("loading");
|
|
1595
1662
|
setReloadKey(0);
|
|
1596
1663
|
if (imgRef.current && imgRef.current.complete && imgRef.current.naturalWidth > 0) {
|
|
@@ -1616,9 +1683,9 @@ var ImageGalleryLightbox = ({
|
|
|
1616
1683
|
setImageStatus("loading");
|
|
1617
1684
|
setReloadKey((prev) => prev + 1);
|
|
1618
1685
|
};
|
|
1619
|
-
const isDraggingRef = (0,
|
|
1620
|
-
const lastMousePosRef = (0,
|
|
1621
|
-
(0,
|
|
1686
|
+
const isDraggingRef = (0, import_react8.useRef)(false);
|
|
1687
|
+
const lastMousePosRef = (0, import_react8.useRef)({ x: 0, y: 0 });
|
|
1688
|
+
(0, import_react8.useEffect)(() => {
|
|
1622
1689
|
const store = storeRef.current;
|
|
1623
1690
|
const updateStrokes = () => {
|
|
1624
1691
|
const s = store.getStrokes(slideId);
|
|
@@ -1635,14 +1702,14 @@ var ImageGalleryLightbox = ({
|
|
|
1635
1702
|
});
|
|
1636
1703
|
return unsubscribe;
|
|
1637
1704
|
}, [slideId, onAnnotationsChange]);
|
|
1638
|
-
const goToNext = (0,
|
|
1705
|
+
const goToNext = (0, import_react8.useCallback)(() => {
|
|
1639
1706
|
if (currentIndex < items.length - 1) {
|
|
1640
1707
|
const nextIdx = currentIndex + 1;
|
|
1641
1708
|
setCurrentIndex(nextIdx);
|
|
1642
1709
|
onIndexChange?.(nextIdx);
|
|
1643
1710
|
}
|
|
1644
1711
|
}, [currentIndex, items.length, onIndexChange]);
|
|
1645
|
-
const goToPrev = (0,
|
|
1712
|
+
const goToPrev = (0, import_react8.useCallback)(() => {
|
|
1646
1713
|
if (currentIndex > 0) {
|
|
1647
1714
|
const prevIdx = currentIndex - 1;
|
|
1648
1715
|
setCurrentIndex(prevIdx);
|
|
@@ -1662,7 +1729,7 @@ var ImageGalleryLightbox = ({
|
|
|
1662
1729
|
handleTouchEnd();
|
|
1663
1730
|
onSwipeTouchEnd(e);
|
|
1664
1731
|
};
|
|
1665
|
-
(0,
|
|
1732
|
+
(0, import_react8.useEffect)(() => {
|
|
1666
1733
|
if (!isOpen) return;
|
|
1667
1734
|
const handleKeyDown = (e) => {
|
|
1668
1735
|
if (e.key === "Escape") {
|
|
@@ -1708,21 +1775,21 @@ var ImageGalleryLightbox = ({
|
|
|
1708
1775
|
const handleStagePointerUp = () => {
|
|
1709
1776
|
isDraggingRef.current = false;
|
|
1710
1777
|
};
|
|
1711
|
-
const handleStrokeComplete = (0,
|
|
1778
|
+
const handleStrokeComplete = (0, import_react8.useCallback)(
|
|
1712
1779
|
(stroke) => {
|
|
1713
1780
|
storeRef.current.addStroke(slideId, stroke);
|
|
1714
1781
|
},
|
|
1715
1782
|
[slideId]
|
|
1716
1783
|
);
|
|
1717
|
-
const handleEraseStroke = (0,
|
|
1784
|
+
const handleEraseStroke = (0, import_react8.useCallback)(
|
|
1718
1785
|
(pt) => {
|
|
1719
1786
|
storeRef.current.removeStrokesNear(slideId, pt, 0.03, import_core4.isPointNearStroke);
|
|
1720
1787
|
},
|
|
1721
1788
|
[slideId]
|
|
1722
1789
|
);
|
|
1723
|
-
const handleUndo = (0,
|
|
1724
|
-
const handleRedo = (0,
|
|
1725
|
-
const handleClear = (0,
|
|
1790
|
+
const handleUndo = (0, import_react8.useCallback)(() => storeRef.current.undo(slideId), [slideId]);
|
|
1791
|
+
const handleRedo = (0, import_react8.useCallback)(() => storeRef.current.redo(slideId), [slideId]);
|
|
1792
|
+
const handleClear = (0, import_react8.useCallback)(() => storeRef.current.clear(slideId), [slideId]);
|
|
1726
1793
|
const toggleFullscreen = () => {
|
|
1727
1794
|
if (!document.fullscreenElement) {
|
|
1728
1795
|
containerRef.current?.requestFullscreen?.();
|
|
@@ -1937,7 +2004,7 @@ var ImageGalleryLightbox = ({
|
|
|
1937
2004
|
};
|
|
1938
2005
|
|
|
1939
2006
|
// src/components/ColorPicker.tsx
|
|
1940
|
-
var
|
|
2007
|
+
var import_react9 = require("react");
|
|
1941
2008
|
var import_react_fontawesome5 = require("@fortawesome/react-fontawesome");
|
|
1942
2009
|
var import_free_solid_svg_icons5 = require("@fortawesome/free-solid-svg-icons");
|
|
1943
2010
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
@@ -1960,9 +2027,9 @@ var PRESET_COLORS2 = [
|
|
|
1960
2027
|
// Slate / Black
|
|
1961
2028
|
];
|
|
1962
2029
|
var ColorPicker = ({ color, onChange }) => {
|
|
1963
|
-
const [isOpen, setIsOpen] = (0,
|
|
1964
|
-
const containerRef = (0,
|
|
1965
|
-
(0,
|
|
2030
|
+
const [isOpen, setIsOpen] = (0, import_react9.useState)(false);
|
|
2031
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
2032
|
+
(0, import_react9.useEffect)(() => {
|
|
1966
2033
|
const handleOutsideClick = (e) => {
|
|
1967
2034
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
1968
2035
|
setIsOpen(false);
|
|
@@ -2020,7 +2087,7 @@ var ColorPicker = ({ color, onChange }) => {
|
|
|
2020
2087
|
};
|
|
2021
2088
|
|
|
2022
2089
|
// src/components/StrokeWidthPicker.tsx
|
|
2023
|
-
var
|
|
2090
|
+
var import_react10 = require("react");
|
|
2024
2091
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
2025
2092
|
var WIDTH_OPTIONS = [
|
|
2026
2093
|
{ label: "Fine (2px)", value: 2, iconSize: "6px" },
|
|
@@ -2032,9 +2099,9 @@ var StrokeWidthPicker = ({
|
|
|
2032
2099
|
strokeWidth,
|
|
2033
2100
|
onChange
|
|
2034
2101
|
}) => {
|
|
2035
|
-
const [isOpen, setIsOpen] = (0,
|
|
2036
|
-
const containerRef = (0,
|
|
2037
|
-
(0,
|
|
2102
|
+
const [isOpen, setIsOpen] = (0, import_react10.useState)(false);
|
|
2103
|
+
const containerRef = (0, import_react10.useRef)(null);
|
|
2104
|
+
(0, import_react10.useEffect)(() => {
|
|
2038
2105
|
const handleOutsideClick = (e) => {
|
|
2039
2106
|
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
2040
2107
|
setIsOpen(false);
|