0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-23 06:04:01 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformFigmaIds.ts

23 lines
548 B
TypeScript
Raw Normal View History

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', '');
};