SketchAPI icon indicating copy to clipboard operation
SketchAPI copied to clipboard

APIs missing: When create a new style (both Layer and Text), we need an easier way to update our Styles list

Open matteogratton opened this issue 3 years ago • 0 comments

It would be nice to be able to update the styles list in a simpler way.

This is what I have to do right now (an example with Layer styles):

let sharedStyle = layerStyles.push({
    name: "New Style Name",
    style: layer.style,
    document: document,
});
updateLayerStyles();

[...]

function updateLayerStyles() {
    layerStyles = document.sharedLayerStyles;
    arrayLayerStyleIDs = layerStyles.map((sharedstyle) => sharedstyle["id"]);
    arrayLayerStyleNames = layerStyles.map(
        (sharedstyle) => sharedstyle["name"]
    );
    arrayLayerStyleStyles = layerStyles.map(
        (sharedstyle) => sharedstyle["style"]
    );
}

It would be nice to have something simpler, like:

let sharedStyle = layerStyles.push({
    name: "New Style Name",
    style: layer.style,
    document: document,
});
sharedStyle.add();

matteogratton avatar Jun 23 '22 10:06 matteogratton