Skip to content

Commit 0d2eb17

Browse files
committed
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.
1 parent 2d0ba7d commit 0d2eb17

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/core/annotation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3842,6 +3842,7 @@ class PopupAnnotation extends Annotation {
38423842
return;
38433843
}
38443844
this.data.parentRect = lookupNormalRect(parentItem.getArray("Rect"), null);
3845+
this.data.creationDate = parentItem.get("CreationDate") || "";
38453846

38463847
const rt = parentItem.get("RT");
38473848
if (isName(rt, AnnotationReplyType.GROUP)) {

src/display/annotation_layer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,7 +2070,7 @@ class PopupAnnotationElement extends AnnotationElement {
20702070
container: this.container,
20712071
color: this.data.color,
20722072
titleObj: this.data.titleObj,
2073-
modificationDate: this.data.modificationDate,
2073+
modificationDate: this.data.modificationDate || this.data.creationDate,
20742074
contentsObj: this.data.contentsObj,
20752075
richText: this.data.richText,
20762076
rect: this.data.rect,
@@ -2211,14 +2211,17 @@ class PopupElement {
22112211

22122212
const header = document.createElement("span");
22132213
header.className = "header";
2214-
const title = document.createElement("h1");
2215-
header.append(title);
2216-
({ dir: title.dir, str: title.textContent } = this.#titleObj);
2214+
if (this.#titleObj?.str) {
2215+
const title = document.createElement("span");
2216+
title.className = "title";
2217+
header.append(title);
2218+
({ dir: title.dir, str: title.textContent } = this.#titleObj);
2219+
}
22172220
popup.append(header);
22182221

22192222
if (this.#dateObj) {
22202223
const modificationDate = document.createElement("time");
2221-
modificationDate.classList.add("popupDate");
2224+
modificationDate.className = "popupDate";
22222225
modificationDate.setAttribute(
22232226
"data-l10n-id",
22242227
"pdfjs-annotation-date-time-string"

web/annotation_layer_builder.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,9 @@
342342
display: inline-block;
343343
}
344344

345-
.popup > .header h1 {
345+
.popup > .header > .title {
346346
display: inline;
347+
font-weight: bold;
347348
}
348349

349350
.popup > .header .popupDate {

0 commit comments

Comments
 (0)