mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Merge pull request #17907 from calixteman/fix_draw_ink
[Editor] Don't add an already added editor (bug 1890367)
This commit is contained in:
commit
30b65ca067
2 changed files with 44 additions and 0 deletions
|
@ -481,6 +481,9 @@ class AnnotationEditorLayer {
|
||||||
* @param {AnnotationEditor} editor
|
* @param {AnnotationEditor} editor
|
||||||
*/
|
*/
|
||||||
add(editor) {
|
add(editor) {
|
||||||
|
if (editor.parent === this && editor.isAttachedToDOM) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.changeParent(editor);
|
this.changeParent(editor);
|
||||||
this.#uiManager.addEditor(editor);
|
this.#uiManager.addEditor(editor);
|
||||||
this.attach(editor);
|
this.attach(editor);
|
||||||
|
|
|
@ -459,4 +459,45 @@ describe("Ink Editor", () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Draw several times in the same editor", () => {
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("empty.pdf", ".annotationEditorLayer");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check that we can draw several times on the same canvas", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await page.click("#editorInk");
|
||||||
|
await page.waitForSelector(".annotationEditorLayer.inkEditing");
|
||||||
|
|
||||||
|
const rect = await page.$eval(".annotationEditorLayer", el => {
|
||||||
|
const { x, y } = el.getBoundingClientRect();
|
||||||
|
return { x, y };
|
||||||
|
});
|
||||||
|
|
||||||
|
let xStart = rect.x + 10;
|
||||||
|
const yStart = rect.y + 10;
|
||||||
|
for (let i = 0; i < 5; i++) {
|
||||||
|
const clickHandle = await waitForPointerUp(page);
|
||||||
|
await page.mouse.move(xStart, yStart);
|
||||||
|
await page.mouse.down();
|
||||||
|
await page.mouse.move(xStart + 50, yStart + 50);
|
||||||
|
await page.mouse.up();
|
||||||
|
await awaitPromise(clickHandle);
|
||||||
|
xStart += 70;
|
||||||
|
}
|
||||||
|
await commit(page);
|
||||||
|
|
||||||
|
await page.waitForSelector(getEditorSelector(0));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue