export default function handleExportSelection()

in src/figma/controllers/message_controller/handlers/export_selection.ts [4:27]


export default function handleExportSelection(): Promise<void> {
  const currentSelection = getCurrentSelection();

  return Promise.all(
    // export all selected components and frames
    [...currentSelection.components, ...currentSelection.frames].map(node => {
      return node
        .exportAsync({ format: 'PNG', constraint: { type: 'SCALE', value: 2 } })
        .then(nodeData => {
          return {
            name: node.name,
            data: nodeData,
          };
        });
    }),
  ).then(selections => {
    figma.ui.postMessage({
      type: FIGMA_MESSAGE_TYPES.EXPORT_SELECTION,
      data: {
        selections,
      },
    });
  });
}