Skip to content

Commit 71f6956

Browse files
committed
ACP2E-3428: Pagebuilder's template preview failure for large content
- added correction in corresponding ts file
1 parent 4d744c4 commit 71f6956

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/template-manager.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
2-
* Copyright © Magento, Inc. All rights reserved.
3-
* See COPYING.txt for license details.
2+
* Copyright 2019 Adobe
3+
* All Rights Reserved.
44
*/
55

66
import html2canvas from "html2canvas";
@@ -138,6 +138,7 @@ function createCapture(stage: Stage) {
138138
renderingLock.then(() => {
139139
// Resolve issues with Parallax
140140
const parallaxRestore = disableParallax(stageElement);
141+
const canvasElement = document.querySelector("#" + stage.id + " .pagebuilder-canvas") as HTMLElement;
141142

142143
stageElement.style.height = $(stageElement).outerHeight(false) + "px";
143144
stageElement.classList.add("capture");
@@ -151,11 +152,12 @@ function createCapture(stage: Stage) {
151152

152153
_.defer(() => {
153154
html2canvas(
154-
document.querySelector("#" + stage.id + " .pagebuilder-canvas"),
155+
canvasElement,
155156
{
156157
scale: 1,
157158
useCORS: true,
158159
scrollY: (window.pageYOffset * -1),
160+
height: correctCanvasHeight(canvasElement),
159161
},
160162
).then((canvas: HTMLCanvasElement) => {
161163
const imageSrc = canvas.toDataURL("image/jpeg", 0.85);
@@ -216,6 +218,16 @@ function restoreParallax(rows: ResetRowInterface[]) {
216218
});
217219
}
218220

221+
/**
222+
* Adjust canvas element size to prevent area overflow.
223+
*
224+
* @param canvasElement
225+
*/
226+
function correctCanvasHeight(canvasElement: HTMLElement) {
227+
// @ts-ignore
228+
return canvasElement.getHeight() < 4096 ? canvasElement.getHeight() : 4096;
229+
}
230+
219231
interface ResetRowInterface {
220232
element: HTMLElement;
221233
styles: string;

0 commit comments

Comments
 (0)