sketch-hq / SketchAPI

The JavaScript plugin library embedded in Sketch
https://developer.sketch.com/reference/api
MIT License
842 stars 126 forks source link

Error when assign style to Text #726

Open qjebbs opened 4 years ago

qjebbs commented 4 years ago

The following code throw an error of Error: image needs to be a Buffer, but:

  1. The fill is not enabled.
  2. even it is enabled, the fill type is color, not pattern
  3. null is valid to pattern.image according to api document

So, it's I think it's a bug of the api environment.

let subText = new sketch.Text({
    text: '123',
    parent: sketch.getSelectedDocument().pages[0].layers[0],
});
subText.style = {
    fills: [
        {
            enabled: false,
            fillType: sketch.Style.FillType.Color,
            pattern: {
                image: null
            }
        }
    ]
}
qjebbs commented 4 years ago

One more thing, if a change the value of image to undefined, the error gone.