Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.map(metaNode => {
const symbolNode = metaNode.firstChild;
const name = metaNode.title;
const {left: x, top: y, width, height} = symbolNode.getBoundingClientRect();
const symbol = new SymbolMaster({x, y, width, height});
symbol.setId(name);
symbol.setName(name);
//symbol.setUserInfo('code', node.innerHTML);
const parentAndChildren = [symbolNode, ...symbolNode.querySelectorAll('*')];
Array.from(parentAndChildren)
.map(node => {
const layers = nodeToSketchLayers(node);
return layers.map(layer => {
// fix font name so the name matches locally installed font
if (layer instanceof Text && layer._style._fontFamily === 'ProximaNova') {
.map((node: Element) => {
const rect: ClientRect = node.getBoundingClientRect();
const x: number = rect.left;
const y: number = rect.top;
const height: number = rect.height;
const width: number = rect.width;
const symbol: SymbolMaster = new SymbolMaster({
x,
y,
width,
height,
});
const children: Element[] = Array.from(node.querySelectorAll("*"));
const allNodes: Element[] = [node].concat(children);
if (node.hasAttribute(symbolNameDataAttribute)) {
symbol.setName(node.getAttribute(symbolNameDataAttribute));
} else {
symbol.setName("Symbol");
}
allNodes
.filter((filtered: Element) => filtered !== null || undefined)
}
if (fixPseudo) {
fixPseudoElements();
}
if (removePreviewMargin) {
removeShowMainMargin();
}
const layer = nodeTreeToSketchGroup(nodes, {
getGroupName: getNodeName,
getRectangleName: getNodeName
});
const symbol = new SymbolMaster({ x, y });
symbol.setName(name);
symbol.addLayer(layer);
return symbol.toJSON();
};