From 6c5c50fcc7204259a53f58aa1ba5d96687bab5c1 Mon Sep 17 00:00:00 2001 From: Jordi Date: Thu, 27 Jun 2024 18:13:02 +0200 Subject: [PATCH] fix my mind --- ui-src/parser/creators/createComponentInstance.ts | 2 +- ui-src/parser/creators/createText.ts | 4 ++-- ui-src/parser/parseFigmaId.ts | 12 +++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/ui-src/parser/creators/createComponentInstance.ts b/ui-src/parser/creators/createComponentInstance.ts index 2012a6a3..dacf074d 100644 --- a/ui-src/parser/creators/createComponentInstance.ts +++ b/ui-src/parser/creators/createComponentInstance.ts @@ -34,7 +34,7 @@ export const createComponentInstance = ( } shape.id = id; - shape.shapeRef = originalUiComponent ? uiComponent.mainInstanceId : shapeRef; + shape.shapeRef = originalUiComponent || !shapeRef ? uiComponent.mainInstanceId : shapeRef; shape.componentFile = file.getId(); shape.componentRoot = isComponentRoot; shape.componentId = uiComponent.componentId; diff --git a/ui-src/parser/creators/createText.ts b/ui-src/parser/creators/createText.ts index bd48a4de..9eaf2c3f 100644 --- a/ui-src/parser/creators/createText.ts +++ b/ui-src/parser/creators/createText.ts @@ -5,7 +5,7 @@ import { symbolFills, symbolStrokes, symbolTouched } from '@ui/parser/creators/s export const createText = ( file: PenpotFile, - { type, figmaId, characters, ...shape }: TextShape + { type, figmaId, characters, componentPropertyReferences, ...shape }: TextShape ) => { const { id, shapeRef } = parseFigmaId(file, figmaId); @@ -17,7 +17,7 @@ export const createText = ( !shape.hidden, characters, shape.touched, - shape.componentPropertyReferences + componentPropertyReferences ); file.createText(shape); diff --git a/ui-src/parser/parseFigmaId.ts b/ui-src/parser/parseFigmaId.ts index 62823804..f8bc23b8 100644 --- a/ui-src/parser/parseFigmaId.ts +++ b/ui-src/parser/parseFigmaId.ts @@ -41,17 +41,11 @@ const parseShapeRef = (file: PenpotFile, figmaId: string | undefined): Uuid | un return; } - const id = identifiers.get(figmaRelatedId); - - if (id) { - return id; + if (!identifiers.has(figmaRelatedId)) { + identifiers.set(figmaRelatedId, file.newId()); } - const newId = file.newId(); - - identifiers.set(figmaRelatedId, newId); - - return newId; + return identifiers.get(figmaRelatedId); }; const getRelatedNodeId = (nodeId: string): string | undefined => {