mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-20 06:22:38 -05:00
7b3192936e
* 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>
22 lines
548 B
TypeScript
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', '');
|
|
};
|