Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
JSON.stringify({
type: PreviewMessageType.ContentResponse,
id,
payload: {
document: new XMLSerializer().serializeToString(document),
location: window.location.href,
height: rec.height,
width: rec.width
}
})
);
break;
}
case PreviewMessageType.SketchExportRequest: {
const sketchPage = HtmlSketchApp.nodeTreeToSketchPage(document.documentElement, {
pageName: payload.pageName,
addArtboard: true,
artboardName: payload.artboardName,
getGroupName: node =>
node.getAttribute('data-sketch-name') || `(${node.nodeName.toLowerCase()})`,
getRectangleName: () => 'background',
skipSystemFonts: true
});
const page = sketchPage.toJSON();
connection.send(
JSON.stringify({
type: PreviewMessageType.SketchExportResponse,
id,
payload: { page }
export function run(mainNode = document.body) {
const page = nodeTreeToSketchPage(mainNode);
page.setName(document.title);
return page.toJSON();
}