343 Commits

Author SHA1 Message Date
calixteman
042e821bec
Merge pull request #20320 from calixteman/bug1991584
[Annotation] Fix some timezone issues when getting a date from the date picker (bug 1991584)
2025-10-01 00:41:17 -11:00
Calixte Denizet
12066af578 [Editor] Add a fake annotation (in the annotation layer) associated with an editor in order to be able to show the comment button (bug 1989420) 2025-10-01 09:08:57 +02:00
Calixte Denizet
7b9cde1daf [Annotation] Fix some timezone issues when getting a date from the date picker (bug 1991584) 2025-09-30 11:07:31 +02:00
Calixte Denizet
7fc7b79cd0 [Annotation] In reading mode with new commment stuff enabled, use the comment popup for annotations without a popup but with some contents (bug 1991029) 2025-09-26 18:24:55 +02:00
Calixte Denizet
f547e834e1 [Editor] Give the focus to the comment button after editing in reading mode 2025-09-26 17:18:37 +02:00
Calixte Denizet
90e56b706e [Editor] Add a title to the comment buttons (bug 1990813) 2025-09-25 18:47:49 +02:00
Calixte Denizet
0b40bf1743 [Editor] Update the color and the position of the comment button in reading mode they've been modified 2025-09-24 09:45:37 +02:00
Tim van der Meij
d85fd12437
Merge pull request #20274 from calixteman/save_comment_reading_mode
[Annotation] Save the comment changes made in reading mode (bug 1987427)
2025-09-15 23:32:51 +02:00
Calixte Denizet
764c2e639c [Editor] Fix the position of the comment popup and its dialog
Only fix the popup position if the user didn't change it.
And don't adjust the dialog position since it should have the same as the popup.
2025-09-15 21:26:36 +02:00
Calixte Denizet
5feb4674d6 [Annotation] Save the comment changes made in reading mode (bug 1987427) 2025-09-15 19:49:49 +02:00
Calixte Denizet
38b86cb97a [Annotation] Use the new popup in reading mode (bug 1987426) 2025-09-15 16:58:22 +02:00
Calixte Denizet
7f85c00ee6 Make sure that a good constrast ratio is respected when darkening/lightening a color 2025-09-11 21:29:28 +02:00
Tim van der Meij
f1f8ee47ff
Fix the rendering of XFA rich text in popup annotations
Before the introduction of the `renderRichText` helper function we
exclusively used `this.#html` for XFA rich text and exclusively used
`this.#contentsObj` for plain text. However, after the refactoring we
tried to access `this.#contentsObj.dir` in both cases, which fails for
XFA rich text because `this.#contentsObj` is `null` in that case.

This commit fixes the issue by using optional chaining to make sure we
don't try to access non-existent `this.#contentsObj` properties, which
makes the `must update an existing annotation and show the right popup`
freetext integration pass again.

