Skip to content

Commit 27aea73

Browse files
committed
Fix the paste button position and add a button before the first thumbnail
1 parent ecb0f57 commit 27aea73

4 files changed

Lines changed: 63 additions & 1 deletion

File tree

test/integration/reorganize_pages_spec.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,48 @@ describe("Reorganize Pages View", () => {
802802
await closePages(pages);
803803
});
804804

805+
it("should check that a page can be copied and pasted before the first thumbnail", async () => {
806+
await Promise.all(
807+
pages.map(async ([browserName, page]) => {
808+
await waitForThumbnailVisible(page, 1);
809+
await page.waitForSelector("#viewsManagerStatusActionButton", {
810+
visible: true,
811+
});
812+
await waitAndClick(
813+
page,
814+
`.thumbnail:has(${getThumbnailSelector(2)}) input`
815+
);
816+
817+
let handlePagesEdited = await waitForPagesEdited(page);
818+
await waitAndClick(page, "#viewsManagerStatusActionButton");
819+
await waitAndClick(page, "#viewsManagerStatusActionCopy");
820+
821+
let pageIndices = await awaitPromise(handlePagesEdited);
822+
let expected = [
823+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
824+
];
825+
expect(pageIndices)
826+
.withContext(`In ${browserName}`)
827+
.toEqual(expected);
828+
await waitForHavingContents(page, expected);
829+
830+
handlePagesEdited = await waitForPagesEdited(page);
831+
await waitAndClick(
832+
page,
833+
`button.thumbnailPasteButton:has(+ ${getThumbnailSelector(1)})`
834+
);
835+
pageIndices = await awaitPromise(handlePagesEdited);
836+
expected = [
837+
2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
838+
];
839+
expect(pageIndices)
840+
.withContext(`In ${browserName}`)
841+
.toEqual(expected);
842+
await waitForHavingContents(page, expected);
843+
})
844+
);
845+
});
846+
805847
it("should check that the pages has been copied and pasted correctly", async () => {
806848
await Promise.all(
807849
pages.map(async ([browserName, page]) => {

web/pdf_thumbnail_view.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,25 @@ class PDFThumbnailView extends RenderableView {
188188
pasteButton.addEventListener("click", () => {
189189
pasteCallback(this.id);
190190
});
191+
if (this.id === 1) {
192+
const prevPasteButton = (this.prevPasteButton =
193+
pasteButton.cloneNode(true));
194+
prevPasteButton.addEventListener("click", () => {
195+
pasteCallback(0);
196+
});
197+
this.imageContainer.before(prevPasteButton);
198+
}
191199

192200
this.imageContainer.after(pasteButton);
193201
}
194202

203+
removePasteButton() {
204+
this.pasteButton?.remove();
205+
this.pasteButton = null;
206+
this.prevPasteButton?.remove();
207+
this.prevPasteButton = null;
208+
}
209+
195210
toggleSelected(isSelected) {
196211
if (this.checkbox) {
197212
this.checkbox.checked = isSelected;

web/pdf_thumbnail_viewer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,9 @@ class PDFThumbnailViewer {
651651

652652
#pastePages(index) {
653653
this.container.classList.remove("pasteMode");
654+
for (const thumbnail of this._thumbnails) {
655+
thumbnail.removePasteButton();
656+
}
654657
this.#toggleMenuEntries(true);
655658

656659
const pagesMapper = this.#pagesMapper;

web/views_manager.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@
543543

544544
#thumbnailsView {
545545
--thumbnail-width: 126px;
546+
--gap-between-input-and-thumbnail: 16px;
546547

547548
display: flex;
548549
flex-flow: row wrap;
@@ -581,6 +582,8 @@
581582
}
582583

583584
&.pasteMode {
585+
gap: var(--gap-between-input-and-thumbnail);
586+
584587
> .thumbnail {
585588
flex-direction: column;
586589

@@ -611,7 +614,6 @@
611614

612615
> .thumbnail {
613616
--input-dim: 16px;
614-
--gap-between-input-and-thumbnail: 16px;
615617

616618
&:not(&:has(input)) {
617619
--input-dim: 0px;

0 commit comments

Comments
 (0)