[Editor] In edit mode, a non-editable stamp must be visible after the page is rendered
This commit is contained in:
parent
dea35aed4a
commit
f3454a738d
@ -4920,7 +4920,7 @@ class StampAnnotation extends MarkupAnnotation {
|
|||||||
mustBeViewedWhenEditing(isEditing, modifiedIds = null) {
|
mustBeViewedWhenEditing(isEditing, modifiedIds = null) {
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
if (!this.data.isEditable) {
|
if (!this.data.isEditable) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
// When we're editing, we want to ensure that the stamp annotation is
|
// When we're editing, we want to ensure that the stamp annotation is
|
||||||
// drawn on a canvas in order to use it in the annotation editor layer.
|
// drawn on a canvas in order to use it in the annotation editor layer.
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import {
|
|||||||
getRect,
|
getRect,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
hover,
|
hover,
|
||||||
isCanvasWhite,
|
isCanvasMonochrome,
|
||||||
kbBigMoveDown,
|
kbBigMoveDown,
|
||||||
kbBigMoveLeft,
|
kbBigMoveLeft,
|
||||||
kbBigMoveRight,
|
kbBigMoveRight,
|
||||||
@ -837,7 +837,7 @@ describe("FreeText Editor", () => {
|
|||||||
await switchToFreeText(page);
|
await switchToFreeText(page);
|
||||||
|
|
||||||
// The page has been re-rendered but with no freetext annotations.
|
// The page has been re-rendered but with no freetext annotations.
|
||||||
let isWhite = await isCanvasWhite(page, 1);
|
let isWhite = await isCanvasMonochrome(page, 1, null, 0xffffffff);
|
||||||
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
||||||
|
|
||||||
let editorIds = await getEditors(page, "freeText");
|
let editorIds = await getEditors(page, "freeText");
|
||||||
@ -880,7 +880,7 @@ describe("FreeText Editor", () => {
|
|||||||
editorIds = await getEditors(page, "freeText");
|
editorIds = await getEditors(page, "freeText");
|
||||||
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(1);
|
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(1);
|
||||||
|
|
||||||
isWhite = await isCanvasWhite(page, 1, editorRect);
|
isWhite = await isCanvasMonochrome(page, 1, editorRect, 0xffffffff);
|
||||||
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
||||||
|
|
||||||
// Check we've now a div containing the text.
|
// Check we've now a div containing the text.
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import {
|
|||||||
getEditorSelector,
|
getEditorSelector,
|
||||||
getRect,
|
getRect,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
isCanvasWhite,
|
isCanvasMonochrome,
|
||||||
kbRedo,
|
kbRedo,
|
||||||
kbUndo,
|
kbUndo,
|
||||||
loadAndWait,
|
loadAndWait,
|
||||||
@ -747,7 +747,12 @@ describe("Ink Editor", () => {
|
|||||||
await switchToInk(page);
|
await switchToInk(page);
|
||||||
|
|
||||||
// The page has been re-rendered but with no ink annotations.
|
// The page has been re-rendered but with no ink annotations.
|
||||||
let isWhite = await isCanvasWhite(page, 1, annotationsRect);
|
let isWhite = await isCanvasMonochrome(
|
||||||
|
page,
|
||||||
|
1,
|
||||||
|
annotationsRect,
|
||||||
|
0xffffffff
|
||||||
|
);
|
||||||
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
||||||
|
|
||||||
let editorIds = await getEditors(page, "ink");
|
let editorIds = await getEditors(page, "ink");
|
||||||
@ -781,7 +786,7 @@ describe("Ink Editor", () => {
|
|||||||
editorIds = await getEditors(page, "ink");
|
editorIds = await getEditors(page, "ink");
|
||||||
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(1);
|
expect(editorIds.length).withContext(`In ${browserName}`).toEqual(1);
|
||||||
|
|
||||||
isWhite = await isCanvasWhite(page, 1, editorRect);
|
isWhite = await isCanvasMonochrome(page, 1, editorRect, 0xffffffff);
|
||||||
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
expect(isWhite).withContext(`In ${browserName}`).toBeTrue();
|
||||||
|
|
||||||
// Check we've now a svg with a red stroke.
|
// Check we've now a svg with a red stroke.
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import {
|
|||||||
getFirstSerialized,
|
getFirstSerialized,
|
||||||
getRect,
|
getRect,
|
||||||
getSerialized,
|
getSerialized,
|
||||||
|
isCanvasMonochrome,
|
||||||
isVisible,
|
isVisible,
|
||||||
kbBigMoveDown,
|
kbBigMoveDown,
|
||||||
kbBigMoveRight,
|
kbBigMoveRight,
|
||||||
@ -45,6 +46,7 @@ import {
|
|||||||
waitForAnnotationEditorLayer,
|
waitForAnnotationEditorLayer,
|
||||||
waitForAnnotationModeChanged,
|
waitForAnnotationModeChanged,
|
||||||
waitForEntryInStorage,
|
waitForEntryInStorage,
|
||||||
|
waitForPageRendered,
|
||||||
waitForSelectedEditor,
|
waitForSelectedEditor,
|
||||||
waitForSerialized,
|
waitForSerialized,
|
||||||
waitForTimeout,
|
waitForTimeout,
|
||||||
@ -1819,4 +1821,57 @@ describe("Stamp Editor", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("Switch to edit mode, zoom and check that the non-editable stamp is still there", () => {
|
||||||
|
const annotationSelector = getAnnotationSelector("14R");
|
||||||
|
|
||||||
|
let pages;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
pages = await loadAndWait("red_stamp.pdf", annotationSelector, 20);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await closePages(pages);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("must check if the canvas is still red", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([, page]) => {
|
||||||
|
expect(
|
||||||
|
await isCanvasMonochrome(page, 1, null, 0xff0000ff)
|
||||||
|
).toBeTrue();
|
||||||
|
|
||||||
|
await switchToStamp(page);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await isCanvasMonochrome(page, 1, null, 0xff0000ff)
|
||||||
|
).toBeTrue();
|
||||||
|
|
||||||
|
const rectPage = await getRect(
|
||||||
|
page,
|
||||||
|
`.page[data-page-number = "1"] .annotationEditorLayer`
|
||||||
|
);
|
||||||
|
|
||||||
|
const handle = await waitForPageRendered(page, 1);
|
||||||
|
const originX = rectPage.x + rectPage.width / 2;
|
||||||
|
const originY = rectPage.y + rectPage.height / 2;
|
||||||
|
await page.evaluate(
|
||||||
|
origin => {
|
||||||
|
window.PDFViewerApplication.pdfViewer.increaseScale({
|
||||||
|
scaleFactor: 2,
|
||||||
|
origin,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[originX, originY]
|
||||||
|
);
|
||||||
|
await awaitPromise(handle);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await isCanvasMonochrome(page, 1, null, 0xff0000ff)
|
||||||
|
).toBeTrue();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -838,9 +838,9 @@ function waitForNoElement(page, selector) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isCanvasWhite(page, pageNumber, rectangle) {
|
function isCanvasMonochrome(page, pageNumber, rectangle, color) {
|
||||||
return page.evaluate(
|
return page.evaluate(
|
||||||
(rect, pageN) => {
|
(rect, pageN, col) => {
|
||||||
const canvas = document.querySelector(
|
const canvas = document.querySelector(
|
||||||
`.page[data-page-number = "${pageN}"] .canvasWrapper canvas`
|
`.page[data-page-number = "${pageN}"] .canvasWrapper canvas`
|
||||||
);
|
);
|
||||||
@ -853,10 +853,11 @@ function isCanvasWhite(page, pageNumber, rectangle) {
|
|||||||
rect.width,
|
rect.width,
|
||||||
rect.height
|
rect.height
|
||||||
);
|
);
|
||||||
return new Uint32Array(data.buffer).every(x => x === 0xffffffff);
|
return new Uint32Array(data.buffer).every(x => x === col);
|
||||||
},
|
},
|
||||||
rectangle,
|
rectangle,
|
||||||
pageNumber
|
pageNumber,
|
||||||
|
color
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -925,7 +926,7 @@ export {
|
|||||||
getSpanRectFromText,
|
getSpanRectFromText,
|
||||||
getXY,
|
getXY,
|
||||||
hover,
|
hover,
|
||||||
isCanvasWhite,
|
isCanvasMonochrome,
|
||||||
isVisible,
|
isVisible,
|
||||||
kbBigMoveDown,
|
kbBigMoveDown,
|
||||||
kbBigMoveLeft,
|
kbBigMoveLeft,
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -710,3 +710,4 @@
|
|||||||
!bug1019475_2.pdf
|
!bug1019475_2.pdf
|
||||||
!issue19505.pdf
|
!issue19505.pdf
|
||||||
!colors.pdf
|
!colors.pdf
|
||||||
|
!red_stamp.pdf
|
||||||
|
|||||||
BIN
test/pdfs/red_stamp.pdf
Executable file
BIN
test/pdfs/red_stamp.pdf
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user