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.
This commit is contained in:
Calixte Denizet 2025-07-04 21:17:21 +02:00
parent b3794c7148
commit bb52a440ce
6 changed files with 20 additions and 6 deletions

View File

@ -3842,6 +3842,7 @@ class PopupAnnotation extends Annotation {
return;
}
this.data.parentRect = lookupNormalRect(parentItem.getArray("Rect"), null);
this.data.creationDate = parentItem.get("CreationDate") || "";
const rt = parentItem.get("RT");
if (isName(rt, AnnotationReplyType.GROUP)) {

View File

@ -2071,7 +2071,7 @@ class PopupAnnotationElement extends AnnotationElement {
container: this.container,
color: this.data.color,
titleObj: this.data.titleObj,
modificationDate: this.data.modificationDate,
modificationDate: this.data.modificationDate || this.data.creationDate,
contentsObj: this.data.contentsObj,
richText: this.data.richText,
rect: this.data.rect,
@ -2212,14 +2212,17 @@ class PopupElement {
const header = document.createElement("span");
header.className = "header";
const title = document.createElement("h1");
header.append(title);
({ dir: title.dir, str: title.textContent } = this.#titleObj);
if (this.#titleObj?.str) {
const title = document.createElement("span");
title.className = "title";
header.append(title);
({ dir: title.dir, str: title.textContent } = this.#titleObj);
}
popup.append(header);
if (this.#dateObj) {
const modificationDate = document.createElement("time");
modificationDate.classList.add("popupDate");
modificationDate.className = "popupDate";
modificationDate.setAttribute(
"data-l10n-id",
"pdfjs-annotation-date-time-string"

View File

@ -730,3 +730,4 @@
!empty#hash.pdf
!bug1885505.pdf
!bug1974436.pdf
!firefox_logo.pdf

BIN
test/pdfs/firefox_logo.pdf Executable file

Binary file not shown.

View File

@ -12156,5 +12156,13 @@
"rounds": 1,
"type": "eq",
"annotations": true
},
{
"id": "firefox_logo",
"file": "pdfs/firefox_logo.pdf",
"md5": "e212e0cec3e39907950c597782a42c3a",
"rounds": 1,
"type": "eq",
"annotations": true
}
]

View File

@ -342,8 +342,9 @@
display: inline-block;
}
.popup > .header h1 {
.popup > .header > .title {
display: inline;
font-weight: bold;
}
.popup > .header .popupDate {