0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-20 06:22:38 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformFigmaIds.ts
Alex Sánchez 7b3192936e
Component Instances (#124)
* wip

* wip

* wipo

* more structure

* wip

* id library wip

* wip

* main instance working

* improvements

* fix node order

* refactor

* remove not used method

* refactor

* fix component set translation

* refactor

* add changelog

* penpot lib update

---------

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
2024-05-30 17:54:37 +02:00

22 lines
548 B
TypeScript

import { ShapeBaseAttributes } from '@ui/lib/types/shapes/shape';
export const transformFigmaIds = (
node: SceneNode
): Pick<ShapeBaseAttributes, 'figmaId' | 'figmaRelatedId'> => {
return {
figmaId: normalizeNodeId(node.id),
figmaRelatedId: getRelatedNodeId(node.id)
};
};
const getRelatedNodeId = (nodeId: string): string | undefined => {
const ids = nodeId.split(';');
if (ids.length > 1) {
return ids.slice(1).join(';');
}
};
const normalizeNodeId = (nodeId: string): string => {
return nodeId.replace('I', '');
};