SketchAPI icon indicating copy to clipboard operation
SketchAPI copied to clipboard

Text.style.textColor is undefined

Open qjebbs opened this issue 5 years ago • 2 comments

With this file, which is reported by my plugin user: text_color_undefined.sketch.zip

executing following in playground:

let document = sketch.getSelectedDocument();
let layer = document.pages[0].layers[0].layers[0];
console.log(
    layer.name,
    layer.style.textColor, //undefined
    layer.style.fontFamily, //undefined
)

But the Text does have color and font family setting.

PS: I don't know how or in what version this Text is created. I just copied it from user's file.

PS: More information from json, the textStyle is missing. But should the api handle this correctly?

image

qjebbs avatar Apr 18 '20 12:04 qjebbs

It's odd, after manually setting the font again it logs the correct info:

进行中 #1188eeff PingFang SC
Script executed in 0.088456s

It might be related to how the document was created?

christianklotz avatar Apr 29 '20 14:04 christianklotz

Sorry, I have no further information. But while the Sketch handles this correctly, may be the API should do it right too.

qjebbs avatar Apr 30 '20 06:04 qjebbs