Fixes #20237.
Fixes 35c90984.
2025-09-07 18:35:17 +02:00
Calixte Denizet
35c909843b Add a new function renderRichText to be used in the annotation layer
and which will be used in order to make the contents of the new popup used for comments.
2025-09-04 22:27:31 +02:00
Calixte Denizet
ca280399c2 [Editor] Use the color of the annotation for the background of the comment button 2025-09-02 21:17:08 +02:00
Calixte Denizet
0ec503e5ef Add a function changeLightness in order to change the lightness of a RGB color 2025-08-30 21:18:12 +02:00
Calixte Denizet
e44e470eb2 [Editor] Remove useless CSS and fix styling for the comment button 2025-08-26 22:06:49 +02:00
Calixte Denizet
bd8c438428 [Editor] Add a button to the annotation having a popup in order to edit it 2025-08-24 21:36:19 +02:00
Calixte Denizet
57ce4f8f43 Use a HTML date/time input when a field requires a date or a time.
The user will be able to enter a date in the format corresponding to their locale
and it'll be formatted in using the format provided by the pdf.
2025-07-24 22:01:45 +02:00
Calixte Denizet
f695e0ca62 Make the link annotations correctly announced by screen readers (bug 1708041)
And focus the targeted page when the user clicks on a link.
2025-07-18 20:15:31 +02:00
Calixte Denizet
6d7e0e7025 [Editor] Only add a popup to an existing annotation if it exits
It fixes the ink integration test "must update an existing annotation".
2025-07-18 17:31:53 +02:00
Calixte Denizet
636ff503ff [Editor] Add the possibility to add Popup annotations (bug 1976724)
It's a first big step.
This patch contains a new modal dialog to let the user edit/update a Popup
2025-07-15 22:39:16 +02:00
Calixte Denizet
b07914843b [Editor] Remove a popup from the DOM when it's deleted 2025-07-11 21:55:14 +02:00
Calixte Denizet
bb52a440ce Use the creation date in the popup when there is no modification date
Remove the h1 element in popup title because it caused a warning in Firefox and use a span instead.
2025-07-07 10:51:35 +02:00
Tim van der Meij
cbeef3233f
Merge pull request #20056 from calixteman/one_click
[Editor] Allow to change the editor mode when selecting the corresponding editor (bug 1975538)
2025-07-06 19:35:31 +02:00
Calixte Denizet
6d2c6cfc9f [Editor] Allow to change the editor mode when selecting the corresponding editor (bug 1975538)
For example, selecting an ink editor just after having created a freetext will switch to ink mode.
2025-07-03 23:27:34 +02:00
Yuyang Liu
d8ecfad8bd Make Popup annotations always have noRotate flag set as true
Necessary because when there is no Popup annotation created along
with a Text annotation, the Popup annotation created by pdf.js
does not receive the noRotate flag
2025-07-03 05:52:31 +09:00
Calixte Denizet
3bdc5d54fe Get the text under highlight/squiggly/underline/strikethrough annotations (bug 1885505)
and add an invisible element containing the text in the annotation layer to make
it readable by a screen reader.
2025-06-22 21:47:29 +02:00
calixteman
e78575e593
Merge pull request #19986 from calixteman/dont_show_empty_popup
Only show popups when they've some contents to display
2025-06-20 13:48:30 +02:00
Calixte Denizet
2541d96bf5 [JS] Make the date parser less strict
and display the expected date formt as a tooltip.
2025-06-20 08:57:07 +02:00
Calixte Denizet
96216de410 Only show popups when they've some contents to display
Chrome, Edge and Acrobat do that.
2025-06-19 16:33:52 +02:00
calixteman
5653458b51
Merge pull request #20013 from calixteman/fix_annotation_tabindex
Make annotations focusable just after the text layer
2025-06-19 14:09:27 +02:00
Calixte Denizet
0d995fa089 Make annotations focusable just after the text layer 2025-06-16 19:06:13 +02:00
Calixte Denizet
27a81c506e Move the popup annotation in the DOM just after the element triggering it 2025-06-16 14:42:44 +02:00
Jonas Jenwald
bd05b255fa [api-major] Apply the userUnit using CSS, to fix the text/annotation layers (bug 1947248)
Rather than modifying the "raw" dimensions of the page, we'll instead apply the `userUnit` as an *additional* scale-factor via CSS.

*Please note:* It's not clear to me if this solution is fully correct either, or if there's other problems with it, but it at least *appears* to work.

---

With these changes, the following CSS variables are now assumed to be available/set as necessary: `--total-scale-factor`, `--scale-factor`, `--user-unit`, `--scale-round-x`, and `--scale-round-y`.
2025-02-11 14:36:06 +01:00
Jonas Jenwald
fba5f3c237 Create the borderStyle of inferred links lazily (PR 19110 follow-up)
Given that most inferred links will overlap existing LinkAnnotations, creating a lot of unused `borderStyle` objects seem unnecessary.
Hence we can move that into the `AnnotationLayer.prototype.addLinkAnnotations` method instead, which also allows us to slightly reduce the API-surface.
2025-02-10 11:53:22 +01:00
Ujjwal Sharma
61ba1ea48c Enable automatic URL linking
Automatically detect links in the text content of a file and automatically
generate link annotations at the appropriate locations to achieve
automatic link detection and hyperlinking.
2025-02-05 16:56:54 +01:00
Jonas Jenwald
9f62a88c38 Remove the color-mix fallback used with PopupAnnotations
This CSS feature is now available in *most* browsers that we support, with old Chromium-based browsers being the only exception; please see https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/color-mix#browser_compatibility

