@embedpdf/react 3.0.0-next.3 → 3.0.0-next.4
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-W0RCsyDE-dWna4TTJ.d.cts → AnnotationListSnapshot-_Z600IzD-DYoq1Iu1.d.cts} +19 -2
- package/dist/{AnnotationListSnapshot-W0RCsyDE-dWna4TTJ.d.ts → AnnotationListSnapshot-_Z600IzD-DYoq1Iu1.d.ts} +19 -2
- package/dist/{annotation-DjGWJljY.js → annotation-BTlcOjcK.js} +2 -2
- package/dist/annotation-BTlcOjcK.js.map +1 -0
- package/dist/{annotation-B6jwfTCh.d.cts → annotation-BvNPtcxN.d.cts} +2 -2
- package/dist/{annotation-nUMefyjw.d.ts → annotation-CPbPvbKa.d.ts} +2 -2
- package/dist/{annotation-Ct6dFtzJ.cjs → annotation-DVwYpWyP.cjs} +2 -2
- package/dist/annotation-DVwYpWyP.cjs.map +1 -0
- package/dist/annotation-menu.cjs +1 -1
- package/dist/annotation-menu.d.cts +1 -1
- package/dist/annotation-menu.d.ts +1 -1
- package/dist/annotation-menu.js +1 -1
- package/dist/annotation.cjs +1 -1
- package/dist/annotation.d.cts +1 -1
- package/dist/annotation.d.ts +1 -1
- package/dist/annotation.js +1 -1
- 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 +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +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 +15 -19
- package/dist/selection.cjs.map +1 -1
- package/dist/selection.js +15 -19
- package/dist/selection.js.map +1 -1
- package/package.json +23 -23
- package/dist/annotation-Ct6dFtzJ.cjs.map +0 -1
- package/dist/annotation-DjGWJljY.js.map +0 -1
package/dist/form.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { shallowArray, useCapability, useOptionalCapability, usePage, useSelector } from "./runtime.js";
|
|
2
|
-
import { l as useAnnotationSelected } from "./annotation-
|
|
2
|
+
import { l as useAnnotationSelected } from "./annotation-BTlcOjcK.js";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
5
|
import { StageToken } from "@embedpdf/plugin-stage";
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ const require_scrollbar = require("./scrollbar.cjs");
|
|
|
7
7
|
const require_page_view = require("./page-view.cjs");
|
|
8
8
|
const require_render = require("./render.cjs");
|
|
9
9
|
const require_selection = require("./selection.cjs");
|
|
10
|
-
const require_annotation = require("./annotation-
|
|
10
|
+
const require_annotation = require("./annotation-DVwYpWyP.cjs");
|
|
11
11
|
const require_annotation_menu = require("./annotation-menu.cjs");
|
|
12
12
|
const require_link = require("./link.cjs");
|
|
13
13
|
const require_views = require("./views.cjs");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as useSelector, _ as useKernel, a as EmbedPDF, b as useOptionalSelector, c as Viewer, d as shallowArray, f as useActiveDocumentId, g as useDocuments, h as useDocumentStatus, i as DocumentScopeProps, l as ViewerProps, m as useDocumentId, n as DocumentGateProps, o as PageContextValue, p as useCapability, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernelValue, x as usePage, y as useOptionalCapability } from "./runtime-CMxIuF2O.cjs";
|
|
2
|
-
import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-
|
|
2
|
+
import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-BvNPtcxN.cjs";
|
|
3
3
|
import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.cjs";
|
|
4
4
|
import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.cjs";
|
|
5
5
|
import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { S as useSelector, _ as useKernel, a as EmbedPDF, b as useOptionalSelector, c as Viewer, d as shallowArray, f as useActiveDocumentId, g as useDocuments, h as useDocumentStatus, i as DocumentScopeProps, l as ViewerProps, m as useDocumentId, n as DocumentGateProps, o as PageContextValue, p as useCapability, r as DocumentScope, s as PageProvider, t as DocumentGate, u as makePageContext, v as useKernelValue, x as usePage, y as useOptionalCapability } from "./runtime-DV98q7I0.js";
|
|
2
|
-
import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-
|
|
2
|
+
import { A as useAnnotation, C as SelectionProps, D as filePickerProvider, E as TextStyle, F as useSelectionFlags, I as useSelectionProps, L as AnnotationMenuPlacement, M as useAnnotationSelected, N as useAnnotationSelection, O as sameAnchor, P as useFilePickerProvider, S as SelectionFlags, T as TextAlign, _ as PageAnnotationMenu, a as AnnotationLayerProps, b as RenderItem, c as AnnotationProps, d as AnnotationRendererProps, f as Border, g as PageAnnotationDraftMenu, h as LineEndings, i as AnnotationLayer, j as useAnnotationDefaults, k as sameCreationDraftAnchor, l as AnnotationPropsPatch, m as LineEnding, n as AnnotationDraftMenuRenderArgs, o as AnnotationMenuProps, p as Geom, r as AnnotationFlags, s as AnnotationMenuRenderArgs, t as AnnotationDraftMenuProps, u as AnnotationRenderer, v as PropKey, w as Style, x as SelectionAnchor, y as PropSpec } from "./annotation-CPbPvbKa.js";
|
|
3
3
|
import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.js";
|
|
4
4
|
import { isMacPlatform, useCommand, useCommandShortcuts, useCommands } from "./commands.js";
|
|
5
5
|
import { FormLayer, FormScriptingUiHandlers, useForm, useFormField, useFormScriptingProvider } from "./form.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Scrollbar, useScrollMetrics } from "./scrollbar.js";
|
|
|
5
5
|
import { PageView } from "./page-view.js";
|
|
6
6
|
import { RenderLayer, TileLayer } from "./render.js";
|
|
7
7
|
import { SelectionLayer, useSelection } from "./selection.js";
|
|
8
|
-
import { a as sameAnchor, c as useAnnotationDefaults, d as useFilePickerProvider, f as useSelectionFlags, i as filePickerProvider, l as useAnnotationSelected, n as PageAnnotationDraftMenu, o as sameCreationDraftAnchor, p as useSelectionProps, r as PageAnnotationMenu, s as useAnnotation, t as AnnotationLayer, u as useAnnotationSelection } from "./annotation-
|
|
8
|
+
import { a as sameAnchor, c as useAnnotationDefaults, d as useFilePickerProvider, f as useSelectionFlags, i as filePickerProvider, l as useAnnotationSelected, n as PageAnnotationDraftMenu, o as sameCreationDraftAnchor, p as useSelectionProps, r as PageAnnotationMenu, s as useAnnotation, t as AnnotationLayer, u as useAnnotationSelection } from "./annotation-BTlcOjcK.js";
|
|
9
9
|
import { AnnotationDraftMenu, AnnotationMenu } from "./annotation-menu.js";
|
|
10
10
|
import { LinkLayer, useLink } from "./link.js";
|
|
11
11
|
import { useViews } from "./views.js";
|
package/dist/search.cjs
CHANGED
|
@@ -17,25 +17,42 @@ function SearchLayer({ color = "#ffd500", activeColor = "#ff9632", blendMode = "
|
|
|
17
17
|
inset: 0,
|
|
18
18
|
pointerEvents: "none"
|
|
19
19
|
},
|
|
20
|
-
children: hits.map((hit) => hit.
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
children: hits.map((hit) => hit.segments.map(({ quad: q }, i) => {
|
|
21
|
+
const fill = hit === active ? activeColor : color;
|
|
22
|
+
if (q.upperStart.y === q.upperEnd.y && q.lowerStart.y === q.lowerEnd.y && q.upperStart.x === q.lowerStart.x) {
|
|
23
|
+
const tl = page.transform.pageToContent(q.upperStart);
|
|
24
|
+
const br = page.transform.pageToContent(q.lowerEnd);
|
|
25
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
|
|
26
|
+
position: "absolute",
|
|
27
|
+
left: tl.x,
|
|
28
|
+
top: tl.y,
|
|
29
|
+
width: br.x - tl.x,
|
|
30
|
+
height: br.y - tl.y,
|
|
31
|
+
background: fill,
|
|
32
|
+
mixBlendMode: blendMode,
|
|
33
|
+
borderRadius: 2
|
|
34
|
+
} }, `${hit.charStart}:${i}`);
|
|
35
|
+
}
|
|
36
|
+
const ring = [
|
|
37
|
+
q.upperStart,
|
|
38
|
+
q.upperEnd,
|
|
39
|
+
q.lowerEnd,
|
|
40
|
+
q.lowerStart
|
|
41
|
+
].map((p) => page.transform.pageToContent(p));
|
|
42
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
43
|
+
style: {
|
|
44
|
+
position: "absolute",
|
|
45
|
+
inset: 0,
|
|
46
|
+
width: "100%",
|
|
47
|
+
height: "100%",
|
|
48
|
+
overflow: "visible",
|
|
49
|
+
mixBlendMode: blendMode
|
|
50
|
+
},
|
|
51
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polygon", {
|
|
52
|
+
points: ring.map((p) => `${p.x},${p.y}`).join(" "),
|
|
53
|
+
fill
|
|
54
|
+
})
|
|
55
|
+
}, `${hit.charStart}:${i}`);
|
|
39
56
|
}))
|
|
40
57
|
});
|
|
41
58
|
}
|
package/dist/search.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.cjs","names":["usePage","useSelector","SearchToken","shallowArray","useCapability"],"sources":["../src/search.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-search.\n *\n * <SearchLayer> is a dumb renderer, the SelectionLayer's twin: it reads\n * the page's content-space hit rects from the capability and paints them\n * through PageContext.pageToContent. The active hit gets its own colour.\n * No pointer handling, no engine calls — search is driven from app chrome\n * via useSearch().\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-search';\nimport * as React from 'react';\nimport { SearchToken } from '@embedpdf/plugin-search';\nimport type { SearchHit } from '@embedpdf/plugin-search';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SearchLayerProps {\n /** Highlight colour for hits — SOLID (default: highlighter yellow). */\n color?: string;\n /** Highlight colour for the ACTIVE hit — SOLID (default: orange). */\n activeColor?: string;\n /**\n * How the highlight composites with the page. `'multiply'` (default) is\n * the real-highlighter look: text stays crisp black through the colour,\n * only the paper tints. Pass `'normal'` (with translucent colours) for\n * dark/scanned documents where multiply-on-dark would vanish.\n */\n blendMode?: React.CSSProperties['mixBlendMode'];\n}\n\nexport function SearchLayer({\n color = '#ffd500',\n activeColor = '#ff9632',\n blendMode = 'multiply',\n}: SearchLayerProps) {\n const page = usePage();\n const hits = useSelector(SearchToken, (c) => c.hitsForPage(page.pon), shallowArray);\n const active = useSelector(SearchToken, (c) => c.activeHit());\n\n if (hits.length === 0) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {hits.map((hit: SearchHit) =>\n hit.
|
|
1
|
+
{"version":3,"file":"search.cjs","names":["usePage","useSelector","SearchToken","shallowArray","useCapability"],"sources":["../src/search.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-search.\n *\n * <SearchLayer> is a dumb renderer, the SelectionLayer's twin: it reads\n * the page's content-space hit rects from the capability and paints them\n * through PageContext.pageToContent. The active hit gets its own colour.\n * No pointer handling, no engine calls — search is driven from app chrome\n * via useSearch().\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-search';\nimport * as React from 'react';\nimport { SearchToken } from '@embedpdf/plugin-search';\nimport type { SearchHit } from '@embedpdf/plugin-search';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SearchLayerProps {\n /** Highlight colour for hits — SOLID (default: highlighter yellow). */\n color?: string;\n /** Highlight colour for the ACTIVE hit — SOLID (default: orange). */\n activeColor?: string;\n /**\n * How the highlight composites with the page. `'multiply'` (default) is\n * the real-highlighter look: text stays crisp black through the colour,\n * only the paper tints. Pass `'normal'` (with translucent colours) for\n * dark/scanned documents where multiply-on-dark would vanish.\n */\n blendMode?: React.CSSProperties['mixBlendMode'];\n}\n\nexport function SearchLayer({\n color = '#ffd500',\n activeColor = '#ff9632',\n blendMode = 'multiply',\n}: SearchLayerProps) {\n const page = usePage();\n const hits = useSelector(SearchToken, (c) => c.hitsForPage(page.pon), shallowArray);\n const active = useSelector(SearchToken, (c) => c.activeHit());\n\n if (hits.length === 0) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {hits.map((hit: SearchHit) =>\n hit.segments.map(({ quad: q }, i) => {\n const fill = hit === active ? activeColor : color;\n // Upright hits keep the classic rounded div (pixel-identical to the\n // pre-orientation layer); rotated hits draw their true oriented cell.\n const upright =\n q.upperStart.y === q.upperEnd.y &&\n q.lowerStart.y === q.lowerEnd.y &&\n q.upperStart.x === q.lowerStart.x;\n if (upright) {\n const tl = page.transform.pageToContent(q.upperStart);\n const br = page.transform.pageToContent(q.lowerEnd);\n return (\n <div\n key={`${hit.charStart}:${i}`}\n style={{\n position: 'absolute',\n left: tl.x,\n top: tl.y,\n width: br.x - tl.x,\n height: br.y - tl.y,\n background: fill,\n mixBlendMode: blendMode,\n borderRadius: 2,\n }}\n />\n );\n }\n const ring = [q.upperStart, q.upperEnd, q.lowerEnd, q.lowerStart].map((p) =>\n page.transform.pageToContent(p),\n );\n return (\n <svg\n key={`${hit.charStart}:${i}`}\n style={{\n position: 'absolute',\n inset: 0,\n width: '100%',\n height: '100%',\n overflow: 'visible',\n mixBlendMode: blendMode,\n }}\n >\n <polygon points={ring.map((p) => `${p.x},${p.y}`).join(' ')} fill={fill} />\n </svg>\n );\n }),\n )}\n </div>\n );\n}\n\n/** The search capability (search/clear/next/prev/…) for app chrome. */\nexport function useSearch() {\n return useCapability(SearchToken);\n}\n\n/** Reactive search read-model for chrome: the query, status, counts, progress. */\nexport function useSearchState() {\n const query = useSelector(SearchToken, (c) => c.query());\n const status = useSelector(SearchToken, (c) => c.status());\n const hitCount = useSelector(SearchToken, (c) => c.hitCount());\n const activeIndex = useSelector(SearchToken, (c) => c.activeIndex());\n const progress = useSelector(\n SearchToken,\n (c) => c.progress(),\n (a, b) => a.scanned === b.scanned && a.total === b.total,\n );\n const error = useSelector(SearchToken, (c) => c.errorMessage());\n return { query, status, hitCount, activeIndex, progress, error };\n}\n"],"mappings":";;;;;;;;AA+BA,SAAgB,YAAY,EAC1B,QAAQ,WACR,cAAc,WACd,YAAY,cACO;CACnB,MAAM,OAAOA,gBAAAA,QAAQ;CACrB,MAAM,OAAOC,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,YAAY,KAAK,GAAG,GAAGC,gBAAAA,YAAY;CAClF,MAAM,SAASF,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,UAAU,CAAC;CAE5D,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EAAK,OAAO;GAAE,UAAU;GAAY,OAAO;GAAG,eAAe;EAAO;EACjE,UAAA,KAAK,KAAK,QACT,IAAI,SAAS,KAAK,EAAE,MAAM,KAAK,MAAM;GACnC,MAAM,OAAO,QAAQ,SAAS,cAAc;GAO5C,IAHE,EAAE,WAAW,MAAM,EAAE,SAAS,KAC9B,EAAE,WAAW,MAAM,EAAE,SAAS,KAC9B,EAAE,WAAW,MAAM,EAAE,WAAW,GACrB;IACX,MAAM,KAAK,KAAK,UAAU,cAAc,EAAE,UAAU;IACpD,MAAM,KAAK,KAAK,UAAU,cAAc,EAAE,QAAQ;IAClD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD,EAEE,OAAO;KACL,UAAU;KACV,MAAM,GAAG;KACT,KAAK,GAAG;KACR,OAAO,GAAG,IAAI,GAAG;KACjB,QAAQ,GAAG,IAAI,GAAG;KAClB,YAAY;KACZ,cAAc;KACd,cAAc;IAChB,EACD,GAXM,GAAG,IAAI,UAAU,GAAG,GAW1B;GAEL;GACA,MAAM,OAAO;IAAC,EAAE;IAAY,EAAE;IAAU,EAAE;IAAU,EAAE;GAAU,CAAC,CAAC,KAAK,MACrE,KAAK,UAAU,cAAc,CAAC,CAChC;GACA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAEE,OAAO;KACL,UAAU;KACV,OAAO;KACP,OAAO;KACP,QAAQ;KACR,UAAU;KACV,cAAc;IAChB;IAEA,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;KAAS,QAAQ,KAAK,KAAK,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG;KAAS;IAAO,CAAA;GACvE,GAXE,GAAG,IAAI,UAAU,GAAG,GAWtB;EAET,CAAC,CACH;CACG,CAAA;AAET;;AAGA,SAAgB,YAAY;CAC1B,OAAOE,gBAAAA,cAAcF,wBAAAA,WAAW;AAClC;;AAGA,SAAgB,iBAAiB;CAW/B,OAAO;EAAE,OAVKD,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,MAAM,CAUzC;EAAG,QATDD,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,OAAO,CASnC;EAAG,UARPD,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,SAAS,CAQ7B;EAAG,aAPdD,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,YAAY,CAOtB;EAAG,UAN9BD,gBAAAA,YACfC,wBAAAA,cACC,MAAM,EAAE,SAAS,IACjB,GAAG,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,KAGC;EAAG,OAD3CD,gBAAAA,YAAYC,wBAAAA,cAAc,MAAM,EAAE,aAAa,CACA;CAAE;AACjE"}
|
package/dist/search.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as SearchQuery } from "./AnnotationListSnapshot-
|
|
1
|
+
import { r as SearchQuery } from "./AnnotationListSnapshot-_Z600IzD-DYoq1Iu1.cjs";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
export * from "@embedpdf/plugin-search";
|
|
4
4
|
//#region src/search.d.ts
|
package/dist/search.d.ts
CHANGED
package/dist/search.js
CHANGED
|
@@ -15,25 +15,42 @@ function SearchLayer({ color = "#ffd500", activeColor = "#ff9632", blendMode = "
|
|
|
15
15
|
inset: 0,
|
|
16
16
|
pointerEvents: "none"
|
|
17
17
|
},
|
|
18
|
-
children: hits.map((hit) => hit.
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
children: hits.map((hit) => hit.segments.map(({ quad: q }, i) => {
|
|
19
|
+
const fill = hit === active ? activeColor : color;
|
|
20
|
+
if (q.upperStart.y === q.upperEnd.y && q.lowerStart.y === q.lowerEnd.y && q.upperStart.x === q.lowerStart.x) {
|
|
21
|
+
const tl = page.transform.pageToContent(q.upperStart);
|
|
22
|
+
const br = page.transform.pageToContent(q.lowerEnd);
|
|
23
|
+
return /* @__PURE__ */ jsx("div", { style: {
|
|
24
|
+
position: "absolute",
|
|
25
|
+
left: tl.x,
|
|
26
|
+
top: tl.y,
|
|
27
|
+
width: br.x - tl.x,
|
|
28
|
+
height: br.y - tl.y,
|
|
29
|
+
background: fill,
|
|
30
|
+
mixBlendMode: blendMode,
|
|
31
|
+
borderRadius: 2
|
|
32
|
+
} }, `${hit.charStart}:${i}`);
|
|
33
|
+
}
|
|
34
|
+
const ring = [
|
|
35
|
+
q.upperStart,
|
|
36
|
+
q.upperEnd,
|
|
37
|
+
q.lowerEnd,
|
|
38
|
+
q.lowerStart
|
|
39
|
+
].map((p) => page.transform.pageToContent(p));
|
|
40
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
41
|
+
style: {
|
|
42
|
+
position: "absolute",
|
|
43
|
+
inset: 0,
|
|
44
|
+
width: "100%",
|
|
45
|
+
height: "100%",
|
|
46
|
+
overflow: "visible",
|
|
47
|
+
mixBlendMode: blendMode
|
|
48
|
+
},
|
|
49
|
+
children: /* @__PURE__ */ jsx("polygon", {
|
|
50
|
+
points: ring.map((p) => `${p.x},${p.y}`).join(" "),
|
|
51
|
+
fill
|
|
52
|
+
})
|
|
53
|
+
}, `${hit.charStart}:${i}`);
|
|
37
54
|
}))
|
|
38
55
|
});
|
|
39
56
|
}
|
package/dist/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","names":[],"sources":["../src/search.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-search.\n *\n * <SearchLayer> is a dumb renderer, the SelectionLayer's twin: it reads\n * the page's content-space hit rects from the capability and paints them\n * through PageContext.pageToContent. The active hit gets its own colour.\n * No pointer handling, no engine calls — search is driven from app chrome\n * via useSearch().\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-search';\nimport * as React from 'react';\nimport { SearchToken } from '@embedpdf/plugin-search';\nimport type { SearchHit } from '@embedpdf/plugin-search';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SearchLayerProps {\n /** Highlight colour for hits — SOLID (default: highlighter yellow). */\n color?: string;\n /** Highlight colour for the ACTIVE hit — SOLID (default: orange). */\n activeColor?: string;\n /**\n * How the highlight composites with the page. `'multiply'` (default) is\n * the real-highlighter look: text stays crisp black through the colour,\n * only the paper tints. Pass `'normal'` (with translucent colours) for\n * dark/scanned documents where multiply-on-dark would vanish.\n */\n blendMode?: React.CSSProperties['mixBlendMode'];\n}\n\nexport function SearchLayer({\n color = '#ffd500',\n activeColor = '#ff9632',\n blendMode = 'multiply',\n}: SearchLayerProps) {\n const page = usePage();\n const hits = useSelector(SearchToken, (c) => c.hitsForPage(page.pon), shallowArray);\n const active = useSelector(SearchToken, (c) => c.activeHit());\n\n if (hits.length === 0) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {hits.map((hit: SearchHit) =>\n hit.
|
|
1
|
+
{"version":3,"file":"search.js","names":[],"sources":["../src/search.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-search.\n *\n * <SearchLayer> is a dumb renderer, the SelectionLayer's twin: it reads\n * the page's content-space hit rects from the capability and paints them\n * through PageContext.pageToContent. The active hit gets its own colour.\n * No pointer handling, no engine calls — search is driven from app chrome\n * via useSearch().\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-search';\nimport * as React from 'react';\nimport { SearchToken } from '@embedpdf/plugin-search';\nimport type { SearchHit } from '@embedpdf/plugin-search';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SearchLayerProps {\n /** Highlight colour for hits — SOLID (default: highlighter yellow). */\n color?: string;\n /** Highlight colour for the ACTIVE hit — SOLID (default: orange). */\n activeColor?: string;\n /**\n * How the highlight composites with the page. `'multiply'` (default) is\n * the real-highlighter look: text stays crisp black through the colour,\n * only the paper tints. Pass `'normal'` (with translucent colours) for\n * dark/scanned documents where multiply-on-dark would vanish.\n */\n blendMode?: React.CSSProperties['mixBlendMode'];\n}\n\nexport function SearchLayer({\n color = '#ffd500',\n activeColor = '#ff9632',\n blendMode = 'multiply',\n}: SearchLayerProps) {\n const page = usePage();\n const hits = useSelector(SearchToken, (c) => c.hitsForPage(page.pon), shallowArray);\n const active = useSelector(SearchToken, (c) => c.activeHit());\n\n if (hits.length === 0) return null;\n\n return (\n <div style={{ position: 'absolute', inset: 0, pointerEvents: 'none' }}>\n {hits.map((hit: SearchHit) =>\n hit.segments.map(({ quad: q }, i) => {\n const fill = hit === active ? activeColor : color;\n // Upright hits keep the classic rounded div (pixel-identical to the\n // pre-orientation layer); rotated hits draw their true oriented cell.\n const upright =\n q.upperStart.y === q.upperEnd.y &&\n q.lowerStart.y === q.lowerEnd.y &&\n q.upperStart.x === q.lowerStart.x;\n if (upright) {\n const tl = page.transform.pageToContent(q.upperStart);\n const br = page.transform.pageToContent(q.lowerEnd);\n return (\n <div\n key={`${hit.charStart}:${i}`}\n style={{\n position: 'absolute',\n left: tl.x,\n top: tl.y,\n width: br.x - tl.x,\n height: br.y - tl.y,\n background: fill,\n mixBlendMode: blendMode,\n borderRadius: 2,\n }}\n />\n );\n }\n const ring = [q.upperStart, q.upperEnd, q.lowerEnd, q.lowerStart].map((p) =>\n page.transform.pageToContent(p),\n );\n return (\n <svg\n key={`${hit.charStart}:${i}`}\n style={{\n position: 'absolute',\n inset: 0,\n width: '100%',\n height: '100%',\n overflow: 'visible',\n mixBlendMode: blendMode,\n }}\n >\n <polygon points={ring.map((p) => `${p.x},${p.y}`).join(' ')} fill={fill} />\n </svg>\n );\n }),\n )}\n </div>\n );\n}\n\n/** The search capability (search/clear/next/prev/…) for app chrome. */\nexport function useSearch() {\n return useCapability(SearchToken);\n}\n\n/** Reactive search read-model for chrome: the query, status, counts, progress. */\nexport function useSearchState() {\n const query = useSelector(SearchToken, (c) => c.query());\n const status = useSelector(SearchToken, (c) => c.status());\n const hitCount = useSelector(SearchToken, (c) => c.hitCount());\n const activeIndex = useSelector(SearchToken, (c) => c.activeIndex());\n const progress = useSelector(\n SearchToken,\n (c) => c.progress(),\n (a, b) => a.scanned === b.scanned && a.total === b.total,\n );\n const error = useSelector(SearchToken, (c) => c.errorMessage());\n return { query, status, hitCount, activeIndex, progress, error };\n}\n"],"mappings":";;;;;;AA+BA,SAAgB,YAAY,EAC1B,QAAQ,WACR,cAAc,WACd,YAAY,cACO;CACnB,MAAM,OAAO,QAAQ;CACrB,MAAM,OAAO,YAAY,cAAc,MAAM,EAAE,YAAY,KAAK,GAAG,GAAG,YAAY;CAClF,MAAM,SAAS,YAAY,cAAc,MAAM,EAAE,UAAU,CAAC;CAE5D,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OACE,oBAAC,OAAD;EAAK,OAAO;GAAE,UAAU;GAAY,OAAO;GAAG,eAAe;EAAO;EACjE,UAAA,KAAK,KAAK,QACT,IAAI,SAAS,KAAK,EAAE,MAAM,KAAK,MAAM;GACnC,MAAM,OAAO,QAAQ,SAAS,cAAc;GAO5C,IAHE,EAAE,WAAW,MAAM,EAAE,SAAS,KAC9B,EAAE,WAAW,MAAM,EAAE,SAAS,KAC9B,EAAE,WAAW,MAAM,EAAE,WAAW,GACrB;IACX,MAAM,KAAK,KAAK,UAAU,cAAc,EAAE,UAAU;IACpD,MAAM,KAAK,KAAK,UAAU,cAAc,EAAE,QAAQ;IAClD,OACE,oBAAC,OAAD,EAEE,OAAO;KACL,UAAU;KACV,MAAM,GAAG;KACT,KAAK,GAAG;KACR,OAAO,GAAG,IAAI,GAAG;KACjB,QAAQ,GAAG,IAAI,GAAG;KAClB,YAAY;KACZ,cAAc;KACd,cAAc;IAChB,EACD,GAXM,GAAG,IAAI,UAAU,GAAG,GAW1B;GAEL;GACA,MAAM,OAAO;IAAC,EAAE;IAAY,EAAE;IAAU,EAAE;IAAU,EAAE;GAAU,CAAC,CAAC,KAAK,MACrE,KAAK,UAAU,cAAc,CAAC,CAChC;GACA,OACE,oBAAC,OAAD;IAEE,OAAO;KACL,UAAU;KACV,OAAO;KACP,OAAO;KACP,QAAQ;KACR,UAAU;KACV,cAAc;IAChB;IAEA,UAAA,oBAAC,WAAD;KAAS,QAAQ,KAAK,KAAK,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG;KAAS;IAAO,CAAA;GACvE,GAXE,GAAG,IAAI,UAAU,GAAG,GAWtB;EAET,CAAC,CACH;CACG,CAAA;AAET;;AAGA,SAAgB,YAAY;CAC1B,OAAO,cAAc,WAAW;AAClC;;AAGA,SAAgB,iBAAiB;CAW/B,OAAO;EAAE,OAVK,YAAY,cAAc,MAAM,EAAE,MAAM,CAUzC;EAAG,QATD,YAAY,cAAc,MAAM,EAAE,OAAO,CASnC;EAAG,UARP,YAAY,cAAc,MAAM,EAAE,SAAS,CAQ7B;EAAG,aAPd,YAAY,cAAc,MAAM,EAAE,YAAY,CAOtB;EAAG,UAN9B,YACf,cACC,MAAM,EAAE,SAAS,IACjB,GAAG,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,KAGC;EAAG,OAD3C,YAAY,cAAc,MAAM,EAAE,aAAa,CACA;CAAE;AACjE"}
|
package/dist/selection.cjs
CHANGED
|
@@ -9,35 +9,31 @@ let _embedpdf_plugin_selection = require("@embedpdf/plugin-selection");
|
|
|
9
9
|
function SelectionLayer({ color = "rgba(33, 150, 243, 0.35)" }) {
|
|
10
10
|
const page = require_runtime.usePage();
|
|
11
11
|
const selection = require_runtime.useCapability(_embedpdf_plugin_selection.SelectionToken);
|
|
12
|
-
const
|
|
12
|
+
const segments = require_runtime.useSelector(_embedpdf_plugin_selection.SelectionToken, (c) => c.segmentsForPage(page.pon), require_runtime.shallowArray);
|
|
13
13
|
const visible = require_runtime.useSelector(_embedpdf_plugin_selection.SelectionToken, (c) => c.highlightVisible());
|
|
14
14
|
(0, react.useEffect)(() => {
|
|
15
15
|
selection.ensurePage(page.pon);
|
|
16
16
|
}, [selection, page.pon]);
|
|
17
17
|
if (!visible) return null;
|
|
18
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
18
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
19
19
|
style: {
|
|
20
20
|
position: "absolute",
|
|
21
21
|
inset: 0,
|
|
22
|
+
width: "100%",
|
|
23
|
+
height: "100%",
|
|
24
|
+
overflow: "visible",
|
|
22
25
|
pointerEvents: "none"
|
|
23
26
|
},
|
|
24
|
-
children:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
position: "absolute",
|
|
35
|
-
left: tl.x,
|
|
36
|
-
top: tl.y,
|
|
37
|
-
width: br.x - tl.x,
|
|
38
|
-
height: br.y - tl.y,
|
|
39
|
-
background: color
|
|
40
|
-
} }, i);
|
|
27
|
+
children: segments.map((s, i) => {
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polygon", {
|
|
29
|
+
points: [
|
|
30
|
+
s.quad.upperStart,
|
|
31
|
+
s.quad.upperEnd,
|
|
32
|
+
s.quad.lowerEnd,
|
|
33
|
+
s.quad.lowerStart
|
|
34
|
+
].map((p) => page.transform.pageToContent(p)).map((p) => `${p.x},${p.y}`).join(" "),
|
|
35
|
+
fill: color
|
|
36
|
+
}, i);
|
|
41
37
|
})
|
|
42
38
|
});
|
|
43
39
|
}
|
package/dist/selection.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.cjs","names":["usePage","useCapability","SelectionToken","useSelector","shallowArray"],"sources":["../src/selection.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-selection.\n *\n * <SelectionLayer> is a dumb renderer: it warms the page's geometry on mount,\n * reads the content-space highlight rects from the capability, and paints them —\n * mapping each rect through PageContext.pageToContent (the same path markers use).\n * Zero pointer handling here; that's the PagePointerSource + the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-selection';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { SelectionToken } from '@embedpdf/plugin-selection';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SelectionLayerProps {\n /** Highlight colour (default: translucent blue). */\n color?: string;\n}\n\nexport function SelectionLayer({ color = 'rgba(33, 150, 243, 0.35)' }: SelectionLayerProps) {\n const page = usePage();\n const selection = useCapability(SelectionToken);\n const
|
|
1
|
+
{"version":3,"file":"selection.cjs","names":["usePage","useCapability","SelectionToken","useSelector","shallowArray"],"sources":["../src/selection.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-selection.\n *\n * <SelectionLayer> is a dumb renderer: it warms the page's geometry on mount,\n * reads the content-space highlight rects from the capability, and paints them —\n * mapping each rect through PageContext.pageToContent (the same path markers use).\n * Zero pointer handling here; that's the PagePointerSource + the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-selection';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { SelectionToken } from '@embedpdf/plugin-selection';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SelectionLayerProps {\n /** Highlight colour (default: translucent blue). */\n color?: string;\n}\n\nexport function SelectionLayer({ color = 'rgba(33, 150, 243, 0.35)' }: SelectionLayerProps) {\n const page = usePage();\n const selection = useCapability(SelectionToken);\n const segments = useSelector(SelectionToken, (c) => c.segmentsForPage(page.pon), shallowArray);\n // A consumer (e.g. a markup tool drawing its own preview) can take over the\n // selection visual; when it does, we render nothing so the two never overlap.\n const visible = useSelector(SelectionToken, (c) => c.highlightVisible());\n\n // Warm this page's text geometry as soon as it's on screen, so the first\n // pointer-down can hit-test without waiting on the engine round-trip.\n useEffect(() => {\n selection.ensurePage(page.pon);\n }, [selection, page.pon]);\n\n if (!visible) return null;\n\n return (\n <svg\n style={{\n position: 'absolute',\n inset: 0,\n width: '100%',\n height: '100%',\n overflow: 'visible',\n pointerEvents: 'none',\n }}\n >\n {segments.map((s, i) => {\n // content space → un-rotated content view px (rides the page's CSS\n // rotation). An affine map, so mapping the four corners is exact —\n // upright segments render pixel-identical to the old div-per-rect.\n const ring = [s.quad.upperStart, s.quad.upperEnd, s.quad.lowerEnd, s.quad.lowerStart].map(\n (p) => page.transform.pageToContent(p),\n );\n return (\n <polygon key={i} points={ring.map((p) => `${p.x},${p.y}`).join(' ')} fill={color} />\n );\n })}\n </svg>\n );\n}\n\n/** The selection capability (clear(), hasSelection(), …) for app chrome. */\nexport function useSelection() {\n return useCapability(SelectionToken);\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,eAAe,EAAE,QAAQ,8BAAmD;CAC1F,MAAM,OAAOA,gBAAAA,QAAQ;CACrB,MAAM,YAAYC,gBAAAA,cAAcC,2BAAAA,cAAc;CAC9C,MAAM,WAAWC,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,gBAAgB,KAAK,GAAG,GAAGE,gBAAAA,YAAY;CAG7F,MAAM,UAAUD,gBAAAA,YAAYD,2BAAAA,iBAAiB,MAAM,EAAE,iBAAiB,CAAC;CAIvE,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,UAAU,WAAW,KAAK,GAAG;CAC/B,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;CAExB,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACE,OAAO;GACL,UAAU;GACV,OAAO;GACP,OAAO;GACP,QAAQ;GACR,UAAU;GACV,eAAe;EACjB;EAEC,UAAA,SAAS,KAAK,GAAG,MAAM;GAOtB,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;IAAiB,QAJN;KAAC,EAAE,KAAK;KAAY,EAAE,KAAK;KAAU,EAAE,KAAK;KAAU,EAAE,KAAK;IAAU,CAAC,CAAC,KACnF,MAAM,KAAK,UAAU,cAAc,CAAC,CAGT,CAAC,CAAC,KAAK,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG;IAAG,MAAM;GAAQ,GAArE,CAAqE;EAEvF,CAAC;CACE,CAAA;AAET;;AAGA,SAAgB,eAAe;CAC7B,OAAOD,gBAAAA,cAAcC,2BAAAA,cAAc;AACrC"}
|
package/dist/selection.js
CHANGED
|
@@ -7,35 +7,31 @@ export * from "@embedpdf/plugin-selection";
|
|
|
7
7
|
function SelectionLayer({ color = "rgba(33, 150, 243, 0.35)" }) {
|
|
8
8
|
const page = usePage();
|
|
9
9
|
const selection = useCapability(SelectionToken);
|
|
10
|
-
const
|
|
10
|
+
const segments = useSelector(SelectionToken, (c) => c.segmentsForPage(page.pon), shallowArray);
|
|
11
11
|
const visible = useSelector(SelectionToken, (c) => c.highlightVisible());
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
selection.ensurePage(page.pon);
|
|
14
14
|
}, [selection, page.pon]);
|
|
15
15
|
if (!visible) return null;
|
|
16
|
-
return /* @__PURE__ */ jsx("
|
|
16
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
17
17
|
style: {
|
|
18
18
|
position: "absolute",
|
|
19
19
|
inset: 0,
|
|
20
|
+
width: "100%",
|
|
21
|
+
height: "100%",
|
|
22
|
+
overflow: "visible",
|
|
20
23
|
pointerEvents: "none"
|
|
21
24
|
},
|
|
22
|
-
children:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
position: "absolute",
|
|
33
|
-
left: tl.x,
|
|
34
|
-
top: tl.y,
|
|
35
|
-
width: br.x - tl.x,
|
|
36
|
-
height: br.y - tl.y,
|
|
37
|
-
background: color
|
|
38
|
-
} }, i);
|
|
25
|
+
children: segments.map((s, i) => {
|
|
26
|
+
return /* @__PURE__ */ jsx("polygon", {
|
|
27
|
+
points: [
|
|
28
|
+
s.quad.upperStart,
|
|
29
|
+
s.quad.upperEnd,
|
|
30
|
+
s.quad.lowerEnd,
|
|
31
|
+
s.quad.lowerStart
|
|
32
|
+
].map((p) => page.transform.pageToContent(p)).map((p) => `${p.x},${p.y}`).join(" "),
|
|
33
|
+
fill: color
|
|
34
|
+
}, i);
|
|
39
35
|
})
|
|
40
36
|
});
|
|
41
37
|
}
|
package/dist/selection.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selection.js","names":[],"sources":["../src/selection.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-selection.\n *\n * <SelectionLayer> is a dumb renderer: it warms the page's geometry on mount,\n * reads the content-space highlight rects from the capability, and paints them —\n * mapping each rect through PageContext.pageToContent (the same path markers use).\n * Zero pointer handling here; that's the PagePointerSource + the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-selection';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { SelectionToken } from '@embedpdf/plugin-selection';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SelectionLayerProps {\n /** Highlight colour (default: translucent blue). */\n color?: string;\n}\n\nexport function SelectionLayer({ color = 'rgba(33, 150, 243, 0.35)' }: SelectionLayerProps) {\n const page = usePage();\n const selection = useCapability(SelectionToken);\n const
|
|
1
|
+
{"version":3,"file":"selection.js","names":[],"sources":["../src/selection.tsx"],"sourcesContent":["/**\n * The React surface for @embedpdf/plugin-selection.\n *\n * <SelectionLayer> is a dumb renderer: it warms the page's geometry on mount,\n * reads the content-space highlight rects from the capability, and paints them —\n * mapping each rect through PageContext.pageToContent (the same path markers use).\n * Zero pointer handling here; that's the PagePointerSource + the hub.\n */\n\n// One-line-per-feature: registration travels with the UI.\nexport * from '@embedpdf/plugin-selection';\nimport * as React from 'react';\nimport { useEffect } from 'react';\nimport { SelectionToken } from '@embedpdf/plugin-selection';\nimport { shallowArray, useCapability, usePage, useSelector } from './runtime';\n\nexport interface SelectionLayerProps {\n /** Highlight colour (default: translucent blue). */\n color?: string;\n}\n\nexport function SelectionLayer({ color = 'rgba(33, 150, 243, 0.35)' }: SelectionLayerProps) {\n const page = usePage();\n const selection = useCapability(SelectionToken);\n const segments = useSelector(SelectionToken, (c) => c.segmentsForPage(page.pon), shallowArray);\n // A consumer (e.g. a markup tool drawing its own preview) can take over the\n // selection visual; when it does, we render nothing so the two never overlap.\n const visible = useSelector(SelectionToken, (c) => c.highlightVisible());\n\n // Warm this page's text geometry as soon as it's on screen, so the first\n // pointer-down can hit-test without waiting on the engine round-trip.\n useEffect(() => {\n selection.ensurePage(page.pon);\n }, [selection, page.pon]);\n\n if (!visible) return null;\n\n return (\n <svg\n style={{\n position: 'absolute',\n inset: 0,\n width: '100%',\n height: '100%',\n overflow: 'visible',\n pointerEvents: 'none',\n }}\n >\n {segments.map((s, i) => {\n // content space → un-rotated content view px (rides the page's CSS\n // rotation). An affine map, so mapping the four corners is exact —\n // upright segments render pixel-identical to the old div-per-rect.\n const ring = [s.quad.upperStart, s.quad.upperEnd, s.quad.lowerEnd, s.quad.lowerStart].map(\n (p) => page.transform.pageToContent(p),\n );\n return (\n <polygon key={i} points={ring.map((p) => `${p.x},${p.y}`).join(' ')} fill={color} />\n );\n })}\n </svg>\n );\n}\n\n/** The selection capability (clear(), hasSelection(), …) for app chrome. */\nexport function useSelection() {\n return useCapability(SelectionToken);\n}\n"],"mappings":";;;;;;AAqBA,SAAgB,eAAe,EAAE,QAAQ,8BAAmD;CAC1F,MAAM,OAAO,QAAQ;CACrB,MAAM,YAAY,cAAc,cAAc;CAC9C,MAAM,WAAW,YAAY,iBAAiB,MAAM,EAAE,gBAAgB,KAAK,GAAG,GAAG,YAAY;CAG7F,MAAM,UAAU,YAAY,iBAAiB,MAAM,EAAE,iBAAiB,CAAC;CAIvE,gBAAgB;EACd,UAAU,WAAW,KAAK,GAAG;CAC/B,GAAG,CAAC,WAAW,KAAK,GAAG,CAAC;CAExB,IAAI,CAAC,SAAS,OAAO;CAErB,OACE,oBAAC,OAAD;EACE,OAAO;GACL,UAAU;GACV,OAAO;GACP,OAAO;GACP,QAAQ;GACR,UAAU;GACV,eAAe;EACjB;EAEC,UAAA,SAAS,KAAK,GAAG,MAAM;GAOtB,OACE,oBAAC,WAAD;IAAiB,QAJN;KAAC,EAAE,KAAK;KAAY,EAAE,KAAK;KAAU,EAAE,KAAK;KAAU,EAAE,KAAK;IAAU,CAAC,CAAC,KACnF,MAAM,KAAK,UAAU,cAAc,CAAC,CAGT,CAAC,CAAC,KAAK,MAAM,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,KAAK,GAAG;IAAG,MAAM;GAAQ,GAArE,CAAqE;EAEvF,CAAC;CACE,CAAA;AAET;;AAGA,SAAgB,eAAe;CAC7B,OAAO,cAAc,cAAc;AACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/react",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "React adapter for EmbedPDF v3: one generic reactive binding + structural components (Viewer, Stage, PageView) + headless layers & hooks. The whole framework surface.",
|
|
6
6
|
"type": "module",
|
|
@@ -103,28 +103,28 @@
|
|
|
103
103
|
"dist"
|
|
104
104
|
],
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@embedpdf/core-annotation": "3.0.0-next.
|
|
107
|
-
"@embedpdf/core": "3.0.0-next.
|
|
108
|
-
"@embedpdf/
|
|
109
|
-
"@embedpdf/
|
|
110
|
-
"@embedpdf/plugin-
|
|
111
|
-
"@embedpdf/plugin-
|
|
112
|
-
"@embedpdf/plugin-
|
|
113
|
-
"@embedpdf/plugin-
|
|
114
|
-
"@embedpdf/plugin-
|
|
115
|
-
"@embedpdf/plugin-
|
|
116
|
-
"@embedpdf/plugin-
|
|
117
|
-
"@embedpdf/plugin-
|
|
118
|
-
"@embedpdf/plugin-render": "3.0.0-next.
|
|
119
|
-
"@embedpdf/plugin-
|
|
120
|
-
"@embedpdf/plugin-
|
|
121
|
-
"@embedpdf/plugin-
|
|
122
|
-
"@embedpdf/plugin-stage": "3.0.0-next.
|
|
123
|
-
"@embedpdf/plugin-stamp": "3.0.0-next.
|
|
124
|
-
"@embedpdf/core-stage": "3.0.0-next.
|
|
125
|
-
"@embedpdf/plugin-view-manager": "3.0.0-next.
|
|
126
|
-
"@embedpdf/core-ui": "3.0.0-next.
|
|
127
|
-
"@embedpdf/web": "3.0.0-next.
|
|
106
|
+
"@embedpdf/core-annotation": "3.0.0-next.4",
|
|
107
|
+
"@embedpdf/core-geometry": "3.0.0-next.4",
|
|
108
|
+
"@embedpdf/core": "3.0.0-next.4",
|
|
109
|
+
"@embedpdf/plugin-commands": "3.0.0-next.4",
|
|
110
|
+
"@embedpdf/plugin-form": "3.0.0-next.4",
|
|
111
|
+
"@embedpdf/plugin-annotation": "3.0.0-next.4",
|
|
112
|
+
"@embedpdf/plugin-i18n": "3.0.0-next.4",
|
|
113
|
+
"@embedpdf/plugin-interaction": "3.0.0-next.4",
|
|
114
|
+
"@embedpdf/plugin-link": "3.0.0-next.4",
|
|
115
|
+
"@embedpdf/plugin-metadata": "3.0.0-next.4",
|
|
116
|
+
"@embedpdf/plugin-page-edit": "3.0.0-next.4",
|
|
117
|
+
"@embedpdf/plugin-search": "3.0.0-next.4",
|
|
118
|
+
"@embedpdf/plugin-render": "3.0.0-next.4",
|
|
119
|
+
"@embedpdf/plugin-shell": "3.0.0-next.4",
|
|
120
|
+
"@embedpdf/plugin-redaction": "3.0.0-next.4",
|
|
121
|
+
"@embedpdf/plugin-selection": "3.0.0-next.4",
|
|
122
|
+
"@embedpdf/plugin-stage": "3.0.0-next.4",
|
|
123
|
+
"@embedpdf/plugin-stamp": "3.0.0-next.4",
|
|
124
|
+
"@embedpdf/core-stage": "3.0.0-next.4",
|
|
125
|
+
"@embedpdf/plugin-view-manager": "3.0.0-next.4",
|
|
126
|
+
"@embedpdf/core-ui": "3.0.0-next.4",
|
|
127
|
+
"@embedpdf/web": "3.0.0-next.4"
|
|
128
128
|
},
|
|
129
129
|
"peerDependencies": {
|
|
130
130
|
"react": ">=18",
|