Commit Graph

17747 Commits

Author SHA1 Message Date
Jonas Jenwald
89779b3f6c Add the .mjs file-extension to the EditorConfig
Given that this file-extension is used for JavaScript modules, those files should obviously be formatted just like any "normal" JS file.
2023-08-23 11:22:25 +02:00
Tim van der Meij
a7d829155b
Merge pull request #16852 from Snuffleupagus/less-workerPort
Initialize the `PDFWorker.#workerPorts` WeakMap lazily
2023-08-20 12:45:41 +02:00
Jonas Jenwald
988ce2820b Initialize the PDFWorker.#workerPorts WeakMap lazily
By default this WeakMap isn't needed, and it's simple enough to initialize it lazily instead.
2023-08-19 16:18:38 +02:00
Jonas Jenwald
2993c7725b [Firefox] Exclude more workerPort related code in MOZCENTRAL builds
Given that this code is (and has always been) unused in the Firefox PDF Viewer, we don't need to include it in that build-target.
2023-08-19 15:52:00 +02:00
Tim van der Meij
5828ac0ee3
Merge pull request #16834 from Snuffleupagus/globalWorkerPort-parallel-test
Add a unit-test for the "correct" way of using the global `workerPort` in parallel (PR 16830 follow-up)
2023-08-19 13:38:16 +02:00
Tim van der Meij
05fa7dcc7e
Merge pull request #16850 from Snuffleupagus/update-packages
Update packages and translations
2023-08-19 13:33:48 +02:00
Jonas Jenwald
d762986bb0 Update l10n files 2023-08-19 09:30:41 +02:00
Jonas Jenwald
4d19db0b19 Re-format the code to account for prettier and globals updates
The `prettier` update slightly changed the formatting of some await-expressions; please see https://github.com/prettier/prettier/blob/main/CHANGELOG.md#302

The `globals` update removed the need for some eslint-disable statements; please see https://github.com/sindresorhus/globals/releases/tag/v13.21.0
2023-08-19 09:30:34 +02:00
Jonas Jenwald
c5ebfa51a7 Update npm packages 2023-08-19 09:08:11 +02:00
Jonas Jenwald
60581c427e
Merge pull request #16844 from Snuffleupagus/StampEditor-isEmpty
Update the `StampEditor.isEmpty` method to handle File (PR 16828 follow-up)
2023-08-18 20:40:09 +02:00
Jonas Jenwald
520397e1e8
Merge pull request #16840 from Snuffleupagus/Stamp-#getBitmapFetched
Add a helper method to reduce duplication in `StampEditor.#getBitmap`
2023-08-18 20:38:55 +02:00
Jonas Jenwald
d513899fc7 Update the StampEditor.isEmpty method to handle File (PR 16828 follow-up)
After the changes in PR 16828 the `StampEditor` can now be initialized with a File, in addition to a URL, hence it seems that the `isEmpty` method ought to take that property into account as well.

Looking at this I also noticed that the assignment in the constructor may cause the `this.#bitmapUrl`/`this.#bitmapFile` fields be `undefined` which "breaks" the comparisons in the `isEmpty` method.
We could obviously fix those specific cases, but it seemed overall safer (with future changes) to just update the `isEmpty` method to be less sensitive to exactly how these fields are initialized and reset.
2023-08-17 09:25:58 +02:00
Jonas Jenwald
df9cb772d9 Add a helper method to reduce duplication in StampEditor.#getBitmap
Currently we're repeating virtually the same code *four times* when fetching the bitmap-data, which seems unnecessary.

