Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function convertNodeToSketchLayers(node: Element): any[] {
const layers: Base[] = nodeToSketchLayers(node);
return layers.map((layer: Base) => {
if (!(layer instanceof Text) && node.classList && node.classList.length) {
const classes: string = Array.from(node.classList).join(" ");
// Trim unique class ids created by JSS
const trimmed: string = classes.replace(/[-0-9]+/g, "");
layer.setName(trimmed.replace(/[^A-Za-z0-9_]/g, " "));
}
return layer;
});
}
.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') {
layer._style._fontFamily = 'Proxima Nova';
}
if (layer instanceof SVG && node.classList.contains('sg-icon__svg') && symbol._name.startsWith('Icon/')) {
layer.setHasClippingMask(true);
}
// eslint-disable-next-line max-len
if (symbol._name.startsWith('Button/') && layer instanceof SVG || symbol._name.startsWith('Label/') && layer instanceof SVG) {
const type = node.children[0].id;
const size = node.clientHeight;
.forEach(node => {
const styleName = node.title;
const layers = nodeToSketchLayers(node.firstChild);
layers
.filter(layer => layer instanceof Text)
.forEach(layer => {
// fix font name so the name matches localy installed font
if (layer._style._fontFamily === 'ProximaNova') {
layer._style._fontFamily = 'Proxima Nova';
}
layer.setName(styleName);
doc.addTextStyle(layer);
});
});