@embedpdf/plugin-search 2.15.0 → 3.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +192 -21
- package/dist/index.cjs +363 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +156 -0
- package/dist/index.d.ts +156 -1
- package/dist/index.js +346 -433
- package/dist/index.js.map +1 -1
- package/package.json +21 -57
- package/dist/lib/actions.d.ts +0 -91
- package/dist/lib/index.d.ts +0 -10
- package/dist/lib/manifest.d.ts +0 -4
- package/dist/lib/reducer.d.ts +0 -6
- package/dist/lib/search-plugin.d.ts +0 -32
- package/dist/lib/types.d.ts +0 -165
- package/dist/preact/adapter.d.ts +0 -5
- package/dist/preact/core.d.ts +0 -1
- package/dist/preact/index.cjs +0 -2
- package/dist/preact/index.cjs.map +0 -1
- package/dist/preact/index.d.ts +0 -1
- package/dist/preact/index.js +0 -107
- package/dist/preact/index.js.map +0 -1
- package/dist/react/adapter.d.ts +0 -2
- package/dist/react/core.d.ts +0 -1
- package/dist/react/index.cjs +0 -2
- package/dist/react/index.cjs.map +0 -1
- package/dist/react/index.d.ts +0 -1
- package/dist/react/index.js +0 -106
- package/dist/react/index.js.map +0 -1
- package/dist/shared/components/index.d.ts +0 -1
- package/dist/shared/components/search-layer.d.ts +0 -11
- package/dist/shared/hooks/index.d.ts +0 -1
- package/dist/shared/hooks/use-search.d.ts +0 -15
- package/dist/shared/index.d.ts +0 -3
- package/dist/shared-preact/components/index.d.ts +0 -1
- package/dist/shared-preact/components/search-layer.d.ts +0 -11
- package/dist/shared-preact/hooks/index.d.ts +0 -1
- package/dist/shared-preact/hooks/use-search.d.ts +0 -15
- package/dist/shared-preact/index.d.ts +0 -3
- package/dist/shared-react/components/index.d.ts +0 -1
- package/dist/shared-react/components/search-layer.d.ts +0 -11
- package/dist/shared-react/hooks/index.d.ts +0 -1
- package/dist/shared-react/hooks/use-search.d.ts +0 -15
- package/dist/shared-react/index.d.ts +0 -3
- package/dist/svelte/components/SearchLayer.svelte.d.ts +0 -11
- package/dist/svelte/components/index.d.ts +0 -1
- package/dist/svelte/hooks/index.d.ts +0 -1
- package/dist/svelte/hooks/use-search.svelte.d.ts +0 -21
- package/dist/svelte/index.cjs +0 -2
- package/dist/svelte/index.cjs.map +0 -1
- package/dist/svelte/index.d.ts +0 -3
- package/dist/svelte/index.js +0 -134
- package/dist/svelte/index.js.map +0 -1
- package/dist/vue/components/index.d.ts +0 -1
- package/dist/vue/components/search-layer.vue.d.ts +0 -13
- package/dist/vue/hooks/index.d.ts +0 -1
- package/dist/vue/hooks/use-search.d.ts +0 -12
- package/dist/vue/index.cjs +0 -2
- package/dist/vue/index.cjs.map +0 -1
- package/dist/vue/index.d.ts +0 -3
- package/dist/vue/index.js +0 -131
- package/dist/vue/index.js.map +0 -1
package/dist/preact/index.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/preact";
|
|
2
|
-
import { initialSearchDocumentState, SearchPlugin } from "@embedpdf/plugin-search";
|
|
3
|
-
export * from "@embedpdf/plugin-search";
|
|
4
|
-
import "preact";
|
|
5
|
-
import { useState, useMemo, useEffect } from "preact/hooks";
|
|
6
|
-
import { jsx } from "preact/jsx-runtime";
|
|
7
|
-
const useSearchPlugin = () => usePlugin(SearchPlugin.id);
|
|
8
|
-
const useSearchCapability = () => useCapability(SearchPlugin.id);
|
|
9
|
-
const useSearch = (documentId) => {
|
|
10
|
-
const { provides } = useSearchCapability();
|
|
11
|
-
const [searchState, setSearchState] = useState(initialSearchDocumentState);
|
|
12
|
-
const scope = useMemo(() => provides == null ? void 0 : provides.forDocument(documentId), [provides, documentId]);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
if (!scope) {
|
|
15
|
-
setSearchState(initialSearchDocumentState);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
setSearchState(scope.getState());
|
|
19
|
-
return scope.onStateChange((state) => setSearchState(state));
|
|
20
|
-
}, [scope]);
|
|
21
|
-
return {
|
|
22
|
-
state: searchState,
|
|
23
|
-
provides: scope ?? null
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
function SearchLayer({
|
|
27
|
-
documentId,
|
|
28
|
-
pageIndex,
|
|
29
|
-
scale: scaleOverride,
|
|
30
|
-
style,
|
|
31
|
-
highlightColor = "#FFFF00",
|
|
32
|
-
activeHighlightColor = "#FFBF00",
|
|
33
|
-
...props
|
|
34
|
-
}) {
|
|
35
|
-
const { provides: searchProvides } = useSearchCapability();
|
|
36
|
-
const [searchResultState, setSearchResultState] = useState(null);
|
|
37
|
-
const documentState = useDocumentState(documentId);
|
|
38
|
-
const scope = useMemo(
|
|
39
|
-
() => searchProvides == null ? void 0 : searchProvides.forDocument(documentId),
|
|
40
|
-
[searchProvides, documentId]
|
|
41
|
-
);
|
|
42
|
-
const actualScale = useMemo(() => {
|
|
43
|
-
if (scaleOverride !== void 0) return scaleOverride;
|
|
44
|
-
return (documentState == null ? void 0 : documentState.scale) ?? 1;
|
|
45
|
-
}, [scaleOverride, documentState == null ? void 0 : documentState.scale]);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (!scope) {
|
|
48
|
-
setSearchResultState(null);
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const currentState = scope.getState();
|
|
52
|
-
setSearchResultState({
|
|
53
|
-
results: currentState.results,
|
|
54
|
-
activeResultIndex: currentState.activeResultIndex,
|
|
55
|
-
showAllResults: currentState.showAllResults,
|
|
56
|
-
active: currentState.active
|
|
57
|
-
});
|
|
58
|
-
return scope.onSearchResultStateChange((state) => {
|
|
59
|
-
setSearchResultState(state);
|
|
60
|
-
});
|
|
61
|
-
}, [scope]);
|
|
62
|
-
if (!searchResultState || !searchResultState.active) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
|
|
66
|
-
const resultsToShow = pageResults.filter(
|
|
67
|
-
({ originalIndex }) => searchResultState.showAllResults || originalIndex === searchResultState.activeResultIndex
|
|
68
|
-
);
|
|
69
|
-
return /* @__PURE__ */ jsx(
|
|
70
|
-
"div",
|
|
71
|
-
{
|
|
72
|
-
style: {
|
|
73
|
-
...style,
|
|
74
|
-
pointerEvents: "none"
|
|
75
|
-
},
|
|
76
|
-
...props,
|
|
77
|
-
children: resultsToShow.map(
|
|
78
|
-
({ result, originalIndex }) => result.rects.map((rect, rectIndex) => /* @__PURE__ */ jsx(
|
|
79
|
-
"div",
|
|
80
|
-
{
|
|
81
|
-
style: {
|
|
82
|
-
position: "absolute",
|
|
83
|
-
top: rect.origin.y * actualScale,
|
|
84
|
-
left: rect.origin.x * actualScale,
|
|
85
|
-
width: rect.size.width * actualScale,
|
|
86
|
-
height: rect.size.height * actualScale,
|
|
87
|
-
backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
|
|
88
|
-
mixBlendMode: "multiply",
|
|
89
|
-
transform: "scale(1.02)",
|
|
90
|
-
transformOrigin: "center",
|
|
91
|
-
transition: "opacity .3s ease-in-out",
|
|
92
|
-
opacity: 1
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
`${originalIndex}-${rectIndex}`
|
|
96
|
-
))
|
|
97
|
-
)
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
export {
|
|
102
|
-
SearchLayer,
|
|
103
|
-
useSearch,
|
|
104
|
-
useSearchCapability,
|
|
105
|
-
useSearchPlugin
|
|
106
|
-
};
|
|
107
|
-
//# sourceMappingURL=index.js.map
|
package/dist/preact/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n SearchPlugin,\n SearchDocumentState,\n SearchScope,\n initialSearchDocumentState,\n} from '@embedpdf/plugin-search';\nimport { useEffect, useMemo, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = (\n documentId: string,\n): {\n state: SearchDocumentState;\n provides: SearchScope | null;\n} => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchDocumentState>(initialSearchDocumentState);\n\n const scope = useMemo(() => provides?.forDocument(documentId), [provides, documentId]);\n\n useEffect(() => {\n if (!scope) {\n setSearchState(initialSearchDocumentState);\n return;\n }\n // Set initial state\n setSearchState(scope.getState());\n // Subscribe to changes\n return scope.onStateChange((state) => setSearchState(state));\n }, [scope]);\n\n return {\n state: searchState,\n provides: scope ?? null,\n };\n};\n","import { useEffect, useMemo, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: CSSProperties;\n};\n\nexport function SearchLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n const documentState = useDocumentState(documentId);\n\n const scope = useMemo(\n () => searchProvides?.forDocument(documentId),\n [searchProvides, documentId],\n );\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!scope) {\n setSearchResultState(null);\n return;\n }\n // Set initial state\n const currentState = scope.getState();\n setSearchResultState({\n results: currentState.results,\n activeResultIndex: currentState.activeResultIndex,\n showAllResults: currentState.showAllResults,\n active: currentState.active,\n });\n // Subscribe to changes\n return scope.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [scope]);\n\n if (!searchResultState || !searchResultState.active) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n // Decide which results to show\n const resultsToShow = pageResults.filter(\n ({ originalIndex }) =>\n searchResultState.showAllResults || originalIndex === searchResultState.activeResultIndex,\n );\n\n return (\n <div\n style={{\n ...style,\n pointerEvents: 'none',\n }}\n {...props}\n >\n {resultsToShow.map(({ result, originalIndex }) =>\n result.rects.map((rect, rectIndex) => (\n <div\n key={`${originalIndex}-${rectIndex}`}\n style={{\n position: 'absolute',\n top: rect.origin.y * actualScale,\n left: rect.origin.x * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;;AASO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,CACvB,eAIG;AACH,QAAM,EAAE,SAAA,IAAa,oBAAA;AACrB,QAAM,CAAC,aAAa,cAAc,IAAI,SAA8B,0BAA0B;AAE9F,QAAM,QAAQ,QAAQ,MAAM,qCAAU,YAAY,aAAa,CAAC,UAAU,UAAU,CAAC;AAErF,YAAU,MAAM;AACd,QAAI,CAAC,OAAO;AACV,qBAAe,0BAA0B;AACzC;AAAA,IACF;AAEA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Aa,OAAO,cAAc,SAAS;AAGxD,QAAM,gBAAgB,YAAY;AAAA,IAChC,CAAC,EAAE,cAAA,MACD,kBAAkB,kBAAkB,kBAAkB,kBAAkB;AAAA,EAAA;AAG5E,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe;AAAA,MAAA;AAAA,MAEhB,GAAG;AAAA,MAEH,UAAA,cAAc;AAAA,QAAI,CAAC,EAAE,QAAQ,cAAA,MAC5B,OAAO,MAAM,IAAI,CAAC,MAAM,cACtB;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK,KAAK,OAAO,IAAI;AAAA,cACrB,MAAM,KAAK,OAAO,IAAI;AAAA,cACtB,OAAO,KAAK,KAAK,QAAQ;AAAA,cACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,cAC3B,iBACE,kBAAkB,kBAAkB,oBAChC,uBACA;AAAA,cACN,cAAc;AAAA,cACd,WAAW;AAAA,cACX,iBAAiB;AAAA,cACjB,YAAY;AAAA,cACZ,SAAS;AAAA,YAAA;AAAA,UACX;AAAA,UAhBK,GAAG,aAAa,IAAI,SAAS;AAAA,QAAA,CAkBrC;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;"}
|
package/dist/react/adapter.d.ts
DELETED
package/dist/react/core.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '@embedpdf/core/react';
|
package/dist/react/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-search"),r=require("react"),i=require("react/jsx-runtime"),s=()=>e.useCapability(t.SearchPlugin.id);exports.SearchLayer=function({documentId:t,pageIndex:l,scale:n,style:o,highlightColor:a="#FFFF00",activeHighlightColor:u="#FFBF00",...c}){const{provides:d}=s(),[p,h]=r.useState(null),g=e.useDocumentState(t),f=r.useMemo(()=>null==d?void 0:d.forDocument(t),[d,t]),m=r.useMemo(()=>void 0!==n?n:(null==g?void 0:g.scale)??1,[n,null==g?void 0:g.scale]);if(r.useEffect(()=>{if(!f)return void h(null);const e=f.getState();return h({results:e.results,activeResultIndex:e.activeResultIndex,showAllResults:e.showAllResults,active:e.active}),f.onSearchResultStateChange(e=>{h(e)})},[f]),!p||!p.active)return null;const v=p.results.map((e,t)=>({result:e,originalIndex:t})).filter(({result:e})=>e.pageIndex===l).filter(({originalIndex:e})=>p.showAllResults||e===p.activeResultIndex);return i.jsx("div",{style:{...o,pointerEvents:"none"},...c,children:v.map(({result:e,originalIndex:t})=>e.rects.map((e,r)=>i.jsx("div",{style:{position:"absolute",top:e.origin.y*m,left:e.origin.x*m,width:e.size.width*m,height:e.size.height*m,backgroundColor:t===p.activeResultIndex?u:a,mixBlendMode:"multiply",transform:"scale(1.02)",transformOrigin:"center",transition:"opacity .3s ease-in-out",opacity:1}},`${t}-${r}`)))})},exports.useSearch=e=>{const{provides:i}=s(),[l,n]=r.useState(t.initialSearchDocumentState),o=r.useMemo(()=>null==i?void 0:i.forDocument(e),[i,e]);return r.useEffect(()=>{if(o)return n(o.getState()),o.onStateChange(e=>n(e));n(t.initialSearchDocumentState)},[o]),{state:l,provides:o??null}},exports.useSearchCapability=s,exports.useSearchPlugin=()=>e.usePlugin(t.SearchPlugin.id),Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/react/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n SearchPlugin,\n SearchDocumentState,\n SearchScope,\n initialSearchDocumentState,\n} from '@embedpdf/plugin-search';\nimport { useEffect, useMemo, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = (\n documentId: string,\n): {\n state: SearchDocumentState;\n provides: SearchScope | null;\n} => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchDocumentState>(initialSearchDocumentState);\n\n const scope = useMemo(() => provides?.forDocument(documentId), [provides, documentId]);\n\n useEffect(() => {\n if (!scope) {\n setSearchState(initialSearchDocumentState);\n return;\n }\n // Set initial state\n setSearchState(scope.getState());\n // Subscribe to changes\n return scope.onStateChange((state) => setSearchState(state));\n }, [scope]);\n\n return {\n state: searchState,\n provides: scope ?? null,\n };\n};\n","import { useEffect, useMemo, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: CSSProperties;\n};\n\nexport function SearchLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n const documentState = useDocumentState(documentId);\n\n const scope = useMemo(\n () => searchProvides?.forDocument(documentId),\n [searchProvides, documentId],\n );\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!scope) {\n setSearchResultState(null);\n return;\n }\n // Set initial state\n const currentState = scope.getState();\n setSearchResultState({\n results: currentState.results,\n activeResultIndex: currentState.activeResultIndex,\n showAllResults: currentState.showAllResults,\n active: currentState.active,\n });\n // Subscribe to changes\n return scope.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [scope]);\n\n if (!searchResultState || !searchResultState.active) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n // Decide which results to show\n const resultsToShow = pageResults.filter(\n ({ originalIndex }) =>\n searchResultState.showAllResults || originalIndex === searchResultState.activeResultIndex,\n );\n\n return (\n <div\n style={{\n ...style,\n pointerEvents: 'none',\n }}\n {...props}\n >\n {resultsToShow.map(({ result, originalIndex }) =>\n result.rects.map((rect, rectIndex) => (\n <div\n key={`${originalIndex}-${rectIndex}`}\n style={{\n position: 'absolute',\n top: rect.origin.y * actualScale,\n left: rect.origin.x * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"names":["useSearchCapability","useCapability","SearchPlugin","id","documentId","pageIndex","scale","scaleOverride","style","highlightColor","activeHighlightColor","props","provides","searchProvides","searchResultState","setSearchResultState","useState","documentState","useDocumentState","scope","useMemo","forDocument","actualScale","useEffect","currentState","getState","results","activeResultIndex","showAllResults","active","onSearchResultStateChange","state","resultsToShow","map","result","originalIndex","filter","jsx","pointerEvents","children","rects","rect","rectIndex","position","top","origin","y","left","x","width","size","height","backgroundColor","mixBlendMode","transform","transformOrigin","transition","opacity","searchState","setSearchState","initialSearchDocumentState","onStateChange","usePlugin"],"mappings":"+MAUaA,EAAsB,IAAMC,gBAA4BC,EAAAA,aAAaC,wBCK3E,UA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KAAKC,OAAS7B,EAC3B8B,gBACEjB,IAAkBrB,EAAkBa,kBAChCjB,EACAD,EACN4C,aAAc,WACdC,UAAW,cACXC,gBAAiB,SACjBC,WAAY,0BACZC,QAAS,IAfN,GAAGtB,KAAiBO,QAsBrC,oBD5FEtC,IAKA,MAAMQ,SAAEA,GAAaZ,KACd0D,EAAaC,GAAkB3C,EAAAA,SAA8B4C,EAAAA,4BAE9DzC,EAAQC,UAAQ,IAAM,MAAAR,OAAA,EAAAA,EAAUS,YAAYjB,GAAa,CAACQ,EAAUR,IAa1E,OAXAmB,EAAAA,UAAU,KACR,GAAKJ,EAOL,OAFAwC,EAAexC,EAAMM,YAEdN,EAAM0C,cAAe9B,GAAU4B,EAAe5B,IANnD4B,EAAeC,EAAAA,6BAOhB,CAACzC,IAEG,CACLY,MAAO2B,EACP9C,SAAUO,GAAS,6DA3BQ,IAAM2C,YAAwB5D,EAAAA,aAAaC"}
|
package/dist/react/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../shared-react';
|
package/dist/react/index.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/react";
|
|
2
|
-
import { initialSearchDocumentState, SearchPlugin } from "@embedpdf/plugin-search";
|
|
3
|
-
export * from "@embedpdf/plugin-search";
|
|
4
|
-
import { useState, useMemo, useEffect } from "react";
|
|
5
|
-
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
const useSearchPlugin = () => usePlugin(SearchPlugin.id);
|
|
7
|
-
const useSearchCapability = () => useCapability(SearchPlugin.id);
|
|
8
|
-
const useSearch = (documentId) => {
|
|
9
|
-
const { provides } = useSearchCapability();
|
|
10
|
-
const [searchState, setSearchState] = useState(initialSearchDocumentState);
|
|
11
|
-
const scope = useMemo(() => provides == null ? void 0 : provides.forDocument(documentId), [provides, documentId]);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
if (!scope) {
|
|
14
|
-
setSearchState(initialSearchDocumentState);
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
setSearchState(scope.getState());
|
|
18
|
-
return scope.onStateChange((state) => setSearchState(state));
|
|
19
|
-
}, [scope]);
|
|
20
|
-
return {
|
|
21
|
-
state: searchState,
|
|
22
|
-
provides: scope ?? null
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
function SearchLayer({
|
|
26
|
-
documentId,
|
|
27
|
-
pageIndex,
|
|
28
|
-
scale: scaleOverride,
|
|
29
|
-
style,
|
|
30
|
-
highlightColor = "#FFFF00",
|
|
31
|
-
activeHighlightColor = "#FFBF00",
|
|
32
|
-
...props
|
|
33
|
-
}) {
|
|
34
|
-
const { provides: searchProvides } = useSearchCapability();
|
|
35
|
-
const [searchResultState, setSearchResultState] = useState(null);
|
|
36
|
-
const documentState = useDocumentState(documentId);
|
|
37
|
-
const scope = useMemo(
|
|
38
|
-
() => searchProvides == null ? void 0 : searchProvides.forDocument(documentId),
|
|
39
|
-
[searchProvides, documentId]
|
|
40
|
-
);
|
|
41
|
-
const actualScale = useMemo(() => {
|
|
42
|
-
if (scaleOverride !== void 0) return scaleOverride;
|
|
43
|
-
return (documentState == null ? void 0 : documentState.scale) ?? 1;
|
|
44
|
-
}, [scaleOverride, documentState == null ? void 0 : documentState.scale]);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!scope) {
|
|
47
|
-
setSearchResultState(null);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const currentState = scope.getState();
|
|
51
|
-
setSearchResultState({
|
|
52
|
-
results: currentState.results,
|
|
53
|
-
activeResultIndex: currentState.activeResultIndex,
|
|
54
|
-
showAllResults: currentState.showAllResults,
|
|
55
|
-
active: currentState.active
|
|
56
|
-
});
|
|
57
|
-
return scope.onSearchResultStateChange((state) => {
|
|
58
|
-
setSearchResultState(state);
|
|
59
|
-
});
|
|
60
|
-
}, [scope]);
|
|
61
|
-
if (!searchResultState || !searchResultState.active) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
const pageResults = searchResultState.results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === pageIndex);
|
|
65
|
-
const resultsToShow = pageResults.filter(
|
|
66
|
-
({ originalIndex }) => searchResultState.showAllResults || originalIndex === searchResultState.activeResultIndex
|
|
67
|
-
);
|
|
68
|
-
return /* @__PURE__ */ jsx(
|
|
69
|
-
"div",
|
|
70
|
-
{
|
|
71
|
-
style: {
|
|
72
|
-
...style,
|
|
73
|
-
pointerEvents: "none"
|
|
74
|
-
},
|
|
75
|
-
...props,
|
|
76
|
-
children: resultsToShow.map(
|
|
77
|
-
({ result, originalIndex }) => result.rects.map((rect, rectIndex) => /* @__PURE__ */ jsx(
|
|
78
|
-
"div",
|
|
79
|
-
{
|
|
80
|
-
style: {
|
|
81
|
-
position: "absolute",
|
|
82
|
-
top: rect.origin.y * actualScale,
|
|
83
|
-
left: rect.origin.x * actualScale,
|
|
84
|
-
width: rect.size.width * actualScale,
|
|
85
|
-
height: rect.size.height * actualScale,
|
|
86
|
-
backgroundColor: originalIndex === searchResultState.activeResultIndex ? activeHighlightColor : highlightColor,
|
|
87
|
-
mixBlendMode: "multiply",
|
|
88
|
-
transform: "scale(1.02)",
|
|
89
|
-
transformOrigin: "center",
|
|
90
|
-
transition: "opacity .3s ease-in-out",
|
|
91
|
-
opacity: 1
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
`${originalIndex}-${rectIndex}`
|
|
95
|
-
))
|
|
96
|
-
)
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
SearchLayer,
|
|
102
|
-
useSearch,
|
|
103
|
-
useSearchCapability,
|
|
104
|
-
useSearchPlugin
|
|
105
|
-
};
|
|
106
|
-
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/shared/hooks/use-search.ts","../../src/shared/components/search-layer.tsx"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n SearchPlugin,\n SearchDocumentState,\n SearchScope,\n initialSearchDocumentState,\n} from '@embedpdf/plugin-search';\nimport { useEffect, useMemo, useState } from '@framework';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\nexport const useSearch = (\n documentId: string,\n): {\n state: SearchDocumentState;\n provides: SearchScope | null;\n} => {\n const { provides } = useSearchCapability();\n const [searchState, setSearchState] = useState<SearchDocumentState>(initialSearchDocumentState);\n\n const scope = useMemo(() => provides?.forDocument(documentId), [provides, documentId]);\n\n useEffect(() => {\n if (!scope) {\n setSearchState(initialSearchDocumentState);\n return;\n }\n // Set initial state\n setSearchState(scope.getState());\n // Subscribe to changes\n return scope.onStateChange((state) => setSearchState(state));\n }, [scope]);\n\n return {\n state: searchState,\n provides: scope ?? null,\n };\n};\n","import { useEffect, useMemo, useState, HTMLAttributes, CSSProperties } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { SearchResultState } from '@embedpdf/plugin-search';\n\nimport { useSearchCapability } from '../hooks';\n\ntype SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n scale?: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n style?: CSSProperties;\n};\n\nexport function SearchLayer({\n documentId,\n pageIndex,\n scale: scaleOverride,\n style,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...props\n}: SearchLayoutProps) {\n const { provides: searchProvides } = useSearchCapability();\n const [searchResultState, setSearchResultState] = useState<SearchResultState | null>(null);\n const documentState = useDocumentState(documentId);\n\n const scope = useMemo(\n () => searchProvides?.forDocument(documentId),\n [searchProvides, documentId],\n );\n\n const actualScale = useMemo(() => {\n if (scaleOverride !== undefined) return scaleOverride;\n return documentState?.scale ?? 1;\n }, [scaleOverride, documentState?.scale]);\n\n useEffect(() => {\n if (!scope) {\n setSearchResultState(null);\n return;\n }\n // Set initial state\n const currentState = scope.getState();\n setSearchResultState({\n results: currentState.results,\n activeResultIndex: currentState.activeResultIndex,\n showAllResults: currentState.showAllResults,\n active: currentState.active,\n });\n // Subscribe to changes\n return scope.onSearchResultStateChange((state) => {\n setSearchResultState(state);\n });\n }, [scope]);\n\n if (!searchResultState || !searchResultState.active) {\n return null;\n }\n\n // Filter results for current page while preserving original indices\n const pageResults = searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex);\n\n // Decide which results to show\n const resultsToShow = pageResults.filter(\n ({ originalIndex }) =>\n searchResultState.showAllResults || originalIndex === searchResultState.activeResultIndex,\n );\n\n return (\n <div\n style={{\n ...style,\n pointerEvents: 'none',\n }}\n {...props}\n >\n {resultsToShow.map(({ result, originalIndex }) =>\n result.rects.map((rect, rectIndex) => (\n <div\n key={`${originalIndex}-${rectIndex}`}\n style={{\n position: 'absolute',\n top: rect.origin.y * actualScale,\n left: rect.origin.x * actualScale,\n width: rect.size.width * actualScale,\n height: rect.size.height * actualScale,\n backgroundColor:\n originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor,\n mixBlendMode: 'multiply',\n transform: 'scale(1.02)',\n transformOrigin: 'center',\n transition: 'opacity .3s ease-in-out',\n opacity: 1,\n }}\n ></div>\n )),\n )}\n </div>\n );\n}\n"],"names":[],"mappings":";;;;;AASO,MAAM,kBAAkB,MAAM,UAAwB,aAAa,EAAE;AACrE,MAAM,sBAAsB,MAAM,cAA4B,aAAa,EAAE;AAE7E,MAAM,YAAY,CACvB,eAIG;AACH,QAAM,EAAE,SAAA,IAAa,oBAAA;AACrB,QAAM,CAAC,aAAa,cAAc,IAAI,SAA8B,0BAA0B;AAE9F,QAAM,QAAQ,QAAQ,MAAM,qCAAU,YAAY,aAAa,CAAC,UAAU,UAAU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BAAkB,QACnC,IAAI,CAAC,QAAQ,mBAAmB,EAAE,QAAQ,gBAAgB,EAC1D,OAAO,CAAC,EAAE,aAAa,OAAO,cAAc,SAAS;AAGxD,QAAM,gBAAgB,YAAY;AAAA,IAChC,CAAC,EAAE,cAAA,MACD,kBAAkB,kBAAkB,kBAAkB,kBAAkB;AAAA,EAAA;AAG5E,SACE;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,GAAG;AAAA,QACH,eAAe;AAAA,MAAA;AAAA,MAEhB,GAAG;AAAA,MAEH,UAAA,cAAc;AAAA,QAAI,CAAC,EAAE,QAAQ,cAAA,MAC5B,OAAO,MAAM,IAAI,CAAC,MAAM,cACtB;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,OAAO;AAAA,cACL,UAAU;AAAA,cACV,KAAK,KAAK,OAAO,IAAI;AAAA,cACrB,MAAM,KAAK,OAAO,IAAI;AAAA,cACtB,OAAO,KAAK,KAAK,QAAQ;AAAA,cACzB,QAAQ,KAAK,KAAK,SAAS;AAAA,cAC3B,iBACE,kBAAkB,kBAAkB,oBAChC,uBACA;AAAA,cACN,cAAc;AAAA,cACd,WAAW;AAAA,cACX,iBAAiB;AAAA,cACjB,YAAY;AAAA,cACZ,SAAS;AAAA,YAAA;AAAA,UACX;AAAA,UAhBK,GAAG,aAAa,IAAI,SAAS;AAAA,QAAA,CAkBrC;AAAA,MAAA;AAAA,IACH;AAAA,EAAA;AAGN;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './search-layer';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
-
type SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
-
documentId: string;
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
scale?: number;
|
|
6
|
-
highlightColor?: string;
|
|
7
|
-
activeHighlightColor?: string;
|
|
8
|
-
style?: CSSProperties;
|
|
9
|
-
};
|
|
10
|
-
export declare function SearchLayer({ documentId, pageIndex, scale: scaleOverride, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-search';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SearchPlugin, SearchDocumentState, SearchScope } from '../../index.ts';
|
|
2
|
-
export declare const useSearchPlugin: () => {
|
|
3
|
-
plugin: SearchPlugin | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSearchCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../index.ts').SearchCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export declare const useSearch: (documentId: string) => {
|
|
13
|
-
state: SearchDocumentState;
|
|
14
|
-
provides: SearchScope | null;
|
|
15
|
-
};
|
package/dist/shared/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './search-layer';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes, CSSProperties } from '../../preact/adapter.ts';
|
|
2
|
-
type SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
-
documentId: string;
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
scale?: number;
|
|
6
|
-
highlightColor?: string;
|
|
7
|
-
activeHighlightColor?: string;
|
|
8
|
-
style?: CSSProperties;
|
|
9
|
-
};
|
|
10
|
-
export declare function SearchLayer({ documentId, pageIndex, scale: scaleOverride, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): import("preact").JSX.Element | null;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-search';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SearchPlugin, SearchDocumentState, SearchScope } from '../../lib/index.ts';
|
|
2
|
-
export declare const useSearchPlugin: () => {
|
|
3
|
-
plugin: SearchPlugin | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSearchCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export declare const useSearch: (documentId: string) => {
|
|
13
|
-
state: SearchDocumentState;
|
|
14
|
-
provides: SearchScope | null;
|
|
15
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './search-layer';
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes, CSSProperties } from '../../react/adapter.ts';
|
|
2
|
-
type SearchLayoutProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {
|
|
3
|
-
documentId: string;
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
scale?: number;
|
|
6
|
-
highlightColor?: string;
|
|
7
|
-
activeHighlightColor?: string;
|
|
8
|
-
style?: CSSProperties;
|
|
9
|
-
};
|
|
10
|
-
export declare function SearchLayer({ documentId, pageIndex, scale: scaleOverride, style, highlightColor, activeHighlightColor, ...props }: SearchLayoutProps): import("react/jsx-runtime").JSX.Element | null;
|
|
11
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-search';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { SearchPlugin, SearchDocumentState, SearchScope } from '../../lib/index.ts';
|
|
2
|
-
export declare const useSearchPlugin: () => {
|
|
3
|
-
plugin: SearchPlugin | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSearchCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
export declare const useSearch: (documentId: string) => {
|
|
13
|
-
state: SearchDocumentState;
|
|
14
|
-
provides: SearchScope | null;
|
|
15
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLAttributes } from 'svelte/elements';
|
|
2
|
-
interface SearchLayerProps extends HTMLAttributes<HTMLDivElement> {
|
|
3
|
-
documentId: string;
|
|
4
|
-
pageIndex: number;
|
|
5
|
-
scale?: number;
|
|
6
|
-
highlightColor?: string;
|
|
7
|
-
activeHighlightColor?: string;
|
|
8
|
-
}
|
|
9
|
-
declare const SearchLayer: import('svelte', { with: { "resolution-mode": "import" } }).Component<SearchLayerProps, {}, "">;
|
|
10
|
-
type SearchLayer = ReturnType<typeof SearchLayer>;
|
|
11
|
-
export default SearchLayer;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as SearchLayer } from './SearchLayer.svelte';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './use-search.svelte';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { SearchPlugin, SearchDocumentState, SearchScope } from '../../lib/index.ts';
|
|
2
|
-
export declare const useSearchPlugin: () => {
|
|
3
|
-
plugin: SearchPlugin | null;
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
ready: Promise<void>;
|
|
6
|
-
};
|
|
7
|
-
export declare const useSearchCapability: () => {
|
|
8
|
-
provides: Readonly<import('../../lib/index.ts').SearchCapability> | null;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
ready: Promise<void>;
|
|
11
|
-
};
|
|
12
|
-
interface UseSearchReturn {
|
|
13
|
-
provides: SearchScope | null;
|
|
14
|
-
state: SearchDocumentState;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Hook for search state for a specific document
|
|
18
|
-
* @param getDocumentId Function that returns the document ID
|
|
19
|
-
*/
|
|
20
|
-
export declare const useSearch: (getDocumentId: () => string | null) => UseSearchReturn;
|
|
21
|
-
export {};
|
package/dist/svelte/index.cjs
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("svelte/internal/client"),t=require("@embedpdf/core/svelte"),r=require("@embedpdf/plugin-search");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}require("svelte/internal/disclose-version");const n=i(e),o=()=>t.useCapability(r.SearchPlugin.id);var s=n.from_html("<div></div>"),l=n.from_html("<div></div>");exports.SearchLayer=function(e,r){n.push(r,!0);let i=n.prop(r,"highlightColor",3,"#FFFF00"),a=n.prop(r,"activeHighlightColor",3,"#FFBF00"),c=function(e,t,r){const i=t instanceof Set?t:new Set(t);"function"!=typeof i.includes&&(i.includes=Set.prototype.has.bind(i));return n.rest_props(e,i,r)}(r,["$$slots","$$events","$$legacy","documentId","pageIndex","scale","highlightColor","activeHighlightColor"]);const u=o(),d=t.useDocumentState(()=>r.documentId);let g=n.state(null);const p=n.derived(()=>{var e;return(null==(e=u.provides)?void 0:e.forDocument(r.documentId))??null}),v=n.derived(()=>{var e;return void 0!==r.scale?r.scale:(null==(e=d.current)?void 0:e.scale)??1});n.user_effect(()=>{if(!n.get(p))return void n.set(g,null);const e=n.get(p).getState();return n.set(g,{results:e.results,activeResultIndex:e.activeResultIndex,showAllResults:e.showAllResults,active:e.active},!0),n.get(p).onSearchResultStateChange(e=>{n.set(g,e,!0)})});const f=n.derived(()=>n.get(g)?n.get(g).results.map((e,t)=>({result:e,originalIndex:t})).filter(({result:e})=>e.pageIndex===r.pageIndex):[]),h=n.derived(()=>n.get(g)?n.get(f).filter(({originalIndex:e})=>n.get(g).showAllResults||e===n.get(g).activeResultIndex):[]);var m=n.comment(),x=n.first_child(m),S=e=>{var t=l();n.attribute_effect(t,()=>({...c,[n.STYLE]:{"pointer-events":"none"}})),n.each(t,23,()=>n.get(h),({result:e,originalIndex:t},r)=>`result-${r}`,(e,t,r)=>{var o=n.comment(),l=n.first_child(o);n.each(l,19,()=>n.get(t).result.rects,(e,t)=>`rect-${n.get(r)}-${t}`,(e,r)=>{var o=s();let l;n.template_effect(()=>l=n.set_style(o,"",l,{position:"absolute",top:n.get(r).origin.y*n.get(v)+"px",left:n.get(r).origin.x*n.get(v)+"px",width:n.get(r).size.width*n.get(v)+"px",height:n.get(r).size.height*n.get(v)+"px","background-color":n.get(t).originalIndex===n.get(g).activeResultIndex?a():i(),"mix-blend-mode":"multiply",transform:"scale(1.02)","transform-origin":"center",transition:"opacity .3s ease-in-out",opacity:"1"})),n.append(e,o)}),n.append(e,o)}),n.reset(t),n.append(e,t)};n.if(x,e=>{n.get(g)&&n.get(g).active&&e(S)}),n.append(e,m),n.pop()},exports.useSearch=e=>{const t=o();let i=n.state(n.proxy(r.initialSearchDocumentState));const s=n.derived(e),l=n.derived(()=>t.provides&&n.get(s)?t.provides.forDocument(n.get(s)):null);return n.user_effect(()=>{const e=t.provides,o=n.get(s);if(!e||!o)return void n.set(i,r.initialSearchDocumentState,!0);const l=e.forDocument(o);return n.set(i,l.getState(),!0),l.onStateChange(e=>{n.set(i,e,!0)})}),{get provides(){return n.get(l)},get state(){return n.get(i)}}},exports.useSearchCapability=o,exports.useSearchPlugin=()=>t.usePlugin(r.SearchPlugin.id),Object.keys(r).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>r[e]})});
|
|
2
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/svelte/hooks/use-search.svelte.ts","../../src/svelte/components/SearchLayer.svelte"],"sourcesContent":["import { useCapability, usePlugin } from '@embedpdf/core/svelte';\nimport {\n SearchPlugin,\n SearchDocumentState,\n SearchScope,\n initialSearchDocumentState,\n} from '@embedpdf/plugin-search';\n\nexport const useSearchPlugin = () => usePlugin<SearchPlugin>(SearchPlugin.id);\nexport const useSearchCapability = () => useCapability<SearchPlugin>(SearchPlugin.id);\n\n// Define the return type explicitly to maintain type safety\ninterface UseSearchReturn {\n provides: SearchScope | null;\n state: SearchDocumentState;\n}\n\n/**\n * Hook for search state for a specific document\n * @param getDocumentId Function that returns the document ID\n */\nexport const useSearch = (getDocumentId: () => string | null): UseSearchReturn => {\n const capability = useSearchCapability();\n\n let searchState = $state<SearchDocumentState>(initialSearchDocumentState);\n\n // Reactive documentId\n const documentId = $derived(getDocumentId());\n\n // Scoped capability for current docId\n const scopedProvides = $derived(\n capability.provides && documentId ? capability.provides.forDocument(documentId) : null,\n );\n\n $effect(() => {\n const provides = capability.provides;\n const docId = documentId;\n\n if (!provides || !docId) {\n searchState = initialSearchDocumentState;\n return;\n }\n\n const scope = provides.forDocument(docId);\n\n // Set initial state\n searchState = scope.getState();\n\n // Subscribe to changes\n return scope.onStateChange((state) => {\n searchState = state;\n });\n });\n\n return {\n get provides() {\n return scopedProvides;\n },\n get state() {\n return searchState;\n },\n };\n};\n","<script lang=\"ts\">\n import type { SearchResultState } from '@embedpdf/plugin-search';\n import { useDocumentState } from '@embedpdf/core/svelte';\n import { useSearchCapability } from '../hooks';\n import type { HTMLAttributes } from 'svelte/elements';\n\n interface SearchLayerProps extends HTMLAttributes<HTMLDivElement> {\n documentId: string;\n pageIndex: number;\n scale?: number;\n highlightColor?: string;\n activeHighlightColor?: string;\n }\n\n let {\n documentId,\n pageIndex,\n scale: scaleOverride,\n highlightColor = '#FFFF00',\n activeHighlightColor = '#FFBF00',\n ...divProps\n }: SearchLayerProps = $props();\n\n const searchCapability = useSearchCapability();\n const documentState = useDocumentState(() => documentId);\n\n let searchResultState = $state<SearchResultState | null>(null);\n\n const scope = $derived(searchCapability.provides?.forDocument(documentId) ?? null);\n\n const actualScale = $derived(\n scaleOverride !== undefined ? scaleOverride : (documentState.current?.scale ?? 1),\n );\n\n $effect(() => {\n if (!scope) {\n searchResultState = null;\n return;\n }\n\n // Set initial state\n const currentState = scope.getState();\n searchResultState = {\n results: currentState.results,\n activeResultIndex: currentState.activeResultIndex,\n showAllResults: currentState.showAllResults,\n active: currentState.active,\n };\n\n // Subscribe to changes\n return scope.onSearchResultStateChange((state) => {\n searchResultState = state;\n });\n });\n\n // Filter results for current page while preserving original indices\n const pageResults = $derived(\n searchResultState\n ? searchResultState.results\n .map((result, originalIndex) => ({ result, originalIndex }))\n .filter(({ result }) => result.pageIndex === pageIndex)\n : [],\n );\n\n // Decide which results to show\n const resultsToShow = $derived(\n searchResultState\n ? pageResults.filter(\n ({ originalIndex }) =>\n searchResultState!.showAllResults ||\n originalIndex === searchResultState!.activeResultIndex,\n )\n : [],\n );\n</script>\n\n{#if searchResultState && searchResultState.active}\n <div style:pointer-events=\"none\" {...divProps}>\n {#each resultsToShow as { result, originalIndex }, idx (`result-${idx}`)}\n {#each result.rects as rect, rectIdx (`rect-${idx}-${rectIdx}`)}\n <div\n style:position=\"absolute\"\n style:top=\"{rect.origin.y * actualScale}px\"\n style:left=\"{rect.origin.x * actualScale}px\"\n style:width=\"{rect.size.width * actualScale}px\"\n style:height=\"{rect.size.height * actualScale}px\"\n style:background-color={originalIndex === searchResultState.activeResultIndex\n ? activeHighlightColor\n : highlightColor}\n style:mix-blend-mode=\"multiply\"\n style:transform=\"scale(1.02)\"\n style:transform-origin=\"center\"\n style:transition=\"opacity .3s ease-in-out\"\n style:opacity=\"1\"\n ></div>\n {/each}\n {/each}\n </div>\n{/if}\n"],"names":["useSearchCapability","useCapability","SearchPlugin","id","highlightColor","activeHighlightColor","divProps","$$rest_props_compat","$$props","searchCapability","documentState","useDocumentState","documentId","searchResultState","$","state","scope","_a","provides","forDocument","actualScale","derived","scale","current","user_effect","get","set","currentState","getState","results","activeResultIndex","showAllResults","active","onSearchResultStateChange","pageResults","map","result","originalIndex","filter","pageIndex","resultsToShow","div","root_1","attribute_effect","STYLE","each","idx","$$anchor","$$item","rects","rect","rectIdx","div_1","root_3","styles","top","origin","y","left","x","width","size","height","$$render","consequent","getDocumentId","capability","searchState","initialSearchDocumentState","scopedProvides","docId","onStateChange","usePlugin"],"mappings":"sgBASaA,EAAA,IAA4BC,gBAA4BC,EAAAA,aAAaC,iHCS9E,IAAAC,8BAAiB,WACjBC,oCAAuB,WACpBC,yJAAOC,CAAAC,EAAA,4GAGN,MAAAC,EAAmBT,IACnBU,EAAgBC,EAAAA,iBAAgB,IAAAH,EAAAI,gBAElCC,EAAoBC,EAAAC,MAAiC,MAEnD,MAAAC,uBAAiB,OAAA,OAAAC,EAAAR,EAAiBS,eAAjB,EAAAD,EAA2BE,4BAA2B,OAEvEC,EAAWN,EAAAO,QAAA,WAAA,YACG,IADHb,EAAAc,MACYd,EAAAc,OAAoB,OAAAL,EAAAP,EAAca,kBAASD,QAAS,IAGjFR,EAAAU,YAAO,KACA,IAAAV,EAAAW,IAAAT,eACHF,EAAAY,IAAAb,EAAoB,YAKhBc,EAAYb,EAAAW,IAAGT,GAAMY,WASpB,aARPf,GACEgB,QAASF,EAAaE,QACtBC,kBAAmBH,EAAaG,kBAChCC,eAAgBJ,EAAaI,eAC7BC,OAAQL,EAAaK,YAIhBlB,EAAAW,IAAAT,GAAMiB,0BAA2BlB,IACtCD,EAAAY,IAAAb,EAAoBE,GAAK,OAKvB,MAAAmB,sBACJrB,GACIC,EAAAW,IAAAZ,GAAkBgB,QACfM,IAAG,CAAEC,EAAQC,KAAA,CAAqBD,SAAQC,mBAC1CC,OAAM,EAAIF,YAAaA,EAAOG,YAAS/B,EAAA+B,eAK1CC,sBACJ3B,GACIC,EAAAW,IAAAS,GAAYI,OAAM,EACbD,mBAAavB,EAAAW,IACdZ,GAAmBkB,gBACnBM,IAAavB,EAAAW,IAAKZ,GAAmBiB,sEAO9CW,EAAGC,IAAH5B,EAAA6B,iBAAA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@@ -1,134 +0,0 @@
|
|
|
1
|
-
import * as $ from "svelte/internal/client";
|
|
2
|
-
import { usePlugin, useCapability, useDocumentState } from "@embedpdf/core/svelte";
|
|
3
|
-
import { SearchPlugin, initialSearchDocumentState } from "@embedpdf/plugin-search";
|
|
4
|
-
export * from "@embedpdf/plugin-search";
|
|
5
|
-
import "svelte/internal/disclose-version";
|
|
6
|
-
const useSearchPlugin = () => usePlugin(SearchPlugin.id);
|
|
7
|
-
const useSearchCapability = () => useCapability(SearchPlugin.id);
|
|
8
|
-
const useSearch = (getDocumentId) => {
|
|
9
|
-
const capability = useSearchCapability();
|
|
10
|
-
let searchState = $.state($.proxy(initialSearchDocumentState));
|
|
11
|
-
const documentId = $.derived(getDocumentId);
|
|
12
|
-
const scopedProvides = $.derived(() => capability.provides && $.get(documentId) ? capability.provides.forDocument($.get(documentId)) : null);
|
|
13
|
-
$.user_effect(() => {
|
|
14
|
-
const provides = capability.provides;
|
|
15
|
-
const docId = $.get(documentId);
|
|
16
|
-
if (!provides || !docId) {
|
|
17
|
-
$.set(searchState, initialSearchDocumentState, true);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const scope = provides.forDocument(docId);
|
|
21
|
-
$.set(searchState, scope.getState(), true);
|
|
22
|
-
return scope.onStateChange((state) => {
|
|
23
|
-
$.set(searchState, state, true);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
get provides() {
|
|
28
|
-
return $.get(scopedProvides);
|
|
29
|
-
},
|
|
30
|
-
get state() {
|
|
31
|
-
return $.get(searchState);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
var root_3 = $.from_html(`<div></div>`);
|
|
36
|
-
var root_1 = $.from_html(`<div></div>`);
|
|
37
|
-
function SearchLayer($$anchor, $$props) {
|
|
38
|
-
$.push($$props, true);
|
|
39
|
-
let highlightColor = $.prop($$props, "highlightColor", 3, "#FFFF00"), activeHighlightColor = $.prop($$props, "activeHighlightColor", 3, "#FFBF00"), divProps = $$rest_props_compat($$props, [
|
|
40
|
-
"$$slots",
|
|
41
|
-
"$$events",
|
|
42
|
-
"$$legacy",
|
|
43
|
-
"documentId",
|
|
44
|
-
"pageIndex",
|
|
45
|
-
"scale",
|
|
46
|
-
"highlightColor",
|
|
47
|
-
"activeHighlightColor"
|
|
48
|
-
]);
|
|
49
|
-
const searchCapability = useSearchCapability();
|
|
50
|
-
const documentState = useDocumentState(() => $$props.documentId);
|
|
51
|
-
let searchResultState = $.state(null);
|
|
52
|
-
const scope = $.derived(() => {
|
|
53
|
-
var _a;
|
|
54
|
-
return ((_a = searchCapability.provides) == null ? void 0 : _a.forDocument($$props.documentId)) ?? null;
|
|
55
|
-
});
|
|
56
|
-
const actualScale = $.derived(() => {
|
|
57
|
-
var _a;
|
|
58
|
-
return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState.current) == null ? void 0 : _a.scale) ?? 1;
|
|
59
|
-
});
|
|
60
|
-
$.user_effect(() => {
|
|
61
|
-
if (!$.get(scope)) {
|
|
62
|
-
$.set(searchResultState, null);
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const currentState = $.get(scope).getState();
|
|
66
|
-
$.set(
|
|
67
|
-
searchResultState,
|
|
68
|
-
{
|
|
69
|
-
results: currentState.results,
|
|
70
|
-
activeResultIndex: currentState.activeResultIndex,
|
|
71
|
-
showAllResults: currentState.showAllResults,
|
|
72
|
-
active: currentState.active
|
|
73
|
-
},
|
|
74
|
-
true
|
|
75
|
-
);
|
|
76
|
-
return $.get(scope).onSearchResultStateChange((state) => {
|
|
77
|
-
$.set(searchResultState, state, true);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
const pageResults = $.derived(() => $.get(searchResultState) ? $.get(searchResultState).results.map((result, originalIndex) => ({ result, originalIndex })).filter(({ result }) => result.pageIndex === $$props.pageIndex) : []);
|
|
81
|
-
const resultsToShow = $.derived(() => $.get(searchResultState) ? $.get(pageResults).filter(({ originalIndex }) => $.get(searchResultState).showAllResults || originalIndex === $.get(searchResultState).activeResultIndex) : []);
|
|
82
|
-
var fragment = $.comment();
|
|
83
|
-
var node = $.first_child(fragment);
|
|
84
|
-
{
|
|
85
|
-
var consequent = ($$anchor2) => {
|
|
86
|
-
var div = root_1();
|
|
87
|
-
$.attribute_effect(div, () => ({ ...divProps, [$.STYLE]: { "pointer-events": "none" } }));
|
|
88
|
-
$.each(div, 23, () => $.get(resultsToShow), ({ result, originalIndex }, idx) => `result-${idx}`, ($$anchor3, $$item, idx) => {
|
|
89
|
-
let result = () => $.get($$item).result;
|
|
90
|
-
let originalIndex = () => $.get($$item).originalIndex;
|
|
91
|
-
var fragment_1 = $.comment();
|
|
92
|
-
var node_1 = $.first_child(fragment_1);
|
|
93
|
-
$.each(node_1, 19, () => result().rects, (rect, rectIdx) => `rect-${$.get(idx)}-${rectIdx}`, ($$anchor4, rect) => {
|
|
94
|
-
var div_1 = root_3();
|
|
95
|
-
let styles;
|
|
96
|
-
$.template_effect(() => styles = $.set_style(div_1, "", styles, {
|
|
97
|
-
position: "absolute",
|
|
98
|
-
top: `${$.get(rect).origin.y * $.get(actualScale)}px`,
|
|
99
|
-
left: `${$.get(rect).origin.x * $.get(actualScale)}px`,
|
|
100
|
-
width: `${$.get(rect).size.width * $.get(actualScale)}px`,
|
|
101
|
-
height: `${$.get(rect).size.height * $.get(actualScale)}px`,
|
|
102
|
-
"background-color": originalIndex() === $.get(searchResultState).activeResultIndex ? activeHighlightColor() : highlightColor(),
|
|
103
|
-
"mix-blend-mode": "multiply",
|
|
104
|
-
transform: "scale(1.02)",
|
|
105
|
-
"transform-origin": "center",
|
|
106
|
-
transition: "opacity .3s ease-in-out",
|
|
107
|
-
opacity: "1"
|
|
108
|
-
}));
|
|
109
|
-
$.append($$anchor4, div_1);
|
|
110
|
-
});
|
|
111
|
-
$.append($$anchor3, fragment_1);
|
|
112
|
-
});
|
|
113
|
-
$.reset(div);
|
|
114
|
-
$.append($$anchor2, div);
|
|
115
|
-
};
|
|
116
|
-
$.if(node, ($$render) => {
|
|
117
|
-
if ($.get(searchResultState) && $.get(searchResultState).active) $$render(consequent);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
$.append($$anchor, fragment);
|
|
121
|
-
$.pop();
|
|
122
|
-
}
|
|
123
|
-
function $$rest_props_compat(props, exclude, name) {
|
|
124
|
-
const set = exclude instanceof Set ? exclude : new Set(exclude);
|
|
125
|
-
if (typeof set.includes !== "function") set.includes = Set.prototype.has.bind(set);
|
|
126
|
-
return $.rest_props(props, set, name);
|
|
127
|
-
}
|
|
128
|
-
export {
|
|
129
|
-
SearchLayer,
|
|
130
|
-
useSearch,
|
|
131
|
-
useSearchCapability,
|
|
132
|
-
useSearchPlugin
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=index.js.map
|