Also, ensure that the `#bitmapPromise` is always `null`ed by moving that into the `StampEditor.#getBitmapDone` method.
2023-08-17 08:36:07 +02:00
Jonas Jenwald
c72cb5436d
Merge pull request #16835 from Snuffleupagus/improve-Annotation-compression-test
Improve the "write a new annotation, save the pdf and check that the text content is correct" unit-test (PR 16559 follow-up)
2023-08-15 16:44:18 +02:00
Jonas Jenwald
29b2050ac2 Improve the "write a new annotation, save the pdf and check that the text content is correct" unit-test (PR 16559 follow-up)
Currently this unit-test will pass just fine if compression is disabled, e.g. by commenting out the relevant code in the `src/core/writer.js` file.
While we don't have a simple way of *directly* checking that the Annotation text-content is compressed, we can however use the resulting file-size as a fairly good proxy. (Note that if compression is disabled the file-size is more than doubled.)
2023-08-15 15:12:17 +02:00
Jonas Jenwald
2422492ee3 Add a unit-test for the "correct" way of using the global workerPort in parallel (PR 16830 follow-up)
Please note that for performance reasons it's not really advised to use the same worker-thread *in parallel* for parsing multiple PDF documents, since they will then unnecessarily compete for resources.
However, given that it's still possible to do that e.g. when using the global `workerPort` it probably won't hurt to add a unit-test for this particular situation.
2023-08-15 12:45:54 +02:00
Tim van der Meij
8cf2f6d352
Merge pull request #16830 from Snuffleupagus/issue-16777-2
Avoid using the global `workerPort` when destruction has started, but not yet finished (issue 16777)
2023-08-13 12:18:28 +02:00
Tim van der Meij
43ab1d2da7
Merge pull request #16831 from Snuffleupagus/rm-no-babel-preset
Remove the "no-babel-preset" comment used with the LIB build-target (PR 16829 follow-up)
2023-08-13 12:09:43 +02:00
Jonas Jenwald
6669a99299 Remove the "no-babel-preset" comment used with the LIB build-target (PR 16829 follow-up)
Similar to the changes in PR 16829, this no longer seems necessary now.
2023-08-13 08:55:58 +02:00
Jonas Jenwald
66437917db Avoid using the global workerPort when destruction has started, but not yet finished (issue 16777)
Given that the `PDFDocumentLoadingTask.destroy()`-method is documented as being asynchronous, you thus need to await its completion before attempting to load a new PDF document when using the global `workerPort`.
If you don't await destruction as intended then a new `getDocument`-call can remain pending indefinitely, without any kind of indication of the problem, as shown in the issue.

In order to improve the current situation, without unnecessarily complicating the API-implementation, we'll now throw during the `getDocument`-call if the global `workerPort` is in the process of being destroyed.
This part of the code-base has apparently never been covered by any tests, hence the patch adds unit-tests for both the *correct* usage (awaiting destruction) as well as the specific case outlined in the issue.
2023-08-12 21:21:50 +02:00
Tim van der Meij
690b873897
Merge pull request #16829 from Snuffleupagus/gulpfile-rm-src-babel-excludes
Remove the `src/core/` Babel excludes, since they no longer seem necessary
2023-08-12 13:35:31 +02:00
Jonas Jenwald
1810191be2 Remove the src/core/ Babel excludes, since they no longer seem necessary
- The `src/core/unicode.js` exclude ought to have become unnecessary already with PR 16200, which significantly shortened and simplified that file.
 - The `src/core/glyphlist.js` exclude no longer seems necessary in practice either, possibly because of improvements in Babel.
2023-08-12 10:09:03 +02:00
calixteman
890550653a
Merge pull request #16828 from calixteman/editor_paste_image
[Editor] Add the possibility to paste an image from the clipboard (bug 1848317)
2023-08-11 22:28:33 +02:00
Calixte Denizet
2dd6f07b57 [Editor] Add the possibility to paste an image from the clipboard (bug 1848317) 2023-08-11 19:49:18 +02:00
calixteman
4b2eebf32e
Merge pull request #16826 from calixteman/editor_remove_empty_stamp
[Editor] Remove the stamp editor displayed when the image was loading (bug 1848313)
2023-08-11 17:17:45 +02:00
Calixte Denizet
d527fb3ff2 [Editor] Remove the stamp editor displayed when the image was loading (bug 1848313)
Make the annotation editor layer unclickable while the image is loading and
change the cursor to 'wait'.
2023-08-11 16:46:23 +02:00
calixteman
4eca3ca199
Merge pull request #16819 from calixteman/editor_stamp_button
[Editor] Add a button to explicitly add an image (bug 1848108)
2023-08-11 15:32:47 +02:00
Calixte Denizet
659fbc5020 [Editor] Add a button to explicitly add an image (bug 1848108)
The main stamp button will be used to just enter in a add/edit image mode:
 - the user can add a new image in using the new button.
 - the user can edit an image in resizing, moving it.
In image mode, when the user clicks outside on the page but not on an editor,
then all the selected editors will be unselected.
2023-08-11 15:05:46 +02:00
Jonas Jenwald
d57e3ebbe4
Merge pull request #16810 from Snuffleupagus/_initializeAutoPrint-refactor
Re-factor `PDFViewerApplication._initializeAutoPrint` slightly (PR 16779 follow-up)
2023-08-11 08:49:45 +02:00
Jonas Jenwald
caebe335b2 Re-factor PDFViewerApplication._initializeAutoPrint slightly (PR 16779 follow-up)
After the `src/core/`-changes in PR 16779 the `PDFDocumentProxy.getJSActions` method should no longer be able to return *empty* entries, which means that we can simplify the "JavaScript support is not enabled"-warning in the viewer.
Furthermore, improve the auto-printing hack used when scripting is disabled.
2023-08-10 21:36:08 +02:00
calixteman
1d523d3ec1
Merge pull request #16825 from calixteman/editor_avoid_right_click
[Editor] Avoid showing the context menu or resizing when a resizer is right clicked
2023-08-10 18:37:59 +02:00
calixteman
0dd70c4e66
Merge pull request #16824 from calixteman/editor_dont_unselect_on_render
[Editor] Avoid to unselect when a new page is rendered
2023-08-10 18:37:42 +02:00
Calixte Denizet
96a1f323c4 [Editor] Avoid showing the context menu or resizing when a resizer is right clicked 2023-08-10 18:24:57 +02:00
Jonas Jenwald
f1bd98c6d8
Merge pull request #16823 from Snuffleupagus/_getPageIndex-fallback
Fallback to check all pages when getting the pageIndex of FieldObjects
2023-08-10 18:06:54 +02:00
Calixte Denizet
71f5050ed2 [Editor] Avoid to unselect when a new page is rendered 2023-08-10 18:02:27 +02:00
Jonas Jenwald
389a26c115 Fallback to check all pages when getting the pageIndex of FieldObjects
Given that the FieldObjects are parsed in parallel, in combination with the existing caching in the `getPage`-method and `annotations`-getter, adding additional caches for this fallback code-path doesn't seem entirely necessary.
2023-08-10 17:10:04 +02:00
calixteman
4be6c90796
Merge pull request #16822 from calixteman/issue16821
[Editor] Don't forget to encrypt image streams (see issue #16821)
2023-08-10 16:18:17 +02:00
calixteman
ea259710fa
Merge pull request #16811 from calixteman/editor_drag_selected
[Editor] Add the possibility to move all the selected editors with the mouse (bug 1847894)
2023-08-10 15:23:34 +02:00
Calixte Denizet
7a5b3423d6 [Editor] Don't forget to encrypt image streams (see issue #16821)
and encrypt a compressed stream after having been compressed.
2023-08-10 15:19:45 +02:00
Calixte Denizet
402e3fed95 [Editor] Add the possibility to move all the selected editors with the mouse (bug 1847894) 2023-08-10 14:45:36 +02:00
calixteman
d4ba312f00
Merge pull request #16820 from calixteman/editor_stamp_integer_dims
[Editor] Avoid to have slightly truncated images because of non-integer canvas dimensions
2023-08-10 14:16:46 +02:00
Calixte Denizet
b6b51f57ed [Editor] Avoid to have slightly truncated images because of non-integer canvas dimensions 2023-08-10 14:11:42 +02:00
Jonas Jenwald
4962d005f8
Merge pull request #16815 from Snuffleupagus/more-optional-chaining-3
Introduce even more optional chaining in the code-base
2023-08-10 13:33:20 +02:00
calixteman
f66072b658
Merge pull request #16818 from calixteman/no_cancelled_stamp_in_unod
[Editor] Avoid to add a cancelled added image in the undo/redo stack
2023-08-10 13:19:20 +02:00
Calixte Denizet
b6432ef9de [Editor] Avoid to add a cancelled added image in the undo/redo stack
We're adding the action in the undo/redo stack whatever the status of the
operation was. This patch aims to add the action only when the image has been
successfully added.
2023-08-10 12:18:15 +02:00
Jonas Jenwald
ec7746350d Introduce even more optional chaining in the code-base
This replaces a few more small/simple if-statements with optional chaining.
2023-08-09 17:04:54 +02:00
calixteman
f89020e9b1
Merge pull request #16813 from calixteman/editor_move_params
[Editor] Move the parameter elements for FreeText and Ink annotations at the right place (follow-up of #16802)
2023-08-09 14:06:21 +02:00
calixteman
1447049513
Merge pull request #16812 from calixteman/editor_dont_lose_selection_on_bluring
[Editor] Avoid to unselect some editors when the main window is focused
2023-08-09 14:06:04 +02:00
Calixte Denizet
149f18b766 [Editor] Move the parameter elements for FreeText and Ink annotations at the right place (follow-up of #16802) 2023-08-09 13:35:45 +02:00
Calixte Denizet
9ae7ad0fa6 [Editor] Avoid to unselect some editors when the main window is focused
When several editors are selected and the window loses and then gets back its focus,
the previously focused editor is triggering its focus callback making it the only
selected one.
This patch aims to avoid triggering the focus callback called when the main window
gets its focus back.
2023-08-09 12:09:15 +02:00