@anaralabs/lector 3.15.2 → 3.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_tsup-dts-rollup.d.ts +0 -2
- package/dist/index.js +14 -7
- package/package.json +1 -1
|
@@ -841,7 +841,6 @@ export declare interface SearchResults {
|
|
|
841
841
|
hasMoreResults: boolean;
|
|
842
842
|
}
|
|
843
843
|
|
|
844
|
-
/** A mounted text layer. Only this object owns DOM nodes; snapshots never do. */
|
|
845
844
|
export declare class SelectionPage {
|
|
846
845
|
readonly element: HTMLElement;
|
|
847
846
|
readonly pageNumber: number;
|
|
@@ -1113,7 +1112,6 @@ declare type ViewportRef = {
|
|
|
1113
1112
|
current: HTMLDivElement | null;
|
|
1114
1113
|
};
|
|
1115
1114
|
|
|
1116
|
-
/** Materialize one missing selected page as text only, never as a page canvas. */
|
|
1117
1115
|
export declare function withSelectionPage<T>(proxy: PDFPageProxy, owner: Document, signal: AbortSignal, read: (page: SelectionPage) => T): Promise<T>;
|
|
1118
1116
|
|
|
1119
1117
|
export declare const ZoomIn: ({ ...props }: HTMLProps<HTMLButtonElement>) => JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -267,7 +267,10 @@ var SelectionPage = class {
|
|
|
267
267
|
point(offset3, end = false) {
|
|
268
268
|
const index = Math.max(0, Math.min(offset3, this.content.text.length));
|
|
269
269
|
const item = this.nodes.find((item2) => end ? item2.end >= index : item2.end > index) ?? this.nodes.at(-1);
|
|
270
|
-
return item
|
|
270
|
+
return item && this.element.contains(item.node) ? {
|
|
271
|
+
node: item.node,
|
|
272
|
+
offset: Math.max(0, Math.min(index - item.start, item.node.length))
|
|
273
|
+
} : null;
|
|
271
274
|
}
|
|
272
275
|
rects(from, to) {
|
|
273
276
|
const bounds = this.element.getBoundingClientRect();
|
|
@@ -275,13 +278,17 @@ var SelectionPage = class {
|
|
|
275
278
|
const scaleY = bounds.height / this.height || 1;
|
|
276
279
|
const rects = [];
|
|
277
280
|
for (const item of this.nodes) {
|
|
278
|
-
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
if (!this.element.contains(item.node)) continue;
|
|
282
|
+
const start = Math.max(0, from - item.start);
|
|
283
|
+
const end = Math.min(
|
|
284
|
+
to - item.start,
|
|
285
|
+
item.end - item.start,
|
|
286
|
+
item.node.length
|
|
287
|
+
);
|
|
288
|
+
if (end <= start || !item.node.data.slice(start, end).trim()) continue;
|
|
282
289
|
const range = this.element.ownerDocument.createRange();
|
|
283
|
-
range.setStart(item.node, start
|
|
284
|
-
range.setEnd(item.node, end
|
|
290
|
+
range.setStart(item.node, start);
|
|
291
|
+
range.setEnd(item.node, end);
|
|
285
292
|
for (const rect of range.getClientRects()) {
|
|
286
293
|
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
287
294
|
rects.push({
|