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