react-web-pdf-editor 0.1.3 → 0.1.4
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/README.md +3 -3
- package/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -357,13 +357,13 @@ Keep the default thumbnails by rendering `PagesSidebar`:
|
|
|
357
357
|
|
|
358
358
|
## Workers
|
|
359
359
|
|
|
360
|
-
PDF.js renders pages on a worker. The default worker URL is a version-matched file on unpkg:
|
|
360
|
+
PDF.js renders pages on a worker. The default is the legacy build, because that worker runs in its own thread and does not see polyfills on the page. The URL is a version-matched file on unpkg:
|
|
361
361
|
|
|
362
362
|
```text
|
|
363
|
-
https://unpkg.com/pdfjs-dist@<version>/build/pdf.worker.min.mjs
|
|
363
|
+
https://unpkg.com/pdfjs-dist@<version>/legacy/build/pdf.worker.min.mjs
|
|
364
364
|
```
|
|
365
365
|
|
|
366
|
-
Self-host that file and pass `workerSrc` when the CDN is blocked or you want the worker on your own origin. Copy it from `node_modules/pdfjs-dist/build/pdf.worker.min.mjs`.
|
|
366
|
+
Self-host that file and pass `workerSrc` when the CDN is blocked or you want the worker on your own origin. Copy it from `node_modules/pdfjs-dist/legacy/build/pdf.worker.min.mjs`. A custom `workerSrc` has to be that legacy worker.
|
|
367
367
|
|
|
368
368
|
```tsx
|
|
369
369
|
<PdfEditor file={file} workerSrc="/pdf.worker.min.mjs" />
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pdfLib = require('pdf-lib');
|
|
4
|
-
var
|
|
4
|
+
var pdf_mjs = require('pdfjs-dist/legacy/build/pdf.mjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
@@ -620,9 +620,9 @@ var init_exportPdf = __esm({
|
|
|
620
620
|
HIGHLIGHT_OPACITY = 0.38;
|
|
621
621
|
}
|
|
622
622
|
});
|
|
623
|
-
var DEFAULT_WORKER_SRC = `https://unpkg.com/pdfjs-dist@${
|
|
623
|
+
var DEFAULT_WORKER_SRC = `https://unpkg.com/pdfjs-dist@${pdf_mjs.version}/legacy/build/pdf.worker.min.mjs`;
|
|
624
624
|
function configurePdfWorker(workerSrc) {
|
|
625
|
-
|
|
625
|
+
pdf_mjs.GlobalWorkerOptions.workerSrc = workerSrc ?? DEFAULT_WORKER_SRC;
|
|
626
626
|
}
|
|
627
627
|
var SWATCHES = ["#facc15", "#4ade80", "#38bdf8", "#f472b6", "#fb923c"];
|
|
628
628
|
function sameColor(a, b) {
|
|
@@ -3357,10 +3357,10 @@ function PdfPage({
|
|
|
3357
3357
|
canvas.style.height = `${cssHeight}px`;
|
|
3358
3358
|
context.drawImage(offscreen, 0, 0);
|
|
3359
3359
|
textLayerDiv.replaceChildren();
|
|
3360
|
-
|
|
3360
|
+
pdf_mjs.setLayerDimensions(textLayerDiv, viewport);
|
|
3361
3361
|
textLayerDiv.style.setProperty("--scale-factor", String(viewport.scale));
|
|
3362
3362
|
textLayerDiv.style.setProperty("--total-scale-factor", String(viewport.scale));
|
|
3363
|
-
textLayer = new
|
|
3363
|
+
textLayer = new pdf_mjs.TextLayer({
|
|
3364
3364
|
textContentSource: page.streamTextContent(),
|
|
3365
3365
|
container: textLayerDiv,
|
|
3366
3366
|
viewport
|
|
@@ -7181,7 +7181,7 @@ function usePdfDocument(file, workerSrc) {
|
|
|
7181
7181
|
setLoadPhase("loading");
|
|
7182
7182
|
setDownloadProgress(null);
|
|
7183
7183
|
}
|
|
7184
|
-
loadingTask =
|
|
7184
|
+
loadingTask = pdf_mjs.getDocument(source);
|
|
7185
7185
|
const incoming = await loadingTask.promise;
|
|
7186
7186
|
if (cancelled) {
|
|
7187
7187
|
await incoming.destroy();
|