Skip to content

Commit

Permalink
[editor] Remove the editorNone toolbar button (bug 1787295)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffleupagus committed Aug 26, 2022
1 parent 76f665d commit 19182d5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 35 deletions.
2 changes: 0 additions & 2 deletions l10n/en-US/viewer.properties
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,6 @@ printing_not_ready=Warning: The PDF is not fully loaded for printing.
web_fonts_disabled=Web fonts are disabled: unable to use embedded PDF fonts.

# Editor
editor_none.title=Disable Annotation Editing
editor_none_label=Disable Editing
editor_free_text.title=Add FreeText Annotation
editor_free_text_label=FreeText Annotation
editor_ink.title=Add Ink Annotation
Expand Down
4 changes: 0 additions & 4 deletions web/images/toolbarButton-editorNone.svg

This file was deleted.

35 changes: 17 additions & 18 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const PAGE_NUMBER_LOADING_INDICATOR = "visiblePageIsLoading";
* @property {HTMLButtonElement} openFile - Button to open a new document.
* @property {HTMLButtonElement} presentationModeButton - Button to switch to
* presentation mode.
* @property {HTMLButtonElement} editorNoneButton - Button to disable editing.
* @property {HTMLButtonElement} editorFreeTextButton - Button to switch to
* FreeText editing.
* @property {HTMLButtonElement} download - Button to download the document.
Expand Down Expand Up @@ -76,20 +75,29 @@ class Toolbar {
},
{ element: options.download, eventName: "download" },
{ element: options.viewBookmark, eventName: null },
{
element: options.editorNoneButton,
eventName: "switchannotationeditormode",
eventDetails: { mode: AnnotationEditorType.NONE },
},
{
element: options.editorFreeTextButton,
eventName: "switchannotationeditormode",
eventDetails: { mode: AnnotationEditorType.FREETEXT },
eventDetails: {
get mode() {
const { classList } = options.editorFreeTextButton;
return classList.contains("toggled")
? AnnotationEditorType.NONE
: AnnotationEditorType.FREETEXT;
},
},
},
{
element: options.editorInkButton,
eventName: "switchannotationeditormode",
eventDetails: { mode: AnnotationEditorType.INK },
eventDetails: {
get mode() {
const { classList } = options.editorInkButton;
return classList.contains("toggled")
? AnnotationEditorType.NONE
: AnnotationEditorType.INK;
},
},
},
];
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
Expand All @@ -104,11 +112,6 @@ class Toolbar {
next: options.next,
zoomIn: options.zoomIn,
zoomOut: options.zoomOut,
editorNoneButton: options.editorNoneButton,
editorFreeTextButton: options.editorFreeTextButton,
editorFreeTextParamsToolbar: options.editorFreeTextParamsToolbar,
editorInkButton: options.editorInkButton,
editorInkParamsToolbar: options.editorInkParamsToolbar,
};

// Bind the event listeners for click and various other actions.
Expand Down Expand Up @@ -213,15 +216,13 @@ class Toolbar {
}

#bindEditorToolsListener({
editorNoneButton,
editorFreeTextButton,
editorFreeTextParamsToolbar,
editorInkButton,
editorInkParamsToolbar,
}) {
const editorModeChanged = (evt, disableButtons = false) => {
const editorButtons = [
{ mode: AnnotationEditorType.NONE, button: editorNoneButton },
{
mode: AnnotationEditorType.FREETEXT,
button: editorFreeTextButton,
Expand All @@ -239,9 +240,7 @@ class Toolbar {
button.classList.toggle("toggled", checked);
button.setAttribute("aria-checked", checked);
button.disabled = disableButtons;
if (toolbar) {
toolbar.classList.toggle("hidden", !checked);
}
toolbar?.classList.toggle("hidden", !checked);
}
};
this.eventBus._on("annotationeditormodechanged", editorModeChanged);
Expand Down
5 changes: 0 additions & 5 deletions web/viewer.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
--loading-icon: url(images/loading.svg);
--treeitem-expanded-icon: url(images/treeitem-expanded.svg);
--treeitem-collapsed-icon: url(images/treeitem-collapsed.svg);
--toolbarButton-editorNone-icon: url(images/toolbarButton-editorNone.svg);
--toolbarButton-editorFreeText-icon: url(images/toolbarButton-editorFreeText.svg);
--toolbarButton-editorInk-icon: url(images/toolbarButton-editorInk.svg);
--toolbarButton-menuArrow-icon: url(images/toolbarButton-menuArrow.svg);
Expand Down Expand Up @@ -888,10 +887,6 @@ select {
mask-image: var(--toolbarButton-presentationMode-icon);
}

#editorNone::before {
mask-image: var(--toolbarButton-editorNone-icon);
}

#editorFreeText::before {
mask-image: var(--toolbarButton-editorFreeText-icon);
}
Expand Down
7 changes: 2 additions & 5 deletions web/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,10 @@
<div class="verticalToolbarSeparator hiddenSmallView"></div>

<div id="editorModeButtons" class="splitToolbarButton toggled hidden" role="radiogroup">
<button id="editorNone" class="toolbarButton toggled" disabled="disabled" title="Disable Annotation Editing" role="radio" aria-checked="true" tabindex="36" data-l10n-id="editor_none">
<span data-l10n-id="editor_none_label">Disable Editing</span>
</button>
<button id="editorFreeText" class="toolbarButton" disabled="disabled" title="Add FreeText Annotation" role="radio" aria-checked="false" tabindex="37" data-l10n-id="editor_free_text">
<button id="editorFreeText" class="toolbarButton" disabled="disabled" title="Add FreeText Annotation" role="radio" aria-checked="false" tabindex="36" data-l10n-id="editor_free_text">
<span data-l10n-id="editor_free_text_label">FreeText Annotation</span>
</button>
<button id="editorInk" class="toolbarButton" disabled="disabled" title="Add Ink Annotation" role="radio" aria-checked="false" tabindex="38" data-l10n-id="editor_ink">
<button id="editorInk" class="toolbarButton" disabled="disabled" title="Add Ink Annotation" role="radio" aria-checked="false" tabindex="37" data-l10n-id="editor_ink">
<span data-l10n-id="editor_ink_label">Ink Annotation</span>
</button>
</div>
Expand Down
1 change: 0 additions & 1 deletion web/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ function getViewerConfiguration() {
? document.getElementById("openFile")
: null,
print: document.getElementById("print"),
editorNoneButton: document.getElementById("editorNone"),
editorFreeTextButton: document.getElementById("editorFreeText"),
editorFreeTextParamsToolbar: document.getElementById(
"editorFreeTextParamsToolbar"
Expand Down

0 comments on commit 19182d5

Please sign in to comment.