mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-24 09:08:07 +02:00
Introduce a generic clearEditors
helper function
This replaces the various copies of this logic with a single helper that we template for each editor type, similar to what we already do for the `switchToEditor` helper.
This commit is contained in:
parent
f155b69c07
commit
acc5a2153a
4 changed files with 13 additions and 21 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
import {
|
||||
awaitPromise,
|
||||
clearEditors,
|
||||
closePages,
|
||||
copy,
|
||||
copyToClipboard,
|
||||
|
@ -59,13 +60,7 @@ import { PNG } from "pngjs";
|
|||
|
||||
const selectAll = selectEditors.bind(null, "freeText");
|
||||
|
||||
const clearAll = async page => {
|
||||
await selectAll(page);
|
||||
await page.keyboard.down("Control");
|
||||
await page.keyboard.press("Backspace");
|
||||
await page.keyboard.up("Control");
|
||||
await waitForStorageEntries(page, 0);
|
||||
};
|
||||
const clearAll = clearEditors.bind(null, "freeText");
|
||||
|
||||
const commit = async page => {
|
||||
await page.keyboard.press("Escape");
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import {
|
||||
awaitPromise,
|
||||
clearEditors,
|
||||
closePages,
|
||||
dragAndDrop,
|
||||
getAnnotationSelector,
|
||||
|
@ -42,11 +43,7 @@ import {
|
|||
|
||||
const selectAll = selectEditors.bind(null, "ink");
|
||||
|
||||
const clearAll = async page => {
|
||||
await selectAll(page);
|
||||
await page.keyboard.press("Backspace");
|
||||
await waitForStorageEntries(page, 0);
|
||||
};
|
||||
const clearAll = clearEditors.bind(null, "ink");
|
||||
|
||||
const commit = async page => {
|
||||
await page.keyboard.press("Escape");
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
applyFunctionToEditor,
|
||||
awaitPromise,
|
||||
cleanupEditing,
|
||||
clearEditors,
|
||||
clearInput,
|
||||
closePages,
|
||||
copy,
|
||||
|
@ -38,7 +39,6 @@ import {
|
|||
pasteFromClipboard,
|
||||
scrollIntoView,
|
||||
selectEditor,
|
||||
selectEditors,
|
||||
serializeBitmapDimensions,
|
||||
switchToEditor,
|
||||
unselectEditor,
|
||||
|
@ -47,7 +47,6 @@ import {
|
|||
waitForEntryInStorage,
|
||||
waitForSelectedEditor,
|
||||
waitForSerialized,
|
||||
waitForStorageEntries,
|
||||
waitForTimeout,
|
||||
} from "./test_utils.mjs";
|
||||
import { fileURLToPath } from "url";
|
||||
|
@ -57,13 +56,7 @@ import { PNG } from "pngjs";
|
|||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const selectAll = selectEditors.bind(null, "stamp");
|
||||
|
||||
const clearAll = async page => {
|
||||
await selectAll(page);
|
||||
await page.keyboard.press("Backspace");
|
||||
await waitForStorageEntries(page, 0);
|
||||
};
|
||||
const clearAll = clearEditors.bind(null, "stamp");
|
||||
|
||||
const waitForImage = async (page, selector) => {
|
||||
await page.waitForSelector(`${selector} canvas`);
|
||||
|
|
|
@ -816,6 +816,12 @@ async function selectEditors(name, page) {
|
|||
);
|
||||
}
|
||||
|
||||
async function clearEditors(name, page) {
|
||||
await selectEditors(name, page);
|
||||
await page.keyboard.press("Backspace");
|
||||
await waitForStorageEntries(page, 0);
|
||||
}
|
||||
|
||||
function waitForNoElement(page, selector) {
|
||||
return page.waitForFunction(
|
||||
sel => !document.querySelector(sel),
|
||||
|
@ -888,6 +894,7 @@ export {
|
|||
applyFunctionToEditor,
|
||||
awaitPromise,
|
||||
cleanupEditing,
|
||||
clearEditors,
|
||||
clearInput,
|
||||
closePages,
|
||||
closeSinglePage,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue