@embedpdf/plugin-selection 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +250 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +113 -14
- package/dist/index.d.ts +113 -14
- package/dist/index.js +250 -68
- package/dist/index.js.map +1 -1
- package/dist/preact/index.cjs +49 -11
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.d.cts +5 -2
- package/dist/preact/index.d.ts +5 -2
- package/dist/preact/index.js +52 -11
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +151 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +25 -0
- package/dist/react/index.d.ts +25 -0
- package/dist/react/index.js +125 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +12 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-selection.ts","../../src/preact/components/selection-layer.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","/** @jsxImportSource preact */\nimport { useCallback, useEffect, useMemo,
|
|
1
|
+
{"version":3,"sources":["../../src/preact/index.ts","../../src/preact/hooks/use-selection.ts","../../src/preact/components/selection-layer.tsx","../../src/preact/components/copy-to-clipboard.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","/** @jsxImportSource preact */\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/preact';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability } from '../hooks';\n\ntype Props = {\n pageIndex: number;\n scale: number;\n background?: string;\n};\n\nexport function SelectionLayer({ pageIndex, scale, background = 'rgba(33,150,243)' }: Props) {\n const { provides: sel } = useSelectionCapability();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const { setCursor, removeCursor } = useCursor();\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'default') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n } else {\n setRects([]);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n let geoCache: PdfPageGeometry | undefined;\n const cachedGlyphAt = useCallback((pt: { x: number; y: number }) => {\n if (!geoCache) return -1;\n return glyphAt(geoCache, pt);\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCache = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n };\n }, [sel, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlersWithLifecycle<PointerEvent> => ({\n onPointerDown: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n // clear the selection\n sel.clear();\n const task = sel.getGeometry(pageIndex);\n task.wait((geo) => {\n const g = glyphAt(geo, point);\n if (g !== -1) sel.begin(pageIndex, g);\n }, ignore);\n },\n onPointerMove: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n const g = cachedGlyphAt(point);\n if (g !== -1) {\n setCursor('selection-text', 'text', 10);\n } else {\n removeCursor('selection-text');\n }\n if (g !== -1) sel.update(pageIndex, g);\n },\n onPointerUp: (_point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n sel.end();\n },\n onHandlerActiveEnd(modeId) {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n\n sel.clear();\n },\n }),\n [sel, pageIndex, cachedGlyphAt],\n );\n\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n return (\n <>\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: b.origin.x * scale,\n top: b.origin.y * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </>\n );\n}\n","import { useEffect } from 'preact/hooks';\n\nimport { useSelectionCapability } from '../hooks';\n\nexport function CopyToClipboard() {\n const { provides: sel } = useSelectionCapability();\n\n useEffect(() => {\n if (!sel) return;\n return sel.onCopyToClipboard((text) => {\n navigator.clipboard.writeText(text);\n });\n }, [sel]);\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAAyC;AACzC,8BAAgC;AAEzB,IAAM,yBAAyB,UAAM,6BAA+B,wCAAgB,EAAE;AACtF,IAAM,qBAAqB,UAAM,yBAA2B,wCAAgB,EAAE;;;ACHrF,mBAA0D;AAC1D,oBAA4D;AAC5D,IAAAA,iBAIO;AAEP,IAAAC,2BAAwB;AAgGpB;AAtFG,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,mBAAmB,GAAU;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,EAAE,UAAU,G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AkB,CAAC,SAAS;AACrC,gBAAU,UAAU,UAAU,IAAI;AAAA,IACpC,CAAC;AAAA,EACH,GAAG,CAAC,GAAG,CAAC;AAER,SAAO;AACT;","names":["import_preact","import_plugin_selection","import_hooks"]}
|
package/dist/preact/index.d.cts
CHANGED
|
@@ -16,7 +16,10 @@ declare const useSelectionPlugin: () => {
|
|
|
16
16
|
type Props = {
|
|
17
17
|
pageIndex: number;
|
|
18
18
|
scale: number;
|
|
19
|
+
background?: string;
|
|
19
20
|
};
|
|
20
|
-
declare function SelectionLayer({ pageIndex, scale }: Props): preact.JSX.Element;
|
|
21
|
+
declare function SelectionLayer({ pageIndex, scale, background }: Props): preact.JSX.Element;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
declare function CopyToClipboard(): null;
|
|
24
|
+
|
|
25
|
+
export { CopyToClipboard, SelectionLayer, useSelectionCapability, useSelectionPlugin };
|
package/dist/preact/index.d.ts
CHANGED
|
@@ -16,7 +16,10 @@ declare const useSelectionPlugin: () => {
|
|
|
16
16
|
type Props = {
|
|
17
17
|
pageIndex: number;
|
|
18
18
|
scale: number;
|
|
19
|
+
background?: string;
|
|
19
20
|
};
|
|
20
|
-
declare function SelectionLayer({ pageIndex, scale }: Props): preact.JSX.Element;
|
|
21
|
+
declare function SelectionLayer({ pageIndex, scale, background }: Props): preact.JSX.Element;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
declare function CopyToClipboard(): null;
|
|
24
|
+
|
|
25
|
+
export { CopyToClipboard, SelectionLayer, useSelectionCapability, useSelectionPlugin };
|
package/dist/preact/index.js
CHANGED
|
@@ -6,18 +6,29 @@ var useSelectionPlugin = () => usePlugin(SelectionPlugin.id);
|
|
|
6
6
|
|
|
7
7
|
// src/preact/components/selection-layer.tsx
|
|
8
8
|
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
|
|
9
|
+
import { ignore, PdfErrorCode } from "@embedpdf/models";
|
|
10
|
+
import {
|
|
11
|
+
useCursor,
|
|
12
|
+
useInteractionManagerCapability,
|
|
13
|
+
usePointerHandlers
|
|
14
|
+
} from "@embedpdf/plugin-interaction-manager/preact";
|
|
9
15
|
import { glyphAt } from "@embedpdf/plugin-selection";
|
|
10
|
-
import { useCursor, usePointerHandlers } from "@embedpdf/plugin-interaction-manager/preact";
|
|
11
16
|
import { Fragment, jsx } from "preact/jsx-runtime";
|
|
12
|
-
function SelectionLayer({ pageIndex, scale }) {
|
|
17
|
+
function SelectionLayer({ pageIndex, scale, background = "rgba(33,150,243)" }) {
|
|
13
18
|
const { provides: sel } = useSelectionCapability();
|
|
14
|
-
const {
|
|
19
|
+
const { provides: im } = useInteractionManagerCapability();
|
|
20
|
+
const { register } = usePointerHandlers({ pageIndex });
|
|
15
21
|
const [rects, setRects] = useState([]);
|
|
16
22
|
const { setCursor, removeCursor } = useCursor();
|
|
17
23
|
useEffect(() => {
|
|
18
24
|
if (!sel) return;
|
|
19
25
|
return sel.onSelectionChange(() => {
|
|
20
|
-
|
|
26
|
+
const mode = im?.getActiveMode();
|
|
27
|
+
if (mode === "default") {
|
|
28
|
+
setRects(sel.getHighlightRectsForPage(pageIndex));
|
|
29
|
+
} else {
|
|
30
|
+
setRects([]);
|
|
31
|
+
}
|
|
21
32
|
});
|
|
22
33
|
}, [sel, pageIndex]);
|
|
23
34
|
let geoCache;
|
|
@@ -27,20 +38,30 @@ function SelectionLayer({ pageIndex, scale }) {
|
|
|
27
38
|
}, []);
|
|
28
39
|
useEffect(() => {
|
|
29
40
|
if (!sel) return;
|
|
30
|
-
sel.getGeometry(pageIndex)
|
|
41
|
+
const task = sel.getGeometry(pageIndex);
|
|
42
|
+
task.wait((g) => geoCache = g, ignore);
|
|
43
|
+
return () => {
|
|
44
|
+
task.abort({
|
|
45
|
+
code: PdfErrorCode.Cancelled,
|
|
46
|
+
message: "Cancelled"
|
|
47
|
+
});
|
|
48
|
+
};
|
|
31
49
|
}, [sel, pageIndex]);
|
|
32
50
|
const handlers = useMemo(
|
|
33
51
|
() => ({
|
|
34
|
-
onPointerDown: (point) => {
|
|
52
|
+
onPointerDown: (point, _evt, modeId) => {
|
|
35
53
|
if (!sel) return;
|
|
54
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
36
55
|
sel.clear();
|
|
37
|
-
sel.getGeometry(pageIndex)
|
|
56
|
+
const task = sel.getGeometry(pageIndex);
|
|
57
|
+
task.wait((geo) => {
|
|
38
58
|
const g = glyphAt(geo, point);
|
|
39
59
|
if (g !== -1) sel.begin(pageIndex, g);
|
|
40
|
-
});
|
|
60
|
+
}, ignore);
|
|
41
61
|
},
|
|
42
|
-
onPointerMove: (point) => {
|
|
62
|
+
onPointerMove: (point, _evt, modeId) => {
|
|
43
63
|
if (!sel) return;
|
|
64
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
44
65
|
const g = cachedGlyphAt(point);
|
|
45
66
|
if (g !== -1) {
|
|
46
67
|
setCursor("selection-text", "text", 10);
|
|
@@ -49,9 +70,15 @@ function SelectionLayer({ pageIndex, scale }) {
|
|
|
49
70
|
}
|
|
50
71
|
if (g !== -1) sel.update(pageIndex, g);
|
|
51
72
|
},
|
|
52
|
-
onPointerUp: () => {
|
|
73
|
+
onPointerUp: (_point, _evt, modeId) => {
|
|
53
74
|
if (!sel) return;
|
|
75
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
54
76
|
sel.end();
|
|
77
|
+
},
|
|
78
|
+
onHandlerActiveEnd(modeId) {
|
|
79
|
+
if (!sel) return;
|
|
80
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
81
|
+
sel.clear();
|
|
55
82
|
}
|
|
56
83
|
}),
|
|
57
84
|
[sel, pageIndex, cachedGlyphAt]
|
|
@@ -69,14 +96,28 @@ function SelectionLayer({ pageIndex, scale }) {
|
|
|
69
96
|
top: b.origin.y * scale,
|
|
70
97
|
width: b.size.width * scale,
|
|
71
98
|
height: b.size.height * scale,
|
|
72
|
-
background
|
|
99
|
+
background,
|
|
73
100
|
pointerEvents: "none"
|
|
74
101
|
}
|
|
75
102
|
},
|
|
76
103
|
i
|
|
77
104
|
)) });
|
|
78
105
|
}
|
|
106
|
+
|
|
107
|
+
// src/preact/components/copy-to-clipboard.tsx
|
|
108
|
+
import { useEffect as useEffect2 } from "preact/hooks";
|
|
109
|
+
function CopyToClipboard() {
|
|
110
|
+
const { provides: sel } = useSelectionCapability();
|
|
111
|
+
useEffect2(() => {
|
|
112
|
+
if (!sel) return;
|
|
113
|
+
return sel.onCopyToClipboard((text) => {
|
|
114
|
+
navigator.clipboard.writeText(text);
|
|
115
|
+
});
|
|
116
|
+
}, [sel]);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
79
119
|
export {
|
|
120
|
+
CopyToClipboard,
|
|
80
121
|
SelectionLayer,
|
|
81
122
|
useSelectionCapability,
|
|
82
123
|
useSelectionPlugin
|
package/dist/preact/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/preact/hooks/use-selection.ts","../../src/preact/components/selection-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","/** @jsxImportSource preact */\nimport { useCallback, useEffect, useMemo,
|
|
1
|
+
{"version":3,"sources":["../../src/preact/hooks/use-selection.ts","../../src/preact/components/selection-layer.tsx","../../src/preact/components/copy-to-clipboard.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/preact';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","/** @jsxImportSource preact */\nimport { useCallback, useEffect, useMemo, useState } from 'preact/hooks';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/preact';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability } from '../hooks';\n\ntype Props = {\n pageIndex: number;\n scale: number;\n background?: string;\n};\n\nexport function SelectionLayer({ pageIndex, scale, background = 'rgba(33,150,243)' }: Props) {\n const { provides: sel } = useSelectionCapability();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const { setCursor, removeCursor } = useCursor();\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'default') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n } else {\n setRects([]);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n let geoCache: PdfPageGeometry | undefined;\n const cachedGlyphAt = useCallback((pt: { x: number; y: number }) => {\n if (!geoCache) return -1;\n return glyphAt(geoCache, pt);\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCache = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n };\n }, [sel, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlersWithLifecycle<PointerEvent> => ({\n onPointerDown: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n // clear the selection\n sel.clear();\n const task = sel.getGeometry(pageIndex);\n task.wait((geo) => {\n const g = glyphAt(geo, point);\n if (g !== -1) sel.begin(pageIndex, g);\n }, ignore);\n },\n onPointerMove: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n const g = cachedGlyphAt(point);\n if (g !== -1) {\n setCursor('selection-text', 'text', 10);\n } else {\n removeCursor('selection-text');\n }\n if (g !== -1) sel.update(pageIndex, g);\n },\n onPointerUp: (_point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n sel.end();\n },\n onHandlerActiveEnd(modeId) {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n\n sel.clear();\n },\n }),\n [sel, pageIndex, cachedGlyphAt],\n );\n\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n return (\n <>\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: b.origin.x * scale,\n top: b.origin.y * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </>\n );\n}\n","import { useEffect } from 'preact/hooks';\n\nimport { useSelectionCapability } from '../hooks';\n\nexport function CopyToClipboard() {\n const { provides: sel } = useSelectionCapability();\n\n useEffect(() => {\n if (!sel) return;\n return sel.onCopyToClipboard((text) => {\n navigator.clipboard.writeText(text);\n });\n }, [sel]);\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,uBAAuB;AAEzB,IAAM,yBAAyB,MAAM,cAA+B,gBAAgB,EAAE;AACtF,IAAM,qBAAqB,MAAM,UAA2B,gBAAgB,EAAE;;;ACHrF,SAAS,aAAa,WAAW,SAAS,gBAAgB;AAC1D,SAAS,QAAQ,oBAA2C;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,eAAe;AAgGpB,mBAEI,WAFJ;AAtFG,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,mBAAmB,GAAU;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,EAAE,UAAU,GAAG,IAAI,gCAAgC;AACzD,QAAM,EAAE,SAAS,IAAI,mBAAmB,EA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AAC;AAAA,EACH,GAAG,CAAC,GAAG,CAAC;AAER,SAAO;AACT;","names":["useEffect","useEffect"]}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/react/index.ts
|
|
21
|
+
var react_exports = {};
|
|
22
|
+
__export(react_exports, {
|
|
23
|
+
CopyToClipboard: () => CopyToClipboard,
|
|
24
|
+
SelectionLayer: () => SelectionLayer,
|
|
25
|
+
useSelectionCapability: () => useSelectionCapability,
|
|
26
|
+
useSelectionPlugin: () => useSelectionPlugin
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(react_exports);
|
|
29
|
+
|
|
30
|
+
// src/react/hooks/use-selection.ts
|
|
31
|
+
var import_react = require("@embedpdf/core/react");
|
|
32
|
+
var import_plugin_selection = require("@embedpdf/plugin-selection");
|
|
33
|
+
var useSelectionCapability = () => (0, import_react.useCapability)(import_plugin_selection.SelectionPlugin.id);
|
|
34
|
+
var useSelectionPlugin = () => (0, import_react.usePlugin)(import_plugin_selection.SelectionPlugin.id);
|
|
35
|
+
|
|
36
|
+
// src/react/components/selection-layer.tsx
|
|
37
|
+
var import_react2 = require("react");
|
|
38
|
+
var import_models = require("@embedpdf/models");
|
|
39
|
+
var import_react3 = require("@embedpdf/plugin-interaction-manager/react");
|
|
40
|
+
var import_plugin_selection2 = require("@embedpdf/plugin-selection");
|
|
41
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
42
|
+
function SelectionLayer({ pageIndex, scale, background = "rgba(33,150,243)" }) {
|
|
43
|
+
const { provides: sel } = useSelectionCapability();
|
|
44
|
+
const { provides: im } = (0, import_react3.useInteractionManagerCapability)();
|
|
45
|
+
const { register } = (0, import_react3.usePointerHandlers)({ pageIndex });
|
|
46
|
+
const [rects, setRects] = (0, import_react2.useState)([]);
|
|
47
|
+
const { setCursor, removeCursor } = (0, import_react3.useCursor)();
|
|
48
|
+
(0, import_react2.useEffect)(() => {
|
|
49
|
+
if (!sel) return;
|
|
50
|
+
return sel.onSelectionChange(() => {
|
|
51
|
+
const mode = im?.getActiveMode();
|
|
52
|
+
if (mode === "default") {
|
|
53
|
+
setRects(sel.getHighlightRectsForPage(pageIndex));
|
|
54
|
+
} else {
|
|
55
|
+
setRects([]);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}, [sel, pageIndex]);
|
|
59
|
+
let geoCache;
|
|
60
|
+
const cachedGlyphAt = (0, import_react2.useCallback)((pt) => {
|
|
61
|
+
if (!geoCache) return -1;
|
|
62
|
+
return (0, import_plugin_selection2.glyphAt)(geoCache, pt);
|
|
63
|
+
}, []);
|
|
64
|
+
(0, import_react2.useEffect)(() => {
|
|
65
|
+
if (!sel) return;
|
|
66
|
+
const task = sel.getGeometry(pageIndex);
|
|
67
|
+
task.wait((g) => geoCache = g, import_models.ignore);
|
|
68
|
+
return () => {
|
|
69
|
+
task.abort({
|
|
70
|
+
code: import_models.PdfErrorCode.Cancelled,
|
|
71
|
+
message: "Cancelled"
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
}, [sel, pageIndex]);
|
|
75
|
+
const handlers = (0, import_react2.useMemo)(
|
|
76
|
+
() => ({
|
|
77
|
+
onPointerDown: (point, _evt, modeId) => {
|
|
78
|
+
if (!sel) return;
|
|
79
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
80
|
+
sel.clear();
|
|
81
|
+
const task = sel.getGeometry(pageIndex);
|
|
82
|
+
task.wait((geo) => {
|
|
83
|
+
const g = (0, import_plugin_selection2.glyphAt)(geo, point);
|
|
84
|
+
if (g !== -1) sel.begin(pageIndex, g);
|
|
85
|
+
}, import_models.ignore);
|
|
86
|
+
},
|
|
87
|
+
onPointerMove: (point, _evt, modeId) => {
|
|
88
|
+
if (!sel) return;
|
|
89
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
90
|
+
const g = cachedGlyphAt(point);
|
|
91
|
+
if (g !== -1) {
|
|
92
|
+
setCursor("selection-text", "text", 10);
|
|
93
|
+
} else {
|
|
94
|
+
removeCursor("selection-text");
|
|
95
|
+
}
|
|
96
|
+
if (g !== -1) sel.update(pageIndex, g);
|
|
97
|
+
},
|
|
98
|
+
onPointerUp: (_point, _evt, modeId) => {
|
|
99
|
+
if (!sel) return;
|
|
100
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
101
|
+
sel.end();
|
|
102
|
+
},
|
|
103
|
+
onHandlerActiveEnd(modeId) {
|
|
104
|
+
if (!sel) return;
|
|
105
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
106
|
+
sel.clear();
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
[sel, pageIndex, cachedGlyphAt]
|
|
110
|
+
);
|
|
111
|
+
(0, import_react2.useEffect)(() => {
|
|
112
|
+
if (!register) return;
|
|
113
|
+
return register(handlers);
|
|
114
|
+
}, [register, handlers]);
|
|
115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: rects.map((b, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
style: {
|
|
119
|
+
position: "absolute",
|
|
120
|
+
left: b.origin.x * scale,
|
|
121
|
+
top: b.origin.y * scale,
|
|
122
|
+
width: b.size.width * scale,
|
|
123
|
+
height: b.size.height * scale,
|
|
124
|
+
background,
|
|
125
|
+
pointerEvents: "none"
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
i
|
|
129
|
+
)) });
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// src/react/components/copy-to-clipboard.tsx
|
|
133
|
+
var import_react4 = require("react");
|
|
134
|
+
function CopyToClipboard() {
|
|
135
|
+
const { provides: sel } = useSelectionCapability();
|
|
136
|
+
(0, import_react4.useEffect)(() => {
|
|
137
|
+
if (!sel) return;
|
|
138
|
+
return sel.onCopyToClipboard((text) => {
|
|
139
|
+
navigator.clipboard.writeText(text);
|
|
140
|
+
});
|
|
141
|
+
}, [sel]);
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
145
|
+
0 && (module.exports = {
|
|
146
|
+
CopyToClipboard,
|
|
147
|
+
SelectionLayer,
|
|
148
|
+
useSelectionCapability,
|
|
149
|
+
useSelectionPlugin
|
|
150
|
+
});
|
|
151
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/index.ts","../../src/react/hooks/use-selection.ts","../../src/react/components/selection-layer.tsx","../../src/react/components/copy-to-clipboard.tsx"],"sourcesContent":["export * from './hooks';\nexport * from './components';\n","import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/react';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability } from '../hooks';\n\ntype Props = {\n pageIndex: number;\n scale: number;\n background?: string;\n};\n\nexport function SelectionLayer({ pageIndex, scale, background = 'rgba(33,150,243)' }: Props) {\n const { provides: sel } = useSelectionCapability();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const { setCursor, removeCursor } = useCursor();\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'default') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n } else {\n setRects([]);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n let geoCache: PdfPageGeometry | undefined;\n const cachedGlyphAt = useCallback((pt: { x: number; y: number }) => {\n if (!geoCache) return -1;\n return glyphAt(geoCache, pt);\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCache = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n };\n }, [sel, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlersWithLifecycle<PointerEvent> => ({\n onPointerDown: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n // clear the selection\n sel.clear();\n const task = sel.getGeometry(pageIndex);\n task.wait((geo) => {\n const g = glyphAt(geo, point);\n if (g !== -1) sel.begin(pageIndex, g);\n }, ignore);\n },\n onPointerMove: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n const g = cachedGlyphAt(point);\n if (g !== -1) {\n setCursor('selection-text', 'text', 10);\n } else {\n removeCursor('selection-text');\n }\n if (g !== -1) sel.update(pageIndex, g);\n },\n onPointerUp: (_point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n sel.end();\n },\n onHandlerActiveEnd(modeId) {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n\n sel.clear();\n },\n }),\n [sel, pageIndex, cachedGlyphAt],\n );\n\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n return (\n <>\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: b.origin.x * scale,\n top: b.origin.y * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </>\n );\n}\n","import { useEffect } from 'react';\n\nimport { useSelectionCapability } from '../hooks';\n\nexport function CopyToClipboard() {\n const { provides: sel } = useSelectionCapability();\n\n useEffect(() => {\n if (!sel) return;\n return sel.onCopyToClipboard((text) => {\n navigator.clipboard.writeText(text);\n });\n }, [sel]);\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAyC;AACzC,8BAAgC;AAEzB,IAAM,yBAAyB,UAAM,4BAA+B,wCAAgB,EAAE;AACtF,IAAM,qBAAqB,UAAM,wBAA2B,wCAAgB,EAAE;;;ACJrF,IAAAA,gBAA0D;AAC1D,oBAA4D;AAC5D,IAAAA,gBAIO;AAEP,IAAAC,2BAAwB;AAgGpB;AAtFG,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,mBAAmB,GAAU;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,EAAE,UAAU,GAAG,QAAI,+CAAgC;AACzD,QAAM,EAAE,SAA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,IAAI;AAAA,IACpC,CAAC;AAAA,EACH,GAAG,CAAC,GAAG,CAAC;AAER,SAAO;AACT;","names":["import_react","import_plugin_selection","import_react"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_selection from '@embedpdf/plugin-selection';
|
|
2
|
+
import { SelectionPlugin } from '@embedpdf/plugin-selection';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const useSelectionCapability: () => {
|
|
6
|
+
provides: Readonly<_embedpdf_plugin_selection.SelectionCapability> | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useSelectionPlugin: () => {
|
|
11
|
+
plugin: SelectionPlugin | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
pageIndex: number;
|
|
18
|
+
scale: number;
|
|
19
|
+
background?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function SelectionLayer({ pageIndex, scale, background }: Props): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare function CopyToClipboard(): null;
|
|
24
|
+
|
|
25
|
+
export { CopyToClipboard, SelectionLayer, useSelectionCapability, useSelectionPlugin };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as _embedpdf_plugin_selection from '@embedpdf/plugin-selection';
|
|
2
|
+
import { SelectionPlugin } from '@embedpdf/plugin-selection';
|
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
declare const useSelectionCapability: () => {
|
|
6
|
+
provides: Readonly<_embedpdf_plugin_selection.SelectionCapability> | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
ready: Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
declare const useSelectionPlugin: () => {
|
|
11
|
+
plugin: SelectionPlugin | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
ready: Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type Props = {
|
|
17
|
+
pageIndex: number;
|
|
18
|
+
scale: number;
|
|
19
|
+
background?: string;
|
|
20
|
+
};
|
|
21
|
+
declare function SelectionLayer({ pageIndex, scale, background }: Props): react_jsx_runtime.JSX.Element;
|
|
22
|
+
|
|
23
|
+
declare function CopyToClipboard(): null;
|
|
24
|
+
|
|
25
|
+
export { CopyToClipboard, SelectionLayer, useSelectionCapability, useSelectionPlugin };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// src/react/hooks/use-selection.ts
|
|
2
|
+
import { useCapability, usePlugin } from "@embedpdf/core/react";
|
|
3
|
+
import { SelectionPlugin } from "@embedpdf/plugin-selection";
|
|
4
|
+
var useSelectionCapability = () => useCapability(SelectionPlugin.id);
|
|
5
|
+
var useSelectionPlugin = () => usePlugin(SelectionPlugin.id);
|
|
6
|
+
|
|
7
|
+
// src/react/components/selection-layer.tsx
|
|
8
|
+
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
9
|
+
import { ignore, PdfErrorCode } from "@embedpdf/models";
|
|
10
|
+
import {
|
|
11
|
+
useCursor,
|
|
12
|
+
useInteractionManagerCapability,
|
|
13
|
+
usePointerHandlers
|
|
14
|
+
} from "@embedpdf/plugin-interaction-manager/react";
|
|
15
|
+
import { glyphAt } from "@embedpdf/plugin-selection";
|
|
16
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
17
|
+
function SelectionLayer({ pageIndex, scale, background = "rgba(33,150,243)" }) {
|
|
18
|
+
const { provides: sel } = useSelectionCapability();
|
|
19
|
+
const { provides: im } = useInteractionManagerCapability();
|
|
20
|
+
const { register } = usePointerHandlers({ pageIndex });
|
|
21
|
+
const [rects, setRects] = useState([]);
|
|
22
|
+
const { setCursor, removeCursor } = useCursor();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!sel) return;
|
|
25
|
+
return sel.onSelectionChange(() => {
|
|
26
|
+
const mode = im?.getActiveMode();
|
|
27
|
+
if (mode === "default") {
|
|
28
|
+
setRects(sel.getHighlightRectsForPage(pageIndex));
|
|
29
|
+
} else {
|
|
30
|
+
setRects([]);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}, [sel, pageIndex]);
|
|
34
|
+
let geoCache;
|
|
35
|
+
const cachedGlyphAt = useCallback((pt) => {
|
|
36
|
+
if (!geoCache) return -1;
|
|
37
|
+
return glyphAt(geoCache, pt);
|
|
38
|
+
}, []);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!sel) return;
|
|
41
|
+
const task = sel.getGeometry(pageIndex);
|
|
42
|
+
task.wait((g) => geoCache = g, ignore);
|
|
43
|
+
return () => {
|
|
44
|
+
task.abort({
|
|
45
|
+
code: PdfErrorCode.Cancelled,
|
|
46
|
+
message: "Cancelled"
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
}, [sel, pageIndex]);
|
|
50
|
+
const handlers = useMemo(
|
|
51
|
+
() => ({
|
|
52
|
+
onPointerDown: (point, _evt, modeId) => {
|
|
53
|
+
if (!sel) return;
|
|
54
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
55
|
+
sel.clear();
|
|
56
|
+
const task = sel.getGeometry(pageIndex);
|
|
57
|
+
task.wait((geo) => {
|
|
58
|
+
const g = glyphAt(geo, point);
|
|
59
|
+
if (g !== -1) sel.begin(pageIndex, g);
|
|
60
|
+
}, ignore);
|
|
61
|
+
},
|
|
62
|
+
onPointerMove: (point, _evt, modeId) => {
|
|
63
|
+
if (!sel) return;
|
|
64
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
65
|
+
const g = cachedGlyphAt(point);
|
|
66
|
+
if (g !== -1) {
|
|
67
|
+
setCursor("selection-text", "text", 10);
|
|
68
|
+
} else {
|
|
69
|
+
removeCursor("selection-text");
|
|
70
|
+
}
|
|
71
|
+
if (g !== -1) sel.update(pageIndex, g);
|
|
72
|
+
},
|
|
73
|
+
onPointerUp: (_point, _evt, modeId) => {
|
|
74
|
+
if (!sel) return;
|
|
75
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
76
|
+
sel.end();
|
|
77
|
+
},
|
|
78
|
+
onHandlerActiveEnd(modeId) {
|
|
79
|
+
if (!sel) return;
|
|
80
|
+
if (!sel.isEnabledForMode(modeId)) return;
|
|
81
|
+
sel.clear();
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
[sel, pageIndex, cachedGlyphAt]
|
|
85
|
+
);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!register) return;
|
|
88
|
+
return register(handlers);
|
|
89
|
+
}, [register, handlers]);
|
|
90
|
+
return /* @__PURE__ */ jsx(Fragment, { children: rects.map((b, i) => /* @__PURE__ */ jsx(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
style: {
|
|
94
|
+
position: "absolute",
|
|
95
|
+
left: b.origin.x * scale,
|
|
96
|
+
top: b.origin.y * scale,
|
|
97
|
+
width: b.size.width * scale,
|
|
98
|
+
height: b.size.height * scale,
|
|
99
|
+
background,
|
|
100
|
+
pointerEvents: "none"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
i
|
|
104
|
+
)) });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/react/components/copy-to-clipboard.tsx
|
|
108
|
+
import { useEffect as useEffect2 } from "react";
|
|
109
|
+
function CopyToClipboard() {
|
|
110
|
+
const { provides: sel } = useSelectionCapability();
|
|
111
|
+
useEffect2(() => {
|
|
112
|
+
if (!sel) return;
|
|
113
|
+
return sel.onCopyToClipboard((text) => {
|
|
114
|
+
navigator.clipboard.writeText(text);
|
|
115
|
+
});
|
|
116
|
+
}, [sel]);
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
CopyToClipboard,
|
|
121
|
+
SelectionLayer,
|
|
122
|
+
useSelectionCapability,
|
|
123
|
+
useSelectionPlugin
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/react/hooks/use-selection.ts","../../src/react/components/selection-layer.tsx","../../src/react/components/copy-to-clipboard.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/react';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/react';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability } from '../hooks';\n\ntype Props = {\n pageIndex: number;\n scale: number;\n background?: string;\n};\n\nexport function SelectionLayer({ pageIndex, scale, background = 'rgba(33,150,243)' }: Props) {\n const { provides: sel } = useSelectionCapability();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const { setCursor, removeCursor } = useCursor();\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'default') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n } else {\n setRects([]);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n let geoCache: PdfPageGeometry | undefined;\n const cachedGlyphAt = useCallback((pt: { x: number; y: number }) => {\n if (!geoCache) return -1;\n return glyphAt(geoCache, pt);\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCache = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n };\n }, [sel, pageIndex]);\n\n const handlers = useMemo(\n (): PointerEventHandlersWithLifecycle<PointerEvent> => ({\n onPointerDown: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n // clear the selection\n sel.clear();\n const task = sel.getGeometry(pageIndex);\n task.wait((geo) => {\n const g = glyphAt(geo, point);\n if (g !== -1) sel.begin(pageIndex, g);\n }, ignore);\n },\n onPointerMove: (point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n const g = cachedGlyphAt(point);\n if (g !== -1) {\n setCursor('selection-text', 'text', 10);\n } else {\n removeCursor('selection-text');\n }\n if (g !== -1) sel.update(pageIndex, g);\n },\n onPointerUp: (_point, _evt, modeId) => {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n sel.end();\n },\n onHandlerActiveEnd(modeId) {\n if (!sel) return;\n if (!sel.isEnabledForMode(modeId)) return;\n\n sel.clear();\n },\n }),\n [sel, pageIndex, cachedGlyphAt],\n );\n\n useEffect(() => {\n if (!register) return;\n return register(handlers);\n }, [register, handlers]);\n\n return (\n <>\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: b.origin.x * scale,\n top: b.origin.y * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </>\n );\n}\n","import { useEffect } from 'react';\n\nimport { useSelectionCapability } from '../hooks';\n\nexport function CopyToClipboard() {\n const { provides: sel } = useSelectionCapability();\n\n useEffect(() => {\n if (!sel) return;\n return sel.onCopyToClipboard((text) => {\n navigator.clipboard.writeText(text);\n });\n }, [sel]);\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,eAAe,iBAAiB;AACzC,SAAS,uBAAuB;AAEzB,IAAM,yBAAyB,MAAM,cAA+B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B,KAAK,EAAE,OAAO,IAAI;AAAA,QAClB,OAAO,EAAE,KAAK,QAAQ;AAAA,QACtB,QAAQ,EAAE,KAAK,SAAS;AAAA,QACxB;AAAA,QACA,eAAe;AAAA,MACjB;AAAA;AAAA,IATK;AAAA,EAUP,CACD,GACH;AAEJ;;;ACzHA,SAAS,aAAAA,kBAAiB;AAInB,SAAS,kBAAkB;AAChC,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AAEjD,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,IAAK;AACV,WAAO,IAAI,kBAAkB,CAAC,SAAS;AACrC,gBAAU,UAAU,UAAU,IAAI;AAAA,IACpC,CAAC;AAAA,EACH,GAAG,CAAC,GAAG,CAAC;AAER,SAAO;AACT;","names":["useEffect","useEffect"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embedpdf/plugin-selection",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -15,25 +15,30 @@
|
|
|
15
15
|
"types": "./dist/preact/index.d.ts",
|
|
16
16
|
"import": "./dist/preact/index.js",
|
|
17
17
|
"require": "./dist/preact/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./react": {
|
|
20
|
+
"types": "./dist/react/index.d.ts",
|
|
21
|
+
"import": "./dist/react/index.js",
|
|
22
|
+
"require": "./dist/react/index.cjs"
|
|
18
23
|
}
|
|
19
24
|
},
|
|
20
25
|
"dependencies": {
|
|
21
|
-
"@embedpdf/models": "1.0.
|
|
26
|
+
"@embedpdf/models": "1.0.7"
|
|
22
27
|
},
|
|
23
28
|
"devDependencies": {
|
|
24
29
|
"@types/react": "^18.2.0",
|
|
25
30
|
"tsup": "^8.0.0",
|
|
26
31
|
"typescript": "^5.0.0",
|
|
27
|
-
"@embedpdf/plugin-viewport": "1.0.
|
|
28
|
-
"@embedpdf/plugin-interaction-manager": "1.0.
|
|
32
|
+
"@embedpdf/plugin-viewport": "1.0.7",
|
|
33
|
+
"@embedpdf/plugin-interaction-manager": "1.0.7"
|
|
29
34
|
},
|
|
30
35
|
"peerDependencies": {
|
|
31
36
|
"react": ">=16.8.0",
|
|
32
37
|
"react-dom": ">=16.8.0",
|
|
33
38
|
"preact": "^10.26.4",
|
|
34
|
-
"@embedpdf/
|
|
35
|
-
"@embedpdf/
|
|
36
|
-
"@embedpdf/plugin-
|
|
39
|
+
"@embedpdf/core": "1.0.7",
|
|
40
|
+
"@embedpdf/plugin-interaction-manager": "1.0.7",
|
|
41
|
+
"@embedpdf/plugin-viewport": "1.0.7"
|
|
37
42
|
},
|
|
38
43
|
"files": [
|
|
39
44
|
"dist",
|