From this data we see that the feature in question has been supported since Chrome 111, which was released on 2023-03-01 (i.e. almost two years ago).

Please note that we've never guaranteed that all features and functionality will be available in the oldest supported browsers.
Furthermore, even with the `color-mix` fallback removed PopupAnnotations will still function just as before but may render with the default color (defined in the CSS-file) rather than the one specified in the PDF document.
2025-02-02 10:41:35 +01:00
Jonas Jenwald
2fd1344ece Add width/height getters in the AnnotationElement class
This is similar to PR 19397, but for the main-thread code, and helps to slightly shorten the code.
2025-02-01 13:20:15 +01:00
Jonas Jenwald
6f2706fad6 Support the password field-flag in TextWidgetAnnotation (issue 19389) 2025-01-29 12:40:09 +01:00
Calixte Denizet
06f72d5662 [Editor] Don't try to use an non-existing canvas when rendering an invisible existing stamp editor
It fixes #19239.

When the canvas isn't existing the editor has no image: it's fine because the editor is invisible.
Once it's made visible, the canvas is set when the annotation layer has been rendered.
2025-01-10 16:05:59 +01:00
Calixte Denizet
7e02c77250 [Editor] Make ink annotation editable 2024-12-02 17:15:33 +01:00
Calixte Denizet
1460a8128a Fix the clickable area for rotated ink annotations 2024-12-02 09:48:22 +01:00
Jonas Jenwald
4e12906061 Move the various DOM-factories into their own files
- Over time the number and size of these factories have increased, especially the `DOMFilterFactory` class, and this split should thus aid readability/maintainability of the code.

 - By introducing a couple of new import maps we can avoid bundling the `DOMCMapReaderFactory`/`DOMStandardFontDataFactory` classes in the Firefox PDF Viewer, since they are dead code there given that worker-thread fetching is always being used.

 - This patch has been successfully tested, by running `$ ./mach test toolkit/components/pdfjs/`, in a local Firefox artifact-build.

*Note:* This patch reduces the size of the `gulp mozcentral` output by `1.3` kilo-bytes, which isn't a lot but still cannot hurt.
2024-11-01 13:31:28 +01:00
Calixte Denizet
7c43cb2dae Don't add attribute 'aria-haspopup' when no popup is rendered for an annotation
and for ink annotations, create the popup after the loop in order to avoid useless
elements creation.
2024-10-12 20:51:40 +02:00
Calixte Denizet
8410252eb8 [Editor] Make stamp annotations editable (bug 1921291) 2024-10-03 21:54:08 +02:00
calixteman
d3698223a8
Merge pull request #18658 from calixteman/bug1912001
[Editor] Make the stamp annotations alt text readable by either VO or NVDA (bug 1912001)
2024-09-03 21:47:21 +02:00
Calixte Denizet
deedbd1c4f [Editor] Make the stamp annotations alt text readable by either VO or NVDA (bug 1912001) 2024-09-03 16:57:41 +02:00
Calixte Denizet
a62ceedb69 [Editor] Make highlight annotations editable (bug 1883884)
The goal of this patch is to be able to edit existing highlight annotations.
2024-09-03 15:27:55 +02:00
Jonas Jenwald
6ce9f97943 Utilize Fluent to format dates in the AnnotationLayer
The `AnnotationLayer` may not display correctly formatted data in PopupAnnotations, especially in the GENERIC viewer, since it's using native methods[1] that depend on the *browser* locale instead of the viewer locale as intended.
With Fluent we're able to improve things since it's got built-in support for formatting dates. Not only does this simplify the JavaScript code slightly, but it also gives the localizer more fine-grained control of the desired output.

Please find additional information here:
 - https://projectfluent.org/fluent/guide/builtins.html
 - https://projectfluent.org/fluent/guide/functions.html

---

[1] `toLocaleDateString`, and `toLocaleTimeString`.
2024-08-25 12:11:02 +02:00