@embedpdf/plugin-selection 1.4.0 → 1.4.1
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/svelte/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection");require("svelte/internal/disclose-version");const i=require("svelte/internal/client"),o=require("@embedpdf/core/svelte");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection");require("svelte/internal/disclose-version");const i=require("svelte/internal/client"),o=require("@embedpdf/core/svelte");function n(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const i in e)if("default"!==i){const o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:()=>e[i]})}return t.default=e,Object.freeze(t)}const r=n(i),l=()=>o.useCapability(t.SelectionPlugin.id),s=()=>o.usePlugin(t.SelectionPlugin.id);var c=r.from_html("<div></div>"),a=r.from_html("<div></div>");function p(e,t){r.push(t,!0);const i=l();r.user_effect((()=>{if(i.provides)return i.provides.onCopyToClipboard((e=>{navigator.clipboard.writeText(e).catch((e=>{console.error("Failed to copy text to clipboard:",e)}))}))})),r.pop()}const g=e.createPluginPackage(t.SelectionPluginPackage).addUtility(p).build();exports.CopyToClipboard=p,exports.SelectionLayer=function(e,t){r.push(t,!0);let i=r.prop(t,"background",3,"rgba(33, 150, 243, 0.4)");const o=s();let n=r.state(r.proxy([])),l=r.state(null);r.user_effect((()=>{const e=t.pageIndex;if(o.plugin)return o.plugin.registerSelectionOnPage({pageIndex:e,onRectsChange:({rects:e,boundingRect:t})=>{r.set(n,e,!0),r.set(l,t,!0)}})}));var p=r.comment(),g=r.first_child(p),u=e=>{var o=a();let s;r.each(o,21,(()=>r.get(n)),r.index,((e,o)=>{var n=c();let s;r.template_effect((e=>s=r.set_style(n,"",s,e)),[()=>({position:"absolute",left:(r.get(o).origin.x-r.get(l).origin.x)*t.scale+"px",top:(r.get(o).origin.y-r.get(l).origin.y)*t.scale+"px",width:r.get(o).size.width*t.scale+"px",height:r.get(o).size.height*t.scale+"px",background:i(),"pointer-events":"none"})]),r.append(e,n)})),r.reset(o),r.template_effect((e=>s=r.set_style(o,"",s,e)),[()=>({position:"absolute",left:r.get(l).origin.x*t.scale+"px",top:r.get(l).origin.y*t.scale+"px",width:r.get(l).size.width*t.scale+"px",height:r.get(l).size.height*t.scale+"px","mix-blend-mode":"multiply",isolation:"isolate","pointer-events":"none"})]),r.append(e,o)};r.if(g,(e=>{r.get(l)&&e(u)})),r.append(e,p),r.pop()},exports.SelectionPluginPackage=g,exports.useSelectionCapability=l,exports.useSelectionPlugin=s,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../src/svelte/components/CopyToClipboard.svelte","../../src/svelte/index.ts","../../src/svelte/components/SelectionLayer.svelte"],"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 { useSelectionCapability } from '../hooks/use-selection.svelte';\n\n const
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../src/svelte/components/CopyToClipboard.svelte","../../src/svelte/index.ts","../../src/svelte/components/SelectionLayer.svelte"],"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 { 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 '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n","<script lang=\"ts\">\n import type { Rect } from '@embedpdf/models';\n import { useSelectionPlugin } from '../hooks/use-selection.svelte';\n\n interface SelectionLayerProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Background color for selection rectangles */\n background?: string;\n }\n\n let { pageIndex, scale, background = 'rgba(33, 150, 243, 0.4)' }: SelectionLayerProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n // Track pageIndex as dependency\n const _pageIndex = pageIndex;\n\n if (!selectionPlugin.plugin) return;\n\n return selectionPlugin.plugin.registerSelectionOnPage({\n pageIndex: _pageIndex,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects = newRects;\n boundingRect = newBoundingRect;\n },\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:position=\"absolute\"\n style:left={`${boundingRect.origin.x * scale}px`}\n style:top={`${boundingRect.origin.y * scale}px`}\n style:width={`${boundingRect.size.width * scale}px`}\n style:height={`${boundingRect.size.height * scale}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) * scale}px`}\n style:top={`${(rect.origin.y - boundingRect.origin.y) * scale}px`}\n style:width={`${rect.size.width * scale}px`}\n style:height={`${rect.size.height * scale}px`}\n style:background\n style:pointer-events=\"none\"\n ></div>\n {/each}\n </div>\n{/if}\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","useSelectionPlugin","usePlugin","selectionCapability","$","user_effect","provides","onCopyToClipboard","text","navigator","clipboard","writeText","catch","err","console","error","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","CopyToClipboard","build","background","selectionPlugin","rects","state","proxy","boundingRect","_pageIndex","$$props","pageIndex","plugin","registerSelectionOnPage","onRectsChange","newRects","newBoundingRect","$__namespace","set","each","div","get","rect","origin","x","scale","y","size","width","height","consequent"],"mappings":"2iBAOaA,EAA+B,IAAAC,gBAA+BC,EAAAA,gBAAgBC,IAM9EC,EAA2B,IAAAC,YAA2BH,EAAAA,gBAAgBC,+FCV3E,MAAAG,EAAsBN,IAE5BO,EAAAC,aAAc,KACP,GAAAF,EAAoBG,SAElB,OAAAH,EAAoBG,SAASC,mBAAmBC,IACrDC,UAAUC,UAAUC,UAAUH,GAAMI,OAAOC,IACjCC,QAAAC,MAAM,oCAAqCF,EAAG,GACvD,GACF,WAEL,CCLO,MAAMG,EAAyBC,EAAoBA,oBAAAC,EAA0BF,wBACjFG,WAAWC,GACXC,oFCEuB,IAAAC,0BAAa,2BAE/B,MAAAC,EAAkBtB,QACpBuB,EAAKpB,EAAAqB,MAAArB,EAAAsB,MAAA,KACLC,UAAmC,MAEvCvB,EAAAC,aAAc,WAENuB,EAAUC,EAAAC,UAEX,GAAAP,EAAgBQ,OAEd,OAAAR,EAAgBQ,OAAOC,wBAAuB,CACnDF,UAAWF,EACXK,cAAa,EAAKT,MAAOU,EAAUP,aAAcQ,MAC/CC,EAAAC,IAAAb,EAAQU,GAAQ,GAChBE,EAAAC,IAAAV,EAAeQ,GAAe,EAAA,kEAiB3B/B,EAAAkC,KAAAC,EAAA,IAAA,IAAAnC,EAAAoC,IAAAhB,gBAASiB,2GAGIA,GAAKC,OAAOC,QAAIhB,GAAae,OAAOC,GAACd,EAAAe,sBACtCH,GAAKC,OAAOG,QAAIlB,GAAae,OAAOG,GAAChB,EAAAe,uBACpCH,GAAKK,KAAKC,MAAKlB,EAAAe,wBACdH,GAAKK,KAAKE,OAAMnB,EAAAe,uKAdtBjB,GAAae,OAAOC,EAACd,EAAAe,qBACtBjB,GAAae,OAAOG,EAAChB,EAAAe,uBACnBjB,GAAamB,KAAKC,MAAKlB,EAAAe,wBACtBjB,GAAamB,KAAKE,OAAMnB,EAAAe,wHANxCjB,MAAYsB,EAAA,yBAFjB"}
|
package/dist/svelte/index.js
CHANGED
|
@@ -11,13 +11,13 @@ var root_1 = $.from_html(`<div></div>`);
|
|
|
11
11
|
function SelectionLayer($$anchor, $$props) {
|
|
12
12
|
$.push($$props, true);
|
|
13
13
|
let background = $.prop($$props, "background", 3, "rgba(33, 150, 243, 0.4)");
|
|
14
|
-
const
|
|
14
|
+
const selectionPlugin = useSelectionPlugin();
|
|
15
15
|
let rects = $.state($.proxy([]));
|
|
16
16
|
let boundingRect = $.state(null);
|
|
17
17
|
$.user_effect(() => {
|
|
18
18
|
const _pageIndex = $$props.pageIndex;
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
19
|
+
if (!selectionPlugin.plugin) return;
|
|
20
|
+
return selectionPlugin.plugin.registerSelectionOnPage({
|
|
21
21
|
pageIndex: _pageIndex,
|
|
22
22
|
onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {
|
|
23
23
|
$.set(rects, newRects, true);
|
|
@@ -71,10 +71,10 @@ function SelectionLayer($$anchor, $$props) {
|
|
|
71
71
|
}
|
|
72
72
|
function CopyToClipboard($$anchor, $$props) {
|
|
73
73
|
$.push($$props, true);
|
|
74
|
-
const
|
|
74
|
+
const selectionCapability = useSelectionCapability();
|
|
75
75
|
$.user_effect(() => {
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
76
|
+
if (!selectionCapability.provides) return;
|
|
77
|
+
return selectionCapability.provides.onCopyToClipboard((text) => {
|
|
78
78
|
navigator.clipboard.writeText(text).catch((err) => {
|
|
79
79
|
console.error("Failed to copy text to clipboard:", err);
|
|
80
80
|
});
|
package/dist/svelte/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../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 { Rect } from '@embedpdf/models';\n import { useSelectionPlugin } from '../hooks/use-selection.svelte';\n\n interface SelectionLayerProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Background color for selection rectangles */\n background?: string;\n }\n\n let { pageIndex, scale, background = 'rgba(33, 150, 243, 0.4)' }: SelectionLayerProps = $props();\n\n const
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/svelte/hooks/use-selection.svelte.ts","../../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 { Rect } from '@embedpdf/models';\n import { useSelectionPlugin } from '../hooks/use-selection.svelte';\n\n interface SelectionLayerProps {\n /** Index of the page this layer lives on */\n pageIndex: number;\n /** Scale of the page */\n scale: number;\n /** Background color for selection rectangles */\n background?: string;\n }\n\n let { pageIndex, scale, background = 'rgba(33, 150, 243, 0.4)' }: SelectionLayerProps = $props();\n\n const selectionPlugin = useSelectionPlugin();\n let rects = $state<Rect[]>([]);\n let boundingRect = $state<Rect | null>(null);\n\n $effect(() => {\n // Track pageIndex as dependency\n const _pageIndex = pageIndex;\n\n if (!selectionPlugin.plugin) return;\n\n return selectionPlugin.plugin.registerSelectionOnPage({\n pageIndex: _pageIndex,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects = newRects;\n boundingRect = newBoundingRect;\n },\n });\n });\n</script>\n\n{#if boundingRect}\n <div\n style:position=\"absolute\"\n style:left={`${boundingRect.origin.x * scale}px`}\n style:top={`${boundingRect.origin.y * scale}px`}\n style:width={`${boundingRect.size.width * scale}px`}\n style:height={`${boundingRect.size.height * scale}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) * scale}px`}\n style:top={`${(rect.origin.y - boundingRect.origin.y) * scale}px`}\n style:width={`${rect.size.width * scale}px`}\n style:height={`${rect.size.height * scale}px`}\n style:background\n style:pointer-events=\"none\"\n ></div>\n {/each}\n </div>\n{/if}\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 '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n"],"names":["BaseSelectionPluginPackage"],"mappings":";;;;;;AAOa,MAAA,yBAA+B,MAAA,cAA+B,gBAAgB,EAAE;AAMhF,MAAA,qBAA2B,MAAA,UAA2B,gBAAgB,EAAE;;;2CCbrF;;AAa0B,MAAA,8CAAa,yBAAyB;AAExD,QAAA,kBAAkB,mBAAkB;MACtC,QAAK,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA;AACL,MAAA,uBAAmC,IAAI;AAE3C,IAAA,YAAc,MAAA;UAEN,aAAU,QAAA;AAEX,QAAA,CAAA,gBAAgB,OAAM;WAEpB,gBAAgB,OAAO,wBAAuB;AAAA,MAC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1.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@embedpdf/models": "1.4.
|
|
37
|
+
"@embedpdf/models": "1.4.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/react": "^18.2.0",
|
|
41
41
|
"typescript": "^5.0.0",
|
|
42
|
-
"@embedpdf/core": "1.4.0",
|
|
43
|
-
"@embedpdf/plugin-viewport": "1.4.0",
|
|
44
42
|
"@embedpdf/build": "1.1.0",
|
|
45
|
-
"@embedpdf/
|
|
43
|
+
"@embedpdf/core": "1.4.1",
|
|
44
|
+
"@embedpdf/plugin-interaction-manager": "1.4.1",
|
|
45
|
+
"@embedpdf/plugin-viewport": "1.4.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": ">=16.8.0",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"preact": "^10.26.4",
|
|
51
51
|
"vue": ">=3.2.0",
|
|
52
52
|
"svelte": ">=5 <6",
|
|
53
|
-
"@embedpdf/core": "1.4.
|
|
54
|
-
"@embedpdf/plugin-
|
|
55
|
-
"@embedpdf/plugin-
|
|
53
|
+
"@embedpdf/core": "1.4.1",
|
|
54
|
+
"@embedpdf/plugin-viewport": "1.4.1",
|
|
55
|
+
"@embedpdf/plugin-interaction-manager": "1.4.1"
|
|
56
56
|
},
|
|
57
57
|
"files": [
|
|
58
58
|
"dist",
|