@embedpdf/viewer-chrome 3.0.0-next.1 → 3.0.0-next.10
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/chrome.cjs +8 -1
- package/dist/chrome.cjs.map +1 -1
- package/dist/chrome.d.cts +1 -0
- package/dist/chrome.d.ts +1 -0
- package/dist/chrome.js +8 -1
- package/dist/chrome.js.map +1 -1
- package/dist/commands.cjs +38 -8
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.js +39 -9
- package/dist/commands.js.map +1 -1
- package/dist/{es-C5084JO6.cjs → es-B7b8KjR3.cjs} +44 -1
- package/dist/es-B7b8KjR3.cjs.map +1 -0
- package/dist/{es-D0PzYE9Z.js → es-aQlZ3hcL.js} +44 -1
- package/dist/es-aQlZ3hcL.js.map +1 -0
- package/dist/index.cjs +723 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +728 -141
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/dist/es-C5084JO6.cjs.map +0 -1
- package/dist/es-D0PzYE9Z.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -3,14 +3,14 @@ import { TOOL_ICONS, defaultCommands } from "./commands.js";
|
|
|
3
3
|
import { Fragment, createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { DocumentGate, DocumentsToken, Viewer, createCapabilityToken, definePlugin, useCapability, useDocumentId, useDocumentStatus, useDocuments, useKernel, useOptionalCapability, useOptionalSelector, useSelector } from "@embedpdf/react/runtime";
|
|
5
5
|
import { Stage, StageToken, StageToken as StageToken$1, stagePlugin, usePages } from "@embedpdf/react/stage";
|
|
6
|
-
import { RenderLayer,
|
|
6
|
+
import { RenderLayer, renderPlugin } from "@embedpdf/react/render";
|
|
7
7
|
import { pageEditPlugin } from "@embedpdf/react/page-edit";
|
|
8
|
-
import { InteractionToken, InteractionToken as InteractionToken$1, interactionPlugin, useTool, useToolCursor } from "@embedpdf/react/interaction";
|
|
9
|
-
import { SelectionLayer, SelectionToken, selectionPlugin } from "@embedpdf/react/selection";
|
|
10
|
-
import { AnnotationLayer, AnnotationToken, AnnotationToken as AnnotationToken$1, annotationPlugin, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "@embedpdf/react/annotation";
|
|
8
|
+
import { InteractionToken, InteractionToken as InteractionToken$1, feedbackPlugin, interactionPlugin, useTool, useToolCursor, vibrationFeedback } from "@embedpdf/react/interaction";
|
|
9
|
+
import { SelectionClipboard, SelectionHandles, SelectionLayer, SelectionMenu, SelectionToken, selectionPlugin } from "@embedpdf/react/selection";
|
|
10
|
+
import { AnnotationLayer, AnnotationToken, AnnotationToken as AnnotationToken$1, annotationPlugin, refKey, useAnnotation, useAnnotationDefaults, useAnnotationSelected, useAnnotationSelection, useCommentThreads, useComments, useCommentsHydration, useFilePickerProvider, useSelectionFlags, useSelectionProps } from "@embedpdf/react/annotation";
|
|
11
11
|
import { RedactionToken, RedactionToken as RedactionToken$1, redactionPlugin, usePendingRedactions, useRedaction } from "@embedpdf/react/redaction";
|
|
12
12
|
import { FormToken, formPlugin, formWidgetRenderer, useFormScriptingProvider } from "@embedpdf/react/form";
|
|
13
|
-
import { LinkLayer,
|
|
13
|
+
import { LinkLayer, linkPlugin } from "@embedpdf/react/link";
|
|
14
14
|
import { SearchLayer, SearchToken, SearchToken as SearchToken$1, searchPlugin, useSearch, useSearchState, validateSearchQuery } from "@embedpdf/react/search";
|
|
15
15
|
import { I18nToken, i18nPlugin, negotiateLocale, useT } from "@embedpdf/react/i18n";
|
|
16
16
|
import { CommandsToken, CommandsToken as CommandsToken$1, commandsPlugin, resolvedCommandsEqual, useCommand, useCommandShortcuts, useCommands } from "@embedpdf/react/commands";
|
|
@@ -147,6 +147,10 @@ const en = {
|
|
|
147
147
|
ungroup: "Ungroup",
|
|
148
148
|
strip: "Annotation actions"
|
|
149
149
|
},
|
|
150
|
+
selection: {
|
|
151
|
+
copy: "Copy",
|
|
152
|
+
strip: "Text selection actions"
|
|
153
|
+
},
|
|
150
154
|
shapes: {
|
|
151
155
|
rectangle: "Rectangle",
|
|
152
156
|
circle: "Circle",
|
|
@@ -193,6 +197,24 @@ const en = {
|
|
|
193
197
|
unknown: "The document could not be opened.",
|
|
194
198
|
close: "Close document"
|
|
195
199
|
},
|
|
200
|
+
annotation: {
|
|
201
|
+
comment: "Comment",
|
|
202
|
+
highlight: "Highlight",
|
|
203
|
+
underline: "Underline",
|
|
204
|
+
squiggly: "Squiggly",
|
|
205
|
+
strikeout: "Strikethrough",
|
|
206
|
+
square: "Square",
|
|
207
|
+
circle: "Circle",
|
|
208
|
+
line: "Line",
|
|
209
|
+
polygon: "Polygon",
|
|
210
|
+
polyline: "Polyline",
|
|
211
|
+
ink: "Ink",
|
|
212
|
+
freeText: "Text",
|
|
213
|
+
stamp: "Stamp",
|
|
214
|
+
caret: "Caret",
|
|
215
|
+
redact: "Redact",
|
|
216
|
+
fileAttachment: "Attachment"
|
|
217
|
+
},
|
|
196
218
|
demo: {
|
|
197
219
|
starting: "Starting viewer…",
|
|
198
220
|
opening: "Opening document…",
|
|
@@ -209,6 +231,27 @@ const en = {
|
|
|
209
231
|
searchNoResults: "No results",
|
|
210
232
|
searchPage: "Page {page}",
|
|
211
233
|
commentsTitle: "Comments",
|
|
234
|
+
commentsForbidden: "You don’t have access to comments on this document.",
|
|
235
|
+
commentsLoading: "Loading comments…",
|
|
236
|
+
commentsError: "Comments failed to load.",
|
|
237
|
+
commentsRetry: "Retry",
|
|
238
|
+
commentsEmpty: "No comments yet. Use the note tool to start a thread.",
|
|
239
|
+
commentsAnonymous: "Unknown",
|
|
240
|
+
commentsPage: "Page {page}",
|
|
241
|
+
commentCount: "{count} comment",
|
|
242
|
+
commentCountPlural: "{count} comments",
|
|
243
|
+
commentsReply: "Reply",
|
|
244
|
+
commentsReplyPlaceholder: "Reply…",
|
|
245
|
+
commentsAddPlaceholder: "Add a comment…",
|
|
246
|
+
commentsDelete: "Delete comment",
|
|
247
|
+
commentsDeleteThread: "Delete thread",
|
|
248
|
+
commentsEdit: "Edit comment",
|
|
249
|
+
commentsStatus: "Status",
|
|
250
|
+
commentsStatusNone: "No status",
|
|
251
|
+
commentsStatusAccepted: "Accepted",
|
|
252
|
+
commentsStatusRejected: "Rejected",
|
|
253
|
+
commentsStatusCancelled: "Cancelled",
|
|
254
|
+
commentsStatusCompleted: "Completed",
|
|
212
255
|
styleTitle: "Style",
|
|
213
256
|
empty: "Nothing here yet in this demo panel.",
|
|
214
257
|
page: "Page {current} of {total}",
|
|
@@ -1283,19 +1326,129 @@ function AppToolbar({ bar, className }) {
|
|
|
1283
1326
|
});
|
|
1284
1327
|
}
|
|
1285
1328
|
//#endregion
|
|
1286
|
-
//#region src/ui/
|
|
1329
|
+
//#region src/ui/link-editor.tsx
|
|
1287
1330
|
/**
|
|
1288
|
-
* The
|
|
1289
|
-
*
|
|
1331
|
+
* The link editor POPOVER — v2's "add a link" popup, reborn. It rides the
|
|
1332
|
+
* SAME selection anchor as the action strip (`<AnnotationMenu>` solves
|
|
1333
|
+
* WHERE), opening from the strip's link icon (`annotation:link` toggles the
|
|
1334
|
+
* `link-editor` shell surface) and rendering IN PLACE of the strip while
|
|
1335
|
+
* open — one anchored card at a time.
|
|
1290
1336
|
*
|
|
1291
|
-
*
|
|
1292
|
-
*
|
|
1293
|
-
*
|
|
1294
|
-
*
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
|
|
1298
|
-
|
|
1337
|
+
* Reads the selection's current target from selection props (the `linkOf`
|
|
1338
|
+
* lens — parents derive from their committed child annotations) and writes
|
|
1339
|
+
* through the ONE `updateSelection({ link })` path; the plugin's reconciler
|
|
1340
|
+
* materializes/retargets the attached children. Links are a VERB on the
|
|
1341
|
+
* selection, not a style — which is why this is a popover, not a sidebar
|
|
1342
|
+
* section.
|
|
1343
|
+
*/
|
|
1344
|
+
function ModeToggle({ active, title, onClick, children }) {
|
|
1345
|
+
return /* @__PURE__ */ jsx("button", {
|
|
1346
|
+
type: "button",
|
|
1347
|
+
title,
|
|
1348
|
+
onClick,
|
|
1349
|
+
className: `rounded border px-2.5 py-1 text-xs font-medium transition-colors ${active ? "border-accent bg-accent text-on-accent" : "border-border bg-surface text-fg hover:bg-hover"}`,
|
|
1350
|
+
children
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
function LinkEditorCard({ onClose }) {
|
|
1354
|
+
const t = useT();
|
|
1355
|
+
const kernel = useKernel();
|
|
1356
|
+
const anno = useAnnotation();
|
|
1357
|
+
const value = useSelectionProps().values.link ?? null;
|
|
1358
|
+
const [mode, setMode] = useState(value?.kind === "goto" ? "page" : "uri");
|
|
1359
|
+
const [uri, setUri] = useState(value?.kind === "uri" ? value.uri : "");
|
|
1360
|
+
const [pageNo, setPageNo] = useState("1");
|
|
1361
|
+
const apply = () => {
|
|
1362
|
+
if (mode === "uri") {
|
|
1363
|
+
const trimmed = uri.trim();
|
|
1364
|
+
if (!trimmed) return;
|
|
1365
|
+
anno.updateSelection({ link: {
|
|
1366
|
+
kind: "uri",
|
|
1367
|
+
uri: trimmed
|
|
1368
|
+
} });
|
|
1369
|
+
onClose();
|
|
1370
|
+
return;
|
|
1371
|
+
}
|
|
1372
|
+
const activeId = kernel.documents.activeId();
|
|
1373
|
+
const layout = (activeId ? kernel.getState().core.documents[activeId] : null)?.pages[Math.max(0, Number(pageNo) - 1)];
|
|
1374
|
+
if (!layout) return;
|
|
1375
|
+
anno.updateSelection({ link: {
|
|
1376
|
+
kind: "goto",
|
|
1377
|
+
destination: {
|
|
1378
|
+
kind: "fit",
|
|
1379
|
+
pageObjectNumber: layout.pageObjectNumber
|
|
1380
|
+
}
|
|
1381
|
+
} });
|
|
1382
|
+
onClose();
|
|
1383
|
+
};
|
|
1384
|
+
const inputCls = "border-border bg-surface text-fg focus:border-accent w-full rounded border px-2.5 py-1.5 text-sm outline-none";
|
|
1385
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1386
|
+
className: "border-border bg-surface w-64 rounded-lg border p-3 shadow-lg",
|
|
1387
|
+
children: [
|
|
1388
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1389
|
+
className: "mb-2 flex items-center justify-between",
|
|
1390
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
1391
|
+
className: "text-fg text-sm font-semibold",
|
|
1392
|
+
children: t("commands.annotate.link")
|
|
1393
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
1394
|
+
type: "button",
|
|
1395
|
+
onClick: onClose,
|
|
1396
|
+
className: "text-fg-muted hover:bg-hover grid h-6 w-6 place-items-center rounded",
|
|
1397
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
1398
|
+
name: "x",
|
|
1399
|
+
size: 14
|
|
1400
|
+
})
|
|
1401
|
+
})]
|
|
1402
|
+
}),
|
|
1403
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1404
|
+
className: "mb-2 flex gap-1.5",
|
|
1405
|
+
children: [/* @__PURE__ */ jsx(ModeToggle, {
|
|
1406
|
+
title: "Link to a URL",
|
|
1407
|
+
active: mode === "uri",
|
|
1408
|
+
onClick: () => setMode("uri"),
|
|
1409
|
+
children: "URL"
|
|
1410
|
+
}), /* @__PURE__ */ jsx(ModeToggle, {
|
|
1411
|
+
title: "Link to a page",
|
|
1412
|
+
active: mode === "page",
|
|
1413
|
+
onClick: () => setMode("page"),
|
|
1414
|
+
children: "Page"
|
|
1415
|
+
})]
|
|
1416
|
+
}),
|
|
1417
|
+
mode === "uri" ? /* @__PURE__ */ jsx("input", {
|
|
1418
|
+
type: "url",
|
|
1419
|
+
className: inputCls,
|
|
1420
|
+
placeholder: "https://…",
|
|
1421
|
+
autoFocus: true,
|
|
1422
|
+
value: uri,
|
|
1423
|
+
onChange: (e) => setUri(e.target.value),
|
|
1424
|
+
onKeyDown: (e) => e.key === "Enter" && apply()
|
|
1425
|
+
}) : /* @__PURE__ */ jsx("input", {
|
|
1426
|
+
type: "number",
|
|
1427
|
+
min: 1,
|
|
1428
|
+
className: inputCls,
|
|
1429
|
+
placeholder: "Page number",
|
|
1430
|
+
autoFocus: true,
|
|
1431
|
+
value: pageNo,
|
|
1432
|
+
onChange: (e) => setPageNo(e.target.value),
|
|
1433
|
+
onKeyDown: (e) => e.key === "Enter" && apply()
|
|
1434
|
+
}),
|
|
1435
|
+
/* @__PURE__ */ jsx("button", {
|
|
1436
|
+
type: "button",
|
|
1437
|
+
className: "bg-accent text-on-accent mt-2.5 w-full rounded px-2 py-1.5 text-sm font-medium",
|
|
1438
|
+
onClick: apply,
|
|
1439
|
+
children: value == null ? "Add link" : "Update link"
|
|
1440
|
+
})
|
|
1441
|
+
]
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
//#endregion
|
|
1445
|
+
//#region src/ui/strip-bar.tsx
|
|
1446
|
+
/**
|
|
1447
|
+
* The floating strip's PIXELS, shared by every contextual strip (annotation
|
|
1448
|
+
* selection, text selection, …): a rounded toolbar of command buttons with
|
|
1449
|
+
* derived group separators. The WHERE is each strip's menu component
|
|
1450
|
+
* (`<AnnotationMenu>`, `<SelectionMenu>`); the WHICH is the commands'
|
|
1451
|
+
* `visible`/`enabled` derivations via `useStripView`. This file only draws.
|
|
1299
1452
|
*/
|
|
1300
1453
|
function StripButton({ cmd, run }) {
|
|
1301
1454
|
return /* @__PURE__ */ jsx("button", {
|
|
@@ -1313,24 +1466,76 @@ function StripButton({ cmd, run }) {
|
|
|
1313
1466
|
})
|
|
1314
1467
|
});
|
|
1315
1468
|
}
|
|
1469
|
+
function StripBar({ view, label }) {
|
|
1470
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1471
|
+
role: "toolbar",
|
|
1472
|
+
"aria-label": label,
|
|
1473
|
+
className: "border-border-subtle bg-elevated flex items-center gap-1 rounded-lg border p-1 shadow-xl",
|
|
1474
|
+
children: view.groups.map((g, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", {
|
|
1475
|
+
"aria-hidden": true,
|
|
1476
|
+
className: "bg-border h-5 w-px"
|
|
1477
|
+
}), g.commands.map((cmd) => /* @__PURE__ */ jsx(StripButton, {
|
|
1478
|
+
cmd,
|
|
1479
|
+
run: () => view.execute(cmd.id)
|
|
1480
|
+
}, cmd.id))] }, g.id))
|
|
1481
|
+
});
|
|
1482
|
+
}
|
|
1483
|
+
//#endregion
|
|
1484
|
+
//#region src/ui/annotation-strip.tsx
|
|
1485
|
+
/**
|
|
1486
|
+
* The ANNOTATION-selection floating strip:
|
|
1487
|
+
*
|
|
1488
|
+
* config/chrome.ts `strips.annotation` declares WHAT may appear
|
|
1489
|
+
* each command's visible/enabled decides WHICH items show
|
|
1490
|
+
* <AnnotationMenu> solves WHERE (camera transform,
|
|
1491
|
+
* rotate-knob dodging, pointer isolation)
|
|
1492
|
+
*
|
|
1493
|
+
* useStripView is the live intersection: hidden commands drop out, empty
|
|
1494
|
+
* groups vanish, null when nothing applies. Mounted in the Stage `overlay`
|
|
1495
|
+
* slot. The pixels are the shared <StripBar>.
|
|
1496
|
+
*/
|
|
1316
1497
|
function AnnotationStrip() {
|
|
1317
1498
|
const t = useT();
|
|
1318
1499
|
const view = useStripView(useStripSchema("annotation"));
|
|
1500
|
+
const editor = useSurface("link-editor");
|
|
1501
|
+
const selection = useAnnotationSelection();
|
|
1502
|
+
useEffect(() => {
|
|
1503
|
+
if (!selection.length && editor.isOpen) editor.close();
|
|
1504
|
+
}, [selection.length, editor.isOpen]);
|
|
1319
1505
|
if (!view) return null;
|
|
1320
1506
|
return /* @__PURE__ */ jsx(AnnotationMenu, {
|
|
1321
1507
|
placement: "bottom",
|
|
1322
1508
|
gap: 15,
|
|
1323
|
-
children: ()
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1509
|
+
children: editor.isOpen ? /* @__PURE__ */ jsx(LinkEditorCard, { onClose: editor.close }) : /* @__PURE__ */ jsx(StripBar, {
|
|
1510
|
+
view,
|
|
1511
|
+
label: t("commands.annotate.strip")
|
|
1512
|
+
})
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region src/ui/selection-strip.tsx
|
|
1517
|
+
/**
|
|
1518
|
+
* The TEXT-SELECTION floating strip:
|
|
1519
|
+
*
|
|
1520
|
+
* config/chrome.ts `strips.selection` declares WHAT may appear
|
|
1521
|
+
* each command's visible/enabled decides WHICH items show
|
|
1522
|
+
* <SelectionMenu> solves WHERE (settles on pointer-up,
|
|
1523
|
+
* camera transform, pointer isolation)
|
|
1524
|
+
*
|
|
1525
|
+
* `useStripView` is the live intersection: with copy denied (no
|
|
1526
|
+
* doc.text.copy) every command drops out and this renders nothing — no
|
|
1527
|
+
* empty bubble. Mounted in the Stage `overlay` slot.
|
|
1528
|
+
*/
|
|
1529
|
+
function SelectionStrip() {
|
|
1530
|
+
const t = useT();
|
|
1531
|
+
const view = useStripView(useStripSchema("selection"));
|
|
1532
|
+
if (!view) return null;
|
|
1533
|
+
return /* @__PURE__ */ jsx(SelectionMenu, {
|
|
1534
|
+
placement: "bottom",
|
|
1535
|
+
gap: 12,
|
|
1536
|
+
children: /* @__PURE__ */ jsx(StripBar, {
|
|
1537
|
+
view,
|
|
1538
|
+
label: t("commands.selection.strip")
|
|
1334
1539
|
})
|
|
1335
1540
|
});
|
|
1336
1541
|
}
|
|
@@ -2183,99 +2388,6 @@ function Toggle({ active, title, onClick, children }) {
|
|
|
2183
2388
|
children
|
|
2184
2389
|
});
|
|
2185
2390
|
}
|
|
2186
|
-
/**
|
|
2187
|
-
* The link-target editor — v2's "Link / Go to link / Remove link" menu items,
|
|
2188
|
-
* rebuilt on the schema: any kind whose table declares the `link` spec gets
|
|
2189
|
-
* this control, and every write is the ONE `updateSelection({ link })` path
|
|
2190
|
-
* (the plugin materializes/retargets/deletes the attached children).
|
|
2191
|
-
*/
|
|
2192
|
-
function LinkTargetControl({ label, value, mixed, onChange }) {
|
|
2193
|
-
const kernel = useKernel();
|
|
2194
|
-
const link = useOptionalCapability(LinkToken);
|
|
2195
|
-
const [mode, setMode] = useState(value?.kind === "goto" ? "page" : "uri");
|
|
2196
|
-
const [uri, setUri] = useState(value?.kind === "uri" ? value.uri : "");
|
|
2197
|
-
const [pageNo, setPageNo] = useState("1");
|
|
2198
|
-
useEffect(() => {
|
|
2199
|
-
setMode(value?.kind === "goto" ? "page" : "uri");
|
|
2200
|
-
if (value?.kind === "uri") setUri(value.uri);
|
|
2201
|
-
}, [value]);
|
|
2202
|
-
const apply = () => {
|
|
2203
|
-
if (mode === "uri") {
|
|
2204
|
-
const trimmed = uri.trim();
|
|
2205
|
-
if (trimmed) onChange({ link: {
|
|
2206
|
-
kind: "uri",
|
|
2207
|
-
uri: trimmed
|
|
2208
|
-
} });
|
|
2209
|
-
return;
|
|
2210
|
-
}
|
|
2211
|
-
const activeId = kernel.documents.activeId();
|
|
2212
|
-
const layout = (activeId ? kernel.getState().core.documents[activeId] : null)?.pages[Math.max(0, Number(pageNo) - 1)];
|
|
2213
|
-
if (layout) onChange({ link: {
|
|
2214
|
-
kind: "goto",
|
|
2215
|
-
destination: {
|
|
2216
|
-
kind: "fit",
|
|
2217
|
-
pageObjectNumber: layout.pageObjectNumber
|
|
2218
|
-
}
|
|
2219
|
-
} });
|
|
2220
|
-
};
|
|
2221
|
-
const inputCls = "border-border bg-surface text-fg w-full rounded border px-3 py-1.5 text-sm";
|
|
2222
|
-
return /* @__PURE__ */ jsxs(Field, {
|
|
2223
|
-
label,
|
|
2224
|
-
mixed,
|
|
2225
|
-
children: [
|
|
2226
|
-
value != null && /* @__PURE__ */ jsxs("div", {
|
|
2227
|
-
className: "mb-2 flex items-center gap-2",
|
|
2228
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
2229
|
-
type: "button",
|
|
2230
|
-
className: "border-border bg-surface text-fg flex-1 rounded border px-2 py-1.5 text-sm",
|
|
2231
|
-
onClick: () => link?.activate(value),
|
|
2232
|
-
children: "Go to link"
|
|
2233
|
-
}), /* @__PURE__ */ jsx("button", {
|
|
2234
|
-
type: "button",
|
|
2235
|
-
className: "border-border bg-surface text-fg flex-1 rounded border px-2 py-1.5 text-sm",
|
|
2236
|
-
onClick: () => onChange({ link: null }),
|
|
2237
|
-
children: "Remove link"
|
|
2238
|
-
})]
|
|
2239
|
-
}),
|
|
2240
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2241
|
-
className: "mb-2 flex gap-2",
|
|
2242
|
-
children: [/* @__PURE__ */ jsx(Toggle, {
|
|
2243
|
-
title: "Link to a URL",
|
|
2244
|
-
active: mode === "uri",
|
|
2245
|
-
onClick: () => setMode("uri"),
|
|
2246
|
-
children: "URL"
|
|
2247
|
-
}), /* @__PURE__ */ jsx(Toggle, {
|
|
2248
|
-
title: "Link to a page",
|
|
2249
|
-
active: mode === "page",
|
|
2250
|
-
onClick: () => setMode("page"),
|
|
2251
|
-
children: "Page"
|
|
2252
|
-
})]
|
|
2253
|
-
}),
|
|
2254
|
-
mode === "uri" ? /* @__PURE__ */ jsx("input", {
|
|
2255
|
-
type: "url",
|
|
2256
|
-
className: inputCls,
|
|
2257
|
-
placeholder: "https://…",
|
|
2258
|
-
value: uri,
|
|
2259
|
-
onChange: (e) => setUri(e.target.value),
|
|
2260
|
-
onKeyDown: (e) => e.key === "Enter" && apply()
|
|
2261
|
-
}) : /* @__PURE__ */ jsx("input", {
|
|
2262
|
-
type: "number",
|
|
2263
|
-
min: 1,
|
|
2264
|
-
className: inputCls,
|
|
2265
|
-
placeholder: "Page number",
|
|
2266
|
-
value: pageNo,
|
|
2267
|
-
onChange: (e) => setPageNo(e.target.value),
|
|
2268
|
-
onKeyDown: (e) => e.key === "Enter" && apply()
|
|
2269
|
-
}),
|
|
2270
|
-
/* @__PURE__ */ jsx("button", {
|
|
2271
|
-
type: "button",
|
|
2272
|
-
className: "border-border bg-surface text-fg mt-2 w-full rounded border px-2 py-1.5 text-sm font-medium",
|
|
2273
|
-
onClick: apply,
|
|
2274
|
-
children: value == null ? "Add link" : "Update link"
|
|
2275
|
-
})
|
|
2276
|
-
]
|
|
2277
|
-
});
|
|
2278
|
-
}
|
|
2279
2391
|
function PropControl({ spec, value, mixed, onChange }) {
|
|
2280
2392
|
switch (spec.key) {
|
|
2281
2393
|
case "color":
|
|
@@ -2418,12 +2530,7 @@ function PropControl({ spec, value, mixed, onChange }) {
|
|
|
2418
2530
|
onChange: (blendMode) => onChange({ blendMode })
|
|
2419
2531
|
})
|
|
2420
2532
|
});
|
|
2421
|
-
case "link": return
|
|
2422
|
-
label: spec.label,
|
|
2423
|
-
value: value ?? null,
|
|
2424
|
-
mixed,
|
|
2425
|
-
onChange
|
|
2426
|
-
});
|
|
2533
|
+
case "link": return null;
|
|
2427
2534
|
default: return null;
|
|
2428
2535
|
}
|
|
2429
2536
|
}
|
|
@@ -2525,6 +2632,493 @@ function refKeyOfRedact(ref) {
|
|
|
2525
2632
|
return JSON.stringify(ref);
|
|
2526
2633
|
}
|
|
2527
2634
|
//#endregion
|
|
2635
|
+
//#region src/ui/comment-config.ts
|
|
2636
|
+
/** `/C`-style Color → CSS. */
|
|
2637
|
+
const cssColor = (c) => c ? `rgb(${c.r}, ${c.g}, ${c.b})` : void 0;
|
|
2638
|
+
const TYPE_CONFIG = {
|
|
2639
|
+
text: {
|
|
2640
|
+
icon: "message",
|
|
2641
|
+
labelKey: "annotation.comment",
|
|
2642
|
+
label: "Comment"
|
|
2643
|
+
},
|
|
2644
|
+
highlight: {
|
|
2645
|
+
icon: "highlight",
|
|
2646
|
+
labelKey: "annotation.highlight",
|
|
2647
|
+
label: "Highlight"
|
|
2648
|
+
},
|
|
2649
|
+
underline: {
|
|
2650
|
+
icon: "underline",
|
|
2651
|
+
labelKey: "annotation.underline",
|
|
2652
|
+
label: "Underline"
|
|
2653
|
+
},
|
|
2654
|
+
squiggly: {
|
|
2655
|
+
icon: "squiggly",
|
|
2656
|
+
labelKey: "annotation.squiggly",
|
|
2657
|
+
label: "Squiggly"
|
|
2658
|
+
},
|
|
2659
|
+
strikeout: {
|
|
2660
|
+
icon: "strikethrough",
|
|
2661
|
+
labelKey: "annotation.strikeout",
|
|
2662
|
+
label: "Strikethrough"
|
|
2663
|
+
},
|
|
2664
|
+
square: {
|
|
2665
|
+
icon: "square",
|
|
2666
|
+
labelKey: "annotation.square",
|
|
2667
|
+
label: "Square"
|
|
2668
|
+
},
|
|
2669
|
+
circle: {
|
|
2670
|
+
icon: "circle",
|
|
2671
|
+
labelKey: "annotation.circle",
|
|
2672
|
+
label: "Circle"
|
|
2673
|
+
},
|
|
2674
|
+
line: {
|
|
2675
|
+
icon: "line",
|
|
2676
|
+
labelKey: "annotation.line",
|
|
2677
|
+
label: "Line"
|
|
2678
|
+
},
|
|
2679
|
+
polygon: {
|
|
2680
|
+
icon: "polygon",
|
|
2681
|
+
labelKey: "annotation.polygon",
|
|
2682
|
+
label: "Polygon"
|
|
2683
|
+
},
|
|
2684
|
+
polyline: {
|
|
2685
|
+
icon: "zigzag",
|
|
2686
|
+
labelKey: "annotation.polyline",
|
|
2687
|
+
label: "Polyline"
|
|
2688
|
+
},
|
|
2689
|
+
ink: {
|
|
2690
|
+
icon: "pencilMarker",
|
|
2691
|
+
labelKey: "annotation.ink",
|
|
2692
|
+
label: "Ink"
|
|
2693
|
+
},
|
|
2694
|
+
"free-text": {
|
|
2695
|
+
icon: "freeText",
|
|
2696
|
+
labelKey: "annotation.freeText",
|
|
2697
|
+
label: "Text"
|
|
2698
|
+
},
|
|
2699
|
+
stamp: {
|
|
2700
|
+
icon: "rubberStamp",
|
|
2701
|
+
labelKey: "annotation.stamp",
|
|
2702
|
+
label: "Stamp"
|
|
2703
|
+
},
|
|
2704
|
+
caret: {
|
|
2705
|
+
icon: "insertText",
|
|
2706
|
+
labelKey: "annotation.caret",
|
|
2707
|
+
label: "Caret"
|
|
2708
|
+
},
|
|
2709
|
+
redact: {
|
|
2710
|
+
icon: "redact",
|
|
2711
|
+
labelKey: "annotation.redact",
|
|
2712
|
+
label: "Redact"
|
|
2713
|
+
},
|
|
2714
|
+
"file-attachment": {
|
|
2715
|
+
icon: "paperclip",
|
|
2716
|
+
labelKey: "annotation.fileAttachment",
|
|
2717
|
+
label: "Attachment"
|
|
2718
|
+
}
|
|
2719
|
+
};
|
|
2720
|
+
const FALLBACK = {
|
|
2721
|
+
icon: "message",
|
|
2722
|
+
labelKey: "annotation.comment",
|
|
2723
|
+
label: "Comment"
|
|
2724
|
+
};
|
|
2725
|
+
const commentTypeConfig = (a) => TYPE_CONFIG[a.subtype] ?? FALLBACK;
|
|
2726
|
+
/**
|
|
2727
|
+
* The glyph's tint slots, read off the annotation itself — this is what makes
|
|
2728
|
+
* a card recognizable as "that yellow highlight on page 3". Free-text prefers
|
|
2729
|
+
* its `fontColor` override, since that is the color a reader actually sees.
|
|
2730
|
+
*/
|
|
2731
|
+
const commentIconAccent = (a) => {
|
|
2732
|
+
const anyA = a;
|
|
2733
|
+
const primary = cssColor(anyA.fontColor ?? anyA.color);
|
|
2734
|
+
const secondary = cssColor(anyA.interiorColor);
|
|
2735
|
+
return {
|
|
2736
|
+
...primary ? { primary } : {},
|
|
2737
|
+
...secondary ? { secondary } : {}
|
|
2738
|
+
};
|
|
2739
|
+
};
|
|
2740
|
+
//#endregion
|
|
2741
|
+
//#region src/ui/comments-panel.tsx
|
|
2742
|
+
/**
|
|
2743
|
+
* The comments sidebar (right panel): a live view over the conversation
|
|
2744
|
+
* plane, in the shape v2's reviewers knew — page-grouped sections, and a
|
|
2745
|
+
* card that identifies its annotation at a glance by the type's glyph tinted
|
|
2746
|
+
* with that annotation's own colors. What v2 lacked, and this adds, is the
|
|
2747
|
+
* ISO 32000 §12.5.6.3 review status per thread.
|
|
2748
|
+
*
|
|
2749
|
+
* There is no per-page loading dance: the plugin hydrates the WHOLE document
|
|
2750
|
+
* at open (`listRawAll`), so the list is complete the moment `hydration()`
|
|
2751
|
+
* says so, whether or not a page was ever scrolled to.
|
|
2752
|
+
*
|
|
2753
|
+
* Selection is two-way, as in v2: clicking a card selects the annotation and
|
|
2754
|
+
* flies the camera to it (`stage.reveal`, the same verb search hits use);
|
|
2755
|
+
* selecting in the document scrolls that card into view here.
|
|
2756
|
+
*
|
|
2757
|
+
* Every action routes through the `comments` verbs — plain annotation writes
|
|
2758
|
+
* on the one optimistic pipeline — and every control is gated by
|
|
2759
|
+
* `permissionsFor`, the engine's own collab-resolver mirrors: what shows here
|
|
2760
|
+
* is what the engine will allow.
|
|
2761
|
+
*/
|
|
2762
|
+
const REVIEW_STATES = [
|
|
2763
|
+
"none",
|
|
2764
|
+
"accepted",
|
|
2765
|
+
"rejected",
|
|
2766
|
+
"cancelled",
|
|
2767
|
+
"completed"
|
|
2768
|
+
];
|
|
2769
|
+
const dateLabel = (iso) => {
|
|
2770
|
+
if (!iso) return "";
|
|
2771
|
+
const d = new Date(iso);
|
|
2772
|
+
if (Number.isNaN(d.getTime())) return "";
|
|
2773
|
+
return d.toLocaleDateString(void 0, {
|
|
2774
|
+
month: "short",
|
|
2775
|
+
day: "numeric"
|
|
2776
|
+
});
|
|
2777
|
+
};
|
|
2778
|
+
function CommentsPanel() {
|
|
2779
|
+
const t = useT();
|
|
2780
|
+
const hydration = useCommentsHydration();
|
|
2781
|
+
const comments = useComments();
|
|
2782
|
+
const threads = useCommentThreads();
|
|
2783
|
+
const anno = useCapability(AnnotationToken$1);
|
|
2784
|
+
const stage = useCapability(StageToken$1);
|
|
2785
|
+
const selection = useAnnotationSelection();
|
|
2786
|
+
const scrollRef = useRef(null);
|
|
2787
|
+
const cardRefs = useRef({});
|
|
2788
|
+
/** Which thread the document's selection points at — ANY member counts, so
|
|
2789
|
+
* selecting a reply's parent shape highlights the same card. */
|
|
2790
|
+
const selectedThreadKey = useMemo(() => {
|
|
2791
|
+
for (const id of selection) {
|
|
2792
|
+
const ref = anno.getSelected().find((a) => refKey(a.ref) === id || a.nm === id)?.ref ?? null;
|
|
2793
|
+
const thread = ref ? comments.thread(ref) : null;
|
|
2794
|
+
if (thread) return refKey(thread.root.ref);
|
|
2795
|
+
}
|
|
2796
|
+
return null;
|
|
2797
|
+
}, [
|
|
2798
|
+
selection,
|
|
2799
|
+
anno,
|
|
2800
|
+
comments
|
|
2801
|
+
]);
|
|
2802
|
+
useEffect(() => {
|
|
2803
|
+
if (!selectedThreadKey || !scrollRef.current) return;
|
|
2804
|
+
const el = cardRefs.current[selectedThreadKey];
|
|
2805
|
+
if (!el) return;
|
|
2806
|
+
const container = scrollRef.current;
|
|
2807
|
+
const top = el.offsetTop - container.clientHeight / 2 + el.clientHeight / 2 - container.offsetTop;
|
|
2808
|
+
container.scrollTo({
|
|
2809
|
+
top,
|
|
2810
|
+
behavior: "smooth"
|
|
2811
|
+
});
|
|
2812
|
+
}, [selectedThreadKey]);
|
|
2813
|
+
/** Click a card: select the annotation AND fly the camera to it. */
|
|
2814
|
+
const goTo = (view) => {
|
|
2815
|
+
anno.select(view.root.ref);
|
|
2816
|
+
if (view.pageIndex < 0) return;
|
|
2817
|
+
stage?.reveal(view.pageIndex, {
|
|
2818
|
+
...view.contentRect ? { rect: view.contentRect } : {},
|
|
2819
|
+
anchor: {
|
|
2820
|
+
x: "center",
|
|
2821
|
+
y: .35
|
|
2822
|
+
},
|
|
2823
|
+
behavior: "smooth"
|
|
2824
|
+
});
|
|
2825
|
+
};
|
|
2826
|
+
const byPage = useMemo(() => {
|
|
2827
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2828
|
+
for (const v of threads) {
|
|
2829
|
+
const arr = groups.get(v.pageIndex);
|
|
2830
|
+
if (arr) arr.push(v);
|
|
2831
|
+
else groups.set(v.pageIndex, [v]);
|
|
2832
|
+
}
|
|
2833
|
+
return [...groups.entries()].sort((a, b) => a[0] - b[0]);
|
|
2834
|
+
}, [threads]);
|
|
2835
|
+
if (hydration.status === "loading") return /* @__PURE__ */ jsx(Empty, {
|
|
2836
|
+
icon: "comment",
|
|
2837
|
+
text: t("demo.commentsLoading")
|
|
2838
|
+
});
|
|
2839
|
+
if (hydration.status === "forbidden") return /* @__PURE__ */ jsx(Empty, {
|
|
2840
|
+
icon: "lock",
|
|
2841
|
+
text: t("demo.commentsForbidden")
|
|
2842
|
+
});
|
|
2843
|
+
if (hydration.status === "error") return /* @__PURE__ */ jsx(Empty, {
|
|
2844
|
+
icon: "alertTriangle",
|
|
2845
|
+
text: t("demo.commentsError"),
|
|
2846
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
2847
|
+
type: "button",
|
|
2848
|
+
onClick: () => void comments.rehydrate(),
|
|
2849
|
+
className: "bg-accent text-on-accent rounded-md px-3 py-1.5 text-sm font-medium",
|
|
2850
|
+
children: t("demo.commentsRetry")
|
|
2851
|
+
})
|
|
2852
|
+
});
|
|
2853
|
+
if (threads.length === 0) return /* @__PURE__ */ jsx(Empty, {
|
|
2854
|
+
icon: "comment",
|
|
2855
|
+
text: t("demo.commentsEmpty")
|
|
2856
|
+
});
|
|
2857
|
+
return /* @__PURE__ */ jsx("div", {
|
|
2858
|
+
ref: scrollRef,
|
|
2859
|
+
className: "min-h-0 flex-1 overflow-y-auto",
|
|
2860
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
2861
|
+
className: "flex flex-col gap-5 p-3",
|
|
2862
|
+
children: byPage.map(([pageIndex, group]) => /* @__PURE__ */ jsxs("div", {
|
|
2863
|
+
className: "flex flex-col gap-2",
|
|
2864
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
2865
|
+
className: "bg-surface sticky top-0 z-10",
|
|
2866
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2867
|
+
className: "border-border-subtle border-b pb-1.5",
|
|
2868
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
2869
|
+
className: "text-fg text-sm font-semibold",
|
|
2870
|
+
children: t("demo.commentsPage", { params: { page: group[0].pageLabel } })
|
|
2871
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
2872
|
+
className: "text-fg-muted text-xs",
|
|
2873
|
+
children: t(group.length === 1 ? "demo.commentCount" : "demo.commentCountPlural", { params: { count: String(group.length) } })
|
|
2874
|
+
})]
|
|
2875
|
+
})
|
|
2876
|
+
}), /* @__PURE__ */ jsx("ul", {
|
|
2877
|
+
className: "flex flex-col gap-2",
|
|
2878
|
+
children: group.map((view) => {
|
|
2879
|
+
const key = refKey(view.root.ref);
|
|
2880
|
+
return /* @__PURE__ */ jsx(ThreadCard, {
|
|
2881
|
+
view,
|
|
2882
|
+
selected: selectedThreadKey === key,
|
|
2883
|
+
onSelect: () => goTo(view),
|
|
2884
|
+
cardRef: (el) => {
|
|
2885
|
+
cardRefs.current[key] = el;
|
|
2886
|
+
}
|
|
2887
|
+
}, key);
|
|
2888
|
+
})
|
|
2889
|
+
})]
|
|
2890
|
+
}, pageIndex))
|
|
2891
|
+
})
|
|
2892
|
+
});
|
|
2893
|
+
}
|
|
2894
|
+
function Empty({ icon, text, children }) {
|
|
2895
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
2896
|
+
className: "flex flex-col items-center gap-3 px-4 py-10 text-center",
|
|
2897
|
+
children: [
|
|
2898
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
2899
|
+
name: icon,
|
|
2900
|
+
size: 32,
|
|
2901
|
+
className: "text-fg-muted"
|
|
2902
|
+
}),
|
|
2903
|
+
/* @__PURE__ */ jsx("p", {
|
|
2904
|
+
className: "text-fg-muted text-sm",
|
|
2905
|
+
children: text
|
|
2906
|
+
}),
|
|
2907
|
+
children
|
|
2908
|
+
]
|
|
2909
|
+
});
|
|
2910
|
+
}
|
|
2911
|
+
function ThreadCard({ view, selected, onSelect, cardRef }) {
|
|
2912
|
+
const t = useT();
|
|
2913
|
+
const comments = useComments();
|
|
2914
|
+
const [reply, setReply] = useState("");
|
|
2915
|
+
const perms = comments.permissionsFor(view.root.ref);
|
|
2916
|
+
const config = commentTypeConfig(view.root);
|
|
2917
|
+
const status = view.review.mine?.state ?? "none";
|
|
2918
|
+
const latest = view.review.lastChange;
|
|
2919
|
+
const sendReply = () => {
|
|
2920
|
+
const text = reply.trim();
|
|
2921
|
+
if (!text) return;
|
|
2922
|
+
setReply("");
|
|
2923
|
+
comments.reply(view.root.ref, text);
|
|
2924
|
+
};
|
|
2925
|
+
return /* @__PURE__ */ jsx("li", {
|
|
2926
|
+
ref: cardRef,
|
|
2927
|
+
onClick: onSelect,
|
|
2928
|
+
className: `bg-surface cursor-pointer rounded-lg border shadow-sm transition-all hover:shadow-md ${selected ? "border-accent ring-accent/40 ring-2" : "border-border-subtle"}`,
|
|
2929
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
2930
|
+
className: "flex flex-col gap-2 p-3",
|
|
2931
|
+
children: [
|
|
2932
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2933
|
+
className: "flex items-start gap-2.5",
|
|
2934
|
+
children: [
|
|
2935
|
+
/* @__PURE__ */ jsx("div", {
|
|
2936
|
+
className: "bg-hover mt-0.5 grid h-8 w-8 shrink-0 place-items-center rounded-full",
|
|
2937
|
+
title: t(config.labelKey, { fallback: config.label }),
|
|
2938
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
2939
|
+
name: config.icon,
|
|
2940
|
+
size: 18,
|
|
2941
|
+
accent: commentIconAccent(view.root)
|
|
2942
|
+
})
|
|
2943
|
+
}),
|
|
2944
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2945
|
+
className: "min-w-0 flex-1",
|
|
2946
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
2947
|
+
className: "flex items-baseline gap-2",
|
|
2948
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
2949
|
+
className: "text-fg truncate text-sm font-medium",
|
|
2950
|
+
children: view.root.author ?? t("demo.commentsAnonymous")
|
|
2951
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
2952
|
+
className: "text-fg-muted ml-auto shrink-0 text-xs",
|
|
2953
|
+
children: dateLabel(view.root.modified ?? view.root.created)
|
|
2954
|
+
})]
|
|
2955
|
+
}), latest && /* @__PURE__ */ jsxs("span", {
|
|
2956
|
+
className: "bg-accent-light text-accent mt-1 inline-block rounded px-1.5 py-0.5 text-[11px] font-medium",
|
|
2957
|
+
children: [statusLabel(t, latest.state), latest.by ? ` — ${latest.by}` : ""]
|
|
2958
|
+
})]
|
|
2959
|
+
}),
|
|
2960
|
+
perms.canDeleteThread && /* @__PURE__ */ jsx("button", {
|
|
2961
|
+
type: "button",
|
|
2962
|
+
onClick: (e) => {
|
|
2963
|
+
e.stopPropagation();
|
|
2964
|
+
comments.removeThread(view.root.ref);
|
|
2965
|
+
},
|
|
2966
|
+
className: "text-fg-muted hover:text-fg grid h-6 w-6 shrink-0 place-items-center rounded",
|
|
2967
|
+
title: t("demo.commentsDeleteThread"),
|
|
2968
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
2969
|
+
name: "trash",
|
|
2970
|
+
size: 14
|
|
2971
|
+
})
|
|
2972
|
+
})
|
|
2973
|
+
]
|
|
2974
|
+
}),
|
|
2975
|
+
/* @__PURE__ */ jsx(CommentBody, {
|
|
2976
|
+
annotationRef: view.root.ref,
|
|
2977
|
+
text: view.root.contents ?? "",
|
|
2978
|
+
deletable: false
|
|
2979
|
+
}),
|
|
2980
|
+
view.replies.length > 0 && /* @__PURE__ */ jsx("div", {
|
|
2981
|
+
className: "border-border-subtle flex flex-col gap-2 border-t pt-2",
|
|
2982
|
+
children: view.replies.map((r) => /* @__PURE__ */ jsx(Reply, { dto: r }, refKey(r.ref)))
|
|
2983
|
+
}),
|
|
2984
|
+
/* @__PURE__ */ jsxs("div", {
|
|
2985
|
+
className: "border-border-subtle flex flex-col gap-1.5 border-t pt-2",
|
|
2986
|
+
children: [perms.canSetStatus && /* @__PURE__ */ jsxs("label", {
|
|
2987
|
+
className: "text-fg-muted flex items-center gap-2 text-xs",
|
|
2988
|
+
onClick: (e) => e.stopPropagation(),
|
|
2989
|
+
children: [t("demo.commentsStatus"), /* @__PURE__ */ jsx("select", {
|
|
2990
|
+
value: status,
|
|
2991
|
+
onChange: (e) => void comments.setStatus(view.root.ref, e.target.value),
|
|
2992
|
+
className: "border-border bg-surface text-fg flex-1 rounded-md border px-1.5 py-1 text-xs outline-none",
|
|
2993
|
+
children: REVIEW_STATES.map((s) => /* @__PURE__ */ jsx("option", {
|
|
2994
|
+
value: s,
|
|
2995
|
+
children: statusLabel(t, s)
|
|
2996
|
+
}, s))
|
|
2997
|
+
})]
|
|
2998
|
+
}), perms.canReply && /* @__PURE__ */ jsxs("div", {
|
|
2999
|
+
className: "flex items-center gap-1.5",
|
|
3000
|
+
onClick: (e) => e.stopPropagation(),
|
|
3001
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
3002
|
+
type: "text",
|
|
3003
|
+
value: reply,
|
|
3004
|
+
placeholder: view.root.contents || view.replies.length ? t("demo.commentsReplyPlaceholder") : t("demo.commentsAddPlaceholder"),
|
|
3005
|
+
onChange: (e) => setReply(e.target.value),
|
|
3006
|
+
onKeyDown: (e) => e.key === "Enter" && sendReply(),
|
|
3007
|
+
className: "border-border bg-surface text-fg focus:border-accent w-full min-w-0 flex-1 rounded-md border px-2 py-1 text-sm outline-none"
|
|
3008
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
3009
|
+
type: "button",
|
|
3010
|
+
onClick: sendReply,
|
|
3011
|
+
disabled: !reply.trim(),
|
|
3012
|
+
className: "text-accent disabled:text-fg-muted grid h-7 w-7 shrink-0 place-items-center rounded-md",
|
|
3013
|
+
title: t("demo.commentsReply"),
|
|
3014
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3015
|
+
name: "arrowForwardUp",
|
|
3016
|
+
size: 16
|
|
3017
|
+
})
|
|
3018
|
+
})]
|
|
3019
|
+
})]
|
|
3020
|
+
})
|
|
3021
|
+
]
|
|
3022
|
+
})
|
|
3023
|
+
});
|
|
3024
|
+
}
|
|
3025
|
+
function Reply({ dto }) {
|
|
3026
|
+
const t = useT();
|
|
3027
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3028
|
+
className: "border-border-subtle ml-1 border-l-2 pl-2",
|
|
3029
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
3030
|
+
className: "flex items-baseline gap-2",
|
|
3031
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
3032
|
+
className: "text-fg-secondary text-xs font-medium",
|
|
3033
|
+
children: dto.author ?? t("demo.commentsAnonymous")
|
|
3034
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
3035
|
+
className: "text-fg-muted text-[11px]",
|
|
3036
|
+
children: dateLabel(dto.modified ?? dto.created)
|
|
3037
|
+
})]
|
|
3038
|
+
}), /* @__PURE__ */ jsx(CommentBody, {
|
|
3039
|
+
annotationRef: dto.ref,
|
|
3040
|
+
text: dto.contents ?? "",
|
|
3041
|
+
deletable: true
|
|
3042
|
+
})]
|
|
3043
|
+
});
|
|
3044
|
+
}
|
|
3045
|
+
/** One comment's text with inline edit (own, unlocked) and delete (replies). */
|
|
3046
|
+
function CommentBody({ annotationRef, text, deletable }) {
|
|
3047
|
+
const t = useT();
|
|
3048
|
+
const comments = useComments();
|
|
3049
|
+
const perms = comments.permissionsFor(annotationRef);
|
|
3050
|
+
const [draft, setDraft] = useState(null);
|
|
3051
|
+
if (draft !== null) {
|
|
3052
|
+
const save = () => {
|
|
3053
|
+
const next = draft.trim();
|
|
3054
|
+
setDraft(null);
|
|
3055
|
+
if (next && next !== text) comments.edit(annotationRef, next);
|
|
3056
|
+
};
|
|
3057
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
3058
|
+
value: draft,
|
|
3059
|
+
autoFocus: true,
|
|
3060
|
+
rows: 2,
|
|
3061
|
+
onClick: (e) => e.stopPropagation(),
|
|
3062
|
+
onChange: (e) => setDraft(e.target.value),
|
|
3063
|
+
onBlur: save,
|
|
3064
|
+
onKeyDown: (e) => {
|
|
3065
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
3066
|
+
e.preventDefault();
|
|
3067
|
+
save();
|
|
3068
|
+
}
|
|
3069
|
+
if (e.key === "Escape") setDraft(null);
|
|
3070
|
+
},
|
|
3071
|
+
className: "border-accent bg-surface text-fg w-full resize-none rounded-md border px-2 py-1 text-sm outline-none"
|
|
3072
|
+
});
|
|
3073
|
+
}
|
|
3074
|
+
if (!text && !perms.canEditText && !deletable) return null;
|
|
3075
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3076
|
+
className: "group/body flex items-start gap-1",
|
|
3077
|
+
children: [
|
|
3078
|
+
/* @__PURE__ */ jsx("p", {
|
|
3079
|
+
className: "text-fg min-w-0 flex-1 whitespace-pre-wrap text-sm",
|
|
3080
|
+
children: text
|
|
3081
|
+
}),
|
|
3082
|
+
perms.canEditText && /* @__PURE__ */ jsx("button", {
|
|
3083
|
+
type: "button",
|
|
3084
|
+
onClick: (e) => {
|
|
3085
|
+
e.stopPropagation();
|
|
3086
|
+
setDraft(text);
|
|
3087
|
+
},
|
|
3088
|
+
className: "text-fg-muted hover:text-fg grid h-5 w-5 shrink-0 place-items-center rounded opacity-0 group-hover/body:opacity-100",
|
|
3089
|
+
title: t("demo.commentsEdit"),
|
|
3090
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3091
|
+
name: "pencilMarker",
|
|
3092
|
+
size: 12
|
|
3093
|
+
})
|
|
3094
|
+
}),
|
|
3095
|
+
deletable && perms.canDelete && /* @__PURE__ */ jsx("button", {
|
|
3096
|
+
type: "button",
|
|
3097
|
+
onClick: (e) => {
|
|
3098
|
+
e.stopPropagation();
|
|
3099
|
+
comments.remove(annotationRef);
|
|
3100
|
+
},
|
|
3101
|
+
className: "text-fg-muted hover:text-fg grid h-5 w-5 shrink-0 place-items-center rounded opacity-0 group-hover/body:opacity-100",
|
|
3102
|
+
title: t("demo.commentsDelete"),
|
|
3103
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
3104
|
+
name: "trash",
|
|
3105
|
+
size: 12
|
|
3106
|
+
})
|
|
3107
|
+
})
|
|
3108
|
+
]
|
|
3109
|
+
});
|
|
3110
|
+
}
|
|
3111
|
+
function statusLabel(t, state) {
|
|
3112
|
+
switch (state) {
|
|
3113
|
+
case "none": return t("demo.commentsStatusNone");
|
|
3114
|
+
case "accepted": return t("demo.commentsStatusAccepted");
|
|
3115
|
+
case "rejected": return t("demo.commentsStatusRejected");
|
|
3116
|
+
case "cancelled": return t("demo.commentsStatusCancelled");
|
|
3117
|
+
case "completed": return t("demo.commentsStatusCompleted");
|
|
3118
|
+
default: return state;
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
//#endregion
|
|
2528
3122
|
//#region src/ui/redaction-panel.tsx
|
|
2529
3123
|
/**
|
|
2530
3124
|
* The pending-redactions review panel (right sidebar). The list is a LIVE view
|
|
@@ -2959,13 +3553,7 @@ function RightSidebar() {
|
|
|
2959
3553
|
size: 16
|
|
2960
3554
|
})
|
|
2961
3555
|
})]
|
|
2962
|
-
}), active === "style" ? /* @__PURE__ */ jsx(AnnotationStylePanel, {}) : active === "search" ? /* @__PURE__ */ jsx(SearchPanel, {}, documentId ?? "none") : active === "redaction" ? /* @__PURE__ */ jsx(RedactionPanel, {}) : /* @__PURE__ */ jsx(
|
|
2963
|
-
className: "p-3",
|
|
2964
|
-
children: /* @__PURE__ */ jsx("p", {
|
|
2965
|
-
className: "text-fg-muted text-sm",
|
|
2966
|
-
children: t("demo.empty")
|
|
2967
|
-
})
|
|
2968
|
-
})]
|
|
3556
|
+
}), active === "style" ? /* @__PURE__ */ jsx(AnnotationStylePanel, {}) : active === "search" ? /* @__PURE__ */ jsx(SearchPanel, {}, documentId ?? "none") : active === "redaction" ? /* @__PURE__ */ jsx(RedactionPanel, {}) : /* @__PURE__ */ jsx(CommentsPanel, {}, documentId ?? "none")]
|
|
2969
3557
|
});
|
|
2970
3558
|
}
|
|
2971
3559
|
function PageControls() {
|
|
@@ -3314,10 +3902,12 @@ function Shell() {
|
|
|
3314
3902
|
className: "relative min-w-0 flex-1",
|
|
3315
3903
|
children: [
|
|
3316
3904
|
/* @__PURE__ */ jsx(ArmedToolCursor, {}),
|
|
3905
|
+
/* @__PURE__ */ jsx(SelectionClipboard, {}),
|
|
3317
3906
|
/* @__PURE__ */ jsx(Stage, {
|
|
3318
|
-
interaction: true,
|
|
3319
3907
|
overlay: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3320
3908
|
/* @__PURE__ */ jsx(AnnotationStrip, {}),
|
|
3909
|
+
/* @__PURE__ */ jsx(SelectionStrip, {}),
|
|
3910
|
+
/* @__PURE__ */ jsx(SelectionHandles, {}),
|
|
3321
3911
|
/* @__PURE__ */ jsx(Scrollbar, { axis: "y" }),
|
|
3322
3912
|
/* @__PURE__ */ jsx(Scrollbar, { axis: "x" })
|
|
3323
3913
|
] }),
|
|
@@ -3325,7 +3915,6 @@ function Shell() {
|
|
|
3325
3915
|
style: { background: "var(--ep-canvas)" },
|
|
3326
3916
|
children: () => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
3327
3917
|
/* @__PURE__ */ jsx(RenderLayer, { annotations: false }),
|
|
3328
|
-
/* @__PURE__ */ jsx(TileLayer, { annotations: false }),
|
|
3329
3918
|
/* @__PURE__ */ jsx(SelectionLayer, {}),
|
|
3330
3919
|
/* @__PURE__ */ jsx(SearchLayer, {}),
|
|
3331
3920
|
/* @__PURE__ */ jsx(LinkLayer, {}),
|
|
@@ -3364,7 +3953,7 @@ function Shell() {
|
|
|
3364
3953
|
* changing these props on a mounted viewer does not rebuild the workspace.
|
|
3365
3954
|
*/
|
|
3366
3955
|
/** Lazy built-in packs — a strings override for one of these wraps its loader. */
|
|
3367
|
-
const BUILTIN_LOADERS = { es: () => import("./es-
|
|
3956
|
+
const BUILTIN_LOADERS = { es: () => import("./es-aQlZ3hcL.js").then((m) => m.es) };
|
|
3368
3957
|
const isDict = (v) => typeof v === "object" && v !== null;
|
|
3369
3958
|
/**
|
|
3370
3959
|
* Deep-merge `over` into `base` (immutably), expanding dotted keys —
|
|
@@ -3453,10 +4042,7 @@ function FullViewer({ engine, initialDocuments, fallback, commands, icons, strin
|
|
|
3453
4042
|
for (const c of resolved.commands) if (c.icon && !(c.icon in ICON_PATHS) && !(c.icon in resolved.icons)) console.warn(`[embedpdf] command "${c.id}": unknown icon "${c.icon}"`);
|
|
3454
4043
|
}, [resolved]);
|
|
3455
4044
|
const [plugins] = useState(() => [
|
|
3456
|
-
stagePlugin({
|
|
3457
|
-
layout: "vertical",
|
|
3458
|
-
interaction: true
|
|
3459
|
-
}),
|
|
4045
|
+
stagePlugin({ layout: "vertical" }),
|
|
3460
4046
|
stagePlugin({
|
|
3461
4047
|
id: "stage-thumbs",
|
|
3462
4048
|
token: ThumbsStageToken,
|
|
@@ -3480,7 +4066,8 @@ function FullViewer({ engine, initialDocuments, fallback, commands, icons, strin
|
|
|
3480
4066
|
}),
|
|
3481
4067
|
renderPlugin(),
|
|
3482
4068
|
pageEditPlugin(),
|
|
3483
|
-
interactionPlugin(
|
|
4069
|
+
interactionPlugin(),
|
|
4070
|
+
feedbackPlugin({ provider: vibrationFeedback }),
|
|
3484
4071
|
selectionPlugin(),
|
|
3485
4072
|
annotationPlugin({ tools: [{
|
|
3486
4073
|
id: "arrow",
|