@embedpdf/react 3.0.0-next.1 → 3.0.0-next.11
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/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.cts +546 -0
- package/dist/AnnotationListSnapshot-C1U3XUxP-6kGwNoxy.d.ts +546 -0
- package/dist/actions.cjs +42 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +18 -0
- package/dist/actions.d.ts +18 -0
- package/dist/actions.js +34 -0
- package/dist/actions.js.map +1 -0
- package/dist/anchored.cjs +89 -0
- package/dist/anchored.cjs.map +1 -0
- package/dist/anchored.d.cts +45 -0
- package/dist/anchored.d.ts +45 -0
- package/dist/anchored.js +60 -0
- package/dist/anchored.js.map +1 -0
- package/dist/{annotation-B6jwfTCh.d.cts → annotation-BCED_p9H.d.cts} +56 -69
- package/dist/annotation-anchors-CetwM1g7.js +15 -0
- package/dist/annotation-anchors-CetwM1g7.js.map +1 -0
- package/dist/annotation-anchors-DuYRBJLl.cjs +26 -0
- package/dist/annotation-anchors-DuYRBJLl.cjs.map +1 -0
- package/dist/annotation-hooks-BB5ZhPpf.cjs +16 -0
- package/dist/annotation-hooks-BB5ZhPpf.cjs.map +1 -0
- package/dist/annotation-hooks-Df8EmzDO.js +11 -0
- package/dist/annotation-hooks-Df8EmzDO.js.map +1 -0
- package/dist/{annotation-nUMefyjw.d.ts → annotation-k38KDlIZ.d.ts} +57 -70
- package/dist/annotation-menu.cjs +37 -88
- package/dist/annotation-menu.cjs.map +1 -1
- package/dist/annotation-menu.d.cts +28 -2
- package/dist/annotation-menu.d.ts +28 -2
- package/dist/annotation-menu.js +28 -79
- package/dist/annotation-menu.js.map +1 -1
- package/dist/annotation.cjs +738 -16
- package/dist/annotation.cjs.map +1 -0
- package/dist/annotation.d.cts +2 -2
- package/dist/annotation.d.ts +2 -2
- package/dist/annotation.js +723 -3
- package/dist/annotation.js.map +1 -0
- package/dist/commands.js +1 -0
- package/dist/commands.js.map +1 -1
- package/dist/form-BwrLFpKN.js +805 -0
- package/dist/form-BwrLFpKN.js.map +1 -0
- package/dist/form-D-ZSfGmB.cjs +836 -0
- package/dist/form-D-ZSfGmB.cjs.map +1 -0
- package/dist/form.cjs +8 -551
- package/dist/form.d.cts +4 -21
- package/dist/form.d.ts +4 -21
- package/dist/form.js +3 -544
- package/dist/index.cjs +49 -16
- package/dist/index.d.cts +17 -10
- package/dist/index.d.ts +17 -10
- package/dist/index.js +14 -9
- package/dist/interaction.cjs +17 -4
- package/dist/interaction.cjs.map +1 -1
- package/dist/interaction.d.cts +2 -2
- package/dist/interaction.d.ts +2 -2
- package/dist/interaction.js +7 -5
- package/dist/interaction.js.map +1 -1
- package/dist/link.cjs +70 -7
- package/dist/link.cjs.map +1 -1
- package/dist/link.d.cts +12 -3
- package/dist/link.d.ts +12 -3
- package/dist/link.js +73 -10
- package/dist/link.js.map +1 -1
- package/dist/metadata.js +1 -0
- package/dist/metadata.js.map +1 -1
- package/dist/page-edit.js +1 -0
- package/dist/page-edit.js.map +1 -1
- package/dist/page-view.cjs +62 -38
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.js +59 -37
- package/dist/page-view.js.map +1 -1
- package/dist/redaction.js +1 -0
- package/dist/redaction.js.map +1 -1
- package/dist/render.cjs +67 -50
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +6 -19
- package/dist/render.d.ts +6 -19
- package/dist/render.js +71 -52
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-BBjsoOtd.js +27 -0
- package/dist/{runtime-CMxIuF2O.d.cts → runtime-DE76hlnl.d.ts} +32 -11
- package/dist/{runtime-DV98q7I0.d.ts → runtime-umHA_xHt.d.cts} +32 -11
- package/dist/runtime.cjs +25 -5
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/runtime.js +26 -6
- package/dist/runtime.js.map +1 -1
- package/dist/scrollbar.cjs +3 -3
- package/dist/scrollbar.cjs.map +1 -1
- package/dist/scrollbar.d.cts +1 -1
- package/dist/scrollbar.d.ts +1 -1
- package/dist/scrollbar.js +1 -1
- package/dist/scrollbar.js.map +1 -1
- package/dist/search.cjs +36 -19
- package/dist/search.cjs.map +1 -1
- package/dist/search.d.cts +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/search.js +36 -19
- package/dist/search.js.map +1 -1
- package/dist/selection.cjs +217 -22
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +60 -2
- package/dist/selection.d.ts +60 -2
- package/dist/selection.js +214 -27
- package/dist/selection.js.map +1 -1
- package/dist/shell.js +1 -0
- package/dist/shell.js.map +1 -1
- package/dist/stage.cjs +49 -148
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.d.cts +18 -5
- package/dist/stage.d.ts +18 -5
- package/dist/stage.js +51 -149
- package/dist/stage.js.map +1 -1
- package/dist/stamp.js +1 -0
- package/dist/stamp.js.map +1 -1
- package/dist/toolbar.cjs +4 -4
- package/dist/toolbar.cjs.map +1 -1
- package/dist/toolbar.d.cts +1 -1
- package/dist/toolbar.d.ts +1 -1
- package/dist/toolbar.js +2 -1
- package/dist/toolbar.js.map +1 -1
- package/dist/views.js +1 -0
- package/dist/views.js.map +1 -1
- package/package.json +33 -26
- package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.cts +0 -2593
- package/dist/AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts +0 -2593
- package/dist/annotation-Ct6dFtzJ.cjs +0 -913
- package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
- package/dist/annotation-DjGWJljY.js +0 -829
- package/dist/annotation-DjGWJljY.js.map +0 -1
- package/dist/form.cjs.map +0 -1
- package/dist/form.js.map +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
|
|
3
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
react = require_rolldown_runtime.__toESM(react, 1);
|
|
6
|
+
let react_dom = require("react-dom");
|
|
7
|
+
let _embedpdf_web = require("@embedpdf/web");
|
|
8
|
+
//#region src/anchored.tsx
|
|
9
|
+
/**
|
|
10
|
+
* Anchored overlays — ONE primitive for every piece of UI that floats over
|
|
11
|
+
* page content (selection menus, draft menus, future popovers).
|
|
12
|
+
*
|
|
13
|
+
* The factoring:
|
|
14
|
+
* - PLUGINS produce anchors (a content-space rect on a page, plus points
|
|
15
|
+
* to dodge) as capability reads.
|
|
16
|
+
* - The projection SNAPSHOT contract and the placement math are shared,
|
|
17
|
+
* framework-neutral, in `@embedpdf/web` ({@link ViewProjector},
|
|
18
|
+
* `projectAnchoredTarget`).
|
|
19
|
+
* - SURFACES (<Stage>, <PageView>) provide a {@link ProjectorBinding}:
|
|
20
|
+
* the snapshot plus REACT's way of knowing when it changed.
|
|
21
|
+
* - <Anchored> renders at the projected position, isolates pointer
|
|
22
|
+
* events, and portals when the space demands it.
|
|
23
|
+
*
|
|
24
|
+
* THE SCHEDULING LAW (this is what keeps menus glued to the content): a
|
|
25
|
+
* state-driven projection change (the Stage camera) reaches consumers as a
|
|
26
|
+
* NEW BINDING IDENTITY through context — surface and overlay re-render in
|
|
27
|
+
* the SAME React commit, so they can never paint a frame apart. No
|
|
28
|
+
* listener sets, no post-commit notifications, no second menu-only render.
|
|
29
|
+
* `subscribe` exists ONLY for genuinely browser-driven invalidation (a
|
|
30
|
+
* PageView moving because the document scrolled), where no state change
|
|
31
|
+
* announces the move.
|
|
32
|
+
*/
|
|
33
|
+
const ProjectorContext = (0, react.createContext)(null);
|
|
34
|
+
/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
|
|
35
|
+
const ProjectorProvider = ProjectorContext.Provider;
|
|
36
|
+
/** The surface's projector binding. Reading it subscribes the caller to
|
|
37
|
+
* projection changes (the binding's identity IS the revision). */
|
|
38
|
+
function useProjectorBinding() {
|
|
39
|
+
const binding = (0, react.useContext)(ProjectorContext);
|
|
40
|
+
if (!binding) throw new Error("No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.");
|
|
41
|
+
return binding;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Position `children` around a content-space anchor, on whichever page
|
|
45
|
+
* surface is in scope. Projection runs during render from the shared pure
|
|
46
|
+
* helper; pointer isolation keeps a click inside anchored UI from reaching
|
|
47
|
+
* the surface's own listener (which would read it as click-outside).
|
|
48
|
+
*/
|
|
49
|
+
function Anchored({ anchor, placement = "top", gap = 8, children }) {
|
|
50
|
+
const { projector, subscribe } = useProjectorBinding();
|
|
51
|
+
const [, force] = (0, react.useReducer)((x) => x + 1, 0);
|
|
52
|
+
(0, react.useLayoutEffect)(() => subscribe ? subscribe(force) : void 0, [subscribe]);
|
|
53
|
+
(0, react.useLayoutEffect)(() => {
|
|
54
|
+
if (projector.space === "client") force();
|
|
55
|
+
}, [projector, anchor]);
|
|
56
|
+
const ref = (0, react.useRef)(null);
|
|
57
|
+
(0, react.useEffect)(() => {
|
|
58
|
+
const el = ref.current;
|
|
59
|
+
if (!el) return;
|
|
60
|
+
const stop = (e) => e.stopPropagation();
|
|
61
|
+
el.addEventListener("pointerdown", stop);
|
|
62
|
+
return () => el.removeEventListener("pointerdown", stop);
|
|
63
|
+
});
|
|
64
|
+
if (!anchor) return null;
|
|
65
|
+
const pos = (0, _embedpdf_web.projectAnchoredTarget)(projector, anchor, placement, gap);
|
|
66
|
+
if (!pos) return null;
|
|
67
|
+
const node = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
68
|
+
ref,
|
|
69
|
+
style: {
|
|
70
|
+
position: projector.space === "client" ? "fixed" : "absolute",
|
|
71
|
+
left: pos.left,
|
|
72
|
+
top: pos.top,
|
|
73
|
+
transform: pos.transform,
|
|
74
|
+
pointerEvents: "auto"
|
|
75
|
+
},
|
|
76
|
+
children
|
|
77
|
+
});
|
|
78
|
+
if (projector.space === "client") {
|
|
79
|
+
if (typeof document === "undefined") return null;
|
|
80
|
+
return (0, react_dom.createPortal)(node, document.body);
|
|
81
|
+
}
|
|
82
|
+
return node;
|
|
83
|
+
}
|
|
84
|
+
//#endregion
|
|
85
|
+
exports.Anchored = Anchored;
|
|
86
|
+
exports.ProjectorProvider = ProjectorProvider;
|
|
87
|
+
exports.useProjectorBinding = useProjectorBinding;
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=anchored.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchored.cjs","names":[],"sources":["../src/anchored.tsx"],"sourcesContent":["/**\n * Anchored overlays — ONE primitive for every piece of UI that floats over\n * page content (selection menus, draft menus, future popovers).\n *\n * The factoring:\n * - PLUGINS produce anchors (a content-space rect on a page, plus points\n * to dodge) as capability reads.\n * - The projection SNAPSHOT contract and the placement math are shared,\n * framework-neutral, in `@embedpdf/web` ({@link ViewProjector},\n * `projectAnchoredTarget`).\n * - SURFACES (<Stage>, <PageView>) provide a {@link ProjectorBinding}:\n * the snapshot plus REACT's way of knowing when it changed.\n * - <Anchored> renders at the projected position, isolates pointer\n * events, and portals when the space demands it.\n *\n * THE SCHEDULING LAW (this is what keeps menus glued to the content): a\n * state-driven projection change (the Stage camera) reaches consumers as a\n * NEW BINDING IDENTITY through context — surface and overlay re-render in\n * the SAME React commit, so they can never paint a frame apart. No\n * listener sets, no post-commit notifications, no second menu-only render.\n * `subscribe` exists ONLY for genuinely browser-driven invalidation (a\n * PageView moving because the document scrolled), where no state change\n * announces the move.\n */\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useLayoutEffect, useReducer, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n projectAnchoredTarget,\n type AnchoredPlacement,\n type AnchorTarget,\n type ViewProjector,\n} from '@embedpdf/web';\n\nexport type { AnchoredPlacement, AnchorTarget, ViewProjector } from '@embedpdf/web';\n\n/**\n * What a page surface provides via context: the pure projection snapshot,\n * bound to React's reactivity.\n */\nexport interface ProjectorBinding {\n projector: ViewProjector;\n /**\n * Changes identity exactly when projection may have changed for\n * STATE-driven reasons — the Stage uses its `visiblePages()` value (a\n * stable reference that already folds camera, viewport, scene and DPR).\n * Consumers re-render because the binding's identity changes with it;\n * nothing reads this field, but it is what makes the memoized binding\n * change, so do not \"optimize\" it away.\n */\n revision: unknown;\n /** Browser-driven invalidation ONLY (PageView scroll/resize — see\n * `observeClientGeometry`). The Stage deliberately provides none. */\n subscribe?: (callback: () => void) => () => void;\n}\n\nconst ProjectorContext = createContext<ProjectorBinding | null>(null);\n\n/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */\nexport const ProjectorProvider = ProjectorContext.Provider;\n\n/** The surface's projector binding. Reading it subscribes the caller to\n * projection changes (the binding's identity IS the revision). */\nexport function useProjectorBinding(): ProjectorBinding {\n const binding = useContext(ProjectorContext);\n if (!binding) {\n throw new Error(\n 'No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.',\n );\n }\n return binding;\n}\n\nexport interface AnchoredProps {\n anchor: AnchorTarget | null;\n /** Which side of the anchor to sit on. Default 'top'. */\n placement?: AnchoredPlacement;\n /** Gap in screen px between the anchor box and the content. Default 8. */\n gap?: number;\n children: React.ReactNode;\n}\n\n/**\n * Position `children` around a content-space anchor, on whichever page\n * surface is in scope. Projection runs during render from the shared pure\n * helper; pointer isolation keeps a click inside anchored UI from reaching\n * the surface's own listener (which would read it as click-outside).\n */\nexport function Anchored({ anchor, placement = 'top', gap = 8, children }: AnchoredProps) {\n const { projector, subscribe } = useProjectorBinding();\n\n // Browser-driven invalidation only (PageView). State-driven changes come\n // through the binding identity — no local bump involved.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useLayoutEffect(() => (subscribe ? subscribe(force) : undefined), [subscribe]);\n // Client-space surfaces measure the DOM, which does not exist during the\n // surface's first render — force one post-commit pass so the position\n // appears as soon as it is measurable. (Solves measurability, not\n // reactivity.)\n useLayoutEffect(() => {\n if (projector.space === 'client') force();\n }, [projector, anchor]);\n\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const stop = (e: Event) => e.stopPropagation();\n el.addEventListener('pointerdown', stop);\n return () => el.removeEventListener('pointerdown', stop);\n });\n\n if (!anchor) return null;\n const pos = projectAnchoredTarget(projector, anchor, placement, gap);\n if (!pos) return null;\n\n const node = (\n <div\n ref={ref}\n style={{\n position: projector.space === 'client' ? 'fixed' : 'absolute',\n left: pos.left,\n top: pos.top,\n transform: pos.transform,\n pointerEvents: 'auto',\n }}\n >\n {children}\n </div>\n );\n if (projector.space === 'client') {\n if (typeof document === 'undefined') return null;\n return createPortal(node, document.body);\n }\n return node;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,MAAM,oBAAA,GAAA,MAAA,cAAA,CAA0D,IAAI;;AAGpE,MAAa,oBAAoB,iBAAiB;;;AAIlD,SAAgB,sBAAwC;CACtD,MAAM,WAAA,GAAA,MAAA,WAAA,CAAqB,gBAAgB;CAC3C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,0FACF;CAEF,OAAO;AACT;;;;;;;AAiBA,SAAgB,SAAS,EAAE,QAAQ,YAAY,OAAO,MAAM,GAAG,YAA2B;CACxF,MAAM,EAAE,WAAW,cAAc,oBAAoB;CAIrD,MAAM,GAAG,UAAA,GAAA,MAAA,WAAA,EAAqB,MAAc,IAAI,GAAG,CAAC;CACpD,CAAA,GAAA,MAAA,gBAAA,OAAuB,YAAY,UAAU,KAAK,IAAI,KAAA,GAAY,CAAC,SAAS,CAAC;CAK7E,CAAA,GAAA,MAAA,gBAAA,OAAsB;EACpB,IAAI,UAAU,UAAU,UAAU,MAAM;CAC1C,GAAG,CAAC,WAAW,MAAM,CAAC;CAEtB,MAAM,OAAA,GAAA,MAAA,OAAA,CAA6B,IAAI;CACvC,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,MAAM,QAAQ,MAAa,EAAE,gBAAgB;EAC7C,GAAG,iBAAiB,eAAe,IAAI;EACvC,aAAa,GAAG,oBAAoB,eAAe,IAAI;CACzD,CAAC;CAED,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,OAAA,GAAA,cAAA,sBAAA,CAA4B,WAAW,QAAQ,WAAW,GAAG;CACnE,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,OACJ,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACO;EACL,OAAO;GACL,UAAU,UAAU,UAAU,WAAW,UAAU;GACnD,MAAM,IAAI;GACV,KAAK,IAAI;GACT,WAAW,IAAI;GACf,eAAe;EACjB;EAEC;CACE,CAAA;CAEP,IAAI,UAAU,UAAU,UAAU;EAChC,IAAI,OAAO,aAAa,aAAa,OAAO;EAC5C,QAAA,GAAA,UAAA,aAAA,CAAoB,MAAM,SAAS,IAAI;CACzC;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AnchorTarget, AnchorTarget as AnchorTarget$1, AnchoredPlacement, AnchoredPlacement as AnchoredPlacement$1, ViewProjector, ViewProjector as ViewProjector$1 } from "@embedpdf/web";
|
|
3
|
+
//#region src/anchored.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* What a page surface provides via context: the pure projection snapshot,
|
|
6
|
+
* bound to React's reactivity.
|
|
7
|
+
*/
|
|
8
|
+
interface ProjectorBinding {
|
|
9
|
+
projector: ViewProjector$1;
|
|
10
|
+
/**
|
|
11
|
+
* Changes identity exactly when projection may have changed for
|
|
12
|
+
* STATE-driven reasons — the Stage uses its `visiblePages()` value (a
|
|
13
|
+
* stable reference that already folds camera, viewport, scene and DPR).
|
|
14
|
+
* Consumers re-render because the binding's identity changes with it;
|
|
15
|
+
* nothing reads this field, but it is what makes the memoized binding
|
|
16
|
+
* change, so do not "optimize" it away.
|
|
17
|
+
*/
|
|
18
|
+
revision: unknown;
|
|
19
|
+
/** Browser-driven invalidation ONLY (PageView scroll/resize — see
|
|
20
|
+
* `observeClientGeometry`). The Stage deliberately provides none. */
|
|
21
|
+
subscribe?: (callback: () => void) => () => void;
|
|
22
|
+
}
|
|
23
|
+
/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
|
|
24
|
+
declare const ProjectorProvider: React.Provider<ProjectorBinding | null>;
|
|
25
|
+
/** The surface's projector binding. Reading it subscribes the caller to
|
|
26
|
+
* projection changes (the binding's identity IS the revision). */
|
|
27
|
+
declare function useProjectorBinding(): ProjectorBinding;
|
|
28
|
+
interface AnchoredProps {
|
|
29
|
+
anchor: AnchorTarget$1 | null;
|
|
30
|
+
/** Which side of the anchor to sit on. Default 'top'. */
|
|
31
|
+
placement?: AnchoredPlacement$1;
|
|
32
|
+
/** Gap in screen px between the anchor box and the content. Default 8. */
|
|
33
|
+
gap?: number;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Position `children` around a content-space anchor, on whichever page
|
|
38
|
+
* surface is in scope. Projection runs during render from the shared pure
|
|
39
|
+
* helper; pointer isolation keeps a click inside anchored UI from reaching
|
|
40
|
+
* the surface's own listener (which would read it as click-outside).
|
|
41
|
+
*/
|
|
42
|
+
declare function Anchored({ anchor, placement, gap, children }: AnchoredProps): import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, type ViewProjector, useProjectorBinding };
|
|
45
|
+
//# sourceMappingURL=anchored.d.cts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { AnchorTarget, AnchorTarget as AnchorTarget$1, AnchoredPlacement, AnchoredPlacement as AnchoredPlacement$1, ViewProjector, ViewProjector as ViewProjector$1 } from "@embedpdf/web";
|
|
3
|
+
//#region src/anchored.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* What a page surface provides via context: the pure projection snapshot,
|
|
6
|
+
* bound to React's reactivity.
|
|
7
|
+
*/
|
|
8
|
+
interface ProjectorBinding {
|
|
9
|
+
projector: ViewProjector$1;
|
|
10
|
+
/**
|
|
11
|
+
* Changes identity exactly when projection may have changed for
|
|
12
|
+
* STATE-driven reasons — the Stage uses its `visiblePages()` value (a
|
|
13
|
+
* stable reference that already folds camera, viewport, scene and DPR).
|
|
14
|
+
* Consumers re-render because the binding's identity changes with it;
|
|
15
|
+
* nothing reads this field, but it is what makes the memoized binding
|
|
16
|
+
* change, so do not "optimize" it away.
|
|
17
|
+
*/
|
|
18
|
+
revision: unknown;
|
|
19
|
+
/** Browser-driven invalidation ONLY (PageView scroll/resize — see
|
|
20
|
+
* `observeClientGeometry`). The Stage deliberately provides none. */
|
|
21
|
+
subscribe?: (callback: () => void) => () => void;
|
|
22
|
+
}
|
|
23
|
+
/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
|
|
24
|
+
declare const ProjectorProvider: React.Provider<ProjectorBinding | null>;
|
|
25
|
+
/** The surface's projector binding. Reading it subscribes the caller to
|
|
26
|
+
* projection changes (the binding's identity IS the revision). */
|
|
27
|
+
declare function useProjectorBinding(): ProjectorBinding;
|
|
28
|
+
interface AnchoredProps {
|
|
29
|
+
anchor: AnchorTarget$1 | null;
|
|
30
|
+
/** Which side of the anchor to sit on. Default 'top'. */
|
|
31
|
+
placement?: AnchoredPlacement$1;
|
|
32
|
+
/** Gap in screen px between the anchor box and the content. Default 8. */
|
|
33
|
+
gap?: number;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Position `children` around a content-space anchor, on whichever page
|
|
38
|
+
* surface is in scope. Projection runs during render from the shared pure
|
|
39
|
+
* helper; pointer isolation keeps a click inside anchored UI from reaching
|
|
40
|
+
* the surface's own listener (which would read it as click-outside).
|
|
41
|
+
*/
|
|
42
|
+
declare function Anchored({ anchor, placement, gap, children }: AnchoredProps): import("react/jsx-runtime").JSX.Element | null;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { type AnchorTarget, Anchored, type AnchoredPlacement, AnchoredProps, ProjectorBinding, ProjectorProvider, type ViewProjector, useProjectorBinding };
|
|
45
|
+
//# sourceMappingURL=anchored.d.ts.map
|
package/dist/anchored.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useLayoutEffect, useReducer, useRef } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { projectAnchoredTarget } from "@embedpdf/web";
|
|
5
|
+
//#region src/anchored.tsx
|
|
6
|
+
const ProjectorContext = createContext(null);
|
|
7
|
+
/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */
|
|
8
|
+
const ProjectorProvider = ProjectorContext.Provider;
|
|
9
|
+
/** The surface's projector binding. Reading it subscribes the caller to
|
|
10
|
+
* projection changes (the binding's identity IS the revision). */
|
|
11
|
+
function useProjectorBinding() {
|
|
12
|
+
const binding = useContext(ProjectorContext);
|
|
13
|
+
if (!binding) throw new Error("No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.");
|
|
14
|
+
return binding;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Position `children` around a content-space anchor, on whichever page
|
|
18
|
+
* surface is in scope. Projection runs during render from the shared pure
|
|
19
|
+
* helper; pointer isolation keeps a click inside anchored UI from reaching
|
|
20
|
+
* the surface's own listener (which would read it as click-outside).
|
|
21
|
+
*/
|
|
22
|
+
function Anchored({ anchor, placement = "top", gap = 8, children }) {
|
|
23
|
+
const { projector, subscribe } = useProjectorBinding();
|
|
24
|
+
const [, force] = useReducer((x) => x + 1, 0);
|
|
25
|
+
useLayoutEffect(() => subscribe ? subscribe(force) : void 0, [subscribe]);
|
|
26
|
+
useLayoutEffect(() => {
|
|
27
|
+
if (projector.space === "client") force();
|
|
28
|
+
}, [projector, anchor]);
|
|
29
|
+
const ref = useRef(null);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const el = ref.current;
|
|
32
|
+
if (!el) return;
|
|
33
|
+
const stop = (e) => e.stopPropagation();
|
|
34
|
+
el.addEventListener("pointerdown", stop);
|
|
35
|
+
return () => el.removeEventListener("pointerdown", stop);
|
|
36
|
+
});
|
|
37
|
+
if (!anchor) return null;
|
|
38
|
+
const pos = projectAnchoredTarget(projector, anchor, placement, gap);
|
|
39
|
+
if (!pos) return null;
|
|
40
|
+
const node = /* @__PURE__ */ jsx("div", {
|
|
41
|
+
ref,
|
|
42
|
+
style: {
|
|
43
|
+
position: projector.space === "client" ? "fixed" : "absolute",
|
|
44
|
+
left: pos.left,
|
|
45
|
+
top: pos.top,
|
|
46
|
+
transform: pos.transform,
|
|
47
|
+
pointerEvents: "auto"
|
|
48
|
+
},
|
|
49
|
+
children
|
|
50
|
+
});
|
|
51
|
+
if (projector.space === "client") {
|
|
52
|
+
if (typeof document === "undefined") return null;
|
|
53
|
+
return createPortal(node, document.body);
|
|
54
|
+
}
|
|
55
|
+
return node;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { Anchored, ProjectorProvider, useProjectorBinding };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=anchored.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anchored.js","names":[],"sources":["../src/anchored.tsx"],"sourcesContent":["/**\n * Anchored overlays — ONE primitive for every piece of UI that floats over\n * page content (selection menus, draft menus, future popovers).\n *\n * The factoring:\n * - PLUGINS produce anchors (a content-space rect on a page, plus points\n * to dodge) as capability reads.\n * - The projection SNAPSHOT contract and the placement math are shared,\n * framework-neutral, in `@embedpdf/web` ({@link ViewProjector},\n * `projectAnchoredTarget`).\n * - SURFACES (<Stage>, <PageView>) provide a {@link ProjectorBinding}:\n * the snapshot plus REACT's way of knowing when it changed.\n * - <Anchored> renders at the projected position, isolates pointer\n * events, and portals when the space demands it.\n *\n * THE SCHEDULING LAW (this is what keeps menus glued to the content): a\n * state-driven projection change (the Stage camera) reaches consumers as a\n * NEW BINDING IDENTITY through context — surface and overlay re-render in\n * the SAME React commit, so they can never paint a frame apart. No\n * listener sets, no post-commit notifications, no second menu-only render.\n * `subscribe` exists ONLY for genuinely browser-driven invalidation (a\n * PageView moving because the document scrolled), where no state change\n * announces the move.\n */\nimport * as React from 'react';\nimport { createContext, useContext, useEffect, useLayoutEffect, useReducer, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport {\n projectAnchoredTarget,\n type AnchoredPlacement,\n type AnchorTarget,\n type ViewProjector,\n} from '@embedpdf/web';\n\nexport type { AnchoredPlacement, AnchorTarget, ViewProjector } from '@embedpdf/web';\n\n/**\n * What a page surface provides via context: the pure projection snapshot,\n * bound to React's reactivity.\n */\nexport interface ProjectorBinding {\n projector: ViewProjector;\n /**\n * Changes identity exactly when projection may have changed for\n * STATE-driven reasons — the Stage uses its `visiblePages()` value (a\n * stable reference that already folds camera, viewport, scene and DPR).\n * Consumers re-render because the binding's identity changes with it;\n * nothing reads this field, but it is what makes the memoized binding\n * change, so do not \"optimize\" it away.\n */\n revision: unknown;\n /** Browser-driven invalidation ONLY (PageView scroll/resize — see\n * `observeClientGeometry`). The Stage deliberately provides none. */\n subscribe?: (callback: () => void) => () => void;\n}\n\nconst ProjectorContext = createContext<ProjectorBinding | null>(null);\n\n/** Installed by page surfaces (<Stage>, <PageView>) — not by app code. */\nexport const ProjectorProvider = ProjectorContext.Provider;\n\n/** The surface's projector binding. Reading it subscribes the caller to\n * projection changes (the binding's identity IS the revision). */\nexport function useProjectorBinding(): ProjectorBinding {\n const binding = useContext(ProjectorContext);\n if (!binding) {\n throw new Error(\n 'No ViewProjector in scope: mount anchored UI under <Stage> (overlay slot) or <PageView>.',\n );\n }\n return binding;\n}\n\nexport interface AnchoredProps {\n anchor: AnchorTarget | null;\n /** Which side of the anchor to sit on. Default 'top'. */\n placement?: AnchoredPlacement;\n /** Gap in screen px between the anchor box and the content. Default 8. */\n gap?: number;\n children: React.ReactNode;\n}\n\n/**\n * Position `children` around a content-space anchor, on whichever page\n * surface is in scope. Projection runs during render from the shared pure\n * helper; pointer isolation keeps a click inside anchored UI from reaching\n * the surface's own listener (which would read it as click-outside).\n */\nexport function Anchored({ anchor, placement = 'top', gap = 8, children }: AnchoredProps) {\n const { projector, subscribe } = useProjectorBinding();\n\n // Browser-driven invalidation only (PageView). State-driven changes come\n // through the binding identity — no local bump involved.\n const [, force] = useReducer((x: number) => x + 1, 0);\n useLayoutEffect(() => (subscribe ? subscribe(force) : undefined), [subscribe]);\n // Client-space surfaces measure the DOM, which does not exist during the\n // surface's first render — force one post-commit pass so the position\n // appears as soon as it is measurable. (Solves measurability, not\n // reactivity.)\n useLayoutEffect(() => {\n if (projector.space === 'client') force();\n }, [projector, anchor]);\n\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const el = ref.current;\n if (!el) return;\n const stop = (e: Event) => e.stopPropagation();\n el.addEventListener('pointerdown', stop);\n return () => el.removeEventListener('pointerdown', stop);\n });\n\n if (!anchor) return null;\n const pos = projectAnchoredTarget(projector, anchor, placement, gap);\n if (!pos) return null;\n\n const node = (\n <div\n ref={ref}\n style={{\n position: projector.space === 'client' ? 'fixed' : 'absolute',\n left: pos.left,\n top: pos.top,\n transform: pos.transform,\n pointerEvents: 'auto',\n }}\n >\n {children}\n </div>\n );\n if (projector.space === 'client') {\n if (typeof document === 'undefined') return null;\n return createPortal(node, document.body);\n }\n return node;\n}\n"],"mappings":";;;;;AAwDA,MAAM,mBAAmB,cAAuC,IAAI;;AAGpE,MAAa,oBAAoB,iBAAiB;;;AAIlD,SAAgB,sBAAwC;CACtD,MAAM,UAAU,WAAW,gBAAgB;CAC3C,IAAI,CAAC,SACH,MAAM,IAAI,MACR,0FACF;CAEF,OAAO;AACT;;;;;;;AAiBA,SAAgB,SAAS,EAAE,QAAQ,YAAY,OAAO,MAAM,GAAG,YAA2B;CACxF,MAAM,EAAE,WAAW,cAAc,oBAAoB;CAIrD,MAAM,GAAG,SAAS,YAAY,MAAc,IAAI,GAAG,CAAC;CACpD,sBAAuB,YAAY,UAAU,KAAK,IAAI,KAAA,GAAY,CAAC,SAAS,CAAC;CAK7E,sBAAsB;EACpB,IAAI,UAAU,UAAU,UAAU,MAAM;CAC1C,GAAG,CAAC,WAAW,MAAM,CAAC;CAEtB,MAAM,MAAM,OAAuB,IAAI;CACvC,gBAAgB;EACd,MAAM,KAAK,IAAI;EACf,IAAI,CAAC,IAAI;EACT,MAAM,QAAQ,MAAa,EAAE,gBAAgB;EAC7C,GAAG,iBAAiB,eAAe,IAAI;EACvC,aAAa,GAAG,oBAAoB,eAAe,IAAI;CACzD,CAAC;CAED,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAM,sBAAsB,WAAW,QAAQ,WAAW,GAAG;CACnE,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,OACJ,oBAAC,OAAD;EACO;EACL,OAAO;GACL,UAAU,UAAU,UAAU,WAAW,UAAU;GACnD,MAAM,IAAI;GACV,KAAK,IAAI;GACT,WAAW,IAAI;GACf,eAAe;EACjB;EAEC;CACE,CAAA;CAEP,IAAI,UAAU,UAAU,UAAU;EAChC,IAAI,OAAO,aAAa,aAAa,OAAO;EAC5C,OAAO,aAAa,MAAM,SAAS,IAAI;CACzC;CACA,OAAO;AACT"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as PageContextValue } from "./runtime-CMxIuF2O.cjs";
|
|
3
|
-
import { Behavior, FilePickerProvider, SelectionFlags, SelectionFlags as SelectionFlags$1, SelectionProps, SelectionProps as SelectionProps$1 } from "@embedpdf/plugin-annotation";
|
|
1
|
+
import { d as runtime_d_exports, o as PageContextValue } from "./runtime-umHA_xHt.cjs";
|
|
4
2
|
import * as React from "react";
|
|
5
|
-
import { AnnotationFlags, AnnotationProps, AnnotationProps as AnnotationProps$1, AnnotationPropsPatch,
|
|
6
|
-
import {
|
|
7
|
-
//#region src/
|
|
8
|
-
|
|
3
|
+
import { AnnotationFlags, AnnotationProps, AnnotationProps as AnnotationProps$1, AnnotationPropsPatch, Border, CreationDraftAnchor, CreationDraftAnchor as CreationDraftAnchor$1, Geom, LineEnding, LineEndings, PropKey, PropSpec, Rect, RenderItem, RenderItem as RenderItem$1, Style, TextAlign, TextStyle, Vec } from "@embedpdf/core-annotation";
|
|
4
|
+
import { AnnotationHydration, AnnotationRef, Behavior, CommentThread, CommentsApi, FilePickerProvider, SelectionFlags, SelectionFlags as SelectionFlags$1, SelectionProps, SelectionProps as SelectionProps$1 } from "@embedpdf/plugin-annotation";
|
|
5
|
+
//#region src/annotation-anchors.d.ts
|
|
6
|
+
/** The selection's menu anchor on its primary page, in content space. */
|
|
7
|
+
type SelectionAnchor = {
|
|
8
|
+
pon: number;
|
|
9
|
+
bounds: Rect;
|
|
10
|
+
knob?: Vec;
|
|
11
|
+
};
|
|
12
|
+
declare function sameAnchor(a: SelectionAnchor | null, b: SelectionAnchor | null): boolean;
|
|
13
|
+
declare function sameCreationDraftAnchor(a: CreationDraftAnchor | null, b: CreationDraftAnchor | null): boolean;
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/annotation-hooks.d.ts
|
|
16
|
+
/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */
|
|
17
|
+
declare function useAnnotationSelected(): import("@embedpdf/plugin-annotation").AnnotationDTO[];
|
|
9
18
|
//#endregion
|
|
10
19
|
//#region src/annotation.d.ts
|
|
11
20
|
/**
|
|
@@ -81,8 +90,6 @@ declare const filePickerProvider: FilePickerProvider;
|
|
|
81
90
|
declare function useFilePickerProvider(provider?: FilePickerProvider | null): void;
|
|
82
91
|
declare function useAnnotation(): import("@embedpdf/plugin-annotation").AnnotationCapability;
|
|
83
92
|
declare function useAnnotationSelection(): string[];
|
|
84
|
-
/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */
|
|
85
|
-
declare function useAnnotationSelected(): AnnotationDTO[];
|
|
86
93
|
/**
|
|
87
94
|
* A tool's RESOLVED defaults (base + per-tool override) as a full flat props
|
|
88
95
|
* bag, subscribed so a `setDefaults` re-renders the consumer. Use this — not the
|
|
@@ -107,67 +114,47 @@ declare function useSelectionProps(): SelectionProps;
|
|
|
107
114
|
* between model changes, like {@link useSelectionProps}.
|
|
108
115
|
*/
|
|
109
116
|
declare function useSelectionFlags(): SelectionFlags | null;
|
|
110
|
-
/**
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
resetRotation: () => void;
|
|
132
|
-
/** Group the current selection into one unit (selecting any member then
|
|
133
|
-
* selects all). */
|
|
134
|
-
group: () => Promise<void>;
|
|
135
|
-
/** Ungroup the group(s) the current selection touches. */
|
|
136
|
-
ungroup: () => Promise<void>;
|
|
137
|
-
/** Whether {@link group} would do something for the current selection. */
|
|
138
|
-
canGroup: boolean;
|
|
139
|
-
/** Whether {@link ungroup} would do something for the current selection. */
|
|
140
|
-
canUngroup: boolean;
|
|
141
|
-
}
|
|
142
|
-
interface AnnotationMenuProps {
|
|
143
|
-
children: (args: AnnotationMenuRenderArgs) => React.ReactNode;
|
|
144
|
-
/** Gap in screen px between the selection box and the menu (default 8). */
|
|
145
|
-
gap?: number;
|
|
146
|
-
/** Where to place the menu relative to the selection box. Default 'top'. */
|
|
147
|
-
placement?: AnnotationMenuPlacement;
|
|
148
|
-
}
|
|
149
|
-
declare function sameCreationDraftAnchor(a: CreationDraftAnchor | null, b: CreationDraftAnchor | null): boolean;
|
|
150
|
-
interface AnnotationDraftMenuRenderArgs extends CreationDraftAnchor {
|
|
151
|
-
finish: () => void;
|
|
152
|
-
cancel: () => void;
|
|
153
|
-
}
|
|
154
|
-
interface AnnotationDraftMenuProps {
|
|
155
|
-
children: (args: AnnotationDraftMenuRenderArgs) => React.ReactNode;
|
|
156
|
-
/** Gap in screen px between the draft anchor and the menu (default 8). */
|
|
157
|
-
gap?: number;
|
|
158
|
-
/** Where to place the menu relative to the draft anchor. Default 'top'. */
|
|
159
|
-
placement?: AnnotationMenuPlacement;
|
|
117
|
+
/**
|
|
118
|
+
* A {@link CommentThread} enriched with its page's live display position —
|
|
119
|
+
* the framework-layer join. Identity stays `pageObjectNumber` (like every
|
|
120
|
+
* annotation surface); these two fields are PRESENTATION, tracking page
|
|
121
|
+
* moves and deletes.
|
|
122
|
+
*/
|
|
123
|
+
interface CommentThreadView extends CommentThread {
|
|
124
|
+
/** Current 0-based display index of the thread's page; `-1` when the page
|
|
125
|
+
* is no longer in the document (one-frame teardown race on delete). */
|
|
126
|
+
pageIndex: number;
|
|
127
|
+
/** The page's `/PageLabels` label when the PDF declares one ("iv", "A-2"),
|
|
128
|
+
* else the 1-based position as a string — print it verbatim. */
|
|
129
|
+
pageLabel: string;
|
|
130
|
+
/**
|
|
131
|
+
* The root annotation's rect in CONTENT space (y-down, crop-relative,
|
|
132
|
+
* unscaled points) — the space `StageCapability.reveal` takes, so a
|
|
133
|
+
* "jump to this comment" is `stage.reveal(pageIndex, { rect: contentRect })`.
|
|
134
|
+
* Null when the page is gone. Identity still travels as `pageObjectNumber`;
|
|
135
|
+
* this, like `pageIndex`, is presentation.
|
|
136
|
+
*/
|
|
137
|
+
contentRect: Rect | null;
|
|
160
138
|
}
|
|
139
|
+
/** Pure join behind {@link useCommentThreads} — exported for tests. */
|
|
140
|
+
declare function enrichCommentThreads(threads: readonly CommentThread[], pages: readonly runtime_d_exports.PageLayout[]): CommentThreadView[];
|
|
141
|
+
/** The comments surface (verbs + `permissionsFor`) — imperative; pair with
|
|
142
|
+
* {@link useCommentThreads} for the subscribed view. */
|
|
143
|
+
declare function useComments(): CommentsApi;
|
|
161
144
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* from `@embedpdf/react/annotation-menu` (camera-driven, more responsive).
|
|
145
|
+
* Every comment thread in the document, display-ordered (page position →
|
|
146
|
+
* top of page → creation date) and enriched with `pageIndex`/`pageLabel`.
|
|
147
|
+
* Subscribed to BOTH stores: annotation writes (own, remote, hydration)
|
|
148
|
+
* recompute the threads; page moves/deletes re-run the join. Reference-
|
|
149
|
+
* stable between changes — safe to memo child renders on the array.
|
|
168
150
|
*/
|
|
169
|
-
declare function
|
|
170
|
-
|
|
151
|
+
declare function useCommentThreads(): CommentThreadView[];
|
|
152
|
+
/** The enriched thread containing ANY member ref (root, reply, grouped part,
|
|
153
|
+
* state annotation), or null. */
|
|
154
|
+
declare function useCommentThread(ref: AnnotationRef | null): CommentThreadView | null;
|
|
155
|
+
/** Whole-document hydration status — the comments sidebar's honest loading
|
|
156
|
+
* state (`loading` until `listRawAll` lands, then `complete`/`error`). */
|
|
157
|
+
declare function useCommentsHydration(): AnnotationHydration;
|
|
171
158
|
//#endregion
|
|
172
|
-
export {
|
|
173
|
-
//# sourceMappingURL=annotation-
|
|
159
|
+
export { useCommentsHydration as A, filePickerProvider as C, useCommentThread as D, useAnnotationSelection as E, SelectionAnchor as F, sameAnchor as I, sameCreationDraftAnchor as L, useSelectionFlags as M, useSelectionProps as N, useCommentThreads as O, useAnnotationSelected as P, enrichCommentThreads as S, useAnnotationDefaults as T, SelectionFlags$1 as _, AnnotationPropsPatch as a, TextAlign as b, Border as c, Geom as d, LineEnding as f, RenderItem$1 as g, PropSpec as h, AnnotationProps$1 as i, useFilePickerProvider as j, useComments as k, CommentThreadView as l, PropKey as m, AnnotationLayer as n, AnnotationRenderer as o, LineEndings as p, AnnotationLayerProps as r, AnnotationRendererProps as s, AnnotationFlags as t, CreationDraftAnchor$1 as u, SelectionProps$1 as v, useAnnotation as w, TextStyle as x, Style as y };
|
|
160
|
+
//# sourceMappingURL=annotation-BCED_p9H.d.cts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/annotation-anchors.ts
|
|
2
|
+
function sameAnchor(a, b) {
|
|
3
|
+
if (a === b) return true;
|
|
4
|
+
if (!a || !b) return false;
|
|
5
|
+
return a.pon === b.pon && a.bounds.x === b.bounds.x && a.bounds.y === b.bounds.y && a.bounds.width === b.bounds.width && a.bounds.height === b.bounds.height && a.knob?.x === b.knob?.x && a.knob?.y === b.knob?.y;
|
|
6
|
+
}
|
|
7
|
+
function sameCreationDraftAnchor(a, b) {
|
|
8
|
+
if (a === b) return true;
|
|
9
|
+
if (!a || !b) return false;
|
|
10
|
+
return a.kind === b.kind && a.subtype === b.subtype && a.pon === b.pon && a.pointCount === b.pointCount && a.minPoints === b.minPoints && a.canFinish === b.canFinish && a.bounds.x === b.bounds.x && a.bounds.y === b.bounds.y && a.bounds.width === b.bounds.width && a.bounds.height === b.bounds.height;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { sameCreationDraftAnchor as n, sameAnchor as t };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=annotation-anchors-CetwM1g7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-anchors-CetwM1g7.js","names":[],"sources":["../src/annotation-anchors.ts"],"sourcesContent":["import type { CreationDraftAnchor, Rect, Vec } from '@embedpdf/core-annotation';\n\n/** The selection's menu anchor on its primary page, in content space. */\nexport type SelectionAnchor = { pon: number; bounds: Rect; knob?: Vec };\n\nexport function sameAnchor(a: SelectionAnchor | null, b: SelectionAnchor | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.pon === b.pon &&\n a.bounds.x === b.bounds.x &&\n a.bounds.y === b.bounds.y &&\n a.bounds.width === b.bounds.width &&\n a.bounds.height === b.bounds.height &&\n a.knob?.x === b.knob?.x &&\n a.knob?.y === b.knob?.y\n );\n}\n\nexport function sameCreationDraftAnchor(\n a: CreationDraftAnchor | null,\n b: CreationDraftAnchor | null,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.kind === b.kind &&\n a.subtype === b.subtype &&\n a.pon === b.pon &&\n a.pointCount === b.pointCount &&\n a.minPoints === b.minPoints &&\n a.canFinish === b.canFinish &&\n a.bounds.x === b.bounds.x &&\n a.bounds.y === b.bounds.y &&\n a.bounds.width === b.bounds.width &&\n a.bounds.height === b.bounds.height\n );\n}\n"],"mappings":";AAKA,SAAgB,WAAW,GAA2B,GAAoC;CACxF,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OACE,EAAE,QAAQ,EAAE,OACZ,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,UAAU,EAAE,OAAO,SAC5B,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,MAAM,MAAM,EAAE,MAAM,KACtB,EAAE,MAAM,MAAM,EAAE,MAAM;AAE1B;AAEA,SAAgB,wBACd,GACA,GACS;CACT,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OACE,EAAE,SAAS,EAAE,QACb,EAAE,YAAY,EAAE,WAChB,EAAE,QAAQ,EAAE,OACZ,EAAE,eAAe,EAAE,cACnB,EAAE,cAAc,EAAE,aAClB,EAAE,cAAc,EAAE,aAClB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,UAAU,EAAE,OAAO,SAC5B,EAAE,OAAO,WAAW,EAAE,OAAO;AAEjC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/annotation-anchors.ts
|
|
2
|
+
function sameAnchor(a, b) {
|
|
3
|
+
if (a === b) return true;
|
|
4
|
+
if (!a || !b) return false;
|
|
5
|
+
return a.pon === b.pon && a.bounds.x === b.bounds.x && a.bounds.y === b.bounds.y && a.bounds.width === b.bounds.width && a.bounds.height === b.bounds.height && a.knob?.x === b.knob?.x && a.knob?.y === b.knob?.y;
|
|
6
|
+
}
|
|
7
|
+
function sameCreationDraftAnchor(a, b) {
|
|
8
|
+
if (a === b) return true;
|
|
9
|
+
if (!a || !b) return false;
|
|
10
|
+
return a.kind === b.kind && a.subtype === b.subtype && a.pon === b.pon && a.pointCount === b.pointCount && a.minPoints === b.minPoints && a.canFinish === b.canFinish && a.bounds.x === b.bounds.x && a.bounds.y === b.bounds.y && a.bounds.width === b.bounds.width && a.bounds.height === b.bounds.height;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
Object.defineProperty(exports, "sameAnchor", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return sameAnchor;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "sameCreationDraftAnchor", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return sameCreationDraftAnchor;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=annotation-anchors-DuYRBJLl.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-anchors-DuYRBJLl.cjs","names":[],"sources":["../src/annotation-anchors.ts"],"sourcesContent":["import type { CreationDraftAnchor, Rect, Vec } from '@embedpdf/core-annotation';\n\n/** The selection's menu anchor on its primary page, in content space. */\nexport type SelectionAnchor = { pon: number; bounds: Rect; knob?: Vec };\n\nexport function sameAnchor(a: SelectionAnchor | null, b: SelectionAnchor | null): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.pon === b.pon &&\n a.bounds.x === b.bounds.x &&\n a.bounds.y === b.bounds.y &&\n a.bounds.width === b.bounds.width &&\n a.bounds.height === b.bounds.height &&\n a.knob?.x === b.knob?.x &&\n a.knob?.y === b.knob?.y\n );\n}\n\nexport function sameCreationDraftAnchor(\n a: CreationDraftAnchor | null,\n b: CreationDraftAnchor | null,\n): boolean {\n if (a === b) return true;\n if (!a || !b) return false;\n return (\n a.kind === b.kind &&\n a.subtype === b.subtype &&\n a.pon === b.pon &&\n a.pointCount === b.pointCount &&\n a.minPoints === b.minPoints &&\n a.canFinish === b.canFinish &&\n a.bounds.x === b.bounds.x &&\n a.bounds.y === b.bounds.y &&\n a.bounds.width === b.bounds.width &&\n a.bounds.height === b.bounds.height\n );\n}\n"],"mappings":";AAKA,SAAgB,WAAW,GAA2B,GAAoC;CACxF,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OACE,EAAE,QAAQ,EAAE,OACZ,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,UAAU,EAAE,OAAO,SAC5B,EAAE,OAAO,WAAW,EAAE,OAAO,UAC7B,EAAE,MAAM,MAAM,EAAE,MAAM,KACtB,EAAE,MAAM,MAAM,EAAE,MAAM;AAE1B;AAEA,SAAgB,wBACd,GACA,GACS;CACT,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OACE,EAAE,SAAS,EAAE,QACb,EAAE,YAAY,EAAE,WAChB,EAAE,QAAQ,EAAE,OACZ,EAAE,eAAe,EAAE,cACnB,EAAE,cAAc,EAAE,aAClB,EAAE,cAAc,EAAE,aAClB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,MAAM,EAAE,OAAO,KACxB,EAAE,OAAO,UAAU,EAAE,OAAO,SAC5B,EAAE,OAAO,WAAW,EAAE,OAAO;AAEjC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const require_runtime = require("./runtime.cjs");
|
|
2
|
+
let _embedpdf_plugin_annotation_contract = require("@embedpdf/plugin-annotation/contract");
|
|
3
|
+
//#region src/annotation-hooks.ts
|
|
4
|
+
/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */
|
|
5
|
+
function useAnnotationSelected() {
|
|
6
|
+
return require_runtime.useSelector(_embedpdf_plugin_annotation_contract.AnnotationToken, (c) => c.getSelected(), require_runtime.shallowArray);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
Object.defineProperty(exports, "useAnnotationSelected", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function() {
|
|
12
|
+
return useAnnotationSelected;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=annotation-hooks-BB5ZhPpf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-hooks-BB5ZhPpf.cjs","names":["useSelector","AnnotationToken","shallowArray"],"sources":["../src/annotation-hooks.ts"],"sourcesContent":["import { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\n\nimport { shallowArray, useSelector } from './runtime';\n\n/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */\nexport function useAnnotationSelected() {\n return useSelector(AnnotationToken, (c) => c.getSelected(), shallowArray);\n}\n"],"mappings":";;;;AAKA,SAAgB,wBAAwB;CACtC,OAAOA,gBAAAA,YAAYC,qCAAAA,kBAAkB,MAAM,EAAE,YAAY,GAAGC,gBAAAA,YAAY;AAC1E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { shallowArray, useSelector } from "./runtime.js";
|
|
2
|
+
import { AnnotationToken } from "@embedpdf/plugin-annotation/contract";
|
|
3
|
+
//#region src/annotation-hooks.ts
|
|
4
|
+
/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */
|
|
5
|
+
function useAnnotationSelected() {
|
|
6
|
+
return useSelector(AnnotationToken, (c) => c.getSelected(), shallowArray);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { useAnnotationSelected as t };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=annotation-hooks-Df8EmzDO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotation-hooks-Df8EmzDO.js","names":[],"sources":["../src/annotation-hooks.ts"],"sourcesContent":["import { AnnotationToken } from '@embedpdf/plugin-annotation/contract';\n\nimport { shallowArray, useSelector } from './runtime';\n\n/** The selected annotations as engine DTOs — for selection-aware toolbars/sidebars. */\nexport function useAnnotationSelected() {\n return useSelector(AnnotationToken, (c) => c.getSelected(), shallowArray);\n}\n"],"mappings":";;;;AAKA,SAAgB,wBAAwB;CACtC,OAAO,YAAY,kBAAkB,MAAM,EAAE,YAAY,GAAG,YAAY;AAC1E"}
|