Commit Graph

16153 Commits

Author SHA1 Message Date
calixteman
3043423c82
Merge pull request #15381 from calixteman/rm_leftover
[Editor] Remove some useless code (#15373 follow-up)
2022-09-01 20:38:07 +02:00
Calixte Denizet
c4aa00bee1 [Editor] Remove some useless code (#15373 follow-up) 2022-09-01 19:34:30 +02:00
calixteman
e9bdbe4574
Merge pull request #15373 from calixteman/copy_paste
[Editor] Use the global clipboard for the copy/paste/cut operations
2022-08-31 16:53:16 +02:00
Calixte Denizet
372d4d64e3 [Editor] Use the global clipboard for the copy/paste/cut operations
It slightly helps to reduce the code size and its complexity.
But the cool thing is that it allows to copy/paste some anntations from a pdf
to an other.
2022-08-31 16:32:19 +02:00
calixteman
54d3b64497
Merge pull request #15369 from calixteman/update_params
[Editor] Avoid to update default params too early
2022-08-31 11:18:08 +02:00
Calixte Denizet
e91d67563f [Editor] Avoid to update default params too early 2022-08-31 10:28:58 +02:00
Jonas Jenwald
1865bb6526
Merge pull request #15368 from Snuffleupagus/issue-15367
[api-minor] Support Named-actions in the outline (issue 15367)
2022-08-30 22:13:29 +02:00
Jonas Jenwald
216b86a082 [api-minor] Support Named-actions in the outline (issue 15367)
Apparently this is implemented in e.g. Adobe Reader, and the specification does support it, however it cannot be commonly used in real-world PDF documents since it took over ten years for this feature to be requested.
2022-08-30 18:47:45 +02:00
Tim van der Meij
86370bd5c5
Merge pull request #15286 from Snuffleupagus/rm-deprecated
[api-major] Remove (most of) the remaining `deprecated` code
2022-08-28 19:21:45 +02:00
Tim van der Meij
7b7b54ce0f
Merge pull request #15259 from Snuffleupagus/rm-enhanceTextSelection
[api-major] Remove the `enhanceTextSelection` functionality (PR 15145 follow-up)
2022-08-28 19:13:33 +02:00
Jonas Jenwald
78f24e5535 [api-major] Remove (most of) the remaining deprecated code
There's three notable exceptions here:
 - The `saveDocument` one is converted into a permanent `warn`, since it still works when the `annotationStorage` is empty although it's (obviously) less efficient than `getData`.
 - The `fallbackWorkerSrc` functionality (for browsers), since just removing it would risk too much third-party breakage.
 - The SVG back-end, since a final decision is yet to be made. (It might be completely removed, or left as-is in an essentially "frozen" state.)
2022-08-28 15:05:00 +02:00
Jonas Jenwald
d3005603e1 Move the saveDocument method, within the PDFDocumentProxy/WorkerTransport classes
To improve discoverability, since these methods are very closely related, move `saveDocument` to just after `getData` instead.
2022-08-28 15:05:00 +02:00
Jonas Jenwald
571ce13dd6 [api-major] Remove the enhanceTextSelection functionality (PR 15145 follow-up)
For the `gulp mozcentral` command, this reduces the size of the *built* `pdf.js` file by `> 10` kB.
2022-08-28 15:04:47 +02:00
Tim van der Meij
3f8b5449e8
Merge pull request #15357 from timvandermeij/bump
Bump versions in `pdfjs.config`
2022-08-28 13:48:00 +02:00
Tim van der Meij
eba4da5802
Bump versions in pdfjs.config 2022-08-28 13:34:57 +02:00
Tim van der Meij
172ccdbe5b
Merge pull request #15356 from Snuffleupagus/Node-amend-compat-info
Update the Node.js `atob`/`btoa` compatibility info
2022-08-28 13:04:11 +02:00
Jonas Jenwald
ca823d1bbc Update the Node.js atob/btoa compatibility info
Given that Node.js has finally implemented native support for `atob`/`btoa`, it can't hurt to update the comments in `src/shared/compatibility.js` so that we don't forget to remove the polyfills once Node.js version `16` becomes the lowest supported LTS release; see
 - https://developer.mozilla.org/en-US/docs/Web/API/atob#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/API/btoa#browser_compatibility
2022-08-28 12:58:02 +02:00
Tim van der Meij
d62cce455f
Merge pull request #15349 from Snuffleupagus/bug-1787295
[editor] Remove the `editorNone` toolbar button (bug 1787295)
2022-08-27 14:04:06 +02:00
Tim van der Meij
c5b9e9aef8
Merge pull request #15351 from Snuffleupagus/bug-1785854
[api-minor][editor] Indicate, in the title, if the document has been edited (bug 1785854)
2022-08-27 13:52:07 +02:00
Tim van der Meij
d715094383
Merge pull request #15346 from Snuffleupagus/deprecated-imageLayer
[api-minor] Deprecate the `imageLayer` functionality
2022-08-27 13:16:31 +02:00
Tim van der Meij
4469453425
Merge pull request #15341 from Snuffleupagus/PasswordPrompt-cancel-button
Improve handling of the "Cancel"-button in the password dialog
2022-08-27 13:10:39 +02:00
Tim van der Meij
a1cc9238b0
Merge pull request #15343 from Snuffleupagus/AbortController-unconditional
Use `AbortController` unconditionally with the Fetch API
2022-08-27 13:08:26 +02:00
Tim van der Meij
cb8d56f988
Merge pull request #15344 from Snuffleupagus/prefer-array-find
Enable the `unicorn/prefer-array-find` ESLint plugin rule
2022-08-27 13:06:41 +02:00
Jonas Jenwald
4c63a91036
Merge pull request #15355 from Snuffleupagus/bug-1787456
Always focus the `viewerContainer` when entering PresentationMode (bug 1787456)
2022-08-27 11:18:19 +02:00
Jonas Jenwald
d93d21fdfd Always focus the viewerContainer when entering PresentationMode (bug 1787456)
This fixes the regression in [bug 1787456](https://bugzilla.mozilla.org/show_bug.cgi?id=1787456), assuming that it should be handled on the PDF.js side.
2022-08-26 21:42:06 +02:00
Jonas Jenwald
f2b5210b36
Merge pull request #15347 from federicobond/fix-types
Update types in PDFPageViewOptions to properly declare optional parameters
2022-08-26 20:48:12 +02:00
Jonas Jenwald
19182d5f25 [editor] Remove the editorNone toolbar button (bug 1787295) 2022-08-26 09:25:05 +02:00
Jonas Jenwald
151dfc9a25 [api-minor][editor] Indicate, in the title, if the document has been edited (bug 1785854)
Note that this patch prepends the document title with "* ", rather than only "*" as suggested in the bug, since there's nothing that says that a PDF document cannot specify a title[1] beginning with an asterisk. To reduce possible confusion, having a space between the "editing marker" and the actual document title thus cannot hurt as far as I'm concerned.

In order to notify the viewer when all `AnnotationEditor`s have been removed, we utilize the existing `onAnnotationEditor`-callback to allow the document title to be updated as necessary.

Finally, this patch makes the following (slightly unrelated) changes:
 - Rename the `AnnotationStorage.removeKey` method to just `AnnotationStorage.remove` instead. This is consistent with e.g. the `has`-method and should suffice to explain what it does.
 - Remove the `AnnotationStorage.hasAnnotationEditors` getter, since the viewer now tracks the necessary state internally. This avoids unnecessarily having to iterate through the `AnnotationStorage`-instance when saving/printing the document.

---
[1] Using either an /Info dictionary or a /Metadata stream.
2022-08-26 00:20:58 +02:00
Jonas Jenwald
76f665d57f
Merge pull request #15348 from Snuffleupagus/bug-1787296
[editor] Change the focus-outline to blue (bug 1787296)
2022-08-25 22:53:10 +02:00
Jonas Jenwald
a4bfa7d18b [editor] Change the focus-outline to blue (bug 1787296) 2022-08-25 22:40:20 +02:00
Federico Bond
df912e9ab6 Update types in PDFPageViewOptions to properly declare optional parameters 2022-08-25 13:36:05 -03:00
Jonas Jenwald
118da8e85d [api-minor] Deprecate the imageLayer functionality
This functionality has never been used anywhere in the PDF.js library/viewer itself, since it was added in 2013.
Furthermore this functionality is, and has always been, *completely untested* and also unmaintained.
Finally, there's (at least) one old issue about `appendImage` not returning the correct position; see issue 4182.

All-in-all, it seems that keeping very old, untested, unmaintained, and partially broken code around probably isn't what we want here.
(On the off-chance that any future a11y-work requires getting access to image-positions, it'd likely be much better to re-implement the necessary functionality from scratch and also make sure that it's properly tested from the beginning.)
2022-08-25 13:06:01 +02:00
Jonas Jenwald
3c8aeb445a Remove the CanvasGraphics.getCanvasPosition method
This old method, which is only used with the `imageLayer` functionality, is essentially just a re-implementation of the existing `Util.applyTransform` method.
2022-08-25 13:06:00 +02:00
Jonas Jenwald
723584dd4f Enable the unicorn/prefer-array-find ESLint plugin rule
Please find additional information here:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find#browser_compatibility
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-find.md
2022-08-24 16:46:26 +02:00
Jonas Jenwald
b0a73a9388 Use AbortController unconditionally with the Fetch API
Given the browsers that we currently support in the PDF.js project and the MDN compatibility data, see links below, it should no longer be necessary to check for the availability of `AbortController` before using it.
 - https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
 - https://developer.mozilla.org/en-US/docs/Web/API/AbortController#browser_compatibility
2022-08-24 12:13:09 +02:00
Jonas Jenwald
de14b82af9 Improve handling of the "Cancel"-button in the password dialog
The password dialog can be cancelled in three different ways:
 - By clicking on its "Cancel"-button.
 - By pressing the Escape-key.
 - By force-opening another dialog, although this shouldn't happen in practice.

Here the "Cancel"-button case is slightly special since it'll trigger `PasswordPrompt.#cancel` *twice*, first directly via the click and secondly via the "close" event on the `dialog`-element.
While this shouldn't, as far as I know, cause any bugs it's nonetheless inconsistent with the other cases outlined above. To improve this we can simply attempt to *close* the password dialog instead, and then rely on the "close" event to run the `PasswordPrompt.#cancel` method.
2022-08-22 11:17:08 +02:00
Tim van der Meij
14e8167df9
Merge pull request #15335 from Snuffleupagus/PasswordPrompt-activeCapability
Ensure that we don't try to re-open, or update the password-callback, when the password dialog is already open
2022-08-21 12:52:34 +02:00
Tim van der Meij
81a700079f
Merge pull request #15332 from Snuffleupagus/Babel-targets
[api-minor] Add the Babel `targets`-option to avoid transpiling code for unsupported browsers
2022-08-21 12:06:43 +02:00
Tim van der Meij
255cc8b9eb
Merge pull request #15338 from Snuffleupagus/update-packages
Update packages and translations
2022-08-21 11:45:46 +02:00
Jonas Jenwald
635db46b0d Update l10n files 2022-08-21 10:04:47 +02:00
Jonas Jenwald
1001ae5474 Update npm packages 2022-08-21 10:04:47 +02:00
Jonas Jenwald
6e31799948 [api-minor] Add the Babel targets-option to avoid transpiling code for unsupported browsers
Currently we simply use the Babel `preset-env` in the `legacy`-builds of the PDF.js library. This has the side-effect of transpiling the code for *very old* browsers/environments, including ones that we (since many years) no longer support which unnecessarily bloats the size of the `legacy`-builds.

For the CSS files we're only targeting *the supported browsers*, and it's thus possible to extend that to also apply to Babel.
One of the most significant changes, with this patch, is that we'll no longer polyfill `async`/`await` in the `legacy`-builds. However, this shouldn't be an issue given the browsers that we currently support in PDF.js; please refer to:
 - https://github.com/mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-support
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function#browser_compatibility
2022-08-19 22:19:43 +02:00
Jonas Jenwald
89840649d9 Ensure that we don't try to re-open, or update the password-callback, when the password dialog is already open
Currently in `disableWorker=true` mode it's possible that opening of password-protected PDF documents outright fails, if an *incorrect* password is entered. Apparently the event ordering is subtly different in the non-Worker case, which causes the password-callback to be updated *before* the dialog has been fully closed.
To avoid that we'll utilize a `PromiseCapability` to keep track of the state of the password dialog, such that we can delay both re-opening and (importantly) updating of the password-callback until doing so is safe.

This patch *may* also fix issue 15330, but it's impossible for me to tell.
2022-08-19 20:10:37 +02:00
calixteman
1a007164f7
Merge pull request #15329 from calixteman/1782564
[api-minor][Annotations] charLimit === 0 means unlimited (bug 1782564)
2022-08-19 12:54:47 +02:00
Calixte Denizet
c06c5f7cbd [Annotations] charLimit === 0 means unlimited (bug 1782564)
Changing the charLimit in JS had no impact, so this patch aims to fix
that and add an integration test for it.
2022-08-19 11:28:28 +02:00
Jonas Jenwald
8f74fe6e1b
Merge pull request #15327 from Snuffleupagus/bug-1785218
Correctly mimic the proper event-format in `AnnotationElement._setDefaultPropertiesFromJS` (bug 1785218)
2022-08-17 16:15:13 +02:00
Jonas Jenwald
5e126032ff Correctly mimic the proper event-format in AnnotationElement._setDefaultPropertiesFromJS (bug 1785218)
*This is a follow-up to PR 14869.*

In the old code we're accidentally "swallowing" part of the event-details, which explains why the annotationLayer didn't render.
One thing that made debugging a lot harder was the lack of error messages, from the viewer, and a few `PDFPageView`-methods were updated to improve this situation.
2022-08-17 15:44:27 +02:00
Jonas Jenwald
b05010c3eb
Merge pull request #15325 from Snuffleupagus/issue-15324
Ignoring "resize" events during printing (issue 15324)
2022-08-16 14:41:36 +02:00
Jonas Jenwald
f669e5dd34 Ignoring "resize" events during printing (issue 15324)
This is a quick work-around, to prevent the viewer from breaking as a result of https://bugzilla.mozilla.org/show_bug.cgi?id=774398
2022-08-16 13:51:35 +02:00
Jonas Jenwald
518115fddc
Merge pull request #15315 from Snuffleupagus/type1-parser-rm-closure
Remove the remaining closures in the `src/core/type1_parser.js` file
2022-08-15 18:56:31 +02:00