Skip to content

Commit

Permalink
fix: Include disabled block pattern in screenshot. (#2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnesky authored Feb 13, 2024
1 parent 2b857d4 commit b60f7be
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/dev-tools/src/screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ function workspaceToSvg_(workspace, callback, customCss) {
const height = bBox.height || bBox.bottom - y;

const blockCanvas = workspace.getCanvas();
const clone = blockCanvas.cloneNode(true);
clone.removeAttribute('transform');
const blockCanvasClone = blockCanvas.cloneNode(true);
blockCanvasClone.removeAttribute('transform');


const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
svg.appendChild(clone);
svg.setAttribute('viewBox', x + ' ' + y + ' ' + width + ' ' + height);

svg.setAttribute(
Expand All @@ -100,7 +100,12 @@ function workspaceToSvg_(workspace, callback, customCss) {
.join('\n');
const style = document.createElement('style');
style.innerHTML = css + '\n' + customCss;
svg.insertBefore(style, svg.firstChild);

svg.appendChild(style);
for (const defs of workspace.getSvgGroup().getElementsByTagName('defs')) {
svg.appendChild(defs.cloneNode(true));
}
svg.appendChild(blockCanvasClone);

let svgAsXML = new XMLSerializer().serializeToString(svg);
svgAsXML = svgAsXML.replace(/&nbsp/g, '&#160');
Expand Down

0 comments on commit b60f7be

Please sign in to comment.