google / AEUX

Editable After Effects layers from Sketch artboards
Apache License 2.0
519 stars 55 forks source link

Fixes issue in Figma plugin where some textfields would have a property value that would cause postMessage to error. #210

Closed craigthings closed 5 months ago

craigthings commented 6 months ago

The team I work with ran into an issue where certain textfields would not export, and AEUX would hang. This was due to the property "openTypeFeatures" on TextNodes occasionally containing a Symbol reference which can't be unwrapped to be sent as data using figma.ui.postMessage method. I added a sanitizeValue utility function that you can put any value into and get back values that postMessage can use without error. This utility function is used in the nodeToObj function on the object that getElement returns.

sanitizeValue runs recursively on and value passed in that is an object or array. It will also return all supported values as is, and will return a string representation of functions, symbols, and regexes. All other values return null.