Skip to main content
Question

Problem with export of nodes inside the remote component

  • January 18, 2023
  • 3 replies
  • 904 views

polar_slon

Hi everyone!

Recently I’ve faced with an unpleasing issue related with export.

I have some components (in external library) and their instances (in another project). I have a custom plugin that initially finds all such instances and then does some processing of their main components (using InstanceNode.mainComponent). While processing plugin exports some inner nodes of the components as SVG.

Code snippet:

async function exportToSvg(node: ExportMixin) {
    const settings = { format: 'SVG' } as ExportSettingsSVG;

    return node.exportAsync(settings)
        .then(data => { return String.fromCharCode.apply(null, new Uint16Array(data)); })
        .catch(**reason** => { /* some error handling */ });
}

And the issue is that export fails if node for export is from the subtree of remote component. In case of local component export operation succeeds, in case of instance of the same remote component export succeeds too.

In case of fail reason variable receives very generic error message: “Failed to export node”.

Is this expected behaviour or a bug?

This topic has been closed for comments

3 replies

polar_slon
  • Author
  • 3 replies
  • January 18, 2023

@Gleb, please take a look 👋


Gleb
  • Power Member
  • 4706 replies
  • January 18, 2023

Nodes need to be instantiated on the canvas to be able to export them. Main components of remote instances are permanently hidden and accessible only for reference, so to export them you need to clone them somewhere to the canvas temporarily.


polar_slon
  • Author
  • 3 replies
  • January 18, 2023

@Gleb, thank for the hint. It would suit as a workaround.

But anyway there is a inconsistance: I can use all the properties and functions of the remote component but the export. Why export is so unique?

If there is some techincal limitation under the hood maybe workaround with temporary instances can be implemented on the Figma API level to mitigate such problem on the side of plugin developers? What do you think?


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