@embedpdf/react 3.0.0-next.4 → 3.0.0-next.5
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-_Z600IzD-DYoq1Iu1.d.cts → AnnotationListSnapshot-CHjkcIaL-CMHGL8-D.d.cts} +2 -2
- package/dist/{AnnotationListSnapshot-_Z600IzD-DYoq1Iu1.d.ts → AnnotationListSnapshot-CHjkcIaL-CMHGL8-D.d.ts} +2 -2
- 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-menu.cjs +33 -84
- 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 +27 -78
- package/dist/annotation-menu.js.map +1 -1
- package/dist/annotation.cjs +689 -16
- package/dist/annotation.cjs.map +1 -0
- package/dist/annotation.d.cts +119 -2
- package/dist/annotation.d.ts +119 -2
- package/dist/annotation.js +678 -3
- package/dist/annotation.js.map +1 -0
- package/dist/form.cjs +1 -1
- package/dist/form.d.cts +2 -2
- package/dist/form.d.ts +2 -2
- package/dist/form.js +1 -1
- package/dist/index.cjs +14 -3
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +4 -3
- package/dist/interaction.cjs +1 -1
- package/dist/interaction.js +1 -1
- package/dist/page-view.cjs +58 -36
- package/dist/page-view.cjs.map +1 -1
- package/dist/page-view.js +54 -34
- package/dist/page-view.js.map +1 -1
- package/dist/search.d.cts +1 -1
- package/dist/search.d.ts +1 -1
- package/dist/selection.cjs +59 -4
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.d.cts +35 -2
- package/dist/selection.d.ts +35 -2
- package/dist/selection.js +52 -5
- package/dist/selection.js.map +1 -1
- package/dist/stage.cjs +33 -1
- package/dist/stage.cjs.map +1 -1
- package/dist/stage.js +33 -1
- package/dist/stage.js.map +1 -1
- package/package.json +27 -23
- package/dist/annotation-BTlcOjcK.js +0 -829
- package/dist/annotation-BTlcOjcK.js.map +0 -1
- package/dist/annotation-BvNPtcxN.d.cts +0 -173
- package/dist/annotation-CPbPvbKa.d.ts +0 -173
- package/dist/annotation-DVwYpWyP.cjs +0 -913
- package/dist/annotation-DVwYpWyP.cjs.map +0 -1
package/dist/annotation-menu.js
CHANGED
|
@@ -1,96 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useSelector } from "./runtime.js";
|
|
2
|
+
import { Anchored, useProjectorBinding } from "./anchored.js";
|
|
3
|
+
import { sameAnchor, sameCreationDraftAnchor } from "./annotation.js";
|
|
3
4
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
import
|
|
5
|
-
import { StageToken } from "@embedpdf/plugin-stage";
|
|
5
|
+
import "react";
|
|
6
6
|
import { AnnotationToken } from "@embedpdf/plugin-annotation/internal";
|
|
7
7
|
//#region src/annotation-menu.tsx
|
|
8
|
+
/**
|
|
9
|
+
* Floats over the current annotation selection (one anchor regardless of
|
|
10
|
+
* cross-page selection), dodging the rotate knob. Compose the contents from
|
|
11
|
+
* hooks: `useAnnotation()` for the verbs, `useAnnotationSelected()` /
|
|
12
|
+
* `useSelectionProps()` for the data.
|
|
13
|
+
*/
|
|
8
14
|
function AnnotationMenu({ children, gap = 15, placement = "top" }) {
|
|
9
|
-
const
|
|
10
|
-
const anno = useCapability(AnnotationToken);
|
|
11
|
-
useSelector(StageToken, (c) => c.visiblePages());
|
|
15
|
+
const { projector } = useProjectorBinding();
|
|
12
16
|
const anchor = useSelector(AnnotationToken, (c) => {
|
|
13
17
|
const a = c.selectionAnchor();
|
|
14
18
|
if (!a) return null;
|
|
15
|
-
const
|
|
16
|
-
return
|
|
19
|
+
const env = projector.viewEnv(a.pon);
|
|
20
|
+
return env ? c.selectionAnchor(env.scale, env.rotation, env.zoom) : a;
|
|
17
21
|
}, sameAnchor);
|
|
18
|
-
const selected = useAnnotationSelected();
|
|
19
|
-
const ref = useRef(null);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const el = ref.current;
|
|
22
|
-
if (!el) return;
|
|
23
|
-
const stop = (e) => e.stopPropagation();
|
|
24
|
-
el.addEventListener("pointerdown", stop);
|
|
25
|
-
return () => el.removeEventListener("pointerdown", stop);
|
|
26
|
-
});
|
|
27
22
|
if (!anchor) return null;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
width: 0,
|
|
34
|
-
height: 0
|
|
35
|
-
}) : null;
|
|
36
|
-
const pos = positionMenuAroundRect(box, placement, gap, kr ? {
|
|
37
|
-
x: kr.x,
|
|
38
|
-
y: kr.y
|
|
39
|
-
} : null);
|
|
40
|
-
return /* @__PURE__ */ jsx("div", {
|
|
41
|
-
ref,
|
|
42
|
-
style: {
|
|
43
|
-
position: "absolute",
|
|
44
|
-
left: pos.left,
|
|
45
|
-
top: pos.top,
|
|
46
|
-
transform: pos.transform,
|
|
47
|
-
pointerEvents: "auto"
|
|
23
|
+
return /* @__PURE__ */ jsx(Anchored, {
|
|
24
|
+
anchor: {
|
|
25
|
+
pon: anchor.pon,
|
|
26
|
+
bounds: anchor.bounds,
|
|
27
|
+
...anchor.knob ? { avoid: [anchor.knob] } : {}
|
|
48
28
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
deselect: anno.deselect,
|
|
53
|
-
updateSelection: anno.updateSelection,
|
|
54
|
-
rotate90: anno.rotateSelection90,
|
|
55
|
-
resetRotation: anno.resetSelectionRotation,
|
|
56
|
-
group: anno.group,
|
|
57
|
-
ungroup: anno.ungroup,
|
|
58
|
-
canGroup: anno.canGroup(),
|
|
59
|
-
canUngroup: anno.canUngroup()
|
|
60
|
-
})
|
|
29
|
+
placement,
|
|
30
|
+
gap,
|
|
31
|
+
children
|
|
61
32
|
});
|
|
62
33
|
}
|
|
34
|
+
/** Floats over a live multi-click creation draft (polygon, polyline, …). */
|
|
63
35
|
function AnnotationDraftMenu({ children, gap = 8, placement = "top" }) {
|
|
64
|
-
const stage = useCapability(StageToken);
|
|
65
|
-
const anno = useCapability(AnnotationToken);
|
|
66
|
-
useSelector(StageToken, (c) => c.visiblePages());
|
|
67
36
|
const anchor = useSelector(AnnotationToken, (c) => c.creationDraftAnchor(), sameCreationDraftAnchor);
|
|
68
|
-
const ref = useRef(null);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
const el = ref.current;
|
|
71
|
-
if (!el) return;
|
|
72
|
-
const stop = (e) => e.stopPropagation();
|
|
73
|
-
el.addEventListener("pointerdown", stop);
|
|
74
|
-
return () => el.removeEventListener("pointerdown", stop);
|
|
75
|
-
});
|
|
76
37
|
if (!anchor) return null;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
style: {
|
|
83
|
-
position: "absolute",
|
|
84
|
-
left: pos.left,
|
|
85
|
-
top: pos.top,
|
|
86
|
-
transform: pos.transform,
|
|
87
|
-
pointerEvents: "auto"
|
|
88
|
-
},
|
|
89
|
-
children: children({
|
|
90
|
-
...anchor,
|
|
91
|
-
finish: anno.finishCreationDraft,
|
|
92
|
-
cancel: anno.cancelCreationDraft
|
|
93
|
-
})
|
|
38
|
+
return /* @__PURE__ */ jsx(Anchored, {
|
|
39
|
+
anchor,
|
|
40
|
+
placement,
|
|
41
|
+
gap,
|
|
42
|
+
children: children(anchor)
|
|
94
43
|
});
|
|
95
44
|
}
|
|
96
45
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation-menu.js","names":["AnnotationHostToken"],"sources":["../src/annotation-menu.tsx"],"sourcesContent":["/**\n *
|
|
1
|
+
{"version":3,"file":"annotation-menu.js","names":["AnnotationHostToken"],"sources":["../src/annotation-menu.tsx"],"sourcesContent":["/**\n * Annotation menus — thin anchor plumbing over the ONE `<Anchored>` primitive.\n *\n * These work identically under `<Stage>` (mount in the overlay slot; the\n * camera projects, no DOM reads) and `<PageView>` (measured + portalled) —\n * the SURFACE provides the projector, the menu doesn't care.\n *\n * No action bags: actions come from the capability hooks (`useAnnotation()`,\n * `useAnnotationSelected()`, …), which subscribe properly and compose across\n * plugins. Render props carry only the ANCHOR'S DATA (the draft menu's\n * progress facts); the annotation-selection menu takes plain children.\n */\nimport * as React from 'react';\nimport { AnnotationToken as AnnotationHostToken } from '@embedpdf/plugin-annotation/internal';\nimport type { CreationDraftAnchor } from '@embedpdf/core-annotation';\nimport { Anchored, useProjectorBinding, type AnchoredPlacement } from './anchored';\nimport { useSelector } from './runtime';\nimport { sameAnchor, sameCreationDraftAnchor } from './annotation';\n\nexport interface AnnotationMenuProps {\n children: React.ReactNode;\n /** Gap in screen px between the selection box and the menu (default 15). */\n gap?: number;\n /** Where to place the menu relative to the selection box. Default 'top'. */\n placement?: AnchoredPlacement;\n}\n\n/**\n * Floats over the current annotation selection (one anchor regardless of\n * cross-page selection), dodging the rotate knob. Compose the contents from\n * hooks: `useAnnotation()` for the verbs, `useAnnotationSelected()` /\n * `useSelectionProps()` for the data.\n */\nexport function AnnotationMenu({ children, gap = 15, placement = 'top' }: AnnotationMenuProps) {\n // Reading the binding subscribes this component to projection changes\n // (its identity IS the revision), so the anchor read below re-runs with\n // fresh view facts in the SAME commit as the surface — the knob offset is\n // screen-constant, so its content-space position depends on the page's\n // live view scale.\n const { projector } = useProjectorBinding();\n const anchor = useSelector(\n AnnotationHostToken,\n (c) => {\n const a = c.selectionAnchor();\n if (!a) return null;\n const env = projector.viewEnv(a.pon);\n return env ? c.selectionAnchor(env.scale, env.rotation, env.zoom) : a;\n },\n sameAnchor,\n );\n if (!anchor) return null;\n return (\n <Anchored\n anchor={{\n pon: anchor.pon,\n bounds: anchor.bounds,\n ...(anchor.knob ? { avoid: [anchor.knob] } : {}),\n }}\n placement={placement}\n gap={gap}\n >\n {children}\n </Anchored>\n );\n}\n\nexport interface AnnotationDraftMenuProps {\n /** Render prop receiving the DRAFT ANCHOR'S DATA (subtype, pointCount,\n * minPoints, canFinish, …). The verbs are capability calls:\n * `useAnnotation().finishCreationDraft()` / `.cancelCreationDraft()`. */\n children: (anchor: CreationDraftAnchor) => React.ReactNode;\n /** Gap in screen px between the draft anchor and the menu (default 8). */\n gap?: number;\n /** Where to place the menu relative to the draft anchor. Default 'top'. */\n placement?: AnchoredPlacement;\n}\n\n/** Floats over a live multi-click creation draft (polygon, polyline, …). */\nexport function AnnotationDraftMenu({\n children,\n gap = 8,\n placement = 'top',\n}: AnnotationDraftMenuProps) {\n const anchor = useSelector(\n AnnotationHostToken,\n (c) => c.creationDraftAnchor(),\n sameCreationDraftAnchor,\n );\n if (!anchor) return null;\n return (\n <Anchored anchor={anchor} placement={placement} gap={gap}>\n {children(anchor)}\n </Anchored>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,SAAgB,eAAe,EAAE,UAAU,MAAM,IAAI,YAAY,SAA8B;CAM7F,MAAM,EAAE,cAAc,oBAAoB;CAC1C,MAAM,SAAS,YACbA,kBACC,MAAM;EACL,MAAM,IAAI,EAAE,gBAAgB;EAC5B,IAAI,CAAC,GAAG,OAAO;EACf,MAAM,MAAM,UAAU,QAAQ,EAAE,GAAG;EACnC,OAAO,MAAM,EAAE,gBAAgB,IAAI,OAAO,IAAI,UAAU,IAAI,IAAI,IAAI;CACtE,GACA,UACF;CACA,IAAI,CAAC,QAAQ,OAAO;CACpB,OACE,oBAAC,UAAD;EACE,QAAQ;GACN,KAAK,OAAO;GACZ,QAAQ,OAAO;GACf,GAAI,OAAO,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,IAAI,CAAC;EAChD;EACW;EACN;EAEJ;CACO,CAAA;AAEd;;AAcA,SAAgB,oBAAoB,EAClC,UACA,MAAM,GACN,YAAY,SACe;CAC3B,MAAM,SAAS,YACbA,kBACC,MAAM,EAAE,oBAAoB,GAC7B,uBACF;CACA,IAAI,CAAC,QAAQ,OAAO;CACpB,OACE,oBAAC,UAAD;EAAkB;EAAmB;EAAgB;EAClD,UAAA,SAAS,MAAM;CACR,CAAA;AAEd"}
|