Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions l10n/en-US/viewer.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,10 @@ pdfjs-comment-floating-button =
.title = Comment
.aria-label = Comment
pdfjs-comment-floating-button-label = Comment
pdfjs-editor-comment-button =
.title = Comment
.aria-label = Comment
pdfjs-editor-comment-button-label = Comment
pdfjs-editor-signature-button =
.title = Add signature
pdfjs-editor-signature-button-label = Add signature
Expand Down Expand Up @@ -395,6 +399,23 @@ pdfjs-free-text2 =
.aria-label = Text Editor
.default-content = Start typing…

# Used to show how many comments are present in the pdf file.
# Variables:
# $count (Number) - the number of comments.
pdfjs-editor-comments-sidebar-title =
{ $count ->
[one] Comment
*[other] Comments
}

pdfjs-editor-comments-sidebar-close-button =
.title = Close the sidebar
.aria-label = Close the sidebar
pdfjs-editor-comments-sidebar-close-button-label = Close the sidebar

# Instructional copy to add a comment by selecting text or an annotations.
pdfjs-editor-comments-sidebar-no-comments = Add a comment by selecting text or an annotation.

## Alt-text dialog

# Alternative text (alt text) helps when people can't see the image.
Expand Down
20 changes: 20 additions & 0 deletions src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ class AnnotationEditorUIManager {

#activeEditor = null;

#allEditableAnnotations = null;

#allEditors = new Map();

#allLayers = new Map();
Expand Down Expand Up @@ -663,6 +665,8 @@ class AnnotationEditorUIManager {

#showAllStates = null;

#pdfDocument = null;

#previousStates = {
isEditing: false,
isEmpty: true,
Expand Down Expand Up @@ -846,6 +850,7 @@ class AnnotationEditorUIManager {
this.#altTextManager = altTextManager;
this.#commentManager = commentManager;
this.#signatureManager = signatureManager;
this.#pdfDocument = pdfDocument;
this._eventBus = eventBus;
eventBus._on("editingaction", this.onEditingAction.bind(this), { signal });
eventBus._on("pagechanging", this.onPageChanging.bind(this), { signal });
Expand Down Expand Up @@ -928,6 +933,7 @@ class AnnotationEditorUIManager {
this.#floatingToolbar = null;
this.#mainHighlightColorPicker?.destroy();
this.#mainHighlightColorPicker = null;
this.#allEditableAnnotations = null;
if (this.#focusMainContainerTimeoutId) {
clearTimeout(this.#focusMainContainerTimeoutId);
this.#focusMainContainerTimeoutId = null;
Expand All @@ -937,6 +943,7 @@ class AnnotationEditorUIManager {
this.#translationTimeoutId = null;
}
this._editorUndoBar?.destroy();
this.#pdfDocument = null;
}

combinedSignal(ac) {
Expand Down Expand Up @@ -1790,6 +1797,10 @@ class AnnotationEditorUIManager {
this.#updateModeCapability = Promise.withResolvers();
this.#currentDrawingSession?.commitOrRemove();

if (this.#mode === AnnotationEditorType.POPUP) {
this.#commentManager?.hideSidebar();
}

this.#mode = mode;
if (mode === AnnotationEditorType.NONE) {
this.setEditingState(false);
Expand All @@ -1800,9 +1811,18 @@ class AnnotationEditorUIManager {
this.#updateModeCapability.resolve();
return;
}

if (mode === AnnotationEditorType.SIGNATURE) {
await this.#signatureManager?.loadSignatures();
}
if (mode === AnnotationEditorType.POPUP) {
this.#allEditableAnnotations ||=
await this.#pdfDocument.getAnnotationsByType(
new Set(this.#editorTypes.map(editorClass => editorClass._editorType))
);
this.#commentManager?.showSidebar(this.#allEditableAnnotations);
}

this.setEditingState(true);
await this.#enableAll();
this.unselectAll();
Expand Down
1 change: 1 addition & 0 deletions src/shared/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const AnnotationEditorType = {
HIGHLIGHT: 9,
STAMP: 13,
INK: 15,
POPUP: 16,
SIGNATURE: 101,
COMMENT: 102,
};
Expand Down
29 changes: 28 additions & 1 deletion web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,30 @@ const PDFViewerApplication = {
: null;
const commentManager =
AppOptions.get("enableComment") && appConfig.editCommentDialog
? new CommentManager(appConfig.editCommentDialog, overlayManager)
? new CommentManager(
appConfig.editCommentDialog,
{
sidebar:
appConfig.annotationEditorParams?.editorCommentsSidebar || null,
commentsList:
appConfig.annotationEditorParams?.editorCommentsSidebarList ||
null,
commentCount:
appConfig.annotationEditorParams?.editorCommentsSidebarCount ||
null,
sidebarTitle:
appConfig.annotationEditorParams?.editorCommentsSidebarTitle ||
null,
closeButton:
appConfig.annotationEditorParams
?.editorCommentsSidebarCloseButton || null,
commentToolbarButton:
appConfig.toolbar?.editorCommentButton || null,
},
eventBus,
linkService,
overlayManager
)
: null;

const enableHWA = AppOptions.get("enableHWA"),
Expand Down Expand Up @@ -589,6 +612,10 @@ const PDFViewerApplication = {
if (editorSignatureButton && AppOptions.get("enableSignatureEditor")) {
editorSignatureButton.parentElement.hidden = false;
}
const editorCommentButton = appConfig.toolbar?.editorCommentButton;
if (editorCommentButton && AppOptions.get("enableComment")) {
editorCommentButton.parentElement.hidden = false;
}
this.annotationEditorParams = new AnnotationEditorParams(
appConfig.annotationEditorParams,
eventBus
Expand Down
Loading
Loading