@rzymek/react-pdf-highlighter 8.0.2 → 8.0.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/components/PdfHighlighter.d.ts +3 -1
- package/dist/node_modules/.pnpm/{pdfjs-dist@4.4.168 → pdfjs-dist@6.0.227}/node_modules/pdfjs-dist/web/pdf_viewer.js +2904 -1247
- package/dist/src/components/PdfHighlighter.js +28 -19
- package/dist/src/components/PdfLoader.js +3 -3
- package/dist/style.css +4942 -1388
- package/package.json +2 -2
|
@@ -29,6 +29,8 @@ class PdfHighlighter extends PureComponent {
|
|
|
29
29
|
tipChildren: null
|
|
30
30
|
});
|
|
31
31
|
__publicField(this, "viewer");
|
|
32
|
+
__publicField(this, "eventBus");
|
|
33
|
+
__publicField(this, "linkService");
|
|
32
34
|
__publicField(this, "resizeObserver", null);
|
|
33
35
|
__publicField(this, "containerNode", null);
|
|
34
36
|
__publicField(this, "containerNodeRef");
|
|
@@ -261,29 +263,36 @@ class PdfHighlighter extends PureComponent {
|
|
|
261
263
|
}
|
|
262
264
|
}
|
|
263
265
|
async init() {
|
|
266
|
+
var _a;
|
|
264
267
|
const { pdfDocument, pdfViewerOptions } = this.props;
|
|
265
|
-
const pdfjs = await import("../../node_modules/.pnpm/pdfjs-dist@
|
|
266
|
-
const eventBus = new pdfjs.EventBus();
|
|
267
|
-
const linkService = new pdfjs.PDFLinkService({
|
|
268
|
-
eventBus,
|
|
269
|
-
externalLinkTarget: 2
|
|
270
|
-
});
|
|
268
|
+
const pdfjs = await import("../../node_modules/.pnpm/pdfjs-dist@6.0.227/node_modules/pdfjs-dist/web/pdf_viewer.js");
|
|
271
269
|
if (!this.containerNodeRef.current) {
|
|
272
270
|
throw new Error("!");
|
|
273
271
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
272
|
+
if (!this.viewer) {
|
|
273
|
+
const eventBus = new pdfjs.EventBus();
|
|
274
|
+
const linkService = new pdfjs.PDFLinkService({
|
|
275
|
+
eventBus,
|
|
276
|
+
externalLinkTarget: 2
|
|
277
|
+
});
|
|
278
|
+
this.viewer = new pdfjs.PDFViewer({
|
|
279
|
+
container: this.containerNodeRef.current,
|
|
280
|
+
eventBus,
|
|
281
|
+
// enhanceTextSelection: true, // deprecated. https://github.com/mozilla/pdf.js/issues/9943#issuecomment-409369485
|
|
282
|
+
textLayerMode: 2,
|
|
283
|
+
removePageBorders: true,
|
|
284
|
+
linkService,
|
|
285
|
+
...pdfViewerOptions
|
|
286
|
+
});
|
|
287
|
+
this.eventBus = eventBus;
|
|
288
|
+
this.linkService = linkService;
|
|
289
|
+
linkService.setViewer(this.viewer);
|
|
290
|
+
this.attachRef(eventBus);
|
|
291
|
+
}
|
|
292
|
+
if (this.viewer.pdfDocument !== pdfDocument) {
|
|
293
|
+
(_a = this.linkService) == null ? void 0 : _a.setDocument(pdfDocument);
|
|
294
|
+
this.viewer.setDocument(pdfDocument);
|
|
295
|
+
}
|
|
287
296
|
}
|
|
288
297
|
componentWillUnmount() {
|
|
289
298
|
this.unsubscribe();
|
|
@@ -19,7 +19,7 @@ class PdfLoader extends Component {
|
|
|
19
19
|
componentWillUnmount() {
|
|
20
20
|
const { pdfDocument: discardedDocument } = this.state;
|
|
21
21
|
if (discardedDocument) {
|
|
22
|
-
discardedDocument.destroy();
|
|
22
|
+
discardedDocument.loadingTask.destroy();
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
componentDidUpdate({ url }) {
|
|
@@ -42,7 +42,7 @@ class PdfLoader extends Component {
|
|
|
42
42
|
if (typeof workerSrc === "string") {
|
|
43
43
|
GlobalWorkerOptions.workerSrc = workerSrc;
|
|
44
44
|
}
|
|
45
|
-
Promise.resolve().then(() => discardedDocument == null ? void 0 : discardedDocument.destroy()).then(() => {
|
|
45
|
+
Promise.resolve().then(() => discardedDocument == null ? void 0 : discardedDocument.loadingTask.destroy()).then(() => {
|
|
46
46
|
if (!url) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
@@ -74,7 +74,7 @@ class PdfLoader extends Component {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
__publicField(PdfLoader, "defaultProps", {
|
|
77
|
-
workerSrc: "https://unpkg.com/pdfjs-dist@
|
|
77
|
+
workerSrc: "https://unpkg.com/pdfjs-dist@6.0.227/build/pdf.worker.min.mjs"
|
|
78
78
|
});
|
|
79
79
|
export {
|
|
80
80
|
PdfLoader
|