Skip to content
Open
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
9 changes: 9 additions & 0 deletions src/display/editor/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,15 @@ class AnnotationEditorUIManager {
this.#mode !== AnnotationEditorType.NONE &&
!this.isEditorHandlingKeyboard
) {
if (
event.key === "Escape" &&
!this.hasSomethingToControl() &&
!this.#currentDrawingSession
) {
this.updateToolbar({ mode: AnnotationEditorType.NONE });
stopEvent(event);
return;
}
AnnotationEditorUIManager._keyboardManager.exec(this, event);
}
}
Expand Down
22 changes: 22 additions & 0 deletions test/integration/freetext_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,28 @@ describe("FreeText Editor", () => {
await closePages(pages);
});

it("must turn off the active editor tool with Escape", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await switchToFreeText(page);

const modeChangedHandle = await waitForAnnotationModeChanged(page);
await page.keyboard.press("Escape");
await awaitPromise(modeChangedHandle);

await page.waitForSelector("#editorFreeTextButton:not(.toggled)");
await page.waitForSelector(
".annotationEditorLayer:not(.freetextEditing)"
);

const mode = await page.evaluate(
() => window.PDFViewerApplication.pdfViewer.annotationEditorMode
);
expect(mode).withContext(`In ${browserName}`).toEqual(0);
})
);
});

it("must write a string in a FreeText editor", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
Expand Down
Loading