react-web-pdf-editor 0.1.2 → 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 CHANGED
@@ -11,8 +11,6 @@ The editor includes:
11
11
  - Undo and redo
12
12
  - Export that flattens your edits into a downloadable PDF
13
13
 
14
- ![Editor with the document name and tools in the toolbar, page thumbnails on the left, the open PDF in the center, and the properties panel on the right](https://cdn.jsdelivr.net/npm/react-web-pdf-editor@0.1.1/docs/editor.png)
15
-
16
14
  Annotations stay in memory until you export. Changing the `file` prop starts a fresh document and clears them.
17
15
 
18
16
  ## Install
@@ -359,13 +357,13 @@ Keep the default thumbnails by rendering `PagesSidebar`:
359
357
 
360
358
  ## Workers
361
359
 
362
- 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:
363
361
 
364
362
  ```text
365
- https://unpkg.com/pdfjs-dist@<version>/build/pdf.worker.min.mjs
363
+ https://unpkg.com/pdfjs-dist@<version>/legacy/build/pdf.worker.min.mjs
366
364
  ```
367
365
 
368
- 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.
369
367
 
370
368
  ```tsx
371
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 pdfjsDist = require('pdfjs-dist');
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@${pdfjsDist.version}/build/pdf.worker.min.mjs`;
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
- pdfjsDist.GlobalWorkerOptions.workerSrc = workerSrc ?? DEFAULT_WORKER_SRC;
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
- pdfjsDist.setLayerDimensions(textLayerDiv, viewport);
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 pdfjsDist.TextLayer({
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 = pdfjsDist.getDocument(source);
7184
+ loadingTask = pdf_mjs.getDocument(source);
7185
7185
  const incoming = await loadingTask.promise;
7186
7186
  if (cancelled) {
7187
7187
  await incoming.destroy();