hazo_pdf 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +376 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.js +369 -89
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +404 -0
- package/dist/styles/index.css.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from "./chunk-2POHPGR3.js";
|
|
9
9
|
|
|
10
10
|
// src/components/pdf_viewer/pdf_viewer.tsx
|
|
11
|
-
import { useState as
|
|
12
|
-
import { Save, Undo2 as Undo22, Redo2 } from "lucide-react";
|
|
11
|
+
import { useState as useState6, useEffect as useEffect6, useRef as useRef7, useCallback as useCallback2 } from "react";
|
|
12
|
+
import { Save, Undo2 as Undo22, Redo2, PanelRight } from "lucide-react";
|
|
13
13
|
|
|
14
14
|
// src/components/pdf_viewer/pdf_worker_setup.ts
|
|
15
15
|
var worker_configured = false;
|
|
@@ -1501,6 +1501,232 @@ var TextAnnotationDialog = ({
|
|
|
1501
1501
|
return createPortal2(dialog_content, document.body);
|
|
1502
1502
|
};
|
|
1503
1503
|
|
|
1504
|
+
// src/components/pdf_viewer/metadata_sidepanel.tsx
|
|
1505
|
+
import { useState as useState5, useRef as useRef6, useEffect as useEffect5 } from "react";
|
|
1506
|
+
import { ChevronLeft, ChevronRight, ChevronDown, ChevronUp, Pencil, CheckCircle2, X as X2 } from "lucide-react";
|
|
1507
|
+
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1508
|
+
var FormatText = ({ style, children, className }) => {
|
|
1509
|
+
const baseClassName = cn("cls_metadata_text", className);
|
|
1510
|
+
switch (style) {
|
|
1511
|
+
case "h1":
|
|
1512
|
+
return /* @__PURE__ */ jsx6("h1", { className: cn(baseClassName, "cls_metadata_h1"), children });
|
|
1513
|
+
case "h2":
|
|
1514
|
+
return /* @__PURE__ */ jsx6("h2", { className: cn(baseClassName, "cls_metadata_h2"), children });
|
|
1515
|
+
case "h3":
|
|
1516
|
+
return /* @__PURE__ */ jsx6("h3", { className: cn(baseClassName, "cls_metadata_h3"), children });
|
|
1517
|
+
case "h4":
|
|
1518
|
+
return /* @__PURE__ */ jsx6("h4", { className: cn(baseClassName, "cls_metadata_h4"), children });
|
|
1519
|
+
case "h5":
|
|
1520
|
+
return /* @__PURE__ */ jsx6("h5", { className: cn(baseClassName, "cls_metadata_h5"), children });
|
|
1521
|
+
case "body":
|
|
1522
|
+
default:
|
|
1523
|
+
return /* @__PURE__ */ jsx6("p", { className: cn(baseClassName, "cls_metadata_body"), children });
|
|
1524
|
+
}
|
|
1525
|
+
};
|
|
1526
|
+
var MetadataSidepanel = ({
|
|
1527
|
+
is_open,
|
|
1528
|
+
on_toggle,
|
|
1529
|
+
metadata,
|
|
1530
|
+
on_change,
|
|
1531
|
+
width,
|
|
1532
|
+
on_width_change
|
|
1533
|
+
}) => {
|
|
1534
|
+
const [expanded_items, setExpandedItems] = useState5(/* @__PURE__ */ new Set());
|
|
1535
|
+
const [editing_index, setEditingIndex] = useState5(null);
|
|
1536
|
+
const [edit_value, setEditValue] = useState5("");
|
|
1537
|
+
const resize_ref = useRef6(null);
|
|
1538
|
+
const is_resizing_ref = useRef6(false);
|
|
1539
|
+
const start_width_ref = useRef6(0);
|
|
1540
|
+
const start_x_ref = useRef6(0);
|
|
1541
|
+
const toggle_item = (index) => {
|
|
1542
|
+
setExpandedItems((prev) => {
|
|
1543
|
+
const next = new Set(prev);
|
|
1544
|
+
if (next.has(index)) {
|
|
1545
|
+
next.delete(index);
|
|
1546
|
+
} else {
|
|
1547
|
+
next.add(index);
|
|
1548
|
+
}
|
|
1549
|
+
return next;
|
|
1550
|
+
});
|
|
1551
|
+
};
|
|
1552
|
+
const start_edit = (index, current_value) => {
|
|
1553
|
+
setEditingIndex(index);
|
|
1554
|
+
setEditValue(current_value);
|
|
1555
|
+
};
|
|
1556
|
+
const cancel_edit = () => {
|
|
1557
|
+
setEditingIndex(null);
|
|
1558
|
+
setEditValue("");
|
|
1559
|
+
};
|
|
1560
|
+
const save_edit = () => {
|
|
1561
|
+
if (editing_index === null) return;
|
|
1562
|
+
const updated_data = [...metadata.data];
|
|
1563
|
+
const updated_row = { ...updated_data[editing_index], value: edit_value };
|
|
1564
|
+
updated_data[editing_index] = updated_row;
|
|
1565
|
+
const updated_metadata = {
|
|
1566
|
+
header: metadata.header,
|
|
1567
|
+
data: updated_data,
|
|
1568
|
+
footer: metadata.footer
|
|
1569
|
+
};
|
|
1570
|
+
const result = on_change(updated_row, updated_metadata);
|
|
1571
|
+
setEditingIndex(null);
|
|
1572
|
+
setEditValue("");
|
|
1573
|
+
};
|
|
1574
|
+
const handle_resize_start = (e) => {
|
|
1575
|
+
e.preventDefault();
|
|
1576
|
+
e.stopPropagation();
|
|
1577
|
+
is_resizing_ref.current = true;
|
|
1578
|
+
start_width_ref.current = width;
|
|
1579
|
+
start_x_ref.current = e.clientX;
|
|
1580
|
+
document.addEventListener("mousemove", handle_resize_move);
|
|
1581
|
+
document.addEventListener("mouseup", handle_resize_end);
|
|
1582
|
+
document.body.style.cursor = "ew-resize";
|
|
1583
|
+
document.body.style.userSelect = "none";
|
|
1584
|
+
};
|
|
1585
|
+
const handle_resize_move = (e) => {
|
|
1586
|
+
if (!is_resizing_ref.current) return;
|
|
1587
|
+
const delta_x = start_x_ref.current - e.clientX;
|
|
1588
|
+
const new_width = Math.max(200, Math.min(800, start_width_ref.current + delta_x));
|
|
1589
|
+
on_width_change(new_width);
|
|
1590
|
+
};
|
|
1591
|
+
const handle_resize_end = () => {
|
|
1592
|
+
is_resizing_ref.current = false;
|
|
1593
|
+
document.removeEventListener("mousemove", handle_resize_move);
|
|
1594
|
+
document.removeEventListener("mouseup", handle_resize_end);
|
|
1595
|
+
document.body.style.cursor = "";
|
|
1596
|
+
document.body.style.userSelect = "";
|
|
1597
|
+
};
|
|
1598
|
+
useEffect5(() => {
|
|
1599
|
+
return () => {
|
|
1600
|
+
document.removeEventListener("mousemove", handle_resize_move);
|
|
1601
|
+
document.removeEventListener("mouseup", handle_resize_end);
|
|
1602
|
+
document.body.style.cursor = "";
|
|
1603
|
+
document.body.style.userSelect = "";
|
|
1604
|
+
};
|
|
1605
|
+
}, []);
|
|
1606
|
+
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1607
|
+
!is_open && /* @__PURE__ */ jsx6(
|
|
1608
|
+
"button",
|
|
1609
|
+
{
|
|
1610
|
+
type: "button",
|
|
1611
|
+
onClick: on_toggle,
|
|
1612
|
+
className: "cls_metadata_sidepanel_toggle_edge",
|
|
1613
|
+
"aria-label": "Open metadata panel",
|
|
1614
|
+
title: "Open metadata panel",
|
|
1615
|
+
children: /* @__PURE__ */ jsx6(ChevronLeft, { size: 20 })
|
|
1616
|
+
}
|
|
1617
|
+
),
|
|
1618
|
+
/* @__PURE__ */ jsxs5(
|
|
1619
|
+
"div",
|
|
1620
|
+
{
|
|
1621
|
+
className: cn("cls_metadata_sidepanel", is_open && "cls_metadata_sidepanel_open"),
|
|
1622
|
+
style: { width: is_open ? `${width}px` : "0", display: is_open ? "flex" : "none" },
|
|
1623
|
+
children: [
|
|
1624
|
+
is_open && /* @__PURE__ */ jsx6(
|
|
1625
|
+
"div",
|
|
1626
|
+
{
|
|
1627
|
+
ref: resize_ref,
|
|
1628
|
+
className: "cls_metadata_sidepanel_resize_handle",
|
|
1629
|
+
onMouseDown: handle_resize_start,
|
|
1630
|
+
"aria-label": "Resize panel"
|
|
1631
|
+
}
|
|
1632
|
+
),
|
|
1633
|
+
/* @__PURE__ */ jsxs5("div", { className: "cls_metadata_sidepanel_content", children: [
|
|
1634
|
+
/* @__PURE__ */ jsxs5("div", { className: "cls_metadata_sidepanel_header", children: [
|
|
1635
|
+
/* @__PURE__ */ jsx6("span", { className: "cls_metadata_sidepanel_title", children: "Metadata" }),
|
|
1636
|
+
/* @__PURE__ */ jsx6(
|
|
1637
|
+
"button",
|
|
1638
|
+
{
|
|
1639
|
+
type: "button",
|
|
1640
|
+
onClick: on_toggle,
|
|
1641
|
+
className: "cls_metadata_sidepanel_close",
|
|
1642
|
+
"aria-label": "Close metadata panel",
|
|
1643
|
+
children: /* @__PURE__ */ jsx6(ChevronRight, { size: 20 })
|
|
1644
|
+
}
|
|
1645
|
+
)
|
|
1646
|
+
] }),
|
|
1647
|
+
/* @__PURE__ */ jsxs5("div", { className: "cls_metadata_sidepanel_body", children: [
|
|
1648
|
+
metadata.header && metadata.header.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cls_metadata_section cls_metadata_header_section", children: metadata.header.map((item, index) => /* @__PURE__ */ jsx6(FormatText, { style: item.style, children: item.label }, `header-${index}`)) }),
|
|
1649
|
+
metadata.data && metadata.data.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cls_metadata_section cls_metadata_data_section", children: metadata.data.map((item, index) => {
|
|
1650
|
+
const is_expanded = expanded_items.has(index);
|
|
1651
|
+
const is_editing = editing_index === index;
|
|
1652
|
+
return /* @__PURE__ */ jsxs5("div", { className: "cls_metadata_accordion", children: [
|
|
1653
|
+
/* @__PURE__ */ jsxs5(
|
|
1654
|
+
"button",
|
|
1655
|
+
{
|
|
1656
|
+
type: "button",
|
|
1657
|
+
onClick: () => toggle_item(index),
|
|
1658
|
+
className: "cls_metadata_accordion_header",
|
|
1659
|
+
"aria-expanded": is_expanded,
|
|
1660
|
+
children: [
|
|
1661
|
+
/* @__PURE__ */ jsx6(FormatText, { style: item.style, className: "cls_metadata_accordion_label", children: item.label }),
|
|
1662
|
+
is_expanded ? /* @__PURE__ */ jsx6(ChevronUp, { className: "cls_metadata_accordion_icon", size: 16 }) : /* @__PURE__ */ jsx6(ChevronDown, { className: "cls_metadata_accordion_icon", size: 16 })
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
),
|
|
1666
|
+
is_expanded && /* @__PURE__ */ jsx6("div", { className: "cls_metadata_accordion_content", children: is_editing ? /* @__PURE__ */ jsxs5("div", { className: "cls_metadata_edit_mode", children: [
|
|
1667
|
+
/* @__PURE__ */ jsx6(
|
|
1668
|
+
"input",
|
|
1669
|
+
{
|
|
1670
|
+
type: "text",
|
|
1671
|
+
value: edit_value,
|
|
1672
|
+
onChange: (e) => setEditValue(e.target.value),
|
|
1673
|
+
className: "cls_metadata_edit_input",
|
|
1674
|
+
autoFocus: true,
|
|
1675
|
+
onKeyDown: (e) => {
|
|
1676
|
+
if (e.key === "Enter") {
|
|
1677
|
+
save_edit();
|
|
1678
|
+
} else if (e.key === "Escape") {
|
|
1679
|
+
cancel_edit();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
),
|
|
1684
|
+
/* @__PURE__ */ jsxs5("div", { className: "cls_metadata_edit_buttons", children: [
|
|
1685
|
+
/* @__PURE__ */ jsx6(
|
|
1686
|
+
"button",
|
|
1687
|
+
{
|
|
1688
|
+
type: "button",
|
|
1689
|
+
onClick: save_edit,
|
|
1690
|
+
className: "cls_metadata_edit_save",
|
|
1691
|
+
"aria-label": "Save",
|
|
1692
|
+
children: /* @__PURE__ */ jsx6(CheckCircle2, { size: 18, className: "text-green-600" })
|
|
1693
|
+
}
|
|
1694
|
+
),
|
|
1695
|
+
/* @__PURE__ */ jsx6(
|
|
1696
|
+
"button",
|
|
1697
|
+
{
|
|
1698
|
+
type: "button",
|
|
1699
|
+
onClick: cancel_edit,
|
|
1700
|
+
className: "cls_metadata_edit_cancel",
|
|
1701
|
+
"aria-label": "Cancel",
|
|
1702
|
+
children: /* @__PURE__ */ jsx6(X2, { size: 18, className: "text-red-600" })
|
|
1703
|
+
}
|
|
1704
|
+
)
|
|
1705
|
+
] })
|
|
1706
|
+
] }) : /* @__PURE__ */ jsxs5("div", { className: "cls_metadata_value_container", children: [
|
|
1707
|
+
/* @__PURE__ */ jsx6("span", { className: "cls_metadata_value", children: item.value }),
|
|
1708
|
+
item.editable && /* @__PURE__ */ jsx6(
|
|
1709
|
+
"button",
|
|
1710
|
+
{
|
|
1711
|
+
type: "button",
|
|
1712
|
+
onClick: () => start_edit(index, item.value),
|
|
1713
|
+
className: "cls_metadata_edit_button",
|
|
1714
|
+
"aria-label": "Edit",
|
|
1715
|
+
children: /* @__PURE__ */ jsx6(Pencil, { size: 16 })
|
|
1716
|
+
}
|
|
1717
|
+
)
|
|
1718
|
+
] }) })
|
|
1719
|
+
] }, `data-${index}`);
|
|
1720
|
+
}) }),
|
|
1721
|
+
metadata.footer && metadata.footer.length > 0 && /* @__PURE__ */ jsx6("div", { className: "cls_metadata_section cls_metadata_footer_section", children: metadata.footer.map((item, index) => /* @__PURE__ */ jsx6(FormatText, { style: item.style, children: item.label }, `footer-${index}`)) })
|
|
1722
|
+
] })
|
|
1723
|
+
] })
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
)
|
|
1727
|
+
] });
|
|
1728
|
+
};
|
|
1729
|
+
|
|
1504
1730
|
// src/utils/config_loader.ts
|
|
1505
1731
|
function parse_ini_browser(ini_text) {
|
|
1506
1732
|
const result = {};
|
|
@@ -1908,7 +2134,7 @@ function load_pdf_config(config_file) {
|
|
|
1908
2134
|
}
|
|
1909
2135
|
|
|
1910
2136
|
// src/components/pdf_viewer/pdf_viewer.tsx
|
|
1911
|
-
import { Fragment as
|
|
2137
|
+
import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1912
2138
|
var PdfViewer = ({
|
|
1913
2139
|
url,
|
|
1914
2140
|
className = "",
|
|
@@ -1924,17 +2150,22 @@ var PdfViewer = ({
|
|
|
1924
2150
|
config_file,
|
|
1925
2151
|
append_timestamp_to_text_edits,
|
|
1926
2152
|
annotation_text_suffix_fixed_text,
|
|
1927
|
-
right_click_custom_stamps
|
|
2153
|
+
right_click_custom_stamps,
|
|
2154
|
+
sidepanel_metadata_enabled = false,
|
|
2155
|
+
metadata_input,
|
|
2156
|
+
on_metadata_change
|
|
1928
2157
|
}) => {
|
|
1929
|
-
const [pdf_document, setPdfDocument] =
|
|
1930
|
-
const [loading, setLoading] =
|
|
1931
|
-
const [error, setError] =
|
|
1932
|
-
const [scale, setScale] =
|
|
1933
|
-
const [annotations, setAnnotations] =
|
|
1934
|
-
const [current_tool, setCurrentTool] =
|
|
1935
|
-
const [saving, setSaving] =
|
|
1936
|
-
const
|
|
1937
|
-
|
|
2158
|
+
const [pdf_document, setPdfDocument] = useState6(null);
|
|
2159
|
+
const [loading, setLoading] = useState6(true);
|
|
2160
|
+
const [error, setError] = useState6(null);
|
|
2161
|
+
const [scale, setScale] = useState6(initial_scale);
|
|
2162
|
+
const [annotations, setAnnotations] = useState6(initial_annotations);
|
|
2163
|
+
const [current_tool, setCurrentTool] = useState6(null);
|
|
2164
|
+
const [saving, setSaving] = useState6(false);
|
|
2165
|
+
const [sidepanel_open, setSidepanelOpen] = useState6(false);
|
|
2166
|
+
const [sidepanel_width, setSidepanelWidth] = useState6(300);
|
|
2167
|
+
const config_ref = useRef7(null);
|
|
2168
|
+
useEffect6(() => {
|
|
1938
2169
|
if (!config_file) {
|
|
1939
2170
|
config_ref.current = load_pdf_config();
|
|
1940
2171
|
return;
|
|
@@ -2196,12 +2427,12 @@ ${suffix_line}`;
|
|
|
2196
2427
|
});
|
|
2197
2428
|
return result;
|
|
2198
2429
|
};
|
|
2199
|
-
const [history, setHistory] =
|
|
2200
|
-
const [history_index, setHistoryIndex] =
|
|
2201
|
-
const history_ref =
|
|
2202
|
-
const [context_menu, setContextMenu] =
|
|
2203
|
-
const [text_dialog, setTextDialog] =
|
|
2204
|
-
|
|
2430
|
+
const [history, setHistory] = useState6([initial_annotations]);
|
|
2431
|
+
const [history_index, setHistoryIndex] = useState6(0);
|
|
2432
|
+
const history_ref = useRef7({ saving: false });
|
|
2433
|
+
const [context_menu, setContextMenu] = useState6(null);
|
|
2434
|
+
const [text_dialog, setTextDialog] = useState6(null);
|
|
2435
|
+
useEffect6(() => {
|
|
2205
2436
|
if (history.length === 1 && history[0].length === 0 && initial_annotations.length === 0) {
|
|
2206
2437
|
return;
|
|
2207
2438
|
}
|
|
@@ -2209,7 +2440,7 @@ ${suffix_line}`;
|
|
|
2209
2440
|
setHistoryIndex(0);
|
|
2210
2441
|
history_ref.current.saving = false;
|
|
2211
2442
|
}, [url]);
|
|
2212
|
-
|
|
2443
|
+
useEffect6(() => {
|
|
2213
2444
|
if (typeof window === "undefined") {
|
|
2214
2445
|
return;
|
|
2215
2446
|
}
|
|
@@ -2307,7 +2538,7 @@ ${suffix_line}`;
|
|
|
2307
2538
|
}, 0);
|
|
2308
2539
|
}
|
|
2309
2540
|
}, [history_index, history]);
|
|
2310
|
-
|
|
2541
|
+
useEffect6(() => {
|
|
2311
2542
|
const handle_keydown = (e) => {
|
|
2312
2543
|
const target = e.target;
|
|
2313
2544
|
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) {
|
|
@@ -2336,6 +2567,18 @@ ${suffix_line}`;
|
|
|
2336
2567
|
const handle_zoom_reset = () => {
|
|
2337
2568
|
setScale(1);
|
|
2338
2569
|
};
|
|
2570
|
+
const handle_sidepanel_toggle = () => {
|
|
2571
|
+
setSidepanelOpen((prev) => !prev);
|
|
2572
|
+
};
|
|
2573
|
+
const handle_sidepanel_width_change = (width) => {
|
|
2574
|
+
setSidepanelWidth(width);
|
|
2575
|
+
};
|
|
2576
|
+
const handle_metadata_change = (updatedRow, allData) => {
|
|
2577
|
+
if (on_metadata_change) {
|
|
2578
|
+
return on_metadata_change(updatedRow, allData);
|
|
2579
|
+
}
|
|
2580
|
+
return { updatedRow, allData };
|
|
2581
|
+
};
|
|
2339
2582
|
const handle_save = async () => {
|
|
2340
2583
|
if (annotations.length === 0) {
|
|
2341
2584
|
console.warn("PdfViewer: No annotations to save");
|
|
@@ -2367,21 +2610,21 @@ ${suffix_line}`;
|
|
|
2367
2610
|
}
|
|
2368
2611
|
};
|
|
2369
2612
|
if (loading) {
|
|
2370
|
-
return /* @__PURE__ */
|
|
2613
|
+
return /* @__PURE__ */ jsx7("div", { className: cn("cls_pdf_viewer", "cls_pdf_viewer_loading", className), children: /* @__PURE__ */ jsx7("div", { className: "cls_pdf_viewer_spinner", children: "Loading PDF document..." }) });
|
|
2371
2614
|
}
|
|
2372
2615
|
if (error) {
|
|
2373
|
-
return /* @__PURE__ */
|
|
2616
|
+
return /* @__PURE__ */ jsx7("div", { className: cn("cls_pdf_viewer", "cls_pdf_viewer_error", className), children: /* @__PURE__ */ jsxs6("div", { className: "cls_pdf_viewer_error_message", children: [
|
|
2374
2617
|
"Error loading PDF: ",
|
|
2375
2618
|
error.message
|
|
2376
2619
|
] }) });
|
|
2377
2620
|
}
|
|
2378
2621
|
if (!pdf_document) {
|
|
2379
|
-
return /* @__PURE__ */
|
|
2622
|
+
return /* @__PURE__ */ jsx7("div", { className: cn("cls_pdf_viewer", className), children: /* @__PURE__ */ jsx7("div", { className: "cls_pdf_viewer_no_document", children: "No PDF document loaded" }) });
|
|
2380
2623
|
}
|
|
2381
|
-
return /* @__PURE__ */
|
|
2382
|
-
/* @__PURE__ */
|
|
2383
|
-
/* @__PURE__ */
|
|
2384
|
-
/* @__PURE__ */
|
|
2624
|
+
return /* @__PURE__ */ jsxs6("div", { className: cn("cls_pdf_viewer", className), children: [
|
|
2625
|
+
/* @__PURE__ */ jsxs6("div", { className: "cls_pdf_viewer_toolbar", children: [
|
|
2626
|
+
/* @__PURE__ */ jsxs6("div", { className: "cls_pdf_viewer_toolbar_group", children: [
|
|
2627
|
+
/* @__PURE__ */ jsx7(
|
|
2385
2628
|
"button",
|
|
2386
2629
|
{
|
|
2387
2630
|
type: "button",
|
|
@@ -2391,11 +2634,11 @@ ${suffix_line}`;
|
|
|
2391
2634
|
children: "\u2212"
|
|
2392
2635
|
}
|
|
2393
2636
|
),
|
|
2394
|
-
/* @__PURE__ */
|
|
2637
|
+
/* @__PURE__ */ jsxs6("span", { className: "cls_pdf_viewer_zoom_level", children: [
|
|
2395
2638
|
Math.round(scale * 100),
|
|
2396
2639
|
"%"
|
|
2397
2640
|
] }),
|
|
2398
|
-
/* @__PURE__ */
|
|
2641
|
+
/* @__PURE__ */ jsx7(
|
|
2399
2642
|
"button",
|
|
2400
2643
|
{
|
|
2401
2644
|
type: "button",
|
|
@@ -2405,7 +2648,7 @@ ${suffix_line}`;
|
|
|
2405
2648
|
children: "+"
|
|
2406
2649
|
}
|
|
2407
2650
|
),
|
|
2408
|
-
/* @__PURE__ */
|
|
2651
|
+
/* @__PURE__ */ jsx7(
|
|
2409
2652
|
"button",
|
|
2410
2653
|
{
|
|
2411
2654
|
type: "button",
|
|
@@ -2416,7 +2659,7 @@ ${suffix_line}`;
|
|
|
2416
2659
|
}
|
|
2417
2660
|
)
|
|
2418
2661
|
] }),
|
|
2419
|
-
/* @__PURE__ */
|
|
2662
|
+
/* @__PURE__ */ jsx7("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsx7(
|
|
2420
2663
|
"button",
|
|
2421
2664
|
{
|
|
2422
2665
|
type: "button",
|
|
@@ -2429,8 +2672,8 @@ ${suffix_line}`;
|
|
|
2429
2672
|
children: "Square"
|
|
2430
2673
|
}
|
|
2431
2674
|
) }),
|
|
2432
|
-
/* @__PURE__ */
|
|
2433
|
-
/* @__PURE__ */
|
|
2675
|
+
/* @__PURE__ */ jsxs6("div", { className: "cls_pdf_viewer_toolbar_group", children: [
|
|
2676
|
+
/* @__PURE__ */ jsxs6(
|
|
2434
2677
|
"button",
|
|
2435
2678
|
{
|
|
2436
2679
|
type: "button",
|
|
@@ -2443,12 +2686,12 @@ ${suffix_line}`;
|
|
|
2443
2686
|
"aria-label": "Undo last annotation",
|
|
2444
2687
|
title: "Undo (Ctrl+Z)",
|
|
2445
2688
|
children: [
|
|
2446
|
-
/* @__PURE__ */
|
|
2447
|
-
/* @__PURE__ */
|
|
2689
|
+
/* @__PURE__ */ jsx7(Undo22, { className: "cls_pdf_viewer_toolbar_icon", size: 16 }),
|
|
2690
|
+
/* @__PURE__ */ jsx7("span", { className: "cls_pdf_viewer_toolbar_button_text", children: "Undo" })
|
|
2448
2691
|
]
|
|
2449
2692
|
}
|
|
2450
2693
|
),
|
|
2451
|
-
/* @__PURE__ */
|
|
2694
|
+
/* @__PURE__ */ jsxs6(
|
|
2452
2695
|
"button",
|
|
2453
2696
|
{
|
|
2454
2697
|
type: "button",
|
|
@@ -2461,13 +2704,13 @@ ${suffix_line}`;
|
|
|
2461
2704
|
"aria-label": "Redo last undone annotation",
|
|
2462
2705
|
title: "Redo (Ctrl+Y)",
|
|
2463
2706
|
children: [
|
|
2464
|
-
/* @__PURE__ */
|
|
2465
|
-
/* @__PURE__ */
|
|
2707
|
+
/* @__PURE__ */ jsx7(Redo2, { className: "cls_pdf_viewer_toolbar_icon", size: 16 }),
|
|
2708
|
+
/* @__PURE__ */ jsx7("span", { className: "cls_pdf_viewer_toolbar_button_text", children: "Redo" })
|
|
2466
2709
|
]
|
|
2467
2710
|
}
|
|
2468
2711
|
)
|
|
2469
2712
|
] }),
|
|
2470
|
-
/* @__PURE__ */
|
|
2713
|
+
/* @__PURE__ */ jsx7("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsxs6(
|
|
2471
2714
|
"button",
|
|
2472
2715
|
{
|
|
2473
2716
|
type: "button",
|
|
@@ -2481,58 +2724,95 @@ ${suffix_line}`;
|
|
|
2481
2724
|
"aria-label": "Save annotations to PDF",
|
|
2482
2725
|
title: annotations.length === 0 ? "No annotations to save" : "Save annotations to PDF",
|
|
2483
2726
|
children: [
|
|
2484
|
-
/* @__PURE__ */
|
|
2485
|
-
/* @__PURE__ */
|
|
2727
|
+
/* @__PURE__ */ jsx7(Save, { className: "cls_pdf_viewer_toolbar_icon", size: 16 }),
|
|
2728
|
+
/* @__PURE__ */ jsx7("span", { className: "cls_pdf_viewer_toolbar_button_text", children: saving ? "Saving..." : "Save" })
|
|
2729
|
+
]
|
|
2730
|
+
}
|
|
2731
|
+
) }),
|
|
2732
|
+
sidepanel_metadata_enabled && metadata_input && /* @__PURE__ */ jsx7("div", { className: "cls_pdf_viewer_toolbar_group", children: /* @__PURE__ */ jsxs6(
|
|
2733
|
+
"button",
|
|
2734
|
+
{
|
|
2735
|
+
type: "button",
|
|
2736
|
+
onClick: handle_sidepanel_toggle,
|
|
2737
|
+
className: cn(
|
|
2738
|
+
"cls_pdf_viewer_toolbar_button",
|
|
2739
|
+
sidepanel_open && "cls_pdf_viewer_toolbar_button_active"
|
|
2740
|
+
),
|
|
2741
|
+
"aria-label": "Toggle metadata panel",
|
|
2742
|
+
title: "Toggle metadata panel",
|
|
2743
|
+
children: [
|
|
2744
|
+
/* @__PURE__ */ jsx7(PanelRight, { className: "cls_pdf_viewer_toolbar_icon", size: 16 }),
|
|
2745
|
+
/* @__PURE__ */ jsx7("span", { className: "cls_pdf_viewer_toolbar_button_text", children: "Metadata" })
|
|
2486
2746
|
]
|
|
2487
2747
|
}
|
|
2488
2748
|
) })
|
|
2489
2749
|
] }),
|
|
2490
|
-
/* @__PURE__ */
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2750
|
+
/* @__PURE__ */ jsxs6("div", { className: cn("cls_pdf_viewer_content_wrapper", sidepanel_open && "cls_pdf_viewer_content_wrapper_with_sidepanel"), children: [
|
|
2751
|
+
/* @__PURE__ */ jsx7(
|
|
2752
|
+
"div",
|
|
2753
|
+
{
|
|
2754
|
+
className: cn("cls_pdf_viewer_content", sidepanel_open && "cls_pdf_viewer_content_with_sidepanel"),
|
|
2755
|
+
style: sidepanel_open ? { width: `calc(100% - ${sidepanel_width}px)` } : void 0,
|
|
2756
|
+
children: /* @__PURE__ */ jsx7(
|
|
2757
|
+
PdfViewerLayout,
|
|
2758
|
+
{
|
|
2759
|
+
pdf_document,
|
|
2760
|
+
scale,
|
|
2761
|
+
annotations,
|
|
2762
|
+
current_tool,
|
|
2763
|
+
background_color: effective_background_color,
|
|
2764
|
+
config: config_ref.current,
|
|
2765
|
+
on_annotation_create: handle_annotation_create,
|
|
2766
|
+
on_annotation_click: (annotation, screen_x, screen_y, mapper) => {
|
|
2767
|
+
console.log(
|
|
2768
|
+
`\u{1F7E0} [AnnotationClick] opening editor id=${annotation.id}, page=${annotation.page_index}, screen=(${screen_x.toFixed(
|
|
2769
|
+
1
|
|
2770
|
+
)}, ${screen_y.toFixed(1)})`
|
|
2771
|
+
);
|
|
2772
|
+
const dialog_x = window.innerWidth / 2;
|
|
2773
|
+
const dialog_y = Math.max(50, screen_y);
|
|
2774
|
+
setTextDialog({
|
|
2775
|
+
open: true,
|
|
2776
|
+
page_index: annotation.page_index,
|
|
2777
|
+
x: dialog_x,
|
|
2778
|
+
y: dialog_y,
|
|
2779
|
+
screen_x,
|
|
2780
|
+
screen_y,
|
|
2781
|
+
mapper,
|
|
2782
|
+
editing_annotation: annotation
|
|
2783
|
+
});
|
|
2784
|
+
},
|
|
2785
|
+
on_context_menu: (e, page_index, screen_x, screen_y, mapper) => {
|
|
2786
|
+
const menu_x = e.clientX;
|
|
2787
|
+
const menu_y = e.clientY;
|
|
2788
|
+
setContextMenu({
|
|
2789
|
+
visible: true,
|
|
2790
|
+
x: menu_x,
|
|
2791
|
+
y: menu_y,
|
|
2792
|
+
page_index,
|
|
2793
|
+
screen_x,
|
|
2794
|
+
screen_y,
|
|
2795
|
+
mapper
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
)
|
|
2531
2800
|
}
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2801
|
+
),
|
|
2802
|
+
sidepanel_metadata_enabled && metadata_input && /* @__PURE__ */ jsx7(
|
|
2803
|
+
MetadataSidepanel,
|
|
2804
|
+
{
|
|
2805
|
+
is_open: sidepanel_open,
|
|
2806
|
+
on_toggle: handle_sidepanel_toggle,
|
|
2807
|
+
metadata: metadata_input,
|
|
2808
|
+
on_change: handle_metadata_change,
|
|
2809
|
+
width: sidepanel_width,
|
|
2810
|
+
on_width_change: handle_sidepanel_width_change
|
|
2811
|
+
}
|
|
2812
|
+
)
|
|
2813
|
+
] }),
|
|
2814
|
+
context_menu?.visible && /* @__PURE__ */ jsxs6(Fragment4, { children: [
|
|
2815
|
+
/* @__PURE__ */ jsx7(
|
|
2536
2816
|
"div",
|
|
2537
2817
|
{
|
|
2538
2818
|
className: "cls_pdf_viewer_context_menu_backdrop",
|
|
@@ -2543,7 +2823,7 @@ ${suffix_line}`;
|
|
|
2543
2823
|
}
|
|
2544
2824
|
}
|
|
2545
2825
|
),
|
|
2546
|
-
/* @__PURE__ */
|
|
2826
|
+
/* @__PURE__ */ jsx7(
|
|
2547
2827
|
ContextMenu,
|
|
2548
2828
|
{
|
|
2549
2829
|
x: context_menu.x,
|
|
@@ -2608,7 +2888,7 @@ ${suffix_line}`;
|
|
|
2608
2888
|
}
|
|
2609
2889
|
)
|
|
2610
2890
|
] }),
|
|
2611
|
-
text_dialog && /* @__PURE__ */
|
|
2891
|
+
text_dialog && /* @__PURE__ */ jsx7(
|
|
2612
2892
|
TextAnnotationDialog,
|
|
2613
2893
|
{
|
|
2614
2894
|
open: text_dialog.open,
|