@embedpdf/plugin-selection 1.0.20 → 1.0.22

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.
@@ -28,6 +28,14 @@ export interface FormattedSelection {
28
28
  rect: Rect;
29
29
  segmentRects: Rect[];
30
30
  }
31
+ export interface SelectionRectsCallback {
32
+ rects: Rect[];
33
+ boundingRect: Rect | null;
34
+ }
35
+ export interface RegisterSelectionOnPageOptions {
36
+ pageIndex: number;
37
+ onRectsChange: (data: SelectionRectsCallback) => void;
38
+ }
31
39
  export interface SelectionCapability {
32
40
  getGeometry(page: number): PdfTask<PdfPageGeometry>;
33
41
  getFormattedSelection(): FormattedSelection[];
@@ -60,4 +68,6 @@ export interface SelectionCapability {
60
68
  isEnabledForMode(modeId: string): boolean;
61
69
  /** Get the current state of the selection plugin. */
62
70
  getState(): SelectionState;
71
+ /** Register selection handlers for a specific page */
72
+ registerSelectionOnPage: (opts: RegisterSelectionOnPageOptions) => () => void;
63
73
  }
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/preact"),t=require("@embedpdf/plugin-selection"),r=require("preact/jsx-runtime");require("preact");const i=require("preact/hooks"),n=require("@embedpdf/models"),o=require("@embedpdf/plugin-interaction-manager/preact"),s=()=>e.useCapability(t.SelectionPlugin.id),u=()=>e.usePlugin(t.SelectionPlugin.id);exports.CopyToClipboard=function(){const{provides:e}=s();return i.useEffect((()=>{if(e)return e.onCopyToClipboard((e=>{navigator.clipboard.writeText(e)}))}),[e]),null},exports.SelectionLayer=function({pageIndex:e,scale:l,background:a="rgba(33,150,243)"}){const{provides:c}=s(),{plugin:d}=u(),{provides:g}=o.useInteractionManagerCapability(),{register:p}=o.usePointerHandlers({pageIndex:e}),[f,b]=i.useState([]),[h,y]=i.useState(null),{setCursor:x,removeCursor:m}=o.useCursor(),C=i.useRef(null);i.useEffect((()=>{if(c)return c.onSelectionChange((()=>{"pointerMode"===(null==g?void 0:g.getActiveMode())?(b(c.getHighlightRectsForPage(e)),y(c.getBoundingRectForPage(e))):(b([]),y(null))}))}),[c,e]);const v=i.useCallback((e=>{const r=C.current;return r?t.glyphAt(r,e):-1}),[]);i.useEffect((()=>{if(!c)return;const t=c.getGeometry(e);return t.wait((e=>C.current=e),n.ignore),()=>{t.abort({code:n.PdfErrorCode.Cancelled,message:"Cancelled"}),C.current=null}}),[c,e]),i.useEffect((()=>{if(d&&c)return d.onRefreshPages((t=>{if(t.includes(e)){c.getGeometry(e).wait((e=>C.current=e),n.ignore)}}))}),[c,d,e]);const P=i.useMemo((()=>({onPointerDown:(r,i,o)=>{if(!c)return;if(!c.isEnabledForMode(o))return;c.clear();c.getGeometry(e).wait((i=>{const n=t.glyphAt(i,r);-1!==n&&c.begin(e,n)}),n.ignore)},onPointerMove:(t,r,i)=>{if(!c)return;if(!c.isEnabledForMode(i))return;const n=v(t);-1!==n?x("selection-text","text",10):m("selection-text"),-1!==n&&c.update(e,n)},onPointerUp:(e,t,r)=>{c&&c.isEnabledForMode(r)&&c.end()},onHandlerActiveEnd(e){c&&c.isEnabledForMode(e)&&c.clear()}})),[c,e,v]);return i.useEffect((()=>{if(p)return p(P)}),[p,P]),h?r.jsx("div",{style:{position:"absolute",left:h.origin.x*l,top:h.origin.y*l,width:h.size.width*l,height:h.size.height*l,mixBlendMode:"multiply",isolation:"isolate"},children:f.map(((e,t)=>r.jsx("div",{style:{position:"absolute",left:(e.origin.x-h.origin.x)*l,top:(e.origin.y-h.origin.y)*l,width:e.size.width*l,height:e.size.height*l,background:a,pointerEvents:"none"}},t)))}):null},exports.useSelectionCapability=s,exports.useSelectionPlugin=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection"),i=require("preact/jsx-runtime");require("preact");const o=require("preact/hooks"),r=require("@embedpdf/core/preact"),n=()=>r.useCapability(t.SelectionPlugin.id);function l(){const{provides:e}=n();return o.useEffect((()=>{if(e)return e.onCopyToClipboard((e=>{navigator.clipboard.writeText(e)}))}),[e]),null}const s=e.createPluginPackage(t.SelectionPluginPackage).addUtility(l).build();exports.CopyToClipboard=l,exports.SelectionLayer=function({pageIndex:e,scale:t,background:r="rgba(33,150,243)"}){const{provides:l}=n(),[s,a]=o.useState([]),[u,c]=o.useState(null);return o.useEffect((()=>{if(l)return l.registerSelectionOnPage({pageIndex:e,onRectsChange:({rects:e,boundingRect:t})=>{a(e),c(t)}})}),[l,e]),u?i.jsx("div",{style:{position:"absolute",left:u.origin.x*t,top:u.origin.y*t,width:u.size.width*t,height:u.size.height*t,mixBlendMode:"multiply",isolation:"isolate"},children:s.map(((e,o)=>i.jsx("div",{style:{position:"absolute",left:(e.origin.x-u.origin.x)*t,top:(e.origin.y-u.origin.y)*t,width:e.size.width*t,height:e.size.height*t,background:r,pointerEvents:"none"}},o)))}):null},exports.SelectionPluginPackage=s,exports.useSelectionCapability=n,exports.useSelectionPlugin=()=>r.usePlugin(t.SelectionPlugin.id),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/shared/hooks/use-selection.ts","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/components/selection-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect } from '@framework';\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","import { useCallback, useEffect, useMemo, useRef, useState } from '@framework';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Position, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/@framework';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability, useSelectionPlugin } 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 { plugin: selectionPlugin } = useSelectionPlugin();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const { setCursor, removeCursor } = useCursor();\n const geoCacheRef = useRef<PdfPageGeometry | null>(null);\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'pointerMode') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n setBoundingRect(sel.getBoundingRectForPage(pageIndex));\n } else {\n setRects([]);\n setBoundingRect(null);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n const cachedGlyphAt = useCallback((pt: Position) => {\n const geo = geoCacheRef.current;\n return geo ? glyphAt(geo, pt) : -1;\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n geoCacheRef.current = null;\n };\n }, [sel, pageIndex]);\n\n useEffect(() => {\n if (!selectionPlugin || !sel) return;\n return selectionPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n }\n });\n }, [sel, selectionPlugin, 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 if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","useSelectionPlugin","usePlugin","provides","sel","useEffect","onCopyToClipboard","text","navigator","clipboard","writeText","pageIndex","scale","background","plugin","selectionPlugin","im","useInteractionManagerCapability","register","usePointerHandlers","rects","setRects","useState","boundingRect","setBoundingRect","setCursor","removeCursor","useCursor","geoCacheRef","useRef","onSelectionChange","getActiveMode","getHighlightRectsForPage","getBoundingRectForPage","cachedGlyphAt","useCallback","pt","geo","current","glyphAt","task","getGeometry","wait","g","ignore","abort","code","PdfErrorCode","Cancelled","message","onRefreshPages","pages","includes","handlers","useMemo","onPointerDown","point","_evt","modeId","isEnabledForMode","clear","begin","onPointerMove","update","onPointerUp","_point","end","onHandlerActiveEnd","jsxRuntime","jsx","style","position","left","origin","x","top","y","width","size","height","mixBlendMode","isolation","children","map","b","i","pointerEvents"],"mappings":"0UAGaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,IAC9EC,EAAqB,IAAMC,YAA2BH,EAAAA,gBAAgBC,4BCA5E,WACL,MAAQG,SAAUC,GAAQP,IASnB,OAPPQ,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAIE,mBAAmBC,IAClBC,UAAAC,UAAUC,UAAUH,EAAI,GACnC,GACA,CAACH,IAEG,IACT,yBCGO,UAAwBO,UAAEA,EAAAC,MAAWA,EAAOC,WAAAA,EAAa,qBAC9D,MAAQV,SAAUC,GAAQP,KAClBiB,OAAQC,GAAoBd,KAC5BE,SAAUa,GAAOC,qCACnBC,SAAEA,GAAaC,qBAAmB,CAAER,eACnCS,EAAOC,GAAYC,EAAAA,SAAsB,KACzCC,EAAcC,GAAmBF,EAAAA,SAAsB,OACxDG,UAAEA,EAAAC,aAAWA,GAAiBC,cAC9BC,EAAcC,SAA+B,MAGnDxB,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAI0B,mBAAkB,KAEd,iBADI,MAAJd,OAAI,EAAAA,EAAAe,kBAENV,EAAAjB,EAAI4B,yBAAyBrB,IACtBa,EAAApB,EAAI6B,uB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D,GACAA,EAAIuD,iBAAiBD,IAC1BtD,EAAI8D,KAAI,EAEV,kBAAAC,CAAmBT,GACZtD,GACAA,EAAIuD,iBAAiBD,IAE1BtD,EAAIwD,OAAM,KAGd,CAACxD,EAAKO,EAAWuB,IAQf,OALJ7B,EAAAA,WAAU,KACR,GAAKa,EACL,OAAOA,EAASmC,EAAQ,GACvB,CAACnC,EAAUmC,IAET9B,EAGH6C,EAAAC,IAAC,MAAA,CACCC,MAAO,CACLC,SAAU,WACVC,KAAMjD,EAAakD,OAAOC,EAAI9D,EAC9B+D,IAAKpD,EAAakD,OAAOG,EAAIhE,EAC7BiE,MAAOtD,EAAauD,KAAKD,MAAQjE,EACjCmE,OAAQxD,EAAauD,KAAKC,OAASnE,EACnCoE,aAAc,WACdC,UAAW,WAGZC,SAAM9D,EAAA+D,KAAI,CAACC,EAAGC,IACbjB,EAAAC,IAAC,MAAA,CAECC,MAAO,CACLC,SAAU,WACVC,MAAOY,EAAEX,OAAOC,EAAInD,EAAakD,OAAOC,GAAK9D,EAC7C+D,KAAMS,EAAEX,OAAOG,EAAIrD,EAAakD,OAAOG,GAAKhE,EAC5CiE,MAAOO,EAAEN,KAAKD,MAAQjE,EACtBmE,OAAQK,EAAEN,KAAKC,OAASnE,EACxBC,aACAyE,cAAe,SARZD,OAhBa,IA8B5B"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/index.ts","../../src/shared/components/selection-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect } from '@framework';\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","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","import { useEffect, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\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 [rects, setRects] = useState<Rect[]>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n\n useEffect(() => {\n if (!sel) return;\n\n return sel.registerSelectionOnPage({\n pageIndex,\n onRectsChange: ({ rects, boundingRect }) => {\n setRects(rects);\n setBoundingRect(boundingRect);\n },\n });\n }, [sel, pageIndex]);\n\n if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","CopyToClipboard","provides","sel","useEffect","onCopyToClipboard","text","navigator","clipboard","writeText","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","build","pageIndex","scale","background","rects","setRects","useState","boundingRect","setBoundingRect","registerSelectionOnPage","onRectsChange","jsxRuntime","jsx","style","position","left","origin","x","top","y","width","size","height","mixBlendMode","isolation","children","map","b","i","pointerEvents","usePlugin"],"mappings":"+QAGaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,ICCpF,SAASC,IACd,MAAQC,SAAUC,GAAQN,IASnB,OAPPO,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAIE,mBAAmBC,IAClBC,UAAAC,UAAUC,UAAUH,EAAI,GACnC,GACA,CAACH,IAEG,IACT,CCNO,MAAMO,EAAyBC,EAAoBA,oBAAAC,EAA0BF,wBACjFG,WAAWZ,GACXa,yDCDI,UAAwBC,UAAEA,EAAAC,MAAWA,EAAOC,WAAAA,EAAa,qBAC9D,MAAQf,SAAUC,GAAQN,KACnBqB,EAAOC,GAAYC,EAAAA,SAAiB,KACpCC,EAAcC,GAAmBF,EAAAA,SAAsB,MAc1D,OAZJhB,EAAAA,WAAU,KACR,GAAKD,EAEL,OAAOA,EAAIoB,wBAAwB,CACjCR,YACAS,cAAe,EAAGN,MAAAA,EAAOG,aAAAA,MACvBF,EAASD,GACTI,EAAgBD,EAAY,GAE/B,GACA,CAAClB,EAAKY,IAEJM,EAGHI,EAAAC,IAAC,MAAA,CACCC,MAAO,CACLC,SAAU,WACVC,KAAMR,EAAaS,OAAOC,EAAIf,EAC9BgB,IAAKX,EAAaS,OAAOG,EAAIjB,EAC7BkB,MAAOb,EAAac,KAAKD,MAAQlB,EACjCoB,OAAQf,EAAac,KAAKC,OAASpB,EACnCqB,aAAc,WACdC,UAAW,WAGZC,SAAMrB,EAAAsB,KAAI,CAACC,EAAGC,IACbjB,EAAAC,IAAC,MAAA,CAECC,MAAO,CACLC,SAAU,WACVC,MAAOY,EAAEX,OAAOC,EAAIV,EAAaS,OAAOC,GAAKf,EAC7CgB,KAAMS,EAAEX,OAAOG,EAAIZ,EAAaS,OAAOG,GAAKjB,EAC5CkB,MAAOO,EAAEN,KAAKD,MAAQlB,EACtBoB,OAAQK,EAAEN,KAAKC,OAASpB,EACxBC,aACA0B,cAAe,SARZD,OAhBa,IA8B5B,+FHrDkC,IAAME,YAA2B7C,EAAAA,gBAAgBC"}
@@ -1,99 +1,26 @@
1
- import { useCapability, usePlugin } from "@embedpdf/core/preact";
2
- import { SelectionPlugin, glyphAt } from "@embedpdf/plugin-selection";
1
+ import { createPluginPackage } from "@embedpdf/core";
2
+ import { SelectionPlugin, SelectionPluginPackage as SelectionPluginPackage$1 } from "@embedpdf/plugin-selection";
3
+ export * from "@embedpdf/plugin-selection";
3
4
  import { jsx } from "preact/jsx-runtime";
