Jonas Jenwald
dc0df0a3c2
Update the Path2D polyfill for Node.js environments
...
The polyfill that we use was recently split into two packages, and it now consists of a "core" package and a browser-specific package that build upon the former.
Hence we need to update to use the "core" package, and slightly tweak the code that loads/initializes the polyfill; see also https://www.npmjs.com/package/path2d
This patch was tested successfully with the [pdf2png example](https://github.com/mozilla/pdf.js/tree/master/examples/node/pdf2png ), after running `gulp dist-install` locally, using [this PDF document](https://bug810214.bmoattachments.org/attachment.cgi?id=9254990 ) which contains Type3-fonts that render using `Path2D`.
2024-03-24 12:09:21 +01:00
Calixte Denizet
a3873e4c68
Don't hide the editor layer when rotating (follow-up of #17802 )
...
Before the patch in #17802 , the layer was made visible when calling updateMode
after the rotation angle was set.
2024-03-19 18:36:55 +01:00
Calixte Denizet
1b00511301
[Editor] Make the text layer focusable before the editors (bug 1881746)
...
Keep the different layers in a constant order to avoid the use of a z-index
and a tab-index.
2024-03-19 16:14:55 +01:00
Jonas Jenwald
0022310b9c
Merge pull request #17706 from Snuffleupagus/Node-Fetch-API
...
[api-minor] Use the Fetch API, when supported, to load PDF documents in Node.js environments
2024-03-19 11:04:28 +01:00
Calixte Denizet
5437199c95
[Editor] Fix the rect used to click in some freetext integration tests
...
And avoid to uselessly set the pointer listeners in the annotation editor layer.
2024-03-18 10:29:32 +01:00
Jonas Jenwald
e650b95253
Merge pull request #17714 from Snuffleupagus/Node-fs-promise
...
Use `fs/promises` in the Node.js-specific code in the `src/`-folder
2024-03-12 18:09:33 +01:00
Calixte Denizet
b4267cd294
[Editor] Add a floating button close to the selected text to highlight it (bug 1867742)
...
For now keep this feature behind a pref in order to make some experiments before
deciding to enable it.
2024-03-12 15:06:46 +01:00
Jonas Jenwald
70b6ddc5d9
Move the /SetOCGState handling into the OptionalContentConfig class (PR 15377 follow-up)
...
This helps ensure that /SetOCGState actions always take the `Usage` dictionary into account as expected.
2024-03-12 13:18:15 +01:00
Jonas Jenwald
3c78ff5fb0
[api-minor] Implement basic support for OptionalContent Usage dicts (issue 5764, bug 1826783)
...
The following are some highlights of this patch:
- In the Worker we only extract a *subset* of the potential contents of the `Usage` dictionary, to avoid having to implement/test a bunch of code that'd be completely unused in the viewer.
- In order to still allow the user to *manually* override the default visible layers in the viewer, the viewable/printable state is purposely *not* enforced during initialization in the `OptionalContentConfig` constructor.
- Printing will now always use the *default* visible layers, rather than using the same state as the viewer (as was the case previously).
This ensures that the printing-output will correctly take the `Usage` dictionary into account, and in practice toggling of visible layers rarely seem to be necessary except in the viewer itself (if at all).[1]
---
[1] In the unlikely case that it'd ever be deemed necessary to support fine-grained control of optional content visibility during printing, some new (additional) UI would likely be needed to support that case.
2024-03-12 13:18:15 +01:00
Calixte Denizet
f676c2c0c8
[Editor] Improve the accessibility of the highlight editor (bug 1881743)
2024-03-11 14:21:43 +01:00
calixteman
fb9e438442
Merge pull request #17781 from calixteman/stamp_altext_button_cp
...
[Editor] Make sure the alt-text button is there when pasting an image from an other tab
2024-03-07 21:44:53 +01:00
Calixte Denizet
0f8dda1af0
[Editor] Make sure the alt-text button is there when pasting an image from an other tab
2024-03-07 18:24:34 +01:00
Calixte Denizet
39aeea3e94
[Editor] Add a toggle button to show/hide all the highlights (bug 1867740)
2024-03-07 13:16:59 +01:00
Calixte Denizet
bd5875d066
[Editor] Let a free highlight be clipped when its bounding box exceeds the page limits (bug 1883632)
2024-03-05 16:47:07 +01:00
calixteman
c451b6d684
Merge pull request #17764 from calixteman/telemetry_null_stats
...
[Editor] Use a null instead of an empty stats object when sending the telemetry
2024-03-04 19:16:57 +01:00
calixteman
a55f976e2e
Merge pull request #17766 from calixteman/escape_color_picker
...
[Editor] Unselect highlight editor when pressing Escape when the focus is on the color picker without a dropdown menu
2024-03-04 19:16:34 +01:00
Calixte Denizet
ecb4262b13
[Editor] Set the creation method for free highlights to 'main_toolbar' (bug 1883394)
2024-03-04 16:58:50 +01:00
Calixte Denizet
1859412507
[Editor] Unselect highlight editor when pressing Escape when the focus is on the color picker without a dropdown menu
2024-03-04 16:32:09 +01:00
Calixte Denizet
d096dc79b2
[Editor] Use a null instead of an empty stats object when sending the telemetry
2024-03-04 10:18:24 +01:00
calixteman
29c493d36b
Merge pull request #17760 from calixteman/fix_quadpoints
...
[Editor] Fix the quadpoints value when serializing an highlight annotation
2024-03-01 13:08:44 +01:00
Calixte Denizet
30101cbb31
[Editor] Fix the quadpoints value when serializing an highlight annotation
...
The coordinates of each point in a box are in the page coordinates system.
2024-03-01 11:36:16 +01:00
Jonas Jenwald
61036383b5
Merge pull request #17710 from Snuffleupagus/pr-17277-followup
...
Simplify the `XMLHttpRequest`-branch in the `fetchData` helper function (PR 17277 follow-up)
2024-03-01 10:23:02 +01:00
Calixte Denizet
7af90bb8bc
[Editor] Enable the thickness input when no editors are selected (bug 1881219)
2024-02-29 23:05:33 +01:00
Calixte Denizet
f52bf2836f
[Editor] Make the delete button clickable with the space key (bug 1882248)
2024-02-29 19:05:38 +01:00
Calixte Denizet
a9f47e87d5
[Editor] Add the possibility to move the caret with the keyboard once an highlight has been made (bug 1881684)
2024-02-29 18:18:13 +01:00
Jonas Jenwald
a92b38e71c
Inline the HighlightEditor.#telemetryType getter at its only call-site (PR 17748 follow-up)
2024-02-28 20:47:01 +01:00
Calixte Denizet
3a7e638fce
[Editor] Count the colors used when highlighting whatever the highlight kind is
2024-02-28 18:24:24 +01:00
Calixte Denizet
65342d2bee
[Editor] Add some telemetry for the highlight feature (bug 1866437)
2024-02-28 10:17:11 +01:00
Calixte Denizet
0520f2f0cb
[Editor] In caret browsing mode, allow to select in pressing shift and arrow down (bug 1881802)
...
In implementing caret browsing mode in pdf.js, I didn't notice that selectstart isn't always triggered.
So this patch removes the use of selectstart and rely only on selectionchange.
In order to simplify the selection management, the selection code is moved in the AnnotationUIManager:
- it simplifies the code;
- it allows to have only one listener for selectionchange instead of having one by visible page
for selectstart.
I had to add a delay in the integration tests for highlighting (there's a comment with an explanation),
it isn't really nice, but it's the only way I found and in real life there always is a delay between
press and release.
2024-02-25 15:35:30 +01:00
Calixte Denizet
e1f6f5179f
[Editor] Add the possibility to create an highlight from the context menu when some text is selected (bug 1867739)
2024-02-23 16:18:03 +01:00
Jonas Jenwald
db2849cc17
Use fs/promises in the Node.js-specific code in the src/-folder
...
This is available in all Node.js versions that we currently support, and using it allows us to remove callback-functions; please see https://nodejs.org/docs/latest-v18.x/api/fs.html#promises-api
2024-02-22 16:50:13 +01:00
Jonas Jenwald
33c5ef349e
Simplify the XMLHttpRequest-branch in the fetchData helper function (PR 17277 follow-up)
2024-02-21 23:00:24 +01:00
Jonas Jenwald
eded037d06
[api-minor] Use the Fetch API, when supported, to load PDF documents in Node.js environments
...
Given that modern Node.js versions now implement support for a fair number of "browser" APIs, we can utilize the standard Fetch API to load PDF documents that are specified via http/https URLs.
Please find compatibility information at:
- https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#browser_compatibility
- https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch
- https://developer.mozilla.org/en-US/docs/Web/API/Response#browser_compatibility
- https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#response
2024-02-21 22:38:42 +01:00
calixteman
72b8b29147
Merge pull request #17701 from calixteman/alt_text_ai
...
[Editor] Add the possibility to query some ML stuff to guess an alt text for an image
2024-02-21 10:14:40 +01:00
Calixte Denizet
46416bb131
[Editor] Add the possibility to query some ML stuff to guess an alt text for an image
...
It's only for an experimental purpose.
2024-02-20 21:29:33 +01:00
Calixte Denizet
95f9bedc7c
[Editor] Disable annotation layer when highlighting (bug 1868759)
...
When highlighting, the annotation editor layer is disabled to get pointer events
from the text layer, but the annotation layer must be then disabled either in
order to avoid bad interactions.
2024-02-20 21:17:05 +01:00
Calixte Denizet
c2fcc66302
[Editor] Avoid to scroll when an editor is unselected
2024-02-18 19:21:45 +01:00
Jonas Jenwald
a7bcc81eb1
Add a dummy beginMarkedContentProps operator when optional content parsing fails (issue 17679)
2024-02-17 13:45:16 +01:00
Jonas Jenwald
e60329cea1
Merge pull request #17666 from Snuffleupagus/issue-17665
...
Skip any whitespace after the first object in linearized PDFs (issue 17665)
2024-02-13 12:39:36 +01:00
Jonas Jenwald
37e98e39f6
Skip any whitespace after the first object in linearized PDFs (issue 17665)
...
This way the code is now consistent with the non-linearized branch in the `PDFDocument.startXRef` getter.
2024-02-12 22:05:36 +01:00
calixteman
05b035602e
Merge pull request #17664 from calixteman/bug1879281
...
[Editor] Ends a free highlight where the mouse pointer is (bug 1879281)
2024-02-12 18:39:18 +01:00
Calixte Denizet
750b8e328a
[Editor] Ends a free highlight where the mouse pointer is (bug 1879281)
2024-02-12 17:26:33 +01:00
Calixte Denizet
de1985abbb
[Editor] Set rotated free highlight at the right position after having changed its thickness (bug 1879108)
2024-02-11 21:06:56 +01:00
calixteman
f15b4b34fd
Merge pull request #17650 from calixteman/editor_highlight_keyboard
...
[Editor] Add a way to highlight text in using the keyboard (bug 1877426)
2024-02-11 18:52:37 +01:00
Calixte Denizet
b5e446213e
[Editor] Disable the thickness slider for non-free highlight
2024-02-09 22:54:53 +01:00
Calixte Denizet
8fc6c5c8a6
[Editor] Add a way to highlight text in using the keyboard (bug 1877426)
2024-02-09 22:52:24 +01:00
Calixte Denizet
8d61fc1fde
[Editor] Compute the position of the last point before applying rotation (bug 1879113)
2024-02-08 21:08:24 +01:00
Calixte Denizet
c4ac7eef95
[Editor] Correctly rotate the mask when rotation a free highlight (bug 1879102)
2024-02-08 15:29:29 +01:00
Jonas Jenwald
06cd278808
Simplify the signature of the PDFDataTransportStream constructor
...
Given that we need to pass in a `PDFDataRangeTransport`-instance a number of the needed parameters can be obtained from it, rather than having to specify them manually.
2024-02-03 13:10:42 +01:00
Wojciech Maj
f80ba44fb0
Make downloadManager optional in AnnotationLayerParameters
...
Continuation of fix started in #17038
2024-02-01 11:08:12 +01:00