andrewfiorillo / sketch-palettes

A Sketch plugin for exporting and importing fill presets. It supports colors, gradients, and pattern fills.
MIT License
2.27k stars 135 forks source link

Sketch Palettes not working on Sketch 53 #77

Closed Lowrenz closed 5 years ago

Lowrenz commented 5 years ago

Sketch introduced a new way of displaying colors. Since the update, loading / importing Sketch Palettes doesn't work anymore.

kristof commented 5 years ago

Getting these errors in the console.

TypeError: app.globalAssets is not a function. (In 'app.globalAssets()', 'app.globalAssets' is undefined)
line: 368
TypeError: assets.addColors is not a function. (In 'assets.addColors(colors)', 'assets.addColors' is undefined)
line: 372

Currently trying to figure out what changed in their API.

kristof commented 5 years ago

I was able to figure out how to fix loading, saving and clearing document colors. However, I noticed that app.globalColors() has been removed. So adding colors + gradients on a global level is not yet fixed.

@mathieudutour I noticed your comments on another repo, maybe you know how we can access global assets.

mathieudutour commented 5 years ago

I do :)

MSPersistentAssetCollection.sharedGlobalAssets().colorAssets()

Have a look here

kristof commented 5 years ago

@mathieudutour Amazing, thanks! I was looking at MSPersistentAssetCollection in the sketch headers repo but simply didn't make the link it was accessible through this.

So I've updated my pull request, this basically fixes the functionality as is. There is no support for storing the names of the colors + gradients since this will require a change in how we store the information.

andrewfiorillo commented 5 years ago

This is now fixed. Thanks everyone!