We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent fd77139 commit 80a2f65Copy full SHA for 80a2f65
5 files changed
apps/plugin/plugin-src/code.ts
@@ -8,12 +8,6 @@ import {
8
htmlMain,
9
postSettingsChanged,
10
} from "backend";
11
-import { convertNodesToAltNodes } from "backend/src/altNodes/altConversion";
12
-import {
13
- disableParent,
14
- oldConvertNodesToAltNodes,
15
- setDisableParent,
16
-} from "backend/src/altNodes/oldAltConversion";
17
import { nodesToJSON } from "backend/src/code";
18
import { retrieveGenericSolidUIColors } from "backend/src/common/retrieveUI/retrieveColors";
19
import { flutterCodeGenTextStyles } from "backend/src/flutter/flutterMain";
@@ -198,7 +192,17 @@ const standardMode = async () => {
198
192
}
199
193
200
194
try {
201
- result.newConversion = await nodesToJSON(nodes, userPluginSettings);
195
+ const newNodes = await nodesToJSON(nodes, userPluginSettings);
196
+ const removeParent = (node: any) => {
197
+ if (node.parent) {
+ delete node.parent;
+ }
+ if (node.children) {
+ node.children.forEach(removeParent);
202
203
+ };
204
+ newNodes.forEach(removeParent);
205
+ result.newConversion = newNodes;
206
} catch (error) {
207
console.error("Error in new conversion:", error);
208
apps/plugin/ui-src/App.tsx
@@ -104,7 +104,6 @@ export default function App() {
104
break;
105
106
case "selection-json":
107
- console.log("selection json");
108
const json = event.data.pluginMessage.data;
109
copy(JSON.stringify(json, null, 2));
110
packages/backend/src/code.ts
@@ -163,12 +163,17 @@ function adjustChildrenOrder(node: any) {
163
*/
164
const processNodePair = async (
165
jsonNode: any,
166
- figmaNode: SceneNode,
167
settings: PluginSettings,
168
parentNode?: any,
169
) => {
170
if (!jsonNode.id) return;
171
+ const figmaNode = await figma.getNodeByIdAsync(jsonNode.id);
172
+
173
+ if (!figmaNode) {
174
+ return;
175
176
177
// Set parent reference if parent is provided
178
if (parentNode) {
179
jsonNode.parent = parentNode;
@@ -352,12 +357,7 @@ const processNodePair = async (
352
357
// );
353
358
354
359
for (let i = 0; i < jsonNode.children.length; i++) {
355
- await processNodePair(
356
- jsonNode.children[i],
- figmaNode.children[i],
- settings,
- jsonNode,
360
- );
+ await processNodePair(jsonNode.children[i], settings, jsonNode);
361
362
363
if (
@@ -409,7 +409,7 @@ export const nodesToJSON = async (
409
// Now process each top-level node pair (JSON node + Figma node)
410
const processNodesStart = Date.now();
411
for (let i = 0; i < nodes.length; i++) {
412
- await processNodePair(nodeJson[i], nodes[i], settings);
+ await processNodePair(nodeJson[i], settings);
413
414
console.log(
415
`[benchmark][inside nodesToJSON] Process node pairs: ${Date.now() - processNodesStart}ms`,
packages/backend/src/html/builderImpl/htmlAutoLayout.ts
@@ -69,19 +69,18 @@ const getFlex = (
69
: "inline-flex";
70
71
export const htmlAutoLayoutProps = (
72
- node: SceneNode,
73
- autoLayout: InferredAutoLayoutResult,
+ node: SceneNode & InferredAutoLayoutResult,
74
settings: HTMLSettings,
75
): string[] =>
76
formatMultipleJSXArray(
77
{
78
- "flex-direction": getFlexDirection(autoLayout),
79
- "justify-content": getJustifyContent(autoLayout),
80
- "align-items": getAlignItems(autoLayout),
81
- gap: getGap(autoLayout),
82
- display: getFlex(node, autoLayout),
83
- "flex-wrap": getFlexWrap(autoLayout),
84
- "align-content": getAlignContent(autoLayout),
+ "flex-direction": getFlexDirection(node),
+ "justify-content": getJustifyContent(node),
+ "align-items": getAlignItems(node),
+ gap: getGap(node),
+ display: getFlex(node, node),
+ "flex-wrap": getFlexWrap(node),
+ "align-content": getAlignContent(node),
85
},
86
settings.htmlGenerationMode === "jsx",
87
);
packages/backend/src/html/htmlMain.ts
@@ -564,22 +564,13 @@ const htmlFrame = async (
564
565
566
if (node.layoutMode !== "NONE") {
567
- const rowColumn = htmlAutoLayoutProps(node, node, settings);
+ const rowColumn = htmlAutoLayoutProps(node, settings);
568
return await htmlContainer(node, childrenStr, rowColumn, settings);
569
- } else {
570
- if (settings.optimizeLayout && node.inferredAutoLayout !== null) {
571
- const rowColumn = htmlAutoLayoutProps(
572
- node,
573
- node.inferredAutoLayout,
574
575
576
- return await htmlContainer(node, childrenStr, rowColumn, settings);
577
- }
578
-
579
- // node.layoutMode === "NONE" && node.children.length > 1
580
- // children needs to be absolute
581
- return await htmlContainer(node, childrenStr, [], settings);
582
+ // node.layoutMode === "NONE" && node.children.length > 1
+ // children needs to be absolute
+ return await htmlContainer(node, childrenStr, [], settings);
583
};
584
585
// properties named propSomething always take care of ","
0 commit comments