Skip to main content

Thoughts and questions about readonly in dev-mode in the context of the plugin API


Vincent_Huss

Hi everyone !

 

This is a question for the engineer / design team around the plugin API.

First, a big thanks and cheers to the dev team for this API which is a real pleasure to work with.

So for context, i’m working on a plugin, and i’ve recently subscribed to dev-mode in order to optimize it for dev-mode.
 

My plugin is a code exporter, and there are multiple reasons that force me to write in the user design :

  • removing things like border, radius, shadow, ... in order to define them as CSS rather than leaving them in the exported image (no serious front-end dev want that)
  • for image-background, sometimes, it can’t be defined with the image fill because of some transformation (filters, crop...) and must be exported instead (node.exportAsync), in that case, the content of that node must be hidden before the export (since that content will be HTML dom)
  • other reasons related to nested rotation which are a bit hard to describe in a short sentence.


Of course, i make sure that each of those writes are reversed, even in case of a crash, so the user’s design is always left untouched.

 

So my understanding is that, in the current context, it’s not possible to make a quality code export plugin without having write access to the document.

Are there any options that i am missing ?

  • maybe the REST API can be of any help here ? (from what i understand, it’s only for private design, so it wouldn’t help in this context but maybe i misunderstood something ?)
  • Are there some configuration around the exportAsync function that i missed ? (that would allow for cropping, turning off some properties like strokes, effects ...)


If there’s nothing we can do in the current context, is it conceivable to imagine a sandbox environment in dev-mode ? a kind of virtual page (that doesn’t display in the figma editor) in which the plugin can clone nodes, apply transformations, and having this virtual page being deleted from memory as soon as the plugin exits ?  the cloned node could be completely disconnected from any shared resources (component instances, variables, styles ...) to ensure no access to the outside environment.

 

Thanks in advance if you have the time to read and share feedback on this.

Cheers !

 

 

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings