Commit Graph

15820 Commits

Author SHA1 Message Date
Jonas Jenwald
03757d82b7 Replace element ids with custom attributes for Widget-annotations (issue 15056)
We want to avoid adding regular `id`s to Annotation-elements, since that means that they become "linkable" through the URL hash in a way that's not supported/intended. This could end up clashing with "named destinations", and that could easily lead to bugs; see issue 11499 and PR 11503 for some context.

Rather than using `id`s, we'll instead use a *custom* `data-element-id` attribute such that it's still possible to access the Annotation-elements directly.
Unfortunately these changes required updating most of the integration-tests, and to reduce the amount of repeated code a couple of helper functions were added.
2022-06-18 16:43:05 +02:00
Tim van der Meij
3ca8d2c4f9
Merge pull request #15052 from Snuffleupagus/mv-defaultUrl-option
Simplify setting the `defaultUrl`-option in the CHROME viewer (PR 12470 follow-up)
2022-06-18 11:29:21 +02:00
Tim van der Meij
80af3a0d07
Merge pull request #15048 from Snuffleupagus/mv-renderer-option
Only define the `renderer`-option in the GENERIC viewer
2022-06-18 11:26:43 +02:00
Jonas Jenwald
77aa86e275 Stop defining the defaultUrl-option in the MOZCENTRAL viewer
This option is not used, nor has it ever been used, in the *built-in* Firefox PDF Viewer. Hence we can define it only for the environments where it makes sense instead.
2022-06-18 09:43:35 +02:00
Jonas Jenwald
abcc32ade0 Simplify setting the defaultUrl-option in the CHROME viewer (PR 12470 follow-up)
This should really have been done as part of PR 12470, since it's now possible to directly set the `defaultUrl`-option without having to fallback to `var`-usage.
2022-06-18 09:43:23 +02:00
Jonas Jenwald
be2dfe45f9
Merge pull request #15035 from Snuffleupagus/prefer-modern-dom-apis-2
Use modern DOM methods a bit more (PR 15031 follow-up)
2022-06-17 19:37:43 +02:00
calixteman
31e3427559
Merge pull request #15054 from calixteman/15053
[JS] Hide field borders and buttons (#15053)
2022-06-17 17:58:52 +02:00
Calixte Denizet
7e3941da9d [JS] Hide field borders and buttons (#15053)
- Since the border belongs to the section containing the HTML
  counterpart of an annotation, this section must be hidden when
  a JS action requires it;
- it wasn't possible to hide a button in using JS.
2022-06-17 17:36:38 +02:00
Marco Castelluccio
b9f5a70ded
Merge pull request #15051 from Maxim-Mazurok/patch-1
Fix "Good Beginner Bugs" link
2022-06-17 09:45:12 +02:00
Maxim Mazurok
bd5e1a9540
Fix "Good Beginner Bugs" link
Seems like the label was changed and the link needs to be updated
2022-06-17 11:33:07 +10:00
calixteman
b8688128e3
Merge pull request #15050 from calixteman/make_ink_better
[Editor] - Add the ability to directly draw after selecting ink tool
2022-06-16 20:34:56 +02:00
Calixte Denizet
e7dc1ef4f3 [Editor] - Add the ability to directly draw after selecting ink tool
- Right now, we must select the tool, then click to select a page and
  click to start drawing and it's a bit painful;
- so just create a new ink editor when we're hovering a page without one.
2022-06-16 19:53:07 +02:00
Jonas Jenwald
a19feac217 Reduce some duplication for AppOptions that use compatibilityParams
We can check for a relevant `compatibilityParams`-entry directly in `AppOptions.{get, getAll}` instead, which removes some unnecessary duplication.
2022-06-16 16:51:33 +02:00
Jonas Jenwald
df79b18a31 Only define the renderer-option in the GENERIC viewer
Given that the SVG back-end is not defined anywhere except in GENERIC builds, we can remove a little bit of unnecessary code in e.g. the Firefox PDF Viewer.
2022-06-16 16:11:47 +02:00
Jonas Jenwald
c3d0858062
Merge pull request #15046 from Snuffleupagus/issue-15044
Add basic support for non-embedded ArialUnicodeMS fonts (issue 15044)
2022-06-15 11:27:19 +02:00
Jonas Jenwald
64cce1269e Add basic support for non-embedded ArialUnicodeMS fonts (issue 15044)
This appears to be a Microsoft-specific version of the regular Arial font, hence we simply map this to Helvetica in the same way that we treat many other Arial-named fonts.
2022-06-15 10:37:20 +02:00
Jonas Jenwald
89cebcb6f9
Merge pull request #15034 from Snuffleupagus/issue-15033
Extend `getGlyphMapForStandardFonts` with some Hebrew entries (issue 15033)
2022-06-13 11:35:34 +02:00
Jonas Jenwald
4902ad8923 Use modern DOM methods a bit more (PR 15031 follow-up)
Apparently the ESLint rule added in PR 15031 wasn't able to catch all cases that can be converted, which is probably not all that surprising given how some of these call-sites look.

 - Use `Element.prepend()` to insert nodes before all other ones in the element, rather than using `firstChild` with `insertBefore`-calls; see https://developer.mozilla.org/en-US/docs/Web/API/Element/prepend

 - Fix one *incorrect* `insertBefore` call, in the AnnotationLayer-code.
   Initially the patch simply changed that to an `Element.before()`-call, however that broke one of the integration-tests. It turns out that the `index` may try to access a non-existent select-child, which triggers undefined behaviour; note the warning in https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore#parameters
2022-06-13 10:47:37 +02:00
Jonas Jenwald
2dca14028d Extend getGlyphMapForStandardFonts with some Hebrew entries (issue 15033)
This only adds the minimum entries required in order to render the referenced document correctly, rather than trying to support "all" Hebrew glyphs, to ensure that all lines in `getGlyphMapForStandardFonts` are covered by tests.
2022-06-13 10:08:39 +02:00
Tim van der Meij
1a6ae5f034
Merge pull request #15031 from Snuffleupagus/prefer-modern-dom-apis
Enable the `unicorn/prefer-modern-dom-apis` ESLint plugin rule
2022-06-12 20:36:40 +02:00
Tim van der Meij
0e1e265c61
Merge pull request #15030 from Snuffleupagus/update-packages
Update packages and translations
2022-06-12 20:16:11 +02:00
Tim van der Meij
720f77c7cd
Merge pull request #15028 from Snuffleupagus/update-compat
[api-minor] Update the minimum supported browsers/environments
2022-06-12 20:12:33 +02:00
Tim van der Meij
26ae50e449
Merge pull request #15023 from Snuffleupagus/prefer-array-flat
Enable the `unicorn/prefer-array-flat` and `unicorn/prefer-array-flat-map` ESLint plugin rules
2022-06-12 20:10:52 +02:00
Jonas Jenwald
4d39898823 Enable the unicorn/prefer-modern-dom-apis ESLint plugin rule
This rule will help enforce slightly shorter code, and according to MDN both `Element.replaceWith()` and `Element.before()` are available in all browsers that we currently support.

Please find additional information here:
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-modern-dom-apis.md
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceWith
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/before
2022-06-12 20:05:05 +02:00
Jonas Jenwald
0c65926d5b
Merge pull request #15029 from Snuffleupagus/prefer-dom-node-append
Enable the `unicorn/prefer-dom-node-append` ESLint plugin rule
2022-06-12 19:58:37 +02:00
Jonas Jenwald
17d2380824 Update l10n files 2022-06-12 14:05:41 +02:00
Jonas Jenwald
f052a12968 Update npm packages 2022-06-12 14:02:31 +02:00
Jonas Jenwald
8129815538 Enable the unicorn/prefer-dom-node-append ESLint plugin rule
This rule will help enforce slightly shorter code, especially since you can insert multiple elements at once, and according to MDN `Element.append()` is available in all browsers that we currently support.

Please find additional information here:
 - https://developer.mozilla.org/en-US/docs/Web/API/Element/append
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-dom-node-append.md
2022-06-12 13:07:03 +02:00
Jonas Jenwald
2f0ed3a9ca [api-minor] Update the minimum supported browsers/environments
*Please note:* The dates below are still a little ways off, however that obviously won't affect the existing PDF.js releases. Hence I think that we can make these changes now, since by the time of the *next* official PDF.js release they'll likely match up pretty well.[1]

While we "support" some (by now) fairly old browsers, that essentially means that the library (and viewer) will load and that the basic functionality will work as intended.[2]
However, in older browsers, some functionality may not be available and generally we'll ask users to update to a modern browser when bugs (specific to old browsers) are reported.[3]

Since we've previously settled on only supporting browsers/environments that are approximately *three years old*, this patch updates the minimum supported browsers/environments as follows:
 - Chrome 76, which was released on 2019-07-30; see https://en.wikipedia.org/wiki/Google_Chrome_version_history
 - Firefox ESR (as before); see https://wiki.mozilla.org/Release_Management/Calendar
 - Safari 13, which was released on 2019-09-19; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_13
 - Node.js 14, which was release on 2020-04-21 (all older versions have reached EOL); see https://en.wikipedia.org/wiki/Node.js#Releases

---
[1] Given that the releases usually happen every two to three months.

[2] Assuming that a `legacy/`-build is being used, of course.

[3] In general it's never a good idea to use old/outdated browsers, since those may contain *known* security vulnerabilities.
2022-06-11 16:50:01 +02:00
Jonas Jenwald
d7122becaf
Merge pull request #15027 from Snuffleupagus/parseFloat-fixes
Remove superfluous trailing arguments from `parseFloat`-calls (PR 14978 follow-up)
2022-06-11 15:25:24 +02:00
Jonas Jenwald
4b2526ebf2 Remove superfluous trailing arguments from parseFloat-calls (PR 14978 follow-up)
Fixes two recent "Code scanning alerts" on GitHub, which likely happened because these calls originally used `parseInt` instead (during initial development).
2022-06-11 15:11:34 +02:00
Jonas Jenwald
7f4b1c2149
Merge pull request #15026 from Snuffleupagus/rm-unused-annotation-ops
[api-minor] Stop using the `beginAnnotations`/`endAnnotations` operators (PR 14998 follow-up)
2022-06-11 15:04:51 +02:00
Jonas Jenwald
bbf857d635 [api-minor] Stop using the beginAnnotations/endAnnotations operators (PR 14998 follow-up)
After the changes in PR 14998, these operators are now no-ops in the `src/display/canvas.js` code and should no longer be necessary.
Given that `beginAnnotations`/`endAnnotations` are not in the PDF specification, but are rather *custom* PDF.js operators, it seems reasonable to stop using them now that they've become no-ops.
2022-06-11 14:21:26 +02:00
Marco Castelluccio
b5fb6cdb96
Merge pull request #15022 from Snuffleupagus/editorNone-icon-tweak
Tweak the `editorNone` icon to circumvent the "duplicated files"-check
2022-06-11 11:34:21 +02:00
Jonas Jenwald
010d996b74 Enable the unicorn/prefer-array-flat and unicorn/prefer-array-flat-map ESLint plugin rules
These rules will help enforce shorter and more readable code, and according to MDN these Array-methods are available in all browsers/environments that we currently support:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flat#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap#browser_compatibility

Please find additional information about these ESLint rules here:
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat.md
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-array-flat-map.md
2022-06-11 11:33:43 +02:00
Jonas Jenwald
1465471b10 Tweak the editorNone icon to circumvent the "duplicated files"-check
The update in https://bugzilla.mozilla.org/show_bug.cgi?id=1773794 failed, because the `editorNone` icon is identical to a pre-existing one. Given that all of the editor-icons are simply placeholders for now, we can just make a tiny change to the SVG-paths to prevent these kind of problems.
2022-06-11 11:17:08 +02:00
Tim van der Meij
a57a4bc6c2
Merge pull request #15018 from Snuffleupagus/issue-15016
Expose `TextLayerRenderTask` in the TypeScript definitions (issue 15016, PR 14013 follow-up)
2022-06-10 22:18:35 +02:00
Tim van der Meij
f0b5aee6b8
Merge pull request #15014 from Snuffleupagus/prefer-at
Enable the `unicorn/prefer-at` ESLint plugin rule (PR 15008 follow-up)
2022-06-10 22:12:35 +02:00
Jonas Jenwald
e046b811b7 Expose TextLayerRenderTask in the TypeScript definitions (issue 15016, PR 14013 follow-up)
While `TextLayerRenderTask` apparently makes sense in TypeScript environments, given that it's being returned by the `renderTextLayer`-function in the API, we really don't want to extend the *public* API by simply exporting the class directly in `src/pdf.js` since it should never be called/initialized manually.
Hence we follow the same pattern as in PR 14013, and add some very basic unit-tests to ensure that `renderTextLayer` always returns a `TextLayerRenderTask`-instance as expected.
2022-06-10 22:12:32 +02:00
calixteman
6e6d94ab8d
Merge pull request #15020 from calixteman/1773680
Add an empty entry in combo list when nothing is selected (bug 1773680)
2022-06-10 19:18:31 +02:00
Calixte Denizet
bfe816d0d2 Add an empty entry in combo list when nothing is selected (bug 1773680)
- it aims to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1773680
- the empty is removed once something is selected.
2022-06-10 18:45:02 +02:00
Jonas Jenwald
d45ce8d6a3
Merge pull request #15015 from jerry1100/fix-container-type
Extend TextLayerRenderParameters.container type to include HTMLElement.
2022-06-10 17:05:47 +02:00
jerry1100
b716e82d18 Extend TextLayerRenderParameters.container type to include HTMLElement.
In PR #14717, the type was changed from a HTMLElement to a DocumentFragment.
This broke TypeScript projects that use a HTMLElement container.

To remedy this, we extend the type of container to also include HTMLElement.
2022-06-10 06:50:47 -07:00
calixteman
808a55e42b
Merge pull request #15019 from mozilla/revert-15003-mc
Revert "Change the name of the generated pdf.sandbox.external for mozilla-central"
2022-06-10 11:35:14 +02:00
calixteman
c8f6cb9fcf
Revert "Change the name of the generated pdf.sandbox.external for mozilla-central" 2022-06-10 11:34:28 +02:00
Jonas Jenwald
9ac4536693 Enable the unicorn/prefer-at ESLint plugin rule (PR 15008 follow-up)
Please find additional information here:
 - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/at
 - https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-at.md
2022-06-09 21:21:19 +02:00
calixteman
5d88233fbb
Merge pull request #15006 from calixteman/ink2
[editor] Add support for saving newly added Ink
2022-06-09 21:13:53 +02:00
calixteman
61a65344a3
Merge pull request #14989 from calixteman/ink1
[editor] Add an Ink editor
2022-06-09 21:13:06 +02:00
Calixte Denizet
c161a86ba1 [editor] Add an Ink editor
- Approximate the drawn curve by a set of Bezier curves in using
  js code from https://github.com/soswow/fit-curves.
  The code has been slightly modified in order to make the linter
  happy.
2022-06-09 19:35:59 +02:00
Jonas Jenwald
1eaef6645d
Merge pull request #15013 from Snuffleupagus/issue-15012
Render PopupAnnotations even if they have missing or empty /Rect-entries (issue 15012, PR 14439 follow-up)
2022-06-09 16:51:31 +02:00