@papyrus-sdk/ui-react 0.2.20 → 0.2.21
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.js +406 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +406 -46
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1102,10 +1102,15 @@ var SidebarRight = ({ engine, style }) => {
|
|
|
1102
1102
|
setDocumentState,
|
|
1103
1103
|
triggerScrollToPage,
|
|
1104
1104
|
annotations,
|
|
1105
|
-
accentColor
|
|
1105
|
+
accentColor,
|
|
1106
|
+
updateAnnotation,
|
|
1107
|
+
addAnnotationReply,
|
|
1108
|
+
setSelectedAnnotation
|
|
1106
1109
|
} = useViewerStore3();
|
|
1107
1110
|
const [query, setQuery] = useState3("");
|
|
1108
1111
|
const [isSearching, setIsSearching] = useState3(false);
|
|
1112
|
+
const [contentDrafts, setContentDrafts] = useState3({});
|
|
1113
|
+
const [replyDrafts, setReplyDrafts] = useState3({});
|
|
1109
1114
|
const searchService = new SearchService(engine);
|
|
1110
1115
|
const isDark = uiTheme === "dark";
|
|
1111
1116
|
const accentSoft = withAlpha2(accentColor, 0.12);
|
|
@@ -1121,6 +1126,41 @@ var SidebarRight = ({ engine, style }) => {
|
|
|
1121
1126
|
setSearch(query, results);
|
|
1122
1127
|
setIsSearching(false);
|
|
1123
1128
|
};
|
|
1129
|
+
const jumpToAnnotation = (annotation) => {
|
|
1130
|
+
const page = annotation.pageIndex + 1;
|
|
1131
|
+
engine.goToPage(page);
|
|
1132
|
+
setDocumentState({ currentPage: page });
|
|
1133
|
+
setSelectedAnnotation(annotation.id);
|
|
1134
|
+
triggerScrollToPage(annotation.pageIndex);
|
|
1135
|
+
};
|
|
1136
|
+
const getContentDraft = (annotation) => {
|
|
1137
|
+
if (Object.prototype.hasOwnProperty.call(contentDrafts, annotation.id)) {
|
|
1138
|
+
return contentDrafts[annotation.id];
|
|
1139
|
+
}
|
|
1140
|
+
return annotation.content ?? "";
|
|
1141
|
+
};
|
|
1142
|
+
const updateContentDraft = (annotationId, nextValue) => {
|
|
1143
|
+
setContentDrafts((prev) => ({ ...prev, [annotationId]: nextValue }));
|
|
1144
|
+
};
|
|
1145
|
+
const submitContent = (annotation) => {
|
|
1146
|
+
const nextContent = getContentDraft(annotation).trim();
|
|
1147
|
+
const currentContent = (annotation.content ?? "").trim();
|
|
1148
|
+
if (nextContent === currentContent) return;
|
|
1149
|
+
updateAnnotation(annotation.id, {
|
|
1150
|
+
content: nextContent,
|
|
1151
|
+
updatedAt: Date.now()
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
const getReplyDraft = (annotationId) => replyDrafts[annotationId] ?? "";
|
|
1155
|
+
const updateReplyDraft = (annotationId, nextValue) => {
|
|
1156
|
+
setReplyDrafts((prev) => ({ ...prev, [annotationId]: nextValue }));
|
|
1157
|
+
};
|
|
1158
|
+
const submitReply = (annotationId) => {
|
|
1159
|
+
const nextReply = getReplyDraft(annotationId).trim();
|
|
1160
|
+
if (!nextReply) return;
|
|
1161
|
+
addAnnotationReply(annotationId, nextReply);
|
|
1162
|
+
setReplyDrafts((prev) => ({ ...prev, [annotationId]: "" }));
|
|
1163
|
+
};
|
|
1124
1164
|
if (!sidebarRightOpen) return null;
|
|
1125
1165
|
return /* @__PURE__ */ jsxs3(
|
|
1126
1166
|
"div",
|
|
@@ -1322,48 +1362,152 @@ var SidebarRight = ({ engine, style }) => {
|
|
|
1322
1362
|
}
|
|
1323
1363
|
) }),
|
|
1324
1364
|
/* @__PURE__ */ jsx3("p", { className: "text-[10px] font-bold text-gray-400 uppercase tracking-widest", children: "Sem anota\xE7\xF5es" })
|
|
1325
|
-
] }) : annotations.
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1365
|
+
] }) : annotations.slice().sort(
|
|
1366
|
+
(a, b) => (b.updatedAt ?? b.createdAt) - (a.updatedAt ?? a.createdAt)
|
|
1367
|
+
).map((ann) => {
|
|
1368
|
+
const isCommentThread = ann.type === "comment" || ann.type === "text";
|
|
1369
|
+
const replies = ann.replies ?? [];
|
|
1370
|
+
const contentDraft = getContentDraft(ann);
|
|
1371
|
+
const replyDraft = getReplyDraft(ann.id);
|
|
1372
|
+
const hasExistingContent = Boolean((ann.content ?? "").trim());
|
|
1373
|
+
return /* @__PURE__ */ jsxs3(
|
|
1374
|
+
"div",
|
|
1375
|
+
{
|
|
1376
|
+
className: "rounded-xl border p-4 transition-colors",
|
|
1377
|
+
style: {
|
|
1378
|
+
background: "var(--papyrus-surface-2-resolved, var(--papyrus-surface-2, #1f2937))",
|
|
1379
|
+
borderColor: "var(--papyrus-border-resolved, var(--papyrus-border, #374151))",
|
|
1380
|
+
color: "var(--papyrus-text-resolved, var(--papyrus-text, #e5e7eb))"
|
|
1381
|
+
},
|
|
1382
|
+
children: [
|
|
1383
|
+
/* @__PURE__ */ jsxs3("div", { className: "mb-3 flex items-center justify-between", children: [
|
|
1384
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center space-x-2", children: [
|
|
1385
|
+
/* @__PURE__ */ jsx3(
|
|
1386
|
+
"div",
|
|
1387
|
+
{
|
|
1388
|
+
className: "h-2.5 w-2.5 rounded-full",
|
|
1389
|
+
style: { backgroundColor: ann.color }
|
|
1390
|
+
}
|
|
1391
|
+
),
|
|
1392
|
+
/* @__PURE__ */ jsxs3(
|
|
1393
|
+
"span",
|
|
1394
|
+
{
|
|
1395
|
+
className: "text-[10px] font-black uppercase tracking-wide",
|
|
1396
|
+
style: { color: accentColor },
|
|
1397
|
+
children: [
|
|
1398
|
+
"P",
|
|
1399
|
+
ann.pageIndex + 1
|
|
1400
|
+
]
|
|
1401
|
+
}
|
|
1402
|
+
),
|
|
1403
|
+
/* @__PURE__ */ jsx3("span", { className: "text-[10px] font-semibold opacity-70 uppercase tracking-wide", children: ann.type })
|
|
1404
|
+
] }),
|
|
1332
1405
|
/* @__PURE__ */ jsx3(
|
|
1333
|
-
"
|
|
1406
|
+
"button",
|
|
1334
1407
|
{
|
|
1335
|
-
|
|
1336
|
-
|
|
1408
|
+
type: "button",
|
|
1409
|
+
className: "rounded-md border px-2 py-1 text-[10px] font-semibold uppercase tracking-wide",
|
|
1410
|
+
onClick: () => jumpToAnnotation(ann),
|
|
1411
|
+
style: {
|
|
1412
|
+
borderColor: accentColor,
|
|
1413
|
+
color: accentColor
|
|
1414
|
+
},
|
|
1415
|
+
children: "Ir para pagina"
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
] }),
|
|
1419
|
+
isCommentThread ? /* @__PURE__ */ jsxs3("div", { className: "space-y-2", children: [
|
|
1420
|
+
/* @__PURE__ */ jsx3(
|
|
1421
|
+
"textarea",
|
|
1422
|
+
{
|
|
1423
|
+
className: "w-full resize-none rounded-md border p-2 text-xs focus:outline-none",
|
|
1424
|
+
style: {
|
|
1425
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #111827))",
|
|
1426
|
+
borderColor: "var(--papyrus-border-resolved, var(--papyrus-border, #374151))",
|
|
1427
|
+
color: "var(--papyrus-text-resolved, var(--papyrus-text, #e5e7eb))"
|
|
1428
|
+
},
|
|
1429
|
+
rows: 3,
|
|
1430
|
+
placeholder: "Escreva seu comentario...",
|
|
1431
|
+
value: contentDraft,
|
|
1432
|
+
onChange: (event) => updateContentDraft(ann.id, event.target.value),
|
|
1433
|
+
onKeyDown: (event) => {
|
|
1434
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
1435
|
+
event.preventDefault();
|
|
1436
|
+
submitContent(ann);
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1337
1439
|
}
|
|
1338
1440
|
),
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
"
|
|
1441
|
+
/* @__PURE__ */ jsx3("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx3(
|
|
1442
|
+
"button",
|
|
1341
1443
|
{
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1444
|
+
type: "button",
|
|
1445
|
+
className: "rounded-md px-3 py-1.5 text-[11px] font-semibold text-white",
|
|
1446
|
+
style: { backgroundColor: accentColor },
|
|
1447
|
+
onClick: () => submitContent(ann),
|
|
1448
|
+
children: hasExistingContent ? "Atualizar comentario" : "Enviar comentario"
|
|
1449
|
+
}
|
|
1450
|
+
) })
|
|
1451
|
+
] }) : null,
|
|
1452
|
+
replies.length > 0 ? /* @__PURE__ */ jsx3("div", { className: "mt-3 space-y-2", children: replies.map((reply) => /* @__PURE__ */ jsxs3(
|
|
1453
|
+
"div",
|
|
1454
|
+
{
|
|
1455
|
+
className: "rounded-md border p-2",
|
|
1456
|
+
style: {
|
|
1457
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #111827))",
|
|
1458
|
+
borderColor: "var(--papyrus-border-resolved, var(--papyrus-border, #374151))"
|
|
1459
|
+
},
|
|
1460
|
+
children: [
|
|
1461
|
+
/* @__PURE__ */ jsx3("p", { className: "text-xs leading-relaxed", children: reply.content }),
|
|
1462
|
+
/* @__PURE__ */ jsx3("p", { className: "mt-1 text-[10px] opacity-70", children: new Date(reply.createdAt).toLocaleTimeString(
|
|
1463
|
+
[],
|
|
1464
|
+
{
|
|
1465
|
+
hour: "2-digit",
|
|
1466
|
+
minute: "2-digit"
|
|
1467
|
+
}
|
|
1468
|
+
) })
|
|
1469
|
+
]
|
|
1470
|
+
},
|
|
1471
|
+
reply.id
|
|
1472
|
+
)) }) : null,
|
|
1473
|
+
isCommentThread ? /* @__PURE__ */ jsxs3("div", { className: "mt-3 flex items-center gap-2", children: [
|
|
1474
|
+
/* @__PURE__ */ jsx3(
|
|
1475
|
+
"input",
|
|
1476
|
+
{
|
|
1477
|
+
type: "text",
|
|
1478
|
+
className: "flex-1 rounded-md border px-2 py-1.5 text-xs focus:outline-none",
|
|
1479
|
+
style: {
|
|
1480
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #111827))",
|
|
1481
|
+
borderColor: "var(--papyrus-border-resolved, var(--papyrus-border, #374151))",
|
|
1482
|
+
color: "var(--papyrus-text-resolved, var(--papyrus-text, #e5e7eb))"
|
|
1483
|
+
},
|
|
1484
|
+
value: replyDraft,
|
|
1485
|
+
placeholder: "Responder...",
|
|
1486
|
+
onChange: (event) => updateReplyDraft(ann.id, event.target.value),
|
|
1487
|
+
onKeyDown: (event) => {
|
|
1488
|
+
if (event.key === "Enter") {
|
|
1489
|
+
event.preventDefault();
|
|
1490
|
+
submitReply(ann.id);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
),
|
|
1495
|
+
/* @__PURE__ */ jsx3(
|
|
1496
|
+
"button",
|
|
1497
|
+
{
|
|
1498
|
+
type: "button",
|
|
1499
|
+
className: "rounded-md px-3 py-1.5 text-[11px] font-semibold text-white",
|
|
1500
|
+
style: { backgroundColor: accentColor },
|
|
1501
|
+
onClick: () => submitReply(ann.id),
|
|
1502
|
+
children: "Responder"
|
|
1348
1503
|
}
|
|
1349
1504
|
)
|
|
1350
|
-
] })
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
/* @__PURE__ */ jsx3(
|
|
1357
|
-
"p",
|
|
1358
|
-
{
|
|
1359
|
-
className: `text-[11px] font-bold uppercase tracking-tight ${isDark ? "text-gray-200" : "text-gray-700"}`,
|
|
1360
|
-
children: ann.type
|
|
1361
|
-
}
|
|
1362
|
-
)
|
|
1363
|
-
]
|
|
1364
|
-
},
|
|
1365
|
-
ann.id
|
|
1366
|
-
))
|
|
1505
|
+
] }) : null
|
|
1506
|
+
]
|
|
1507
|
+
},
|
|
1508
|
+
ann.id
|
|
1509
|
+
);
|
|
1510
|
+
})
|
|
1367
1511
|
] }) })
|
|
1368
1512
|
]
|
|
1369
1513
|
}
|
|
@@ -1393,6 +1537,10 @@ var PageRenderer = ({
|
|
|
1393
1537
|
const canvasRef = useRef3(null);
|
|
1394
1538
|
const htmlLayerRef = useRef3(null);
|
|
1395
1539
|
const textLayerRef = useRef3(null);
|
|
1540
|
+
const skipNextAnnotationSelectRef = useRef3(false);
|
|
1541
|
+
const skipSelectResetTimerRef = useRef3(
|
|
1542
|
+
null
|
|
1543
|
+
);
|
|
1396
1544
|
const [loading, setLoading] = useState4(true);
|
|
1397
1545
|
const [pageSize, setPageSize] = useState4(null);
|
|
1398
1546
|
const [isDragging, setIsDragging] = useState4(false);
|
|
@@ -1410,6 +1558,8 @@ var PageRenderer = ({
|
|
|
1410
1558
|
setDocumentState,
|
|
1411
1559
|
annotations,
|
|
1412
1560
|
addAnnotation,
|
|
1561
|
+
addAnnotationReply,
|
|
1562
|
+
updateAnnotation,
|
|
1413
1563
|
activeTool,
|
|
1414
1564
|
removeAnnotation,
|
|
1415
1565
|
selectedAnnotationId,
|
|
@@ -1433,6 +1583,24 @@ var PageRenderer = ({
|
|
|
1433
1583
|
() => Boolean(searchQuery?.trim()) && searchResults.some((res) => res.pageIndex === pageIndex),
|
|
1434
1584
|
[searchQuery, searchResults, pageIndex]
|
|
1435
1585
|
);
|
|
1586
|
+
const suppressNextAnnotationSelect = () => {
|
|
1587
|
+
skipNextAnnotationSelectRef.current = true;
|
|
1588
|
+
if (skipSelectResetTimerRef.current) {
|
|
1589
|
+
clearTimeout(skipSelectResetTimerRef.current);
|
|
1590
|
+
}
|
|
1591
|
+
skipSelectResetTimerRef.current = setTimeout(() => {
|
|
1592
|
+
skipNextAnnotationSelectRef.current = false;
|
|
1593
|
+
skipSelectResetTimerRef.current = null;
|
|
1594
|
+
}, 0);
|
|
1595
|
+
};
|
|
1596
|
+
useEffect3(
|
|
1597
|
+
() => () => {
|
|
1598
|
+
if (skipSelectResetTimerRef.current) {
|
|
1599
|
+
clearTimeout(skipSelectResetTimerRef.current);
|
|
1600
|
+
}
|
|
1601
|
+
},
|
|
1602
|
+
[]
|
|
1603
|
+
);
|
|
1436
1604
|
useEffect3(() => {
|
|
1437
1605
|
let active = true;
|
|
1438
1606
|
const loadSize = async () => {
|
|
@@ -1603,6 +1771,16 @@ var PageRenderer = ({
|
|
|
1603
1771
|
textLayerVersion
|
|
1604
1772
|
]);
|
|
1605
1773
|
const handleMouseDown = (e) => {
|
|
1774
|
+
const target = e.target;
|
|
1775
|
+
const clickedInsideAnnotation = Boolean(
|
|
1776
|
+
target?.closest("[data-papyrus-annotation-id]")
|
|
1777
|
+
);
|
|
1778
|
+
const clickedSelectionMenu = Boolean(
|
|
1779
|
+
target?.closest("[data-papyrus-selection-menu]")
|
|
1780
|
+
);
|
|
1781
|
+
if (!clickedInsideAnnotation && !clickedSelectionMenu) {
|
|
1782
|
+
setSelectedAnnotation(null);
|
|
1783
|
+
}
|
|
1606
1784
|
setSelectionMenu(null);
|
|
1607
1785
|
if (activeTool === "ink") {
|
|
1608
1786
|
const rect2 = containerRef.current?.getBoundingClientRect();
|
|
@@ -1659,6 +1837,7 @@ var PageRenderer = ({
|
|
|
1659
1837
|
x: Math.max(0, Math.min(1, p.x)),
|
|
1660
1838
|
y: Math.max(0, Math.min(1, p.y))
|
|
1661
1839
|
}));
|
|
1840
|
+
suppressNextAnnotationSelect();
|
|
1662
1841
|
addAnnotation({
|
|
1663
1842
|
id: Math.random().toString(36).substr(2, 9),
|
|
1664
1843
|
pageIndex,
|
|
@@ -1739,6 +1918,7 @@ var PageRenderer = ({
|
|
|
1739
1918
|
height: Math.max(...ye) - Math.min(...ys)
|
|
1740
1919
|
};
|
|
1741
1920
|
if (textMarkupTools.has(activeTool)) {
|
|
1921
|
+
suppressNextAnnotationSelect();
|
|
1742
1922
|
addAnnotation({
|
|
1743
1923
|
id: Math.random().toString(36).substr(2, 9),
|
|
1744
1924
|
pageIndex,
|
|
@@ -1774,6 +1954,9 @@ var PageRenderer = ({
|
|
|
1774
1954
|
if (currentRect.w > 5 && currentRect.h > 5) {
|
|
1775
1955
|
const rect = containerRef.current?.getBoundingClientRect();
|
|
1776
1956
|
if (rect) {
|
|
1957
|
+
if (activeTool !== "text" && activeTool !== "comment") {
|
|
1958
|
+
suppressNextAnnotationSelect();
|
|
1959
|
+
}
|
|
1777
1960
|
addAnnotation({
|
|
1778
1961
|
id: Math.random().toString(36).substr(2, 9),
|
|
1779
1962
|
pageIndex,
|
|
@@ -1897,6 +2080,7 @@ var PageRenderer = ({
|
|
|
1897
2080
|
selectionMenu && /* @__PURE__ */ jsx4(
|
|
1898
2081
|
"div",
|
|
1899
2082
|
{
|
|
2083
|
+
"data-papyrus-selection-menu": "true",
|
|
1900
2084
|
className: "absolute z-[60] flex items-center gap-1 rounded-full border px-2 py-1 shadow-xl bg-white/95 backdrop-blur-md text-gray-700",
|
|
1901
2085
|
style: { left: selectionMenu.anchor.x, top: selectionMenu.anchor.y },
|
|
1902
2086
|
children: [
|
|
@@ -1909,6 +2093,7 @@ var PageRenderer = ({
|
|
|
1909
2093
|
{
|
|
1910
2094
|
className: "text-[10px] font-bold px-2 py-1 rounded-full hover:bg-gray-100",
|
|
1911
2095
|
onClick: () => {
|
|
2096
|
+
suppressNextAnnotationSelect();
|
|
1912
2097
|
addAnnotation({
|
|
1913
2098
|
id: Math.random().toString(36).substr(2, 9),
|
|
1914
2099
|
pageIndex,
|
|
@@ -1935,7 +2120,15 @@ var PageRenderer = ({
|
|
|
1935
2120
|
isSelected: selectedAnnotationId === ann.id,
|
|
1936
2121
|
accentColor,
|
|
1937
2122
|
onDelete: () => removeAnnotation(ann.id),
|
|
1938
|
-
onSelect: () =>
|
|
2123
|
+
onSelect: () => {
|
|
2124
|
+
if (skipNextAnnotationSelectRef.current) {
|
|
2125
|
+
skipNextAnnotationSelectRef.current = false;
|
|
2126
|
+
return;
|
|
2127
|
+
}
|
|
2128
|
+
setSelectedAnnotation(ann.id);
|
|
2129
|
+
},
|
|
2130
|
+
onUpdate: (updates) => updateAnnotation(ann.id, updates),
|
|
2131
|
+
onAddReply: (content) => addAnnotationReply(ann.id, content)
|
|
1939
2132
|
},
|
|
1940
2133
|
ann.id
|
|
1941
2134
|
)) })
|
|
@@ -1943,12 +2136,43 @@ var PageRenderer = ({
|
|
|
1943
2136
|
}
|
|
1944
2137
|
);
|
|
1945
2138
|
};
|
|
1946
|
-
var AnnotationItem = ({
|
|
2139
|
+
var AnnotationItem = ({
|
|
2140
|
+
ann,
|
|
2141
|
+
isSelected,
|
|
2142
|
+
accentColor,
|
|
2143
|
+
onDelete,
|
|
2144
|
+
onSelect,
|
|
2145
|
+
onUpdate,
|
|
2146
|
+
onAddReply
|
|
2147
|
+
}) => {
|
|
1947
2148
|
const isText = ann.type === "text" || ann.type === "comment";
|
|
1948
2149
|
const isHighlight = ann.type === "highlight";
|
|
1949
2150
|
const isMarkup = ann.type === "highlight" || ann.type === "underline" || ann.type === "squiggly" || ann.type === "strikeout";
|
|
1950
2151
|
const rects = ann.rects && ann.rects.length > 0 ? ann.rects : [ann.rect];
|
|
1951
2152
|
const isInk = ann.type === "ink" && ann.path && ann.path.length > 1;
|
|
2153
|
+
const [draftContent, setDraftContent] = useState4(ann.content ?? "");
|
|
2154
|
+
const [draftReply, setDraftReply] = useState4("");
|
|
2155
|
+
useEffect3(() => {
|
|
2156
|
+
setDraftContent(ann.content ?? "");
|
|
2157
|
+
}, [ann.id, ann.content]);
|
|
2158
|
+
useEffect3(() => {
|
|
2159
|
+
setDraftReply("");
|
|
2160
|
+
}, [ann.id]);
|
|
2161
|
+
const handleSaveContent = () => {
|
|
2162
|
+
const nextContent = draftContent.trim();
|
|
2163
|
+
const currentContent = (ann.content ?? "").trim();
|
|
2164
|
+
if (nextContent === currentContent) return;
|
|
2165
|
+
onUpdate({
|
|
2166
|
+
content: nextContent,
|
|
2167
|
+
updatedAt: Date.now()
|
|
2168
|
+
});
|
|
2169
|
+
};
|
|
2170
|
+
const handleReplySubmit = () => {
|
|
2171
|
+
const nextReply = draftReply.trim();
|
|
2172
|
+
if (!nextReply) return;
|
|
2173
|
+
onAddReply(nextReply);
|
|
2174
|
+
setDraftReply("");
|
|
2175
|
+
};
|
|
1952
2176
|
const renderMarkupRects = () => {
|
|
1953
2177
|
if (!isMarkup) return null;
|
|
1954
2178
|
return rects.map((r, idx) => {
|
|
@@ -2053,6 +2277,7 @@ var AnnotationItem = ({ ann, isSelected, accentColor, onDelete, onSelect }) => {
|
|
|
2053
2277
|
return /* @__PURE__ */ jsxs4(
|
|
2054
2278
|
"div",
|
|
2055
2279
|
{
|
|
2280
|
+
"data-papyrus-annotation-id": ann.id,
|
|
2056
2281
|
className: `absolute pointer-events-auto transition-all ${isSelected ? "shadow-xl z-30" : "z-10"}`,
|
|
2057
2282
|
style: {
|
|
2058
2283
|
left: `${ann.rect.x * 100}%`,
|
|
@@ -2071,16 +2296,151 @@ var AnnotationItem = ({ ann, isSelected, accentColor, onDelete, onSelect }) => {
|
|
|
2071
2296
|
children: [
|
|
2072
2297
|
renderMarkupRects(),
|
|
2073
2298
|
renderInk(),
|
|
2074
|
-
isText && isSelected && /* @__PURE__ */ jsx4(
|
|
2075
|
-
"
|
|
2299
|
+
isText && !isSelected && /* @__PURE__ */ jsx4(
|
|
2300
|
+
"button",
|
|
2076
2301
|
{
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2302
|
+
type: "button",
|
|
2303
|
+
className: "absolute -top-2 -right-2 h-6 w-6 rounded-full flex items-center justify-center shadow-lg",
|
|
2304
|
+
style: {
|
|
2305
|
+
background: "var(--papyrus-surface-2-resolved, var(--papyrus-surface-2, #1f2937))",
|
|
2306
|
+
border: "1px solid var(--papyrus-border-resolved, #374151)",
|
|
2307
|
+
color: "var(--papyrus-text-resolved, #e5e7eb)"
|
|
2308
|
+
},
|
|
2309
|
+
title: "Abrir comentario",
|
|
2310
|
+
"aria-label": "Abrir comentario",
|
|
2311
|
+
onClick: (event) => {
|
|
2312
|
+
event.stopPropagation();
|
|
2313
|
+
onSelect();
|
|
2314
|
+
},
|
|
2315
|
+
children: /* @__PURE__ */ jsx4(
|
|
2316
|
+
"svg",
|
|
2317
|
+
{
|
|
2318
|
+
className: "h-3.5 w-3.5",
|
|
2319
|
+
fill: "none",
|
|
2320
|
+
stroke: "currentColor",
|
|
2321
|
+
viewBox: "0 0 24 24",
|
|
2322
|
+
children: /* @__PURE__ */ jsx4(
|
|
2323
|
+
"path",
|
|
2324
|
+
{
|
|
2325
|
+
strokeLinecap: "round",
|
|
2326
|
+
strokeLinejoin: "round",
|
|
2327
|
+
strokeWidth: 2,
|
|
2328
|
+
d: "M8 10h.01M12 10h.01M16 10h.01M7 16H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-4l-4 4v-4z"
|
|
2329
|
+
}
|
|
2330
|
+
)
|
|
2331
|
+
}
|
|
2332
|
+
)
|
|
2082
2333
|
}
|
|
2083
|
-
)
|
|
2334
|
+
),
|
|
2335
|
+
isText && isSelected && /* @__PURE__ */ jsxs4(
|
|
2336
|
+
"div",
|
|
2337
|
+
{
|
|
2338
|
+
className: "absolute top-full mt-2 w-72 rounded-xl p-3 z-50",
|
|
2339
|
+
style: {
|
|
2340
|
+
background: "var(--papyrus-popover-resolved, var(--papyrus-popover, #ffffff))",
|
|
2341
|
+
border: "1px solid var(--papyrus-border-resolved, #d1d5db)",
|
|
2342
|
+
color: "var(--papyrus-text-resolved, #111827)",
|
|
2343
|
+
boxShadow: "0 20px 40px var(--papyrus-shadow-resolved, rgba(0, 0, 0, 0.3))"
|
|
2344
|
+
},
|
|
2345
|
+
onClick: (event) => event.stopPropagation(),
|
|
2346
|
+
children: [
|
|
2347
|
+
/* @__PURE__ */ jsxs4("div", { className: "mb-2 flex items-center justify-between", children: [
|
|
2348
|
+
/* @__PURE__ */ jsx4("span", { className: "text-[10px] font-bold uppercase tracking-wider opacity-70", children: ann.type === "comment" ? "Comentario" : "Nota" }),
|
|
2349
|
+
ann.replies?.length ? /* @__PURE__ */ jsxs4("span", { className: "text-[10px] opacity-70", children: [
|
|
2350
|
+
ann.replies.length,
|
|
2351
|
+
" resposta",
|
|
2352
|
+
ann.replies.length > 1 ? "s" : ""
|
|
2353
|
+
] }) : null
|
|
2354
|
+
] }),
|
|
2355
|
+
/* @__PURE__ */ jsx4(
|
|
2356
|
+
"textarea",
|
|
2357
|
+
{
|
|
2358
|
+
className: "w-full rounded-md border p-2 text-xs font-medium resize-none focus:outline-none",
|
|
2359
|
+
style: {
|
|
2360
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #ffffff))",
|
|
2361
|
+
borderColor: "var(--papyrus-border-resolved, #d1d5db)",
|
|
2362
|
+
color: "var(--papyrus-text-resolved, #111827)"
|
|
2363
|
+
},
|
|
2364
|
+
placeholder: "Escreva seu comentario...",
|
|
2365
|
+
rows: 3,
|
|
2366
|
+
value: draftContent,
|
|
2367
|
+
onChange: (event) => setDraftContent(event.target.value),
|
|
2368
|
+
onKeyDown: (event) => {
|
|
2369
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
2370
|
+
event.preventDefault();
|
|
2371
|
+
handleSaveContent();
|
|
2372
|
+
}
|
|
2373
|
+
},
|
|
2374
|
+
autoFocus: true
|
|
2375
|
+
}
|
|
2376
|
+
),
|
|
2377
|
+
/* @__PURE__ */ jsx4("div", { className: "mt-2 flex justify-end", children: /* @__PURE__ */ jsx4(
|
|
2378
|
+
"button",
|
|
2379
|
+
{
|
|
2380
|
+
type: "button",
|
|
2381
|
+
className: "rounded-md px-3 py-1.5 text-[11px] font-semibold text-white",
|
|
2382
|
+
style: { backgroundColor: accentColor },
|
|
2383
|
+
onClick: (event) => {
|
|
2384
|
+
event.stopPropagation();
|
|
2385
|
+
handleSaveContent();
|
|
2386
|
+
},
|
|
2387
|
+
children: (ann.content ?? "").trim() ? "Atualizar" : "Enviar"
|
|
2388
|
+
}
|
|
2389
|
+
) }),
|
|
2390
|
+
ann.replies && ann.replies.length > 0 ? /* @__PURE__ */ jsx4("div", { className: "mt-3 space-y-2", children: ann.replies.map((reply) => /* @__PURE__ */ jsxs4(
|
|
2391
|
+
"div",
|
|
2392
|
+
{
|
|
2393
|
+
className: "rounded-md border p-2",
|
|
2394
|
+
style: {
|
|
2395
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #ffffff))",
|
|
2396
|
+
borderColor: "var(--papyrus-border-resolved, #d1d5db)"
|
|
2397
|
+
},
|
|
2398
|
+
children: [
|
|
2399
|
+
/* @__PURE__ */ jsx4("p", { className: "text-xs", children: reply.content }),
|
|
2400
|
+
/* @__PURE__ */ jsx4("p", { className: "mt-1 text-[10px] opacity-70", children: new Date(reply.createdAt).toLocaleTimeString([], {
|
|
2401
|
+
hour: "2-digit",
|
|
2402
|
+
minute: "2-digit"
|
|
2403
|
+
}) })
|
|
2404
|
+
]
|
|
2405
|
+
},
|
|
2406
|
+
reply.id
|
|
2407
|
+
)) }) : null,
|
|
2408
|
+
/* @__PURE__ */ jsxs4("div", { className: "mt-3 flex items-center gap-2", children: [
|
|
2409
|
+
/* @__PURE__ */ jsx4(
|
|
2410
|
+
"input",
|
|
2411
|
+
{
|
|
2412
|
+
type: "text",
|
|
2413
|
+
className: "flex-1 rounded-md border px-2 py-1.5 text-xs focus:outline-none",
|
|
2414
|
+
style: {
|
|
2415
|
+
background: "var(--papyrus-surface-resolved, var(--papyrus-surface, #ffffff))",
|
|
2416
|
+
borderColor: "var(--papyrus-border-resolved, #d1d5db)",
|
|
2417
|
+
color: "var(--papyrus-text-resolved, #111827)"
|
|
2418
|
+
},
|
|
2419
|
+
placeholder: "Responder...",
|
|
2420
|
+
value: draftReply,
|
|
2421
|
+
onChange: (event) => setDraftReply(event.target.value),
|
|
2422
|
+
onKeyDown: (event) => {
|
|
2423
|
+
if (event.key === "Enter") {
|
|
2424
|
+
event.preventDefault();
|
|
2425
|
+
handleReplySubmit();
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
),
|
|
2430
|
+
/* @__PURE__ */ jsx4(
|
|
2431
|
+
"button",
|
|
2432
|
+
{
|
|
2433
|
+
type: "button",
|
|
2434
|
+
className: "rounded-md px-3 py-1.5 text-[11px] font-semibold text-white",
|
|
2435
|
+
style: { backgroundColor: accentColor },
|
|
2436
|
+
onClick: handleReplySubmit,
|
|
2437
|
+
children: "Responder"
|
|
2438
|
+
}
|
|
2439
|
+
)
|
|
2440
|
+
] })
|
|
2441
|
+
]
|
|
2442
|
+
}
|
|
2443
|
+
),
|
|
2084
2444
|
isSelected && /* @__PURE__ */ jsx4(
|
|
2085
2445
|
"button",
|
|
2086
2446
|
{
|