@embedpdf/viewer-chrome 3.0.0-next.4 → 3.0.0-next.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,10 +3,10 @@ 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, TileLayer, renderPlugin } from "@embedpdf/react/render";
6
+ import { RenderLayer, renderPlugin } from "@embedpdf/react/render";
7
7
  import { pageEditPlugin } from "@embedpdf/react/page-edit";
8
8
  import { InteractionToken, InteractionToken as InteractionToken$1, interactionPlugin, useTool, useToolCursor } from "@embedpdf/react/interaction";
9
- import { SelectionLayer, SelectionToken, selectionPlugin } from "@embedpdf/react/selection";
9
+ import { SelectionClipboard, SelectionLayer, SelectionMenu, SelectionToken, selectionPlugin } from "@embedpdf/react/selection";
10
10
  import { AnnotationLayer, AnnotationToken, AnnotationToken as AnnotationToken$1, annotationPlugin, useAnnotation, useAnnotationDefaults, useAnnotationSelected, 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";
@@ -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",
@@ -1283,19 +1287,13 @@ function AppToolbar({ bar, className }) {
1283
1287
  });
1284
1288
  }
1285
1289
  //#endregion
1286
- //#region src/ui/annotation-strip.tsx
1290
+ //#region src/ui/strip-bar.tsx
1287
1291
  /**
1288
- * The annotation selection strip — v2's floating "selection menu" rebuilt as
1289
- * chrome. Three parties, none of them this file's business to compute:
1290
- *
1291
- * config/chrome.ts `strips.annotation` declares WHAT may appear
1292
- * each command's visible/enabled decides WHICH items show
1293
- * <AnnotationMenu> solves WHERE (camera transform,
1294
- * rotate-knob dodging, pointer isolation)
1295
- *
1296
- * useStripView is the live intersection: hidden commands drop out, empty
1297
- * groups vanish, null when nothing applies. This file only draws pixels.
1298
- * Mounted in the Stage `overlay` slot.
1292
+ * The floating strip's PIXELS, shared by every contextual strip (annotation
1293
+ * selection, text selection, …): a rounded toolbar of command buttons with
1294
+ * derived group separators. The WHERE is each strip's menu component
1295
+ * (`<AnnotationMenu>`, `<SelectionMenu>`); the WHICH is the commands'
1296
+ * `visible`/`enabled` derivations via `useStripView`. This file only draws.
1299
1297
  */
1300
1298
  function StripButton({ cmd, run }) {
1301
1299
  return /* @__PURE__ */ jsx("button", {
@@ -1313,6 +1311,34 @@ function StripButton({ cmd, run }) {
1313
1311
  })
1314
1312
  });
1315
1313
  }
