mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 12:27:21 +02:00
Merge pull request #20789 from calixteman/fix_paste_button_layout
Fix the paste button position and add a button before the first thumbnail
This commit is contained in:
commit
286b0cc536
@ -802,6 +802,48 @@ describe("Reorganize Pages View", () => {
|
|||||||
await closePages(pages);
|
await closePages(pages);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should check that a page can be copied and pasted before the first thumbnail", async () => {
|
||||||
|
await Promise.all(
|
||||||
|
pages.map(async ([browserName, page]) => {
|
||||||
|
await waitForThumbnailVisible(page, 1);
|
||||||
|
await page.waitForSelector("#viewsManagerStatusActionButton", {
|
||||||
|
visible: true,
|
||||||
|
});
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
`.thumbnail:has(${getThumbnailSelector(2)}) input`
|
||||||
|
);
|
||||||
|
|
||||||
|
let handlePagesEdited = await waitForPagesEdited(page);
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionButton");
|
||||||
|
await waitAndClick(page, "#viewsManagerStatusActionCopy");
|
||||||
|
|
||||||
|
let pageIndices = await awaitPromise(handlePagesEdited);
|
||||||
|
let expected = [
|
||||||
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||||
|
];
|
||||||
|
expect(pageIndices)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual(expected);
|
||||||
|
await waitForHavingContents(page, expected);
|
||||||
|
|
||||||
|
handlePagesEdited = await waitForPagesEdited(page);
|
||||||
|
await waitAndClick(
|
||||||
|
page,
|
||||||
|
`button.thumbnailPasteButton:has(+ ${getThumbnailSelector(1)})`
|
||||||
|
);
|
||||||
|
pageIndices = await awaitPromise(handlePagesEdited);
|
||||||
|
expected = [
|
||||||
|
2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||||
|
];
|
||||||
|
expect(pageIndices)
|
||||||
|
.withContext(`In ${browserName}`)
|
||||||
|
.toEqual(expected);
|
||||||
|
await waitForHavingContents(page, expected);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("should check that the pages has been copied and pasted correctly", async () => {
|
it("should check that the pages has been copied and pasted correctly", async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
pages.map(async ([browserName, page]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
|
|||||||
@ -188,10 +188,25 @@ class PDFThumbnailView extends RenderableView {
|
|||||||
pasteButton.addEventListener("click", () => {
|
pasteButton.addEventListener("click", () => {
|
||||||
pasteCallback(this.id);
|
pasteCallback(this.id);
|
||||||
});
|
});
|
||||||
|
if (this.id === 1) {
|
||||||
|
const prevPasteButton = (this.prevPasteButton =
|
||||||
|
pasteButton.cloneNode(true));
|
||||||
|
prevPasteButton.addEventListener("click", () => {
|
||||||
|
pasteCallback(0);
|
||||||
|
});
|
||||||
|
this.imageContainer.before(prevPasteButton);
|
||||||
|
}
|
||||||
|
|
||||||
this.imageContainer.after(pasteButton);
|
this.imageContainer.after(pasteButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removePasteButton() {
|
||||||
|
this.pasteButton?.remove();
|
||||||
|
this.pasteButton = null;
|
||||||
|
this.prevPasteButton?.remove();
|
||||||
|
this.prevPasteButton = null;
|
||||||
|
}
|
||||||
|
|
||||||
toggleSelected(isSelected) {
|
toggleSelected(isSelected) {
|
||||||
if (this.checkbox) {
|
if (this.checkbox) {
|
||||||
this.checkbox.checked = isSelected;
|
this.checkbox.checked = isSelected;
|
||||||
|
|||||||
@ -651,6 +651,9 @@ class PDFThumbnailViewer {
|
|||||||
|
|
||||||
#pastePages(index) {
|
#pastePages(index) {
|
||||||
this.container.classList.remove("pasteMode");
|
this.container.classList.remove("pasteMode");
|
||||||
|
for (const thumbnail of this._thumbnails) {
|
||||||
|
thumbnail.removePasteButton();
|
||||||
|
}
|
||||||
this.#toggleMenuEntries(true);
|
this.#toggleMenuEntries(true);
|
||||||
|
|
||||||
const pagesMapper = this.#pagesMapper;
|
const pagesMapper = this.#pagesMapper;
|
||||||
|
|||||||
@ -543,6 +543,7 @@
|
|||||||
|
|
||||||
#thumbnailsView {
|
#thumbnailsView {
|
||||||
--thumbnail-width: 126px;
|
--thumbnail-width: 126px;
|
||||||
|
--gap-between-input-and-thumbnail: 16px;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-flow: row wrap;
|
flex-flow: row wrap;
|
||||||
@ -581,6 +582,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.pasteMode {
|
&.pasteMode {
|
||||||
|
gap: var(--gap-between-input-and-thumbnail);
|
||||||
|
|
||||||
> .thumbnail {
|
> .thumbnail {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
@ -611,7 +614,6 @@
|
|||||||
|
|
||||||
> .thumbnail {
|
> .thumbnail {
|
||||||
--input-dim: 16px;
|
--input-dim: 16px;
|
||||||
--gap-between-input-and-thumbnail: 16px;
|
|
||||||
|
|
||||||
&:not(&:has(input)) {
|
&:not(&:has(input)) {
|
||||||
--input-dim: 0px;
|
--input-dim: 0px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user