4
5
  import "preact";
5
- import { useState, useRef, useEffect, useCallback, useMemo } from "preact/hooks";
6
- import { ignore, PdfErrorCode } from "@embedpdf/models";
7
- import { useInteractionManagerCapability, usePointerHandlers, useCursor } from "@embedpdf/plugin-interaction-manager/preact";
6
+ import { useState, useEffect } from "preact/hooks";
7
+ import { useCapability, usePlugin } from "@embedpdf/core/preact";
8
8
  const useSelectionCapability = () => useCapability(SelectionPlugin.id);
9
9
  const useSelectionPlugin = () => usePlugin(SelectionPlugin.id);
10
10
  function SelectionLayer({ pageIndex, scale, background = "rgba(33,150,243)" }) {
11
11
  const { provides: sel } = useSelectionCapability();
12
- const { plugin: selectionPlugin } = useSelectionPlugin();
13
- const { provides: im } = useInteractionManagerCapability();
14
- const { register } = usePointerHandlers({ pageIndex });
15
12
  const [rects, setRects] = useState([]);
16
13
  const [boundingRect, setBoundingRect] = useState(null);
17
- const { setCursor, removeCursor } = useCursor();
18
- const geoCacheRef = useRef(null);
19
14
  useEffect(() => {
20
15
  if (!sel) return;
21
- return sel.onSelectionChange(() => {
22
- const mode = im == null ? void 0 : im.getActiveMode();
23
- if (mode === "pointerMode") {
24
- setRects(sel.getHighlightRectsForPage(pageIndex));
25
- setBoundingRect(sel.getBoundingRectForPage(pageIndex));
26
- } else {
27
- setRects([]);
28
- setBoundingRect(null);
16
+ return sel.registerSelectionOnPage({
17
+ pageIndex,
18
+ onRectsChange: ({ rects: rects2, boundingRect: boundingRect2 }) => {
19
+ setRects(rects2);
20
+ setBoundingRect(boundingRect2);
29
21
  }
30
22
  });
31
23
  }, [sel, pageIndex]);
32
- const cachedGlyphAt = useCallback((pt) => {
33
- const geo = geoCacheRef.current;
34
- return geo ? glyphAt(geo, pt) : -1;
35
- }, []);
36
- useEffect(() => {
37
- if (!sel) return;
38
- const task = sel.getGeometry(pageIndex);
39
- task.wait((g) => geoCacheRef.current = g, ignore);
40
- return () => {
41
- task.abort({
42
- code: PdfErrorCode.Cancelled,
43
- message: "Cancelled"
44
- });
45
- geoCacheRef.current = null;
46
- };
47
- }, [sel, pageIndex]);
48
- useEffect(() => {
49
- if (!selectionPlugin || !sel) return;
50
- return selectionPlugin.onRefreshPages((pages) => {
51
- if (pages.includes(pageIndex)) {
52
- const task = sel.getGeometry(pageIndex);
53
- task.wait((g) => geoCacheRef.current = g, ignore);
54
- }
55
- });
56
- }, [sel, selectionPlugin, pageIndex]);
57
- const handlers = useMemo(
58
- () => ({
59
- onPointerDown: (point, _evt, modeId) => {
60
- if (!sel) return;
61
- if (!sel.isEnabledForMode(modeId)) return;
62
- sel.clear();
63
- const task = sel.getGeometry(pageIndex);
64
- task.wait((geo) => {
65
- const g = glyphAt(geo, point);
66
- if (g !== -1) sel.begin(pageIndex, g);
67
- }, ignore);
68
- },
69
- onPointerMove: (point, _evt, modeId) => {
70
- if (!sel) return;
71
- if (!sel.isEnabledForMode(modeId)) return;
72
- const g = cachedGlyphAt(point);
73
- if (g !== -1) {
74
- setCursor("selection-text", "text", 10);
75
- } else {
76
- removeCursor("selection-text");
77
- }
78
- if (g !== -1) sel.update(pageIndex, g);
79
- },
80
- onPointerUp: (_point, _evt, modeId) => {
81
- if (!sel) return;
82
- if (!sel.isEnabledForMode(modeId)) return;
83
- sel.end();
84
- },
85
- onHandlerActiveEnd(modeId) {
86
- if (!sel) return;
87
- if (!sel.isEnabledForMode(modeId)) return;
88
- sel.clear();
89
- }
90
- }),
91
- [sel, pageIndex, cachedGlyphAt]
92
- );
93
- useEffect(() => {
94
- if (!register) return;
95
- return register(handlers);
96
- }, [register, handlers]);
97
24
  if (!boundingRect) return null;
98
25
  return /* @__PURE__ */ jsx(
99
26
  "div",
@@ -135,9 +62,11 @@ function CopyToClipboard() {
135
62
  }, [sel]);
136
63
  return null;
137
64
  }
65
+ const SelectionPluginPackage = createPluginPackage(SelectionPluginPackage$1).addUtility(CopyToClipboard).build();
138
66
  export {
139
67
  CopyToClipboard,
140
68
  SelectionLayer,
69
+ SelectionPluginPackage,
141
70
  useSelectionCapability,
142
71
  useSelectionPlugin
143
72
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/selection-layer.tsx","../../src/shared/components/copy-to-clipboard.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\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, useRef, useState } from '@framework';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Position, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/@framework';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability, useSelectionPlugin } 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 { plugin: selectionPlugin } = useSelectionPlugin();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const { setCursor, removeCursor } = useCursor();\n const geoCacheRef = useRef<PdfPageGeometry | null>(null);\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'pointerMode') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n setBoundingRect(sel.getBoundingRectForPage(pageIndex));\n } else {\n setRects([]);\n setBoundingRect(null);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n const cachedGlyphAt = useCallback((pt: Position) => {\n const geo = geoCacheRef.current;\n return geo ? glyphAt(geo, pt) : -1;\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n geoCacheRef.current = null;\n };\n }, [sel, pageIndex]);\n\n useEffect(() => {\n if (!selectionPlugin || !sel) return;\n return selectionPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n }\n });\n }, [sel, selectionPlugin, 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 if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n","import { useEffect } from '@framework';\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"],"names":[],"mappings":";;;;;;;AAGO,MAAM,yBAAyB,MAAM,cAA+B,gBAAgB,EAAE;AACtF,MAAM,qBAAqB,MAAM,UAA2B,gBAAgB,EAAE;ACc9E,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,sBAA6B;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,EAAE,QAAQ,gBAAgB,IAAI,mBAAmB;AACvD,QAAM,EAAE,UAAU,GAAG,IAAI,gCAAgC;AACzD,QAAM,EAAE,SAAS,IAAI,mBAAmB,EAAE,WAAW;AACrD,QAAM,CAAC,OAAO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AAK,aAAa,OAAO,IAAI;AAAA,QAC7B,OAAO,aAAa,KAAK,QAAQ;AAAA,QACjC,QAAQ,aAAa,KAAK,SAAS;AAAA,QACnC,cAAc;AAAA,QACd,WAAW;AAAA,MACb;AAAA,MAEC,UAAM,MAAA,IAAI,CAAC,GAAG,MACb;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,OAAO;AAAA,YACL,UAAU;AAAA,YACV,OAAO,EAAE,OAAO,IAAI,aAAa,OAAO,KAAK;AAAA,YAC7C,MAAM,EAAE,OAAO,IAAI,aAAa,OAAO,KAAK;AAAA,YAC5C,OAAO,EAAE,KAAK,QAAQ;AAAA,YACtB,QAAQ,EAAE,KAAK,SAAS;AAAA,YACxB;AAAA,YACA,eAAe;AAAA,UAAA;AAAA,QACjB;AAAA,QATK;AAAA,MAWR,CAAA;AAAA,IAAA;AAAA,EACH;AAEJ;AChJO,SAAS,kBAAkB;AAChC,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AAEjD,YAAU,MAAM;AACd,QAAI,CAAC,IAAK;AACH,WAAA,IAAI,kBAAkB,CAAC,SAAS;AAC3B,gBAAA,UAAU,UAAU,IAAI;AAAA,IAAA,CACnC;AAAA,EAAA,GACA,CAAC,GAAG,CAAC;AAED,SAAA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/selection-layer.tsx","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\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 [rects, setRects] = useState<Rect[]>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n\n useEffect(() => {\n if (!sel) return;\n\n return sel.registerSelectionOnPage({\n pageIndex,\n onRectsChange: ({ rects, boundingRect }) => {\n setRects(rects);\n setBoundingRect(boundingRect);\n },\n });\n }, [sel, pageIndex]);\n\n if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n","import { useEffect } from '@framework';\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","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":["rects","boundingRect","BaseSelectionPluginPackage"],"mappings":";;;;;;;AAGO,MAAM,yBAAyB,MAAM,cAA+B,gBAAgB,EAAE;AACtF,MAAM,qBAAqB,MAAM,UAA2B,gBAAgB,EAAE;ACM9E,SAAS,eAAe,EA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IAAK;AACH,WAAA,IAAI,kBAAkB,CAAC,SAAS;AAC3B,gBAAA,UAAU,UAAU,IAAI;AAAA,IAAA,CACnC;AAAA,EAAA,GACA,CAAC,GAAG,CAAC;AAED,SAAA;AACT;ACNO,MAAM,yBAAyB,oBAAoBC,wBAA0B,EACjF,WAAW,eAAe,EAC1B,MAAM;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-selection"),r=require("react/jsx-runtime"),i=require("react"),n=require("@embedpdf/models"),o=require("@embedpdf/plugin-interaction-manager/react"),s=()=>e.useCapability(t.SelectionPlugin.id),l=()=>e.usePlugin(t.SelectionPlugin.id);exports.CopyToClipboard=function(){const{provides:e}=s();return i.useEffect((()=>{if(e)return e.onCopyToClipboard((e=>{navigator.clipboard.writeText(e)}))}),[e]),null},exports.SelectionLayer=function({pageIndex:e,scale:u,background:a="rgba(33,150,243)"}){const{provides:d}=s(),{plugin:c}=l(),{provides:g}=o.useInteractionManagerCapability(),{register:p}=o.usePointerHandlers({pageIndex:e}),[f,b]=i.useState([]),[h,y]=i.useState(null),{setCursor:x,removeCursor:m}=o.useCursor(),C=i.useRef(null);i.useEffect((()=>{if(d)return d.onSelectionChange((()=>{"pointerMode"===(null==g?void 0:g.getActiveMode())?(b(d.getHighlightRectsForPage(e)),y(d.getBoundingRectForPage(e))):(b([]),y(null))}))}),[d,e]);const v=i.useCallback((e=>{const r=C.current;return r?t.glyphAt(r,e):-1}),[]);i.useEffect((()=>{if(!d)return;const t=d.getGeometry(e);return t.wait((e=>C.current=e),n.ignore),()=>{t.abort({code:n.PdfErrorCode.Cancelled,message:"Cancelled"}),C.current=null}}),[d,e]),i.useEffect((()=>{if(c&&d)return c.onRefreshPages((t=>{if(t.includes(e)){d.getGeometry(e).wait((e=>C.current=e),n.ignore)}}))}),[d,c,e]);const P=i.useMemo((()=>({onPointerDown:(r,i,o)=>{if(!d)return;if(!d.isEnabledForMode(o))return;d.clear();d.getGeometry(e).wait((i=>{const n=t.glyphAt(i,r);-1!==n&&d.begin(e,n)}),n.ignore)},onPointerMove:(t,r,i)=>{if(!d)return;if(!d.isEnabledForMode(i))return;const n=v(t);-1!==n?x("selection-text","text",10):m("selection-text"),-1!==n&&d.update(e,n)},onPointerUp:(e,t,r)=>{d&&d.isEnabledForMode(r)&&d.end()},onHandlerActiveEnd(e){d&&d.isEnabledForMode(e)&&d.clear()}})),[d,e,v]);return i.useEffect((()=>{if(p)return p(P)}),[p,P]),h?r.jsx("div",{style:{position:"absolute",left:h.origin.x*u,top:h.origin.y*u,width:h.size.width*u,height:h.size.height*u,mixBlendMode:"multiply",isolation:"isolate"},children:f.map(((e,t)=>r.jsx("div",{style:{position:"absolute",left:(e.origin.x-h.origin.x)*u,top:(e.origin.y-h.origin.y)*u,width:e.size.width*u,height:e.size.height*u,background:a,pointerEvents:"none"}},t)))}):null},exports.useSelectionCapability=s,exports.useSelectionPlugin=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-selection"),i=require("react/jsx-runtime"),o=require("react"),r=require("@embedpdf/core/react"),n=()=>r.useCapability(t.SelectionPlugin.id);function l(){const{provides:e}=n();return o.useEffect((()=>{if(e)return e.onCopyToClipboard((e=>{navigator.clipboard.writeText(e)}))}),[e]),null}const s=e.createPluginPackage(t.SelectionPluginPackage).addUtility(l).build();exports.CopyToClipboard=l,exports.SelectionLayer=function({pageIndex:e,scale:t,background:r="rgba(33,150,243)"}){const{provides:l}=n(),[s,a]=o.useState([]),[u,c]=o.useState(null);return o.useEffect((()=>{if(l)return l.registerSelectionOnPage({pageIndex:e,onRectsChange:({rects:e,boundingRect:t})=>{a(e),c(t)}})}),[l,e]),u?i.jsx("div",{style:{position:"absolute",left:u.origin.x*t,top:u.origin.y*t,width:u.size.width*t,height:u.size.height*t,mixBlendMode:"multiply",isolation:"isolate"},children:s.map(((e,o)=>i.jsx("div",{style:{position:"absolute",left:(e.origin.x-u.origin.x)*t,top:(e.origin.y-u.origin.y)*t,width:e.size.width*t,height:e.size.height*t,background:r,pointerEvents:"none"}},o)))}):null},exports.SelectionPluginPackage=s,exports.useSelectionCapability=n,exports.useSelectionPlugin=()=>r.usePlugin(t.SelectionPlugin.id),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/shared/hooks/use-selection.ts","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/components/selection-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect } from '@framework';\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","import { useCallback, useEffect, useMemo, useRef, useState } from '@framework';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Position, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/@framework';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability, useSelectionPlugin } 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 { plugin: selectionPlugin } = useSelectionPlugin();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const { setCursor, removeCursor } = useCursor();\n const geoCacheRef = useRef<PdfPageGeometry | null>(null);\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'pointerMode') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n setBoundingRect(sel.getBoundingRectForPage(pageIndex));\n } else {\n setRects([]);\n setBoundingRect(null);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n const cachedGlyphAt = useCallback((pt: Position) => {\n const geo = geoCacheRef.current;\n return geo ? glyphAt(geo, pt) : -1;\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n geoCacheRef.current = null;\n };\n }, [sel, pageIndex]);\n\n useEffect(() => {\n if (!selectionPlugin || !sel) return;\n return selectionPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n }\n });\n }, [sel, selectionPlugin, 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 if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","useSelectionPlugin","usePlugin","provides","sel","useEffect","onCopyToClipboard","text","navigator","clipboard","writeText","pageIndex","scale","background","plugin","selectionPlugin","im","useInteractionManagerCapability","register","usePointerHandlers","rects","setRects","useState","boundingRect","setBoundingRect","setCursor","removeCursor","useCursor","geoCacheRef","useRef","onSelectionChange","getActiveMode","getHighlightRectsForPage","getBoundingRectForPage","cachedGlyphAt","useCallback","pt","geo","current","glyphAt","task","getGeometry","wait","g","ignore","abort","code","PdfErrorCode","Cancelled","message","onRefreshPages","pages","includes","handlers","useMemo","onPointerDown","point","_evt","modeId","isEnabledForMode","clear","begin","onPointerMove","update","onPointerUp","_point","end","onHandlerActiveEnd","jsxRuntime","jsx","style","position","left","origin","x","top","y","width","size","height","mixBlendMode","isolation","children","map","b","i","pointerEvents"],"mappings":"wSAGaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,IAC9EC,EAAqB,IAAMC,YAA2BH,EAAAA,gBAAgBC,4BCA5E,WACL,MAAQG,SAAUC,GAAQP,IASnB,OAPPQ,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAIE,mBAAmBC,IAClBC,UAAAC,UAAUC,UAAUH,EAAI,GACnC,GACA,CAACH,IAEG,IACT,yBCGO,UAAwBO,UAAEA,EAAAC,MAAWA,EAAOC,WAAAA,EAAa,qBAC9D,MAAQV,SAAUC,GAAQP,KAClBiB,OAAQC,GAAoBd,KAC5BE,SAAUa,GAAOC,qCACnBC,SAAEA,GAAaC,qBAAmB,CAAER,eACnCS,EAAOC,GAAYC,EAAAA,SAAsB,KACzCC,EAAcC,GAAmBF,EAAAA,SAAsB,OACxDG,UAAEA,EAAAC,aAAWA,GAAiBC,cAC9BC,EAAcC,SAA+B,MAGnDxB,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAI0B,mBAAkB,KAEd,iBADI,MAAJd,OAAI,EAAAA,EAAAe,kBAENV,EAAAjB,EAAI4B,yBAAyBrB,IACtBa,EAAApB,EAAI6B,uBAAuBtB,MAE3CU,EAAS,IACTG,EAAgB,MAAI,GAEvB,GACA,CAACpB,EAAKO,IAGH,MAAAuB,EAAgBC,eAAaC,IACjC,MAAMC,EAAMT,EAAYU,QACxB,OAAOD,EAAME,EAAAA,QAAQF,EAAKD,IAAM,CAAA,GAC/B,IAGH/B,EAAAA,WAAU,KACR,IAAKD,EAAK,OACJ,MAAAoC,EAAOpC,EAAIqC,YAAY9B,GAG7B,OAFA6B,EAAKE,MAAMC,GAAOf,EAAYU,QAAUK,GAAIC,UAErC,KACLJ,EAAKK,MAAM,CACTC,KAAMC,EAAaA,aAAAC,UACnBC,QAAS,cAEXrB,EAAYU,QAAU,IAAA,CACxB,GACC,CAAClC,EAA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AAauD,KAAKC,OAASnE,EACnCoE,aAAc,WACdC,UAAW,WAGZC,SAAM9D,EAAA+D,KAAI,CAACC,EAAGC,IACbjB,EAAAC,IAAC,MAAA,CAECC,MAAO,CACLC,SAAU,WACVC,MAAOY,EAAEX,OAAOC,EAAInD,EAAakD,OAAOC,GAAK9D,EAC7C+D,KAAMS,EAAEX,OAAOG,EAAIrD,EAAakD,OAAOG,GAAKhE,EAC5CiE,MAAOO,EAAEN,KAAKD,MAAQjE,EACtBmE,OAAQK,EAAEN,KAAKC,OAASnE,EACxBC,aACAyE,cAAe,SARZD,OAhBa,IA8B5B"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/index.ts","../../src/shared/components/selection-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect } from '@framework';\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","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","import { useEffect, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\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 [rects, setRects] = useState<Rect[]>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n\n useEffect(() => {\n if (!sel) return;\n\n return sel.registerSelectionOnPage({\n pageIndex,\n onRectsChange: ({ rects, boundingRect }) => {\n setRects(rects);\n setBoundingRect(boundingRect);\n },\n });\n }, [sel, pageIndex]);\n\n if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","CopyToClipboard","provides","sel","useEffect","onCopyToClipboard","text","navigator","clipboard","writeText","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","build","pageIndex","scale","background","rects","setRects","useState","boundingRect","setBoundingRect","registerSelectionOnPage","onRectsChange","jsxRuntime","jsx","style","position","left","origin","x","top","y","width","size","height","mixBlendMode","isolation","children","map","b","i","pointerEvents","usePlugin"],"mappings":"8OAGaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,ICCpF,SAASC,IACd,MAAQC,SAAUC,GAAQN,IASnB,OAPPO,EAAAA,WAAU,KACR,GAAKD,EACE,OAAAA,EAAIE,mBAAmBC,IAClBC,UAAAC,UAAUC,UAAUH,EAAI,GACnC,GACA,CAACH,IAEG,IACT,CCNO,MAAMO,EAAyBC,EAAoBA,oBAAAC,EAA0BF,wBACjFG,WAAWZ,GACXa,yDCDI,UAAwBC,UAAEA,EAAAC,MAAWA,EAAOC,WAAAA,EAAa,qBAC9D,MAAQf,SAAUC,GAAQN,KACnBqB,EAAOC,GAAYC,EAAAA,SAAiB,KACpCC,EAAcC,GAAmBF,EAAAA,SAAsB,MAc1D,OAZJhB,EAAAA,WAAU,KACR,GAAKD,EAEL,OAAOA,EAAIoB,wBAAwB,CACjCR,YACAS,cAAe,EAAGN,MAAAA,EAAOG,aAAAA,MACvBF,EAASD,GACTI,EAAgBD,EAAY,GAE/B,GACA,CAAClB,EAAKY,IAEJM,EAGHI,EAAAC,IAAC,MAAA,CACCC,MAAO,CACLC,SAAU,WACVC,KAAMR,EAAaS,OAAOC,EAAIf,EAC9BgB,IAAKX,EAAaS,OAAOG,EAAIjB,EAC7BkB,MAAOb,EAAac,KAAKD,MAAQlB,EACjCoB,OAAQf,EAAac,KAAKC,OAASpB,EACnCqB,aAAc,WACdC,UAAW,WAGZC,SAAMrB,EAAAsB,KAAI,CAACC,EAAGC,IACbjB,EAAAC,IAAC,MAAA,CAECC,MAAO,CACLC,SAAU,WACVC,MAAOY,EAAEX,OAAOC,EAAIV,EAAaS,OAAOC,GAAKf,EAC7CgB,KAAMS,EAAEX,OAAOG,EAAIZ,EAAaS,OAAOG,GAAKjB,EAC5CkB,MAAOO,EAAEN,KAAKD,MAAQlB,EACtBoB,OAAQK,EAAEN,KAAKC,OAASpB,EACxBC,aACA0B,cAAe,SARZD,OAhBa,IA8B5B,+FHrDkC,IAAME,YAA2B7C,EAAAA,gBAAgBC"}
@@ -1,98 +1,25 @@
1
- import { useCapability, usePlugin } from "@embedpdf/core/react";
2
- import { SelectionPlugin, glyphAt } from "@embedpdf/plugin-selection";
1
+ import { createPluginPackage } from "@embedpdf/core";
2
+ import { SelectionPlugin, SelectionPluginPackage as SelectionPluginPackage$1 } from "@embedpdf/plugin-selection";
3
+ export * from "@embedpdf/plugin-selection";
3
4
  import { jsx } from "react/jsx-runtime";
4
- import { useState, useRef, useEffect, useCallback, useMemo } from "react";
5
- import { ignore, PdfErrorCode } from "@embedpdf/models";
6
- import { useInteractionManagerCapability, usePointerHandlers, useCursor } from "@embedpdf/plugin-interaction-manager/react";
5
+ import { useState, useEffect } from "react";
6
+ import { useCapability, usePlugin } from "@embedpdf/core/react";
7
7
  const useSelectionCapability = () => useCapability(SelectionPlugin.id);
8
8
  const useSelectionPlugin = () => usePlugin(SelectionPlugin.id);
9
9
  function SelectionLayer({ pageIndex, scale, background = "rgba(33,150,243)" }) {
10
10
  const { provides: sel } = useSelectionCapability();
11
- const { plugin: selectionPlugin } = useSelectionPlugin();
12
- const { provides: im } = useInteractionManagerCapability();
13
- const { register } = usePointerHandlers({ pageIndex });
14
11
  const [rects, setRects] = useState([]);
15
12
  const [boundingRect, setBoundingRect] = useState(null);
16
- const { setCursor, removeCursor } = useCursor();
17
- const geoCacheRef = useRef(null);
18
13
  useEffect(() => {
19
14
  if (!sel) return;
20
- return sel.onSelectionChange(() => {
21
- const mode = im == null ? void 0 : im.getActiveMode();
22
- if (mode === "pointerMode") {
23
- setRects(sel.getHighlightRectsForPage(pageIndex));
24
- setBoundingRect(sel.getBoundingRectForPage(pageIndex));
25
- } else {
26
- setRects([]);
27
- setBoundingRect(null);
15
+ return sel.registerSelectionOnPage({
16
+ pageIndex,
17
+ onRectsChange: ({ rects: rects2, boundingRect: boundingRect2 }) => {
18
+ setRects(rects2);
19
+ setBoundingRect(boundingRect2);
28
20
  }
29
21
  });
30
22
  }, [sel, pageIndex]);
31
- const cachedGlyphAt = useCallback((pt) => {
32
- const geo = geoCacheRef.current;
33
- return geo ? glyphAt(geo, pt) : -1;
34
- }, []);
35
- useEffect(() => {
36
- if (!sel) return;
37
- const task = sel.getGeometry(pageIndex);
38
- task.wait((g) => geoCacheRef.current = g, ignore);
39
- return () => {
40
- task.abort({
41
- code: PdfErrorCode.Cancelled,
42
- message: "Cancelled"
43
- });
44
- geoCacheRef.current = null;
45
- };
46
- }, [sel, pageIndex]);
47
- useEffect(() => {
48
- if (!selectionPlugin || !sel) return;
49
- return selectionPlugin.onRefreshPages((pages) => {
50
- if (pages.includes(pageIndex)) {
51
- const task = sel.getGeometry(pageIndex);
52
- task.wait((g) => geoCacheRef.current = g, ignore);
53
- }
54
- });
55
- }, [sel, selectionPlugin, pageIndex]);
56
- const handlers = useMemo(
57
- () => ({
58
- onPointerDown: (point, _evt, modeId) => {
59
- if (!sel) return;
60
- if (!sel.isEnabledForMode(modeId)) return;
61
- sel.clear();
62
- const task = sel.getGeometry(pageIndex);
63
- task.wait((geo) => {
64
- const g = glyphAt(geo, point);
65
- if (g !== -1) sel.begin(pageIndex, g);
66
- }, ignore);
67
- },
68
- onPointerMove: (point, _evt, modeId) => {
69
- if (!sel) return;
70
- if (!sel.isEnabledForMode(modeId)) return;
71
- const g = cachedGlyphAt(point);
72
- if (g !== -1) {
73
- setCursor("selection-text", "text", 10);
74
- } else {
75
- removeCursor("selection-text");
76
- }
77
- if (g !== -1) sel.update(pageIndex, g);
78
- },
79
- onPointerUp: (_point, _evt, modeId) => {
80
- if (!sel) return;
81
- if (!sel.isEnabledForMode(modeId)) return;
82
- sel.end();
83
- },
84
- onHandlerActiveEnd(modeId) {
85
- if (!sel) return;
86
- if (!sel.isEnabledForMode(modeId)) return;
87
- sel.clear();
88
- }
89
- }),
90
- [sel, pageIndex, cachedGlyphAt]
91
- );
92
- useEffect(() => {
93
- if (!register) return;
94
- return register(handlers);
95
- }, [register, handlers]);
96
23
  if (!boundingRect) return null;
97
24
  return /* @__PURE__ */ jsx(
98
25
  "div",
@@ -134,9 +61,11 @@ function CopyToClipboard() {
134
61
  }, [sel]);
135
62
  return null;
136
63
  }
64
+ const SelectionPluginPackage = createPluginPackage(SelectionPluginPackage$1).addUtility(CopyToClipboard).build();
137
65
  export {
138
66
  CopyToClipboard,
139
67
  SelectionLayer,
68
+ SelectionPluginPackage,
140
69
  useSelectionCapability,
141
70
  useSelectionPlugin
142
71
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/selection-layer.tsx","../../src/shared/components/copy-to-clipboard.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\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, useRef, useState } from '@framework';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Position, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/@framework';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\n\nimport { useSelectionCapability, useSelectionPlugin } 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 { plugin: selectionPlugin } = useSelectionPlugin();\n const { provides: im } = useInteractionManagerCapability();\n const { register } = usePointerHandlers({ pageIndex });\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const { setCursor, removeCursor } = useCursor();\n const geoCacheRef = useRef<PdfPageGeometry | null>(null);\n\n /* subscribe to rect updates */\n useEffect(() => {\n if (!sel) return;\n return sel.onSelectionChange(() => {\n const mode = im?.getActiveMode();\n if (mode === 'pointerMode') {\n setRects(sel.getHighlightRectsForPage(pageIndex));\n setBoundingRect(sel.getBoundingRectForPage(pageIndex));\n } else {\n setRects([]);\n setBoundingRect(null);\n }\n });\n }, [sel, pageIndex]);\n\n /* cheap glyphAt cache for the active page */\n const cachedGlyphAt = useCallback((pt: Position) => {\n const geo = geoCacheRef.current;\n return geo ? glyphAt(geo, pt) : -1;\n }, []);\n\n // Initialize geometry cache\n useEffect(() => {\n if (!sel) return;\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n\n return () => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'Cancelled',\n });\n geoCacheRef.current = null;\n };\n }, [sel, pageIndex]);\n\n useEffect(() => {\n if (!selectionPlugin || !sel) return;\n return selectionPlugin.onRefreshPages((pages) => {\n if (pages.includes(pageIndex)) {\n const task = sel.getGeometry(pageIndex);\n task.wait((g) => (geoCacheRef.current = g), ignore);\n }\n });\n }, [sel, selectionPlugin, 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 if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n","import { useEffect } from '@framework';\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"],"names":[],"mappings":";;;;;;AAGO,MAAM,yBAAyB,MAAM,cAA+B,gBAAgB,EAAE;AACtF,MAAM,qBAAqB,MAAM,UAA2B,gBAAgB,EAAE;ACc9E,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,sBAA6B;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,EAAE,QAAQ,gBAAgB,IAAI,mBAAmB;AACvD,QAAM,EAAE,UAAU,GAAG,IAAI,gCAAgC;AACzD,QAAM,EAAE,SAAS,IAAI,mBAAmB,EAAE,WAAW;AACrD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAsB,CAAA,CAAE;AAClD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAsB,IAAI;AAClE,QAAM,EAAE,WAAW,aAAa,IAAI,UAAU;AACxC,QAAA,cAAc,OAA+B,IAAI;AAGvD,YAAU,MAAM;AACd,QAAI,CAAC,IAAK;AACH,WAAA,IAAI,kBAAkB,MAAM;AAC3B,YAAA,OAAO,yBAAI;AACjB,UAAI,SAAS,eAAe;AACjB,iBAAA,IAAI,yBAAyB,SAAS,CAAC;AAChC,wBAAA,IAAI,uBAAuB,SAAS,CAAC;AAAA,MAAA,OAChD;AACL,iBAAS,CAAA,CAAE;AACX,wBAAgB,IAAI;AAAA,MAAA;AAAA,IACtB,CACD;AAAA,EAAA,GACA,CAAC,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A;AAAA,QACjB;AAAA,QATK;AAAA,MAWR,CAAA;AAAA,IAAA;AAAA,EACH;AAEJ;AChJO,SAAS,kBAAkB;AAChC,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AAEjD,YAAU,MAAM;AACd,QAAI,CAAC,IAAK;AACH,WAAA,IAAI,kBAAkB,CAAC,SAAS;AAC3B,gBAAA,UAAU,UAAU,IAAI;AAAA,IAAA,CACnC;AAAA,EAAA,GACA,CAAC,GAAG,CAAC;AAED,SAAA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-selection.ts","../../src/shared/components/selection-layer.tsx","../../src/shared/components/copy-to-clipboard.tsx","../../src/shared/index.ts"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport { SelectionPlugin } from '@embedpdf/plugin-selection';\n\nexport const useSelectionCapability = () => useCapability<SelectionPlugin>(SelectionPlugin.id);\nexport const useSelectionPlugin = () => usePlugin<SelectionPlugin>(SelectionPlugin.id);\n","import { useEffect, useState } from '@framework';\nimport { Rect } from '@embedpdf/models';\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 [rects, setRects] = useState<Rect[]>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n\n useEffect(() => {\n if (!sel) return;\n\n return sel.registerSelectionOnPage({\n pageIndex,\n onRectsChange: ({ rects, boundingRect }) => {\n setRects(rects);\n setBoundingRect(boundingRect);\n },\n });\n }, [sel, pageIndex]);\n\n if (!boundingRect) return null;\n\n return (\n <div\n style={{\n position: 'absolute',\n left: boundingRect.origin.x * scale,\n top: boundingRect.origin.y * scale,\n width: boundingRect.size.width * scale,\n height: boundingRect.size.height * scale,\n mixBlendMode: 'multiply',\n isolation: 'isolate',\n }}\n >\n {rects.map((b, i) => (\n <div\n key={i}\n style={{\n position: 'absolute',\n left: (b.origin.x - boundingRect.origin.x) * scale,\n top: (b.origin.y - boundingRect.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background,\n pointerEvents: 'none',\n }}\n />\n ))}\n </div>\n );\n}\n","import { useEffect } from '@framework';\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","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":["rects","boundingRect","BaseSelectionPluginPackage"],"mappings":";;;;;;AAGO,MAAM,yBAAyB,MAAM,cAA+B,gBAAgB,EAAE;AACtF,MAAM,qBAAqB,MAAM,UAA2B,gBAAgB,EAAE;ACM9E,SAAS,eAAe,EAAE,WAAW,OAAO,aAAa,sBAA6B;AAC3F,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAiB,CAAA,CAAE;AAC7C,QAAM,CAAC,cAAc,eAAe,IAAI,SAAsB,IAAI;AAElE,YAAU,MAAM;AACd,QAAI,CAAC,IAAK;AAEV,WAAO,IAAI,wBAAwB;AAAA,MACjC;AAAA,MACA,eAAe,CAAC,EAAE,OAAAA,QAAO,cAAAC,oBAAmB;AAC1C,iBAASD,MAAK;AACd,wBAAgBC,aAAY;AAAA,MAAA;AAAA,IAC9B,CACD;AAAA,EAAA,GACA,CAAC,KAAK,SAAS,CAAC;AAEf,MAAA,CAAC,aAAqB,QAAA;AAGxB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,UAAU;AAAA,QACV,MAAM,aAAa,OAAO,IAAI;AAAA,QAC9B,KAAK,aAAa,OAAO,IAAI;AAAA,QAC7B,OAAO,aAAa,KAAK,QAAQ;AAAA,QACjC,QAAQ,aAAa,KAAK,SAAS;AAAA,QACnC,cAAc;AAAA,QACd,WAAW;AAAA,MACb;AAAA,MAEC,UAAM,MAAA,IAAI,CAAC,GAAG,MACb;AAAA,QAAC;AAAA,QAAA;AAAA,UAEC,OAAO;AAAA,YACL,UAAU;AAAA,YACV,OAAO,EAAE,OAAO,IAAI,aAAa,OAAO,KAAK;AAAA,YAC7C,MAAM,EAAE,OAAO,IAAI,aAAa,OAAO,KAAK;AAAA,YAC5C,OAAO,EAAE,KAAK,QAAQ;AAAA,YACtB,QAAQ,EAAE,KAAK,SAAS;AAAA,YACxB;AAAA,YACA,eAAe;AAAA,UAAA;AAAA,QACjB;AAAA,QATK;AAAA,MAWR,CAAA;AAAA,IAAA;AAAA,EACH;AAEJ;ACrDO,SAAS,kBAAkB;AAChC,QAAM,EAAE,UAAU,IAAI,IAAI,uBAAuB;AAEjD,YAAU,MAAM;AACd,QAAI,CAAC,IAAK;AACH,WAAA,IAAI,kBAAkB,CAAC,SAAS;AAC3B,gBAAA,UAAU,UAAU,IAAI;AAAA,IAAA,CACnC;AAAA,EAAA,GACA,CAAC,GAAG,CAAC;AAED,SAAA;AACT;ACNO,MAAM,yBAAyB,oBAAoBC,wBAA0B,EACjF,WAAW,eAAe,EAC1B,MAAM;"}
@@ -1,2 +1,4 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
4
+ 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('../lib/actions').SelectionAction>>;
@@ -1,2 +1,4 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
4
+ 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('../lib/actions').SelectionAction>>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/vue"),o=require("@embedpdf/plugin-selection"),t=require("vue"),l=require("@embedpdf/models"),a=require("@embedpdf/plugin-interaction-manager/vue"),n=()=>e.useCapability(o.SelectionPlugin.id),i=t.defineComponent({__name:"selection-layer",props:{pageIndex:{},scale:{},background:{default:"rgba(33, 150, 243)"}},setup(e){const i=e,{provides:r}=n(),{provides:u}=a.useInteractionManagerCapability(),{register:c}=a.usePointerHandlers({pageIndex:i.pageIndex}),{setCursor:d,removeCursor:s}=a.useCursor(),p=t.ref([]),g=t.ref(null);let v;t.watchEffect((e=>{if(r.value){e(r.value.onSelectionChange((()=>{var e;"pointerMode"===(null==(e=u.value)?void 0:e.getActiveMode())?(p.value=r.value.getHighlightRectsForPage(i.pageIndex),g.value=r.value.getBoundingRectForPage(i.pageIndex)):(p.value=[],g.value=null)})))}})),t.watchEffect((e=>{if(r.value){const o=r.value.getGeometry(i.pageIndex);o.wait((e=>v=e),l.ignore),e((()=>{o.abort({code:l.PdfErrorCode.Cancelled,message:"SelectionLayer unmounted"})}))}}));const x=t.computed((()=>({onPointerDown:(e,t,a)=>{if(!r.value||!r.value.isEnabledForMode(a))return;r.value.clear();r.value.getGeometry(i.pageIndex).wait((t=>{const l=o.glyphAt(t,e);-1!==l&&r.value.begin(i.pageIndex,l)}),l.ignore)},onPointerMove:(e,t,l)=>{if(!r.value||!r.value.isEnabledForMode(l))return;const a=v?o.glyphAt(v,e):-1;-1!==a?(d("selection-text","text",10),r.value.update(i.pageIndex,a)):s("selection-text")},onPointerUp:(e,o,t)=>{r.value&&r.value.isEnabledForMode(t)&&r.value.end()},onHandlerActiveEnd:e=>{r.value&&r.value.isEnabledForMode(e)&&r.value.clear()}})));return t.watchEffect((e=>{if(c){const o=c(x.value);o&&e(o)}})),(e,o)=>g.value?(t.openBlock(),t.createElementBlock("div",{key:0,style:t.normalizeStyle({position:"absolute",left:g.value.origin.x*e.scale+"px",top:g.value.origin.y*e.scale+"px",width:g.value.size.width*e.scale+"px",height:g.value.size.height*e.scale+"px",mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"})},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(p.value,((o,l)=>(t.openBlock(),t.createElementBlock("div",{key:l,style:t.normalizeStyle({position:"absolute",left:(o.origin.x-g.value.origin.x)*e.scale+"px",top:(o.origin.y-g.value.origin.y)*e.scale+"px",width:o.size.width*e.scale+"px",height:o.size.height*e.scale+"px",background:e.background})},null,4)))),128))],4)):t.createCommentVNode("",!0)}}),r=t.defineComponent({__name:"copy-to-clipboard",setup(e){const{provides:o}=n();return t.watchEffect((e=>{if(o.value){e(o.value.onCopyToClipboard((e=>{navigator.clipboard.writeText(e).catch((e=>{console.error("Failed to copy text to clipboard:",e)}))})))}})),(e,o)=>null}});exports.CopyToClipboard=r,exports.SelectionLayer=i,exports.useSelectionCapability=n,exports.useSelectionPlugin=()=>e.usePlugin(o.SelectionPlugin.id);
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/core/vue"),i=()=>l.useCapability(t.SelectionPlugin.id),n=o.defineComponent({__name:"selection-layer",props:{pageIndex:{},scale:{},background:{default:"rgba(33, 150, 243)"}},setup(e){const t=e,{provides:l}=i(),n=o.ref([]),a=o.ref(null);let r;return o.onMounted((()=>{l.value&&(r=l.value.registerSelectionOnPage({pageIndex:t.pageIndex,onRectsChange:({rects:e,boundingRect:t})=>{n.value=e,a.value=t}}))})),o.onUnmounted((()=>{null==r||r()})),(e,t)=>a.value?(o.openBlock(),o.createElementBlock("div",{key:0,style:o.normalizeStyle({position:"absolute",left:a.value.origin.x*e.scale+"px",top:a.value.origin.y*e.scale+"px",width:a.value.size.width*e.scale+"px",height:a.value.size.height*e.scale+"px",mixBlendMode:"multiply",isolation:"isolate",pointerEvents:"none"})},[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(n.value,((t,l)=>(o.openBlock(),o.createElementBlock("div",{key:l,style:o.normalizeStyle({position:"absolute",left:(t.origin.x-a.value.origin.x)*e.scale+"px",top:(t.origin.y-a.value.origin.y)*e.scale+"px",width:t.size.width*e.scale+"px",height:t.size.height*e.scale+"px",background:e.background})},null,4)))),128))],4)):o.createCommentVNode("",!0)}}),a=o.defineComponent({__name:"copy-to-clipboard",setup(e){const{provides:t}=i();return o.watchEffect((e=>{if(t.value){e(t.value.onCopyToClipboard((e=>{navigator.clipboard.writeText(e).catch((e=>{console.error("Failed to copy text to clipboard:",e)}))})))}})),(e,t)=>null}}),r=e.createPluginPackage(t.SelectionPluginPackage).addUtility(a).build();exports.CopyToClipboard=a,exports.SelectionLayer=n,exports.SelectionPluginPackage=r,exports.useSelectionCapability=i,exports.useSelectionPlugin=()=>l.usePlugin(t.SelectionPlugin.id),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/vue/hooks/use-selection.ts","../../src/vue/components/selection-layer.vue","../../src/vue/components/copy-to-clipboard.vue"],"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, watchEffect, computed } from 'vue';\nimport { ignore, PdfErrorCode, PdfPageGeometry, Rect } from '@embedpdf/models';\nimport {\n useCursor,\n useInteractionManagerCapability,\n usePointerHandlers,\n} from '@embedpdf/plugin-interaction-manager/vue';\nimport { PointerEventHandlersWithLifecycle } from '@embedpdf/plugin-interaction-manager';\nimport { glyphAt } from '@embedpdf/plugin-selection';\nimport { useSelectionCapability } from '../hooks';\n\ninterface Props {\n pageIndex: number;\n scale: number;\n background?: string;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n background: 'rgba(33, 150, 243)', // Default selection color\n});\n\nconst { provides: sel } = useSelectionCapability();\nconst { provides: im } = useInteractionManagerCapability();\nconst { register } = usePointerHandlers({ pageIndex: props.pageIndex });\nconst { setCursor, removeCursor } = useCursor();\n\nconst rects = ref<Rect[]>([]);\nconst boundingRect = ref<Rect | null>(null);\n\n// Subscribe to selection changes and update the rendered rectangles\nwatchEffect((onCleanup) => {\n if (sel.value) {\n const unsubscribe = sel.value.onSelectionChange(() => {\n const mode = im.value?.getActiveMode();\n if (mode === 'pointerMode') {\n rects.value = sel.value!.getHighlightRectsForPage(props.pageIndex);\n boundingRect.value = sel.value!.getBoundingRectForPage(props.pageIndex);\n } else {\n rects.value = [];\n boundingRect.value = null;\n }\n });\n onCleanup(unsubscribe);\n }\n});\n\n// Cache page geometry for faster hit-testing during pointer moves\nlet geoCache: PdfPageGeometry | undefined;\nwatchEffect((onCleanup) => {\n if (sel.value) {\n const task = sel.value.getGeometry(props.pageIndex);\n task.wait((g) => (geoCache = g), ignore);\n\n onCleanup(() => {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'SelectionLayer unmounted',\n });\n });\n }\n});\n\nconst handlers = computed(\n (): PointerEventHandlersWithLifecycle<PointerEvent> => ({\n onPointerDown: (point, _evt, modeId) => {\n if (!sel.value || !sel.value.isEnabledForMode(modeId)) return;\n sel.value.clear();\n const task = sel.value.getGeometry(props.pageIndex);\n task.wait((geo) => {\n const g = glyphAt(geo, point);\n if (g !== -1) sel.value!.begin(props.pageIndex, g);\n }, ignore);\n },\n onPointerMove: (point, _evt, modeId) => {\n if (!sel.value || !sel.value.isEnabledForMode(modeId)) return;\n const g = geoCache ? glyphAt(geoCache, point) : -1;\n if (g !== -1) {\n setCursor('selection-text', 'text', 10);\n sel.value.update(props.pageIndex, g);\n } else {\n removeCursor('selection-text');\n }\n },\n onPointerUp: (_point, _evt, modeId) => {\n if (!sel.value || !sel.value.isEnabledForMode(modeId)) return;\n sel.value.end();\n },\n onHandlerActiveEnd: (modeId) => {\n if (!sel.value || !sel.value.isEnabledForMode(modeId)) return;\n sel.value.clear();\n },\n }),\n);\n\n// Register the pointer handlers with the interaction manager\nwatchEffect((onCleanup) => {\n if (register) {\n const cleanup = register(handlers.value);\n if (cleanup) onCleanup(cleanup);\n }\n});\n</script>\n\n<template>\n <div\n v-if=\"boundingRect\"\n :style=\"{\n position: 'absolute',\n left: `${boundingRect.origin.x * scale}px`,\n top: `${boundingRect.origin.y * scale}px`,\n width: `${boundingRect.size.width * scale}px`,\n height: `${boundingRect.size.height * scale}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) * scale}px`,\n top: `${(rect.origin.y - boundingRect.origin.y) * scale}px`,\n width: `${rect.size.width * scale}px`,\n height: `${rect.size.height * scale}px`,\n background: background,\n }\"\n />\n </div>\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"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","props","__props","provides","sel","im","useInteractionManagerCapability","register","usePointerHandlers","pageIndex","setCursor","removeCursor","useCursor","rects","ref","boundingRect","geoCache","vue$1","watchEffect","onCleanup","value","onSelectionChange","_a","getActiveMode","getHighlightRectsForPage","getBoundingRectForPage","task","getGeometry","wait","g","ignore","abort","code","PdfErrorCode","Cancelled","message","handlers","computed","onPointerDown","point","_evt","modeId","isEnabledForMode","clear","geo","glyphAt","begin","onPointerMove","update","onPointerUp","_point","end","onHandlerActiveEnd","cleanup","_createElementBlock","style","_normalizeStyle","left","origin","x","scale","top","y","width","size","height","_openBlock","createElementBlock","_Fragment","_renderList","renderList","rect","i","key","background","onCopyToClipboard","text","navigator","clipboard","writeText","catch","err","console","error","usePlugin"],"mappings":"mQAOaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,mICW3F,MAAMC,EAAQC,GAINC,SAAUC,GAAQP,KAClBM,SAAUE,GAAOC,qCACnBC,SAAEA,GAAaC,EAAAA,mBAAmB,CAAEC,UAAWR,EAAMQ,aACrDC,UAAEA,EAAAC,aAAWA,GAAiBC,cAE9BC,EAAQC,EAAYA,IAAA,IACpBC,EAAeD,MAAiB,MAoBlC,IAAAE,EAjBJC,EAAAC,aAAaC,IACX,GAAIf,EAAIgB,MAAO,CAWbD,EAVoBf,EAAIgB,MAAMC,mBAAkB,WAEjC,iBADA,OAAAC,EAAGjB,EAAAe,YAAO,EAAAE,EAAAC,kBAErBV,EAAMO,MAAQhB,EAAIgB,MAAOI,yB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X,GAAIZ,EAAU,CACN,MAAA8C,EAAU9C,EAAS6B,EAAShB,OAC9BiC,KAAmBA,EAAO,YAOxBtC,EAAYK,qBADpBkC,EAAAA,mBAyBM,MAAA,OAvBHC,MAAKC,EAAAA,eAAA,qBAA+CC,KAAA1C,EAAAK,MAAasC,OAAOC,EAAIC,EAAKA,MAA7B,KAAiDC,IAAA9C,EAAAK,MAAasC,OAAOI,EAAIF,EAAKA,MAA7B,KAAmDG,MAAAhD,EAAAK,MAAa4C,KAAKD,MAAQH,EAAKA,MAA/B,KAAsDK,OAAAlD,EAAAK,MAAa4C,KAAKC,OAASL,EAAKA,MAAhC,2EAW/MM,EAAAA,WAAA,GAAAZ,EAWEa,mBAAAC,WAVoB,KAAAC,EAAAC,WAAAzD,EAAAO,OAAZ,CAAAmD,EAAMC,mBADhBlB,EAAAa,mBAWE,MAAA,CATCM,IAAKD,EACLjB,MAAKC,EAAAA,eAAA,2BAAoDe,EAAKb,OAAOC,EAAI5C,EAAYK,MAACsC,OAAOC,GAAKC,EAAKA,gBAAuBW,EAAKb,OAAOI,EAAI/C,EAAYK,MAACsC,OAAOI,GAAKF,EAAKA,WAAwBG,MAAAQ,EAAKP,KAAKD,MAAQH,EAAKA,MAAvB,KAAgDK,OAAAM,EAAKP,KAAKC,OAASL,EAAKA,MAAxB,gBAAkDc,EAAUA,4HCrHvT,MAAQvE,SAAUC,GAAQP,WAI1BoB,EAAAC,aAAaC,IACX,GAAIf,EAAIgB,MAAO,CASbD,EARoBf,EAAIgB,MAAMuD,mBAAmBC,IAE/CC,UAAUC,UAAUC,UAAUH,GAAMI,OAAOC,IACjCC,QAAAC,MAAM,oCAAqCF,EAAG,GACvD,IAIkB,mIFLS,IAAMG,YAA2BrF,EAAAA,gBAAgBC"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/vue/hooks/use-selection.ts","../../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","<template>\n <div\n v-if=\"boundingRect\"\n :style=\"{\n position: 'absolute',\n left: `${boundingRect.origin.x * scale}px`,\n top: `${boundingRect.origin.y * scale}px`,\n width: `${boundingRect.size.width * scale}px`,\n height: `${boundingRect.size.height * scale}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) * scale}px`,\n top: `${(rect.origin.y - boundingRect.origin.y) * scale}px`,\n width: `${rect.size.width * scale}px`,\n height: `${rect.size.height * scale}px`,\n background: background,\n }\"\n />\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref, onMounted, onUnmounted } from 'vue';\nimport type { Rect } from '@embedpdf/models';\nimport { useSelectionCapability } from '../hooks/use-selection';\n\ninterface Props {\n pageIndex: number;\n scale: number;\n background?: string;\n}\n\nconst props = withDefaults(defineProps<Props>(), {\n background: 'rgba(33, 150, 243)',\n});\n\nconst { provides: sel } = useSelectionCapability();\nconst rects = ref<Rect[]>([]);\nconst boundingRect = ref<Rect | null>(null);\n\nlet unregister: (() => void) | undefined;\n\nonMounted(() => {\n if (!sel.value) return;\n\n unregister = sel.value.registerSelectionOnPage({\n pageIndex: props.pageIndex,\n onRectsChange: ({ rects: newRects, boundingRect: newBoundingRect }) => {\n rects.value = newRects;\n boundingRect.value = newBoundingRect;\n },\n });\n});\n\nonUnmounted(() => {\n unregister?.();\n});\n</script>\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 '@embedpdf/plugin-selection';\n\nexport const SelectionPluginPackage = createPluginPackage(BaseSelectionPluginPackage)\n .addUtility(CopyToClipboard)\n .build();\n"],"names":["useSelectionCapability","useCapability","SelectionPlugin","id","props","__props","provides","sel","rects","ref","boundingRect","unregister","onMounted","value","registerSelectionOnPage","pageIndex","onRectsChange","newRects","newBoundingRect","onUnmounted","_createElementBlock","style","_normalizeStyle","left","origin","x","scale","top","y","width","size","height","_openBlock","createElementBlock","_Fragment","_renderList","renderList","rect","i","key","background","vue$1","watchEffect","onCleanup","onCopyToClipboard","text","navigator","clipboard","writeText","catch","err","console","error","SelectionPluginPackage","createPluginPackage","BaseSelectionPluginPackage","addUtility","CopyToClipboard","build","usePlugin"],"mappings":"2MAOaA,EAAyB,IAAMC,gBAA+BC,EAAAA,gBAAgBC,mICiC3F,MAAMC,EAAQC,GAINC,SAAUC,GAAQP,IACpBQ,EAAQC,EAAYA,IAAA,IACpBC,EAAeD,MAAiB,MAElC,IAAAE,SAEJC,EAAAA,WAAU,KACHL,EAAIM,QAEIF,EAAAJ,EAAIM,MAAMC,wBAAwB,CAC7CC,U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 -1,2 +1,4 @@
1
1
  export * from './hooks';
2
2
  export * from './components';
3
+ export * from '../lib/index.ts';
4
+ 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>>;