@embedpdf/plugin-selection 2.14.4 → 3.0.0-next.0

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.
Files changed (90) hide show
  1. package/LICENSE +192 -21
  2. package/dist/index.cjs +575 -2
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +167 -0
  5. package/dist/index.d.ts +167 -1
  6. package/dist/index.js +549 -1375
  7. package/dist/index.js.map +1 -1
  8. package/package.json +21 -62
  9. package/dist/lib/actions.d.ts +0 -103
  10. package/dist/lib/handlers/index.d.ts +0 -2
  11. package/dist/lib/handlers/marquee-selection.handler.d.ts +0 -30
  12. package/dist/lib/handlers/text-selection.handler.d.ts +0 -52
  13. package/dist/lib/index.d.ts +0 -9
  14. package/dist/lib/manifest.d.ts +0 -4
  15. package/dist/lib/reducer.d.ts +0 -5
  16. package/dist/lib/selection-plugin.d.ts +0 -92
  17. package/dist/lib/selectors.d.ts +0 -14
  18. package/dist/lib/types.d.ts +0 -266
  19. package/dist/lib/utils.d.ts +0 -108
  20. package/dist/preact/adapter.d.ts +0 -4
  21. package/dist/preact/core.d.ts +0 -1
  22. package/dist/preact/index.cjs +0 -2
  23. package/dist/preact/index.cjs.map +0 -1
  24. package/dist/preact/index.d.ts +0 -1
  25. package/dist/preact/index.js +0 -218
  26. package/dist/preact/index.js.map +0 -1
  27. package/dist/preact/interaction-manager.d.ts +0 -1
  28. package/dist/preact/utils.d.ts +0 -1
  29. package/dist/react/adapter.d.ts +0 -2
  30. package/dist/react/core.d.ts +0 -1
  31. package/dist/react/index.cjs +0 -2
  32. package/dist/react/index.cjs.map +0 -1
  33. package/dist/react/index.d.ts +0 -1
  34. package/dist/react/index.js +0 -217
  35. package/dist/react/index.js.map +0 -1
  36. package/dist/react/interaction-manager.d.ts +0 -1
  37. package/dist/react/utils.d.ts +0 -1
  38. package/dist/shared/components/copy-to-clipboard.d.ts +0 -1
  39. package/dist/shared/components/index.d.ts +0 -4
  40. package/dist/shared/components/marquee-selection.d.ts +0 -36
  41. package/dist/shared/components/selection-layer.d.ts +0 -29
  42. package/dist/shared/components/text-selection.d.ts +0 -21
  43. package/dist/shared/hooks/index.d.ts +0 -1
  44. package/dist/shared/hooks/use-selection.d.ts +0 -11
  45. package/dist/shared/index.d.ts +0 -5
  46. package/dist/shared/types.d.ts +0 -7
  47. package/dist/shared-preact/components/copy-to-clipboard.d.ts +0 -1
  48. package/dist/shared-preact/components/index.d.ts +0 -4
  49. package/dist/shared-preact/components/marquee-selection.d.ts +0 -36
  50. package/dist/shared-preact/components/selection-layer.d.ts +0 -29
  51. package/dist/shared-preact/components/text-selection.d.ts +0 -21
  52. package/dist/shared-preact/hooks/index.d.ts +0 -1
  53. package/dist/shared-preact/hooks/use-selection.d.ts +0 -11
  54. package/dist/shared-preact/index.d.ts +0 -5
  55. package/dist/shared-preact/types.d.ts +0 -7
  56. package/dist/shared-react/components/copy-to-clipboard.d.ts +0 -1
  57. package/dist/shared-react/components/index.d.ts +0 -4
  58. package/dist/shared-react/components/marquee-selection.d.ts +0 -36
  59. package/dist/shared-react/components/selection-layer.d.ts +0 -29
  60. package/dist/shared-react/components/text-selection.d.ts +0 -21
  61. package/dist/shared-react/hooks/index.d.ts +0 -1
  62. package/dist/shared-react/hooks/use-selection.d.ts +0 -11
  63. package/dist/shared-react/index.d.ts +0 -5
  64. package/dist/shared-react/types.d.ts +0 -7
  65. package/dist/svelte/components/CopyToClipboard.svelte.d.ts +0 -3
  66. package/dist/svelte/components/MarqueeSelection.svelte.d.ts +0 -27
  67. package/dist/svelte/components/SelectionLayer.svelte.d.ts +0 -32
  68. package/dist/svelte/components/TextSelection.svelte.d.ts +0 -22
  69. package/dist/svelte/components/index.d.ts +0 -4
  70. package/dist/svelte/hooks/index.d.ts +0 -1
  71. package/dist/svelte/hooks/use-selection.svelte.d.ts +0 -19
  72. package/dist/svelte/index.cjs +0 -2
  73. package/dist/svelte/index.cjs.map +0 -1
  74. package/dist/svelte/index.d.ts +0 -5
  75. package/dist/svelte/index.js +0 -359
  76. package/dist/svelte/index.js.map +0 -1
  77. package/dist/svelte/types.d.ts +0 -7
  78. package/dist/vue/components/copy-to-clipboard.vue.d.ts +0 -3
  79. package/dist/vue/components/index.d.ts +0 -4
  80. package/dist/vue/components/marquee-selection.vue.d.ts +0 -29
  81. package/dist/vue/components/selection-layer.vue.d.ts +0 -60
  82. package/dist/vue/components/text-selection.vue.d.ts +0 -51
  83. package/dist/vue/hooks/index.d.ts +0 -1
  84. package/dist/vue/hooks/use-selection.d.ts +0 -11
  85. package/dist/vue/index.cjs +0 -2
  86. package/dist/vue/index.cjs.map +0 -1
  87. package/dist/vue/index.d.ts +0 -5
  88. package/dist/vue/index.js +0 -311
  89. package/dist/vue/index.js.map +0 -1
  90. package/dist/vue/types.d.ts +0 -7