1314
+ function StripBar({ view, label }) {
1315
+ return /* @__PURE__ */ jsx("div", {
1316
+ role: "toolbar",
1317
+ "aria-label": label,
1318
+ className: "border-border-subtle bg-elevated flex items-center gap-1 rounded-lg border p-1 shadow-xl",
1319
+ children: view.groups.map((g, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", {
1320
+ "aria-hidden": true,
1321
+ className: "bg-border h-5 w-px"
1322
+ }), g.commands.map((cmd) => /* @__PURE__ */ jsx(StripButton, {
1323
+ cmd,
1324
+ run: () => view.execute(cmd.id)
1325
+ }, cmd.id))] }, g.id))
1326
+ });
1327
+ }
1328
+ //#endregion
1329
+ //#region src/ui/annotation-strip.tsx
1330
+ /**
1331
+ * The ANNOTATION-selection floating strip:
1332
+ *
1333
+ * config/chrome.ts `strips.annotation` declares WHAT may appear
1334
+ * each command's visible/enabled decides WHICH items show
1335
+ * <AnnotationMenu> solves WHERE (camera transform,
1336
+ * rotate-knob dodging, pointer isolation)
1337
+ *
1338
+ * useStripView is the live intersection: hidden commands drop out, empty
1339
+ * groups vanish, null when nothing applies. Mounted in the Stage `overlay`
1340
+ * slot. The pixels are the shared <StripBar>.
1341
+ */
1316
1342
  function AnnotationStrip() {
1317
1343
  const t = useT();
1318
1344
  const view = useStripView(useStripSchema("annotation"));
@@ -1320,17 +1346,36 @@ function AnnotationStrip() {
1320
1346
  return /* @__PURE__ */ jsx(AnnotationMenu, {
1321
1347
  placement: "bottom",
1322
1348
  gap: 15,
1323
- children: () => /* @__PURE__ */ jsx("div", {
1324
- role: "toolbar",
1325
- "aria-label": t("commands.annotate.strip"),
1326
- className: "border-border-subtle bg-elevated flex items-center gap-1 rounded-lg border p-1 shadow-xl",
1327
- children: view.groups.map((g, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("span", {
1328
- "aria-hidden": true,
1329
- className: "bg-border h-5 w-px"
1330
- }), g.commands.map((cmd) => /* @__PURE__ */ jsx(StripButton, {
1331
- cmd,
1332
- run: () => view.execute(cmd.id)
1333
- }, cmd.id))] }, g.id))
1349
+ children: /* @__PURE__ */ jsx(StripBar, {
1350
+ view,
1351
+ label: t("commands.annotate.strip")
1352
+ })
1353
+ });
1354
+ }
1355
+ //#endregion
1356
+ //#region src/ui/selection-strip.tsx
1357
+ /**
1358
+ * The TEXT-SELECTION floating strip:
1359
+ *
1360
+ * config/chrome.ts `strips.selection` declares WHAT may appear
1361
+ * each command's visible/enabled decides WHICH items show
1362
+ * <SelectionMenu> solves WHERE (settles on pointer-up,
1363
+ * camera transform, pointer isolation)
1364
+ *
1365
+ * `useStripView` is the live intersection: with copy denied (no
1366
+ * doc.text.copy) every command drops out and this renders nothing — no
1367
+ * empty bubble. Mounted in the Stage `overlay` slot.
1368
+ */
1369
+ function SelectionStrip() {
1370
+ const t = useT();
1371
+ const view = useStripView(useStripSchema("selection"));
1372
+ if (!view) return null;
1373
+ return /* @__PURE__ */ jsx(SelectionMenu, {
1374
+ placement: "bottom",
1375
+ gap: 12,
1376
+ children: /* @__PURE__ */ jsx(StripBar, {
1377
+ view,
1378
+ label: t("commands.selection.strip")
1334
1379
  })
1335
1380
  });
1336
1381
  }
@@ -3314,10 +3359,12 @@ function Shell() {
3314
3359
  className: "relative min-w-0 flex-1",
3315
3360
  children: [
3316
3361
  /* @__PURE__ */ jsx(ArmedToolCursor, {}),
3362
+ /* @__PURE__ */ jsx(SelectionClipboard, {}),
3317
3363
  /* @__PURE__ */ jsx(Stage, {
3318
3364
  interaction: true,
3319
3365
  overlay: /* @__PURE__ */ jsxs(Fragment$1, { children: [
3320
3366
  /* @__PURE__ */ jsx(AnnotationStrip, {}),
3367
+ /* @__PURE__ */ jsx(SelectionStrip, {}),
3321
3368
  /* @__PURE__ */ jsx(Scrollbar, { axis: "y" }),
3322
3369
  /* @__PURE__ */ jsx(Scrollbar, { axis: "x" })
3323
3370
  ] }),
@@ -3325,7 +3372,6 @@ function Shell() {
3325
3372
  style: { background: "var(--ep-canvas)" },
3326
3373
  children: () => /* @__PURE__ */ jsxs(Fragment$1, { children: [
3327
3374
  /* @__PURE__ */ jsx(RenderLayer, { annotations: false }),
3328
- /* @__PURE__ */ jsx(TileLayer, { annotations: false }),
3329
3375
  /* @__PURE__ */ jsx(SelectionLayer, {}),
3330
3376
  /* @__PURE__ */ jsx(SearchLayer, {}),
3331
3377
  /* @__PURE__ */ jsx(LinkLayer, {}),
@@ -3364,7 +3410,7 @@ function Shell() {
3364
3410
  * changing these props on a mounted viewer does not rebuild the workspace.
3365
3411
  */
3366
3412
  /** Lazy built-in packs — a strings override for one of these wraps its loader. */
3367
- const BUILTIN_LOADERS = { es: () => import("./es-D0PzYE9Z.js").then((m) => m.es) };
3413
+ const BUILTIN_LOADERS = { es: () => import("./es-CfmzJaGm.js").then((m) => m.es) };
3368
3414
  const isDict = (v) => typeof v === "object" && v !== null;
3369
3415
  /**
3370
3416
  * Deep-merge `over` into `base` (immutably), expanding dotted keys —