@@ -1,359 +0,0 @@
1
- import { createPluginPackage } from "@embedpdf/core";
2
- import { SelectionPlugin, SelectionPluginPackage as SelectionPluginPackage$1 } from "@embedpdf/plugin-selection";
3
- export * from "@embedpdf/plugin-selection";
4
- import "svelte/internal/disclose-version";
5
- import * as $ from "svelte/internal/client";
6
- import "@embedpdf/models";
7
- import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/svelte";
8
- import { CounterRotate } from "@embedpdf/utils/svelte";
9
- const useSelectionCapability = () => useCapability(SelectionPlugin.id);
10
- const useSelectionPlugin = () => usePlugin(SelectionPlugin.id);
11
- var root_2 = $.from_html(`<div></div>`);
12
- var root_1$1 = $.from_html(`<div></div> <!>`, 1);
13
- function TextSelection($$anchor, $$props) {
14
- $.push($$props, true);
15
- let background = $.prop($$props, "background", 3, "rgba(33,150,243)");
16
- const selectionPlugin = useSelectionPlugin();
17
- const documentState = useDocumentState(() => $$props.documentId);
18
- const page = $.derived(() => {
19
- var _a, _b, _c;
20
- return (_c = (_b = (_a = documentState.current) == null ? void 0 : _a.document) == null ? void 0 : _b.pages) == null ? void 0 : _c[$$props.pageIndex];
21
- });
22
- let rects = $.state($.proxy([]));
23
- let boundingRect = $.state(null);
24
- let placement = $.state(null);
25
- const actualScale = $.derived(() => {
26
- var _a;
27
- return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
28
- });
29
- const actualRotation = $.derived(() => {
30
- var _a, _b;
31
- if ($$props.rotation !== void 0) return $$props.rotation;
32
- const pageRotation = ((_a = $.get(page)) == null ? void 0 : _a.rotation) ?? 0;
33
- const docRotation = ((_b = documentState.current) == null ? void 0 : _b.rotation) ?? 0;
34
- return (pageRotation + docRotation) % 4;
35
- });
36
- const shouldRenderMenu = $.derived(() => Boolean($.get(placement) && $.get(placement).pageIndex === $$props.pageIndex && $.get(placement).isVisible && ($$props.selectionMenu || $$props.selectionMenuSnippet)));
37
- $.user_effect(() => {
38
- if (!selectionPlugin.plugin || !$$props.documentId) {
39
- $.set(rects, [], true);
40
- $.set(boundingRect, null);
41
- return;
42
- }
43
- return selectionPlugin.plugin.registerSelectionOnPage({
44
- documentId: $$props.documentId,
45
- pageIndex: $$props.pageIndex,
46
- onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {
47
- $.set(rects, newRects, true);
48
- $.set(boundingRect, newBoundingRect, true);
49
- }
50
- });
51
- });
52
- $.user_effect(() => {
53
- if (!selectionPlugin.plugin || !$$props.documentId) {
54
- $.set(placement, null);
55
- return;
56
- }
57
- return selectionPlugin.plugin.onMenuPlacement($$props.documentId, (newPlacement) => {
58
- $.set(placement, newPlacement, true);
59
- });
60
- });
61
- function buildContext() {
62
- return { type: "selection", pageIndex: $$props.pageIndex };
63
- }
64
- function buildMenuPlacement() {
65
- var _a, _b, _c;
66
- return {
67
- suggestTop: ((_a = $.get(placement)) == null ? void 0 : _a.suggestTop) ?? false,
68
- spaceAbove: ((_b = $.get(placement)) == null ? void 0 : _b.spaceAbove) ?? 0,
69
- spaceBelow: ((_c = $.get(placement)) == null ? void 0 : _c.spaceBelow) ?? 0
70
- };
71
- }
72
- function buildMenuProps(rect, menuWrapperProps) {
73
- return {
74
- context: buildContext(),
75
- selected: true,
76
- // Selection is always "selected" when visible
77
- rect,
78
- placement: buildMenuPlacement(),
79
- menuWrapperProps
80
- };
81
- }
82
- var fragment = $.comment();
83
- var node = $.first_child(fragment);
84
- {
85
- var consequent_4 = ($$anchor2) => {
86
- var fragment_1 = root_1$1();
87
- var div = $.first_child(fragment_1);
88
- let styles;
89
- $.each(div, 21, () => $.get(rects), $.index, ($$anchor3, rect) => {
90
- var div_1 = root_2();
91
- let styles_1;
92
- $.template_effect(() => styles_1 = $.set_style(div_1, "", styles_1, {
93
- position: "absolute",
94
- left: `${($.get(rect).origin.x - $.get(boundingRect).origin.x) * $.get(actualScale)}px`,
95
- top: `${($.get(rect).origin.y - $.get(boundingRect).origin.y) * $.get(actualScale)}px`,
96
- width: `${$.get(rect).size.width * $.get(actualScale)}px`,
97
- height: `${$.get(rect).size.height * $.get(actualScale)}px`,
98
- background: background(),
99
- "pointer-events": "none"
100
- }));
101
- $.append($$anchor3, div_1);
102
- });
103
- $.reset(div);
104
- var node_1 = $.sibling(div, 2);
105
- {
106
- var consequent_3 = ($$anchor3) => {
107
- {
108
- const children = ($$anchor4, $$arg0) => {
109
- let rect = () => $$arg0 == null ? void 0 : $$arg0().rect;
110
- let menuWrapperProps = () => $$arg0 == null ? void 0 : $$arg0().menuWrapperProps;
111
- const menuProps = $.derived(() => buildMenuProps(rect(), menuWrapperProps()));
112
- var fragment_3 = $.comment();
113
- var node_2 = $.first_child(fragment_3);
114
- {
115
- var consequent_1 = ($$anchor5) => {
116
- const result = $.derived(() => $$props.selectionMenu($.get(menuProps)));
117
- var fragment_4 = $.comment();
118
- var node_3 = $.first_child(fragment_4);
119
- {
120
- var consequent = ($$anchor6) => {
121
- var fragment_5 = $.comment();
122
- var node_4 = $.first_child(fragment_5);
123
- $.component(node_4, () => $.get(result).component, ($$anchor7, result_component) => {
124
- result_component($$anchor7, $.spread_props(() => $.get(result).props));
125
- });
126
- $.append($$anchor6, fragment_5);
127
- };
128
- $.if(node_3, ($$render) => {
129
- if ($.get(result)) $$render(consequent);
130
- });
131
- }
132
- $.append($$anchor5, fragment_4);
133
- };
134
- var alternate = ($$anchor5) => {
135
- var fragment_6 = $.comment();
136
- var node_5 = $.first_child(fragment_6);
137
- {
138
- var consequent_2 = ($$anchor6) => {
139
- var fragment_7 = $.comment();
140
- var node_6 = $.first_child(fragment_7);
141
- $.snippet(node_6, () => $$props.selectionMenuSnippet, () => $.get(menuProps));
142
- $.append($$anchor6, fragment_7);
143
- };
144
- $.if(
145
- node_5,
146
- ($$render) => {
147
- if ($$props.selectionMenuSnippet) $$render(consequent_2);
148
- },
149
- true
150
- );
151
- }
152
- $.append($$anchor5, fragment_6);
153
- };
154
- $.if(node_2, ($$render) => {
155
- if ($$props.selectionMenu) $$render(consequent_1);
156
- else $$render(alternate, false);
157
- });
158
- }
159
- $.append($$anchor4, fragment_3);
160
- };
161
- let $0 = $.derived(() => ({
162
- origin: {
163
- x: $.get(placement).rect.origin.x * $.get(actualScale),
164
- y: $.get(placement).rect.origin.y * $.get(actualScale)
165
- },
166
- size: {
167
- width: $.get(placement).rect.size.width * $.get(actualScale),
168
- height: $.get(placement).rect.size.height * $.get(actualScale)
169
- }
170
- }));
171
- CounterRotate($$anchor3, {
172
- get rect() {
173
- return $.get($0);
174
- },
175
- get rotation() {
176
- return $.get(actualRotation);
177
- },
178
- children,
179
- $$slots: { default: true }
180
- });
181
- }
182
- };
183
- $.if(node_1, ($$render) => {
184
- if ($.get(shouldRenderMenu) && $.get(placement)) $$render(consequent_3);
185
- });
186
- }
187
- $.template_effect(() => styles = $.set_style(div, "", styles, {
188
- position: "absolute",
189
- left: `${$.get(boundingRect).origin.x * $.get(actualScale)}px`,
190
- top: `${$.get(boundingRect).origin.y * $.get(actualScale)}px`,
191
- width: `${$.get(boundingRect).size.width * $.get(actualScale)}px`,
192
- height: `${$.get(boundingRect).size.height * $.get(actualScale)}px`,
193
- "mix-blend-mode": "multiply",
194
- isolation: "isolate",
195
- "pointer-events": "none"
196
- }));
197
- $.append($$anchor2, fragment_1);
198
- };
199
- $.if(node, ($$render) => {
200
- if ($.get(boundingRect)) $$render(consequent_4);
201
- });
202
- }
203
- $.append($$anchor, fragment);
204
- $.pop();
205
- }
206
- var root_1 = $.from_html(`<div></div>`);
207
- function MarqueeSelection($$anchor, $$props) {
208
- $.push($$props, true);
209
- let borderStyle = $.prop($$props, "borderStyle", 3, "dashed");
210
- const selectionPlugin = useSelectionPlugin();
211
- const documentState = useDocumentState(() => $$props.documentId);
212
- const resolvedBorderColor = $.derived(() => $$props.borderColor ?? $$props.stroke ?? "rgba(0,122,204,0.8)");
213
- const resolvedBackground = $.derived(() => $$props.background ?? $$props.fill ?? "rgba(0,122,204,0.15)");
214
- let rect = $.state(null);
215
- const actualScale = $.derived(() => {
216
- var _a;
217
- return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
218
- });
219
- $.user_effect(() => {
220
- $.set(rect, null);
221
- if (!selectionPlugin.plugin) {
222
- return;
223
- }
224
- return selectionPlugin.plugin.registerMarqueeOnPage({
225
- documentId: $$props.documentId,
226
- pageIndex: $$props.pageIndex,
227
- scale: $.get(actualScale),
228
- onRectChange: (newRect) => {
229
- $.set(rect, newRect, true);
230
- }
231
- });
232
- });
233
- var fragment = $.comment();
234
- var node = $.first_child(fragment);
235
- {
236
- var consequent = ($$anchor2) => {
237
- var div = root_1();
238
- let styles;
239
- $.template_effect(() => {
240
- $.set_class(div, 1, $.clsx($$props.class));
241
- styles = $.set_style(div, "", styles, {
242
- position: "absolute",
243
- "pointer-events": "none",
244
- left: `${$.get(rect).origin.x * $.get(actualScale)}px`,
245
- top: `${$.get(rect).origin.y * $.get(actualScale)}px`,
246
- width: `${$.get(rect).size.width * $.get(actualScale)}px`,
247
- height: `${$.get(rect).size.height * $.get(actualScale)}px`,
248
- border: `1px ${borderStyle()} ${$.get(resolvedBorderColor)}`,
249
- background: $.get(resolvedBackground),
250
- "box-sizing": "border-box",
251
- "z-index": "1000"
252
- });
253
- });
254
- $.append($$anchor2, div);
255
- };
256
- $.if(node, ($$render) => {
257
- if ($.get(rect)) $$render(consequent);
258
- });
259
- }
260
- $.append($$anchor, fragment);
261
- $.pop();
262
- }
263
- var root = $.from_html(`<!> <!>`, 1);
264
- function SelectionLayer($$anchor, $$props) {
265
- $.push($$props, true);
266
- const resolvedTextBackground = $.derived(() => {
267
- var _a;
268
- return ((_a = $$props.textStyle) == null ? void 0 : _a.background) ?? $$props.background;
269
- });
270
- var fragment = root();
271
- var node = $.first_child(fragment);
272
- TextSelection(node, {
273
- get documentId() {
274
- return $$props.documentId;
275
- },
276
- get pageIndex() {
277
- return $$props.pageIndex;
278
- },
279
- get scale() {
280
- return $$props.scale;
281
- },
282
- get rotation() {
283
- return $$props.rotation;
284
- },
285
- get background() {
286
- return $.get(resolvedTextBackground);
287
- },
288
- get selectionMenu() {
289
- return $$props.selectionMenu;
290
- },
291
- get selectionMenuSnippet() {
292
- return $$props.selectionMenuSnippet;
293
- }
294
- });
295
- var node_1 = $.sibling(node, 2);
296
- {
297
- let $0 = $.derived(() => {
298
- var _a;
299
- return (_a = $$props.marqueeStyle) == null ? void 0 : _a.background;
300
- });
301
- let $1 = $.derived(() => {
302
- var _a;
303
- return (_a = $$props.marqueeStyle) == null ? void 0 : _a.borderColor;
304
- });
305
- let $2 = $.derived(() => {
306
- var _a;
307
- return (_a = $$props.marqueeStyle) == null ? void 0 : _a.borderStyle;
308
- });
309
- MarqueeSelection(node_1, {
310
- get documentId() {
311
- return $$props.documentId;
312
- },
313
- get pageIndex() {
314
- return $$props.pageIndex;
315
- },
316
- get scale() {
317
- return $$props.scale;
318
- },
319
- get background() {
320
- return $.get($0);
321
- },
322
- get borderColor() {
323
- return $.get($1);
324
- },
325
- get borderStyle() {
326
- return $.get($2);
327
- },
328
- get class() {
329
- return $$props.marqueeClass;
330
- }
331
- });
332
- }
333
- $.append($$anchor, fragment);
334
- $.pop();
335
- }
336
- function CopyToClipboard($$anchor, $$props) {
337
- $.push($$props, true);
338
- const selectionCapability = useSelectionCapability();
339
- $.user_effect(() => {
340
- if (!selectionCapability.provides) return;
341
- return selectionCapability.provides.onCopyToClipboard(({ text }) => {
342
- navigator.clipboard.writeText(text).catch((err) => {
343
- console.error("Failed to copy text to clipboard:", err);
344
- });
345
- });
346
- });
347
- $.pop();
348
- }
349
- const SelectionPluginPackage = createPluginPackage(SelectionPluginPackage$1).addUtility(CopyToClipboard).build();
350
- export {
351
- CopyToClipboard,
352
- MarqueeSelection,
353
- SelectionLayer,
354
- SelectionPluginPackage,
355
- TextSelection,
356
- useSelectionCapability,
357
- useSelectionPlugin
358
- };
359
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../src/svelte/components/TextSelection.svelte","../../src/svelte/components/MarqueeSelection.svelte","../../src/svelte/components/SelectionLayer.svelte","../../src/svelte/components/CopyToClipboard.svelte","../../src/svelte/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\n/**\n * Hook to get the selection plugin's capability API.\n * This provides methods for controlling and listening to selection events.\n */\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\n\n/**\n * Hook to get the raw selection plugin instance.\n * Useful for accessing plugin-specific properties or methods not exposed in the capability.\n */\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import type { Rect } from '@embedpdf/models';\n import { Rotation } from '@embedpdf/models';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import {\n CounterRotate,\n type MenuWrapperProps,\n type SelectionMenuPlacement,\n } from '@embedpdf/utils/svelte';\n import { useSelectionPlugin } from '../hooks/use-selection.svelte';\n import type {\n SelectionSelectionMenuRenderFn,\n SelectionSelectionMenuProps,\n SelectionSelectionContext,\n } from '../types';\n import type { SelectionMenuPlacement as UtilsSelectionMenuPlacement } from '@embedpdf/plugin-selection';\n\n interface TextSelectionProps {\n /** Document ID */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Rotation of the page (optional, defaults to document rotation) */\n rotation?: Rotation;\n /** Background color for text selection highlights. Default: 'rgba(33,150,243)' */\n background?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n rotation: rotationOverride,\n background = 'rgba(33,150,243)',\n selectionMenu,\n selectionMenuSnippet,\n }: TextSelectionProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n const documentState = useDocumentState(() => documentId);\n\n const page = $derived(documentState.current?.document?.pages?.[pageIndex]);\n\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n let placement = $state<UtilsSelectionMenuPlacement | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n const actualRotation = $derived.by(() => {\n if (rotationOverride !== undefined) return rotationOverride;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page?.rotation ?? 0;\n const docRotation = documentState.current?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n });\n\n // Check if menu should render: placement is valid AND (render fn OR snippet exists)\n const shouldRenderMenu = $derived(\n Boolean(\n placement &&\n placement.pageIndex === pageIndex &&\n placement.isVisible &&\n (selectionMenu || selectionMenuSnippet),\n ),\n );\n\n // Track selection rectangles on this page\n $effect(() => {\n if (!selectionPlugin.plugin || !documentId) {\n rects = [];\n boundingRect = null;\n return;\n }\n\n return selectionPlugin.plugin.registerSelectionOnPage({\n documentId,\n pageIndex,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects = newRects;\n boundingRect = newBoundingRect;\n },\n });\n });\n\n // Track menu placement for this document\n $effect(() => {\n if (!selectionPlugin.plugin || !documentId) {\n placement = null;\n return;\n }\n\n return selectionPlugin.plugin.onMenuPlacement(documentId, (newPlacement) => {\n placement = newPlacement;\n });\n });\n\n // --- Selection Menu Logic ---\n\n // Build context object for selection menu\n function buildContext(): SelectionSelectionContext {\n return {\n type: 'selection',\n pageIndex,\n };\n }\n\n // Build placement hints from plugin placement data\n function buildMenuPlacement(): SelectionMenuPlacement {\n return {\n suggestTop: placement?.suggestTop ?? false,\n spaceAbove: placement?.spaceAbove ?? 0,\n spaceBelow: placement?.spaceBelow ?? 0,\n };\n }\n\n // Build menu props\n function buildMenuProps(\n rect: Rect,\n menuWrapperProps: MenuWrapperProps,\n ): SelectionSelectionMenuProps {\n return {\n context: buildContext(),\n selected: true, // Selection is always \"selected\" when visible\n rect,\n placement: buildMenuPlacement(),\n menuWrapperProps,\n };\n }\n</script>\n\n{#if boundingRect}\n <!-- Highlight layer -->\n <div\n style:position=\"absolute\"\n style:left={`${boundingRect.origin.x * actualScale}px`}\n style:top={`${boundingRect.origin.y * actualScale}px`}\n style:width={`${boundingRect.size.width * actualScale}px`}\n style:height={`${boundingRect.size.height * actualScale}px`}\n style:mix-blend-mode=\"multiply\"\n style:isolation=\"isolate\"\n style:pointer-events=\"none\"\n >\n {#each rects as rect, i (i)}\n <div\n style:position=\"absolute\"\n style:left={`${(rect.origin.x - boundingRect.origin.x) * actualScale}px`}\n style:top={`${(rect.origin.y - boundingRect.origin.y) * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:background\n style:pointer-events=\"none\"\n ></div>\n {/each}\n </div>\n\n <!-- Selection menu (counter-rotated) -->\n {#if shouldRenderMenu && placement}\n <CounterRotate\n rect={{\n origin: {\n x: placement.rect.origin.x * actualScale,\n y: placement.rect.origin.y * actualScale,\n },\n size: {\n width: placement.rect.size.width * actualScale,\n height: placement.rect.size.height * actualScale,\n },\n }}\n rotation={actualRotation}\n >\n {#snippet children({ rect, menuWrapperProps })}\n {@const menuProps = buildMenuProps(rect, menuWrapperProps)}\n {#if selectionMenu}\n <!-- Priority 1: Render function (schema-driven) -->\n {@const result = selectionMenu(menuProps)}\n {#if result}\n <result.component {...result.props} />\n {/if}\n {:else if selectionMenuSnippet}\n <!-- Priority 2: Snippet (manual customization) -->\n {@render selectionMenuSnippet(menuProps)}\n {/if}\n {/snippet}\n </CounterRotate>\n {/if}\n{/if}\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { useSelectionPlugin } from '../hooks';\n\n interface MarqueeSelectionProps {\n /** The ID of the document */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Optional CSS class applied to the marquee rectangle */\n class?: string;\n /** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */\n background?: string;\n /** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */\n borderColor?: string;\n /** Border style. Default: 'dashed' */\n borderStyle?: 'solid' | 'dashed' | 'dotted';\n /**\n * @deprecated Use `borderColor` instead.\n */\n stroke?: string;\n /**\n * @deprecated Use `background` instead.\n */\n fill?: string;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n class: propsClass,\n background,\n borderColor,\n borderStyle = 'dashed',\n stroke,\n fill,\n }: MarqueeSelectionProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n const documentState = useDocumentState(() => documentId);\n\n // Resolve deprecated props: new CSS-standard props take precedence\n const resolvedBorderColor = $derived(borderColor ?? stroke ?? 'rgba(0,122,204,0.8)');\n const resolvedBackground = $derived(background ?? fill ?? 'rgba(0,122,204,0.15)');\n\n let rect = $state<Rect | null>(null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n rect = null;\n\n if (!selectionPlugin.plugin) {\n return;\n }\n\n return selectionPlugin.plugin.registerMarqueeOnPage({\n documentId,\n pageIndex,\n scale: actualScale,\n onRectChange: (newRect) => {\n rect = newRect;\n },\n });\n });\n</script>\n\n{#if rect}\n <div\n style:position=\"absolute\"\n style:pointer-events=\"none\"\n style:left={`${rect.origin.x * actualScale}px`}\n style:top={`${rect.origin.y * actualScale}px`}\n style:width={`${rect.size.width * actualScale}px`}\n style:height={`${rect.size.height * actualScale}px`}\n style:border={`1px ${borderStyle} ${resolvedBorderColor}`}\n style:background={resolvedBackground}\n style:box-sizing=\"border-box\"\n style:z-index=\"1000\"\n class={propsClass}\n ></div>\n{/if}\n","<script lang=\"ts\">\n import type { Snippet } from 'svelte';\n import { Rotation } from '@embedpdf/models';\n import type { TextSelectionStyle, MarqueeSelectionStyle } from '@embedpdf/plugin-selection';\n import type { SelectionSelectionMenuRenderFn, SelectionSelectionMenuProps } from '../types';\n import TextSelection from './TextSelection.svelte';\n import MarqueeSelection from './MarqueeSelection.svelte';\n\n interface SelectionLayerProps {\n /** Document ID */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Rotation of the page (optional, defaults to document rotation) */\n rotation?: Rotation;\n /**\n * @deprecated Use `textStyle.background` instead.\n * Background color for selection rectangles.\n */\n background?: string;\n /** Styling options for text selection highlights */\n textStyle?: TextSelectionStyle;\n /** Styling options for the marquee selection rectangle */\n marqueeStyle?: MarqueeSelectionStyle;\n /** Optional CSS class applied to the marquee rectangle */\n marqueeClass?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n /** Snippet for custom selection menu (slot-based approach) */\n selectionMenuSnippet?: Snippet<[SelectionSelectionMenuProps]>;\n }\n\n let {\n documentId,\n pageIndex,\n scale,\n rotation,\n background,\n textStyle,\n marqueeStyle,\n marqueeClass,\n selectionMenu,\n selectionMenuSnippet,\n }: SelectionLayerProps = $props();\n\n const resolvedTextBackground = $derived(textStyle?.background ?? background);\n</script>\n\n<TextSelection\n {documentId}\n {pageIndex}\n {scale}\n {rotation}\n background={resolvedTextBackground}\n {selectionMenu}\n {selectionMenuSnippet}\n/>\n<MarqueeSelection\n {documentId}\n {pageIndex}\n {scale}\n background={marqueeStyle?.background}\n borderColor={marqueeStyle?.borderColor}\n borderStyle={marqueeStyle?.borderStyle}\n class={marqueeClass}\n/>\n","<script lang=\"ts\">\n import { useSelectionCapability } from '../hooks/use-selection.svelte';\n\n const selectionCapability = useSelectionCapability();\n\n $effect(() => {\n if (!selectionCapability.provides) return;\n\n return selectionCapability.provides.onCopyToClipboard(({ text }) => {\n navigator.clipboard.writeText(text).catch((err) => {\n console.error('Failed to copy text to clipboard:', err);\n });\n });\n });\n</script>\n\n<!-- This component renders nothing to the DOM -->\n","import { createPluginPackage } from '@embedpdf/core';\nimport { SelectionPluginPackage as BaseSelectionPluginPackage } from '@embedpdf/plugin-selection';\n\nimport { CopyToClipboard } from './components';\n\nexport * from './hooks';\nexport * from './components';\nexport * from './types';\nexport * from '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n"],"names":["$$anchor","BaseSelectionPluginPackage"],"mappings":";;;;;;;;AAOa,MAAA,yBAAA,MAA+B,cAA+B,gBAAgB,EAAE;AAMhF,MAAA,qBAAA,MAA2B,UAA2B,gBAAgB,EAAE;;;0CCbrF;;AAwCI,MAAA,8CAAa,kBAAkB;AAK3B,QAAA,kBAAkB,mBAAkB;AACpC,QAAA,gBAAgB,iBAAgB,MAAA,QAAA,UAAA;AAEhC,QAAA;;AAAgB,2CAAc,YAAd,mBAAuB,aAAvB,mBAAiC,UAAjC,mBAAsC,QAAA;AAAA,GAAA;AAExD,MAAA,QAAQ,EAAA,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SAAS,kBAAiB,CAAA,EAAI,KAAI,MAAO;AAClE,gBAAU,UAAU,UAAU,IAAI,EAAE,MAAK,CAAE,QAAQ;AACjD,gBAAQ,MAAM,qCAAqC,GAAG;AAAA,MACxD,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;;AACK;ACJD,MAAM,yBAAyB,oBAAoBC,wBAA0B,EACjF,WAAW,eAAe,EAC1B,MAAA;"}
@@ -1,7 +0,0 @@
1
- import { SelectionMenuRenderFn, SelectionMenuPropsBase } from '@embedpdf/utils/svelte';
2
- export interface SelectionSelectionContext {
3
- type: 'selection';
4
- pageIndex: number;
5
- }
6
- export type SelectionSelectionMenuRenderFn = SelectionMenuRenderFn<SelectionSelectionContext>;
7
- export type SelectionSelectionMenuProps = SelectionMenuPropsBase<SelectionSelectionContext>;
@@ -1,3 +0,0 @@
1
- declare const __VLS_export: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
2
- declare const _default: typeof __VLS_export;
3
- export default _default;
@@ -1,4 +0,0 @@
1
- export { default as SelectionLayer } from './selection-layer.vue';
2
- export { default as TextSelection } from './text-selection.vue';
3
- export { default as CopyToClipboard } from './copy-to-clipboard.vue';
4
- export { default as MarqueeSelection } from './marquee-selection.vue';
@@ -1,29 +0,0 @@
1
- interface MarqueeSelectionProps {
2
- /** The ID of the document */
3
- documentId: string;
4
- /** Index of the page this layer lives on */
5
- pageIndex: number;
6
- /** Scale of the page (optional, defaults to document scale) */
7
- scale?: number;
8
- /** Optional CSS class applied to the marquee rectangle */
9
- className?: string;
10
- /** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */
11
- background?: string;
12
- /** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */
13
- borderColor?: string;
14
- /** Border style. Default: 'dashed' */
15
- borderStyle?: 'solid' | 'dashed' | 'dotted';
16
- /**
17
- * @deprecated Use `borderColor` instead.
18
- */
19
- stroke?: string;
20
- /**
21
- * @deprecated Use `background` instead.
22
- */
23
- fill?: string;
24
- }
25
- declare const __VLS_export: import('vue').DefineComponent<MarqueeSelectionProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<MarqueeSelectionProps> & Readonly<{}>, {
26
- borderStyle: "solid" | "dashed" | "dotted";
27
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
28
- declare const _default: typeof __VLS_export;
29
- export default _default;
@@ -1,60 +0,0 @@
1
- import { Rotation } from '@embedpdf/models';
2
- import { TextSelectionStyle, MarqueeSelectionStyle } from '../../lib/index.ts';
3
- import { SelectionSelectionMenuRenderFn } from '../types';
4
- interface SelectionLayerProps {
5
- documentId: string;
6
- pageIndex: number;
7
- scale?: number;
8
- rotation?: Rotation;
9
- /**
10
- * @deprecated Use `textStyle.background` instead.
11
- * Background color for selection rectangles.
12
- */
13
- background?: string;
14
- /** Styling options for text selection highlights */
15
- textStyle?: TextSelectionStyle;
16
- /** Styling options for the marquee selection rectangle */
17
- marqueeStyle?: MarqueeSelectionStyle;
18
- /** Optional CSS class applied to the marquee rectangle */
19
- marqueeClassName?: string;
20
- /** Render function for selection menu (schema-driven approach) */
21
- selectionMenu?: SelectionSelectionMenuRenderFn;
22
- }
23
- declare var __VLS_8: {
24
- context: import('..').SelectionSelectionContext;
25
- selected: boolean;
26
- rect: {
27
- origin: {
28
- x: number;
29
- y: number;
30
- };
31
- size: {
32
- width: number;
33
- height: number;
34
- };
35
- };
36
- placement: {
37
- suggestTop: boolean;
38
- spaceAbove: number;
39
- spaceBelow: number;
40
- };
41
- menuWrapperProps: {
42
- style: import('vue').CSSProperties;
43
- onPointerdown: (e: PointerEvent) => void;
44
- onTouchstart: (e: TouchEvent) => void;
45
- };
46
- };
47
- type __VLS_Slots = {} & {
48
- 'selection-menu'?: (props: typeof __VLS_8) => any;
49
- };
50
- declare const __VLS_base: import('vue').DefineComponent<SelectionLayerProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<SelectionLayerProps> & Readonly<{}>, {
51
- rotation: Rotation;
52
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
53
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
54
- declare const _default: typeof __VLS_export;
55
- export default _default;
56
- type __VLS_WithSlots<T, S> = T & {
57
- new (): {
58
- $slots: S;
59
- };
60
- };
@@ -1,51 +0,0 @@
1
- import { Rotation } from '@embedpdf/models';
2
- import { SelectionSelectionContext, SelectionSelectionMenuRenderFn } from '../types';
3
- interface TextSelectionProps {
4
- documentId: string;
5
- pageIndex: number;
6
- scale?: number;
7
- rotation?: Rotation;
8
- /** Background color for text selection highlights. Default: 'rgba(33,150,243)' */
9
- background?: string;
10
- /** Render function for selection menu (schema-driven approach) */
11
- selectionMenu?: SelectionSelectionMenuRenderFn;
12
- }
13
- declare var __VLS_13: {
14
- context: SelectionSelectionContext;
15
- selected: boolean;
16
- rect: {
17
- origin: {
18
- x: number;
19
- y: number;
20
- };
21
- size: {
22
- width: number;
23
- height: number;
24
- };
25
- };
26
- placement: {
27
- suggestTop: boolean;
28
- spaceAbove: number;
29
- spaceBelow: number;
30
- };
31
- menuWrapperProps: {
32
- style: import('vue').CSSProperties;
33
- onPointerdown: (e: PointerEvent) => void;
34
- onTouchstart: (e: TouchEvent) => void;
35
- };
36
- };
37
- type __VLS_Slots = {} & {
38
- 'selection-menu'?: (props: typeof __VLS_13) => any;
39
- };
40
- declare const __VLS_base: import('vue').DefineComponent<TextSelectionProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<TextSelectionProps> & Readonly<{}>, {
41
- rotation: Rotation;
42
- background: string;
43
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
44
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
45
- declare const _default: typeof __VLS_export;
46
- export default _default;
47
- type __VLS_WithSlots<T, S> = T & {
48
- new (): {
49
- $slots: S;
50
- };
51
- };
@@ -1 +0,0 @@
1
- export * from './use-selection';
@@ -1,11 +0,0 @@
1
- import { SelectionPlugin } from '../../lib/index.ts';
2
- /**
3
- * Hook to get the selection plugin's capability API.
4
- * This provides methods for controlling and listening to selection events.
5
- */
6
- export declare const useSelectionCapability: () => import('@embedpdf/core/vue').CapabilityState<Readonly<import('../../lib/index.ts').SelectionCapability>>;
7
- /**
8
- * Hook to get the raw selection plugin instance.
9
- * Useful for accessing plugin-specific properties or methods not exposed in the capability.
10
- */
11
- export declare const useSelectionPlugin: () => import('@embedpdf/core/vue').PluginState<SelectionPlugin>;
@@ -1,2 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection"),o=require("vue"),l=require("@embedpdf/models"),n=require("@embedpdf/core/vue"),a=require("@embedpdf/utils/vue"),r=()=>n.useCapability(t.SelectionPlugin.id),u=()=>n.usePlugin(t.SelectionPlugin.id),i=o.defineComponent({__name:"text-selection",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:l.Rotation.Degree0},background:{default:"rgba(33,150,243)"},selectionMenu:{}},setup(e){const t=e,l=o.useSlots(),{plugin:r}=u(),i=n.useDocumentState(()=>t.documentId),c=o.computed(()=>{var e,o,l;return null==(l=null==(o=null==(e=i.value)?void 0:e.document)?void 0:o.pages)?void 0:l[t.pageIndex]}),d=o.ref([]),s=o.ref(null),p=o.ref(null),v=o.computed(()=>{var e;return void 0!==t.scale?t.scale:(null==(e=i.value)?void 0:e.scale)??1}),m=o.computed(()=>{var e,o;if(void 0!==t.rotation)return t.rotation;return(((null==(e=c.value)?void 0:e.rotation)??0)+((null==(o=i.value)?void 0:o.rotation)??0))%4}),g=o.computed(()=>!!p.value&&(p.value.pageIndex===t.pageIndex&&(!!p.value.isVisible&&(!!t.selectionMenu||!!l["selection-menu"]))));o.watch([()=>r.value,()=>t.documentId,()=>t.pageIndex],([e,t,o],l,n)=>{if(!e||!t)return d.value=[],void(s.value=null);n(e.registerSelectionOnPage({documentId:t,pageIndex:o,onRectsChange:({rects:e,boundingRect:t})=>{d.value=e,s.value=t}}))},{immediate:!0}),o.watch([()=>r.value,()=>t.documentId],([e,t],o,l)=>{if(!e||!t)return void(p.value=null);l(e.onMenuPlacement(t,e=>{p.value=e}))},{immediate:!0});const x=()=>({type:"selection",pageIndex:t.pageIndex}),b=()=>{var e,t,o;return{suggestTop:(null==(e=p.value)?void 0:e.suggestTop)??!1,spaceAbove:(null==(t=p.value)?void 0:t.spaceAbove)??0,spaceBelow:(null==(o=p.value)?void 0:o.spaceBelow)??0}},y=(e,o)=>t.selectionMenu?t.selectionMenu({rect:e,menuWrapperProps:o,selected:!0,placement:b(),context:x()}):null;return(t,l)=>s.value?(o.openBlock(),o.createElementBlock(o.Fragment,{key:0},[o.createElementVNode("div",{style:o.normalizeStyle({position:"absolute",left:s.value.origin.x*v.value+"px",top:s.value.origin.y*v.value+"px",width:s.value.size.width*v.value+"px",height:s.value.size.height*v.value+"px",mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(d.value,(t,l)=>(o.openBlock(),o.createElementBlock("div",{key:l,style:o.normalizeStyle({position:"absolute",left:(t.origin.x-s.value.origin.x)*v.value+"px",top:(t.origin.y-s.value.origin.y)*v.value+"px",width:t.size.width*v.value+"px",height:t.size.height*v.value+"px",background:e.background})},null,4))),128))],4),g.value?(o.openBlock(),o.createBlock(o.unref(a.CounterRotate),{key:0,rect:{origin:{x:p.value.rect.origin.x*v.value,y:p.value.rect.origin.y*v.value},size:{width:p.value.rect.size.width*v.value,height:p.value.rect.size.height*v.value}},rotation:m.value},{default:o.withCtx(({rect:l,menuWrapperProps:n})=>[e.selectionMenu?(o.openBlock(),o.createBlock(o.resolveDynamicComponent(y(l,n)),{key:0})):o.renderSlot(t.$slots,"selection-menu",{key:1,context:x(),selected:!0,rect:l,placement:b(),menuWrapperProps:n})]),_:3},8,["rect","rotation"])):o.createCommentVNode("",!0)],64)):o.createCommentVNode("",!0)}}),c=o.defineComponent({__name:"marquee-selection",props:{documentId:{},pageIndex:{},scale:{},className:{},background:{},borderColor:{},borderStyle:{default:"dashed"},stroke:{},fill:{}},setup(e){const t=e,l=o.computed(()=>t.borderColor??t.stroke??"rgba(0,122,204,0.8)"),a=o.computed(()=>t.background??t.fill??"rgba(0,122,204,0.15)"),r=o.computed(()=>t.borderStyle),{plugin:i}=u(),c=n.useDocumentState(()=>t.documentId),d=o.ref(null),s=o.computed(()=>{var e;return void 0!==t.scale?t.scale:(null==(e=c.value)?void 0:e.scale)??1});return o.watch([i,()=>t.documentId,()=>t.pageIndex,s],([e,t,o,l],n,a)=>{if(d.value=null,!e)return;const r=e.registerMarqueeOnPage({documentId:t,pageIndex:o,scale:l,onRectChange:e=>{d.value=e}});a(()=>{null==r||r()})},{immediate:!0}),(t,n)=>d.value?(o.openBlock(),o.createElementBlock("div",{key:0,style:o.normalizeStyle({position:"absolute",pointerEvents:"none",left:d.value.origin.x*s.value+"px",top:d.value.origin.y*s.value+"px",width:d.value.size.width*s.value+"px",height:d.value.size.height*s.value+"px",border:`1px ${r.value} ${l.value}`,background:a.value,boxSizing:"border-box",zIndex:1e3}),class:o.normalizeClass(e.className)},null,6)):o.createCommentVNode("",!0)}}),d=o.defineComponent({__name:"selection-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{default:l.Rotation.Degree0},background:{},textStyle:{},marqueeStyle:{},marqueeClassName:{},selectionMenu:{}},setup(e){const t=e,l=o.computed(()=>{var e;return(null==(e=t.textStyle)?void 0:e.background)??t.background});return(t,n)=>{var a,r,u;return o.openBlock(),o.createElementBlock(o.Fragment,null,[o.createVNode(i,{"document-id":e.documentId,"page-index":e.pageIndex,scale:e.scale,rotation:e.rotation,background:l.value,"selection-menu":e.selectionMenu},{"selection-menu":o.withCtx(e=>[o.renderSlot(t.$slots,"selection-menu",o.normalizeProps(o.guardReactiveProps(e)))]),_:3},8,["document-id","page-index","scale","rotation","background","selection-menu"]),o.createVNode(c,{"document-id":e.documentId,"page-index":e.pageIndex,scale:e.scale,background:null==(a=e.marqueeStyle)?void 0:a.background,"border-color":null==(r=e.marqueeStyle)?void 0:r.borderColor,"border-style":null==(u=e.marqueeStyle)?void 0:u.borderStyle,"class-name":e.marqueeClassName},null,8,["document-id","page-index","scale","background","border-color","border-style","class-name"])],64)}}}),s=o.defineComponent({__name:"copy-to-clipboard",setup(e){const{provides:t}=r();return o.watchEffect(e=>{if(t.value){e(t.value.onCopyToClipboard(({text:e})=>{navigator.clipboard.writeText(e).catch(e=>{console.error("Failed to copy text to clipboard:",e)})}))}}),(e,t)=>null}}),p=e.createPluginPackage(t.SelectionPluginPackage).addUtility(s).build();exports.CopyToClipboard=s,exports.MarqueeSelection=c,exports.SelectionLayer=d,exports.SelectionPluginPackage=p,exports.TextSelection=i,exports.useSelectionCapability=r,exports.useSelectionPlugin=u,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
- //# sourceMappingURL=index.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-selection.ts","../../src/vue/components/text-selection.vue","../../src/vue/components/marquee-selection.vue","../../src/vue/components/selection-layer.vue","../../src/vue/components/copy-to-clipboard.vue","../../src/vue/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/vue';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\n/**\n * Hook to get the selection plugin's capability API.\n * This provides methods for controlling and listening to selection events.\n */\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\n\n/**\n * Hook to get the raw selection plugin instance.\n * Useful for accessing plugin-specific properties or methods not exposed in the capability.\n */\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","<script setup lang=\"ts\">\nimport { ref, watch, computed, useSlots, type VNode } from 'vue';\nimport { useDocumentState } from '@embedpdf/core/vue';\nimport { Rotation, type Rect } from '@embedpdf/models';\nimport type { SelectionMenuPlacement } from '@embedpdf/plugin-selection';\nimport { CounterRotate, type MenuWrapperProps } from '@embedpdf/utils/vue';\nimport { useSelectionPlugin } from '../hooks/use-selection';\nimport type { SelectionSelectionContext, SelectionSelectionMenuRenderFn } from '../types';\n\ninterface TextSelectionProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: Rotation;\n /** Background color for text selection highlights. Default: 'rgba(33,150,243)' */\n background?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n}\n\nconst props = withDefaults(defineProps<TextSelectionProps>(), {\n background: 'rgba(33,150,243)',\n rotation: Rotation.Degree0,\n});\n\nconst slots = useSlots();\nconst { plugin: selPlugin } = useSelectionPlugin();\nconst documentState = useDocumentState(() => props.documentId);\nconst page = computed(() => documentState.value?.document?.pages?.[props.pageIndex]);\nconst rects = ref<Rect[]>([]);\nconst boundingRect = ref<Rect | null>(null);\nconst placement = ref<SelectionMenuPlacement | null>(null);\n\nconst actualScale = computed(() => {\n if (props.scale !== undefined) return props.scale;\n return documentState.value?.scale ?? 1;\n});\n\nconst actualRotation = computed(() => {\n if (props.rotation !== undefined) return props.rotation;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page.value?.rotation ?? 0;\n const docRotation = documentState.value?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n});\n\n// Check if menu should render: placement is valid AND (render fn OR slot exists)\nconst shouldRenderMenu = computed(() => {\n if (!placement.value) return false;\n if (placement.value.pageIndex !== props.pageIndex) return false;\n if (!placement.value.isVisible) return false;\n\n // Must have either render function or slot\n return !!props.selectionMenu || !!slots['selection-menu'];\n});\n\nwatch(\n [() => selPlugin.value, () => props.documentId, () => props.pageIndex],\n ([plugin, docId, pageIdx], _, onCleanup) => {\n if (!plugin || !docId) {\n rects.value = [];\n boundingRect.value = null;\n return;\n }\n\n const unregister = plugin.registerSelectionOnPage({\n documentId: docId,\n pageIndex: pageIdx,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects.value = newRects;\n boundingRect.value = newBoundingRect;\n },\n });\n\n onCleanup(unregister);\n },\n { immediate: true },\n);\n\nwatch(\n [() => selPlugin.value, () => props.documentId],\n ([plugin, docId], _, onCleanup) => {\n if (!plugin || !docId) {\n placement.value = null;\n return;\n }\n\n const unsubscribe = plugin.onMenuPlacement(docId, (newPlacement) => {\n placement.value = newPlacement;\n });\n\n onCleanup(unsubscribe);\n },\n { immediate: true },\n);\n\n// --- Selection Menu Logic ---\n\n// Build context object for selection menu\nconst buildContext = (): SelectionSelectionContext => ({\n type: 'selection',\n pageIndex: props.pageIndex,\n});\n\n// Build placement hints from plugin placement data\nconst buildMenuPlacement = () => ({\n suggestTop: placement.value?.suggestTop ?? false,\n spaceAbove: placement.value?.spaceAbove ?? 0,\n spaceBelow: placement.value?.spaceBelow ?? 0,\n});\n\n// Render via function (for schema-driven approach)\nconst renderSelectionMenu = (rect: Rect, menuWrapperProps: MenuWrapperProps): VNode | null => {\n if (!props.selectionMenu) return null;\n\n return props.selectionMenu({\n rect,\n menuWrapperProps,\n selected: true, // Selection is always \"selected\" when visible\n placement: buildMenuPlacement(),\n context: buildContext(),\n });\n};\n</script>\n\n<template>\n <template v-if=\"boundingRect\">\n <div\n :style=\"{\n position: 'absolute',\n left: `${boundingRect.origin.x * actualScale}px`,\n top: `${boundingRect.origin.y * actualScale}px`,\n width: `${boundingRect.size.width * actualScale}px`,\n height: `${boundingRect.size.height * actualScale}px`,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n pointerEvents: 'none',\n }\"\n >\n <div\n v-for=\"(rect, i) in rects\"\n :key=\"i\"\n :style=\"{\n position: 'absolute',\n left: `${(rect.origin.x - boundingRect.origin.x) * actualScale}px`,\n top: `${(rect.origin.y - boundingRect.origin.y) * actualScale}px`,\n width: `${rect.size.width * actualScale}px`,\n height: `${rect.size.height * actualScale}px`,\n background: background,\n }\"\n />\n </div>\n\n <!-- Selection Menu: Supports BOTH render function and slot -->\n <CounterRotate\n v-if=\"shouldRenderMenu\"\n :rect=\"{\n origin: {\n x: placement!.rect.origin.x * actualScale,\n y: placement!.rect.origin.y * actualScale,\n },\n size: {\n width: placement!.rect.size.width * actualScale,\n height: placement!.rect.size.height * actualScale,\n },\n }\"\n :rotation=\"actualRotation\"\n >\n <template #default=\"{ rect, menuWrapperProps }\">\n <!-- Priority 1: Render function prop (schema-driven) -->\n <component v-if=\"selectionMenu\" :is=\"renderSelectionMenu(rect, menuWrapperProps)\" />\n\n <!-- Priority 2: Slot (manual customization) -->\n <slot\n v-else\n name=\"selection-menu\"\n :context=\"buildContext()\"\n :selected=\"true\"\n :rect=\"rect\"\n :placement=\"buildMenuPlacement()\"\n :menuWrapperProps=\"menuWrapperProps\"\n />\n </template>\n </CounterRotate>\n </template>\n</template>\n","<template>\n <div\n v-if=\"rect\"\n :style=\"{\n position: 'absolute',\n pointerEvents: 'none',\n left: `${rect.origin.x * actualScale}px`,\n top: `${rect.origin.y * actualScale}px`,\n width: `${rect.size.width * actualScale}px`,\n height: `${rect.size.height * actualScale}px`,\n border: `1px ${resolvedBorderStyle} ${resolvedBorderColor}`,\n background: resolvedBackground,\n boxSizing: 'border-box',\n zIndex: 1000,\n }\"\n :class=\"className\"\n />\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, computed, watch } from 'vue';\nimport type { Rect } from '@embedpdf/models';\nimport { useDocumentState } from '@embedpdf/core/vue';\nimport { useSelectionPlugin } from '../hooks';\n\ninterface MarqueeSelectionProps {\n /** The ID of the document */\n documentId: string;\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page (optional, defaults to document scale) */\n scale?: number;\n /** Optional CSS class applied to the marquee rectangle */\n className?: string;\n /** Fill/background color inside the marquee rectangle. Default: 'rgba(0,122,204,0.15)' */\n background?: string;\n /** Border color of the marquee rectangle. Default: 'rgba(0,122,204,0.8)' */\n borderColor?: string;\n /** Border style. Default: 'dashed' */\n borderStyle?: 'solid' | 'dashed' | 'dotted';\n /**\n * @deprecated Use `borderColor` instead.\n */\n stroke?: string;\n /**\n * @deprecated Use `background` instead.\n */\n fill?: string;\n}\n\nconst props = withDefaults(defineProps<MarqueeSelectionProps>(), {\n borderStyle: 'dashed',\n});\n\n// Resolve deprecated props: new CSS-standard props take precedence\nconst resolvedBorderColor = computed(\n () => props.borderColor ?? props.stroke ?? 'rgba(0,122,204,0.8)',\n);\nconst resolvedBackground = computed(() => props.background ?? props.fill ?? 'rgba(0,122,204,0.15)');\nconst resolvedBorderStyle = computed(() => props.borderStyle);\n\nconst { plugin: selPlugin } = useSelectionPlugin();\nconst documentState = useDocumentState(() => props.documentId);\nconst rect = ref<Rect | null>(null);\n\nconst actualScale = computed(() => {\n if (props.scale !== undefined) return props.scale;\n return documentState.value?.scale ?? 1;\n});\n\nwatch(\n [selPlugin, () => props.documentId, () => props.pageIndex, actualScale],\n ([plugin, docId, pageIdx, scale], _, onCleanup) => {\n rect.value = null;\n\n if (!plugin) {\n return;\n }\n\n const unregister = plugin.registerMarqueeOnPage({\n documentId: docId,\n pageIndex: pageIdx,\n scale,\n onRectChange: (newRect) => {\n rect.value = newRect;\n },\n });\n\n onCleanup(() => {\n unregister?.();\n });\n },\n { immediate: true },\n);\n</script>\n","<script setup lang=\"ts\">\nimport { computed } from 'vue';\nimport { Rotation } from '@embedpdf/models';\nimport type { TextSelectionStyle, MarqueeSelectionStyle } from '@embedpdf/plugin-selection';\nimport type { SelectionSelectionMenuRenderFn } from '../types';\nimport TextSelection from './text-selection.vue';\nimport MarqueeSelection from './marquee-selection.vue';\n\ninterface SelectionLayerProps {\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: Rotation;\n /**\n * @deprecated Use `textStyle.background` instead.\n * Background color for selection rectangles.\n */\n background?: string;\n /** Styling options for text selection highlights */\n textStyle?: TextSelectionStyle;\n /** Styling options for the marquee selection rectangle */\n marqueeStyle?: MarqueeSelectionStyle;\n /** Optional CSS class applied to the marquee rectangle */\n marqueeClassName?: string;\n /** Render function for selection menu (schema-driven approach) */\n selectionMenu?: SelectionSelectionMenuRenderFn;\n}\n\nconst props = withDefaults(defineProps<SelectionLayerProps>(), {\n rotation: Rotation.Degree0,\n});\n\nconst resolvedTextBackground = computed(() => props.textStyle?.background ?? props.background);\n</script>\n\n<template>\n <TextSelection\n :document-id=\"documentId\"\n :page-index=\"pageIndex\"\n :scale=\"scale\"\n :rotation=\"rotation\"\n :background=\"resolvedTextBackground\"\n :selection-menu=\"selectionMenu\"\n >\n <template #selection-menu=\"menuProps\">\n <slot name=\"selection-menu\" v-bind=\"menuProps\" />\n </template>\n </TextSelection>\n <MarqueeSelection\n :document-id=\"documentId\"\n :page-index=\"pageIndex\"\n :scale=\"scale\"\n :background=\"marqueeStyle?.background\"\n :border-color=\"marqueeStyle?.borderColor\"\n :border-style=\"marqueeStyle?.borderStyle\"\n :class-name=\"marqueeClassName\"\n />\n</template>\n","<script setup lang=\"ts\">\nimport { watchEffect } from 'vue';\nimport { useSelectionCapability } from '../hooks';\n\nconst { provides: sel } = useSelectionCapability();\n\n// This effect runs when the component is mounted and the capability is available.\n// It automatically handles unsubscribing when the component is unmounted.\nwatchEffect((onCleanup) => {\n if (sel.value) {\n const unsubscribe = sel.value.onCopyToClipboard(({ text }) => {\n // Use the Clipboard API to write the text\n navigator.clipboard.writeText(text).catch((err) => {\n console.error('Failed to copy text to clipboard:', err);\n });\n });\n\n // Register the cleanup function to run on unmount or re-run\n onCleanup(unsubscribe);\n }\n});\n</script>\n\n<template>\n <!-- This component renders nothing to the DOM -->\n</template>\n","import { createPluginPackage } from '@embedpdf/core';\nimport { SelectionPluginPackage as BaseSelectionPluginPackage } from '@embedpdf/plugin-selection';\n\nimport { CopyToClipboard } from './components';\n\nexport * from './hooks';\nexport * from './components';\nexport * from './types';\nexport * from '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","useSelectionPlugin","usePlugin","props","__props","slots","useSlots","plugin","selPlugin","documentState","useDocumentState","documentId","page","computed","_c","_b","_a","value","document","pages","pageIndex","rects","ref","boundingRect","placement","actualScale","scale","actualRotation","rotation","shouldRenderMenu","isVisible","selectionMenu","watch","docId","pageIdx","_","onCleanup","registerSelectionOnPage","onRectsChange","newRects","newBoundingRect","immediate","onMenuPlacement","newPlacement","buildContext","type","buildMenuPlacement","suggestTop","spaceAbove","spaceBelow","renderSelectionMenu","rect","menuWrapperProps","selected","context","_createElementBlock","_Fragment","key","_createElementVNode","style","_normalizeStyle","left","origin","x","top","y","width","size","height","_openBlock","_renderList","i","background","_createBlock","_unref","CounterRotate","default","_withCtx","_resolveDynamicComponent","_renderSlot","_ctx","$slots","resolvedBorderColor","borderColor","stroke","resolvedBackground","fill","resolvedBorderStyle","borderStyle","unregister","registerMarqueeOnPage","onRectChange","newRect","border","class","className","resolvedTextBackground","textStyle","_createVNode","TextSelection","menuProps","MarqueeSelection","marqueeStyle","marqueeClassName","provides","sel","watchEffect","onCopyToClipboard","text","navigator","clipboard","writeText","catch","err","console","error","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","CopyToClipboard","build"],"mappings":"0QAOaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,IAM9EC,EAAqB,IAAMC,YAA2BH,EAAAA,gBAAgBC,qMCOnF,MAAMG,EAAQC,EAKRC,EAAQC,EAAAA,YACNC,OAAQC,GAAcP,IACx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UACZM,MAAOtB,EAAAsB,MACP8C,WAAY,OAAAxD,EAAAZ,EAAAkG,mBAAA,EAAAtF,EAAcwD,WAC1B,eAAc,OAAAzD,EAAAX,EAAAkG,mBAAA,EAAAvF,EAAcoE,YAC5B,eAAc,OAAArE,EAAAV,EAAAkG,mBAAA,EAAAxF,EAAc0E,YAC5B,aAAYpF,EAAAmG,yLCnDjB,MAAQC,SAAUC,GAAQ5G,WAI1B6G,EAAAA,YAAatE,IACX,GAAIqE,EAAIxF,MAAO,CASbmB,EARoBqE,EAAIxF,MAAM0F,kBAAkB,EAAGC,WAEjDC,UAAUC,UAAUC,UAAUH,GAAMI,MAAOC,IACzCC,QAAQC,MAAM,oCAAqCF,OAMzD,mBCTWG,EAAyBC,EAAAA,oBAAoBC,EAAAA,wBACvDC,WAAWC,GACXC"}
@@ -1,5 +0,0 @@
1
- export * from './hooks';
2
- export * from './components';
3
- export * from './types';
4
- export * from '../lib/index.ts';
5
- export declare const SelectionPluginPackage: import('@embedpdf/core').WithAutoMount<import('@embedpdf/core').PluginPackage<import('../lib/index.ts').SelectionPlugin, import('../lib/index.ts').SelectionPluginConfig, import('../lib/index.ts').SelectionState, import('src/lib/actions').SelectionAction>>;