From 01a4fa562293d2cab44665184262092749c9a585 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Mon, 15 Apr 2024 16:30:51 +0000 Subject: [PATCH] add block concept --- plugin-src/transformers/partials/index.ts | 1 + .../transformers/partials/transformSceneNode.ts | 8 ++++++++ plugin-src/transformers/transformEllipseNode.ts | 7 ++++++- plugin-src/transformers/transformFrameNode.ts | 5 +++-- plugin-src/transformers/transformGroupNode.ts | 9 +++++++-- plugin-src/transformers/transformRectangleNode.ts | 11 ++++++++--- plugin-src/transformers/transformTextNode.ts | 11 ++++++++--- 7 files changed, 41 insertions(+), 11 deletions(-) create mode 100644 plugin-src/transformers/partials/transformSceneNode.ts diff --git a/plugin-src/transformers/partials/index.ts b/plugin-src/transformers/partials/index.ts index 2ab8c84..8929383 100644 --- a/plugin-src/transformers/partials/index.ts +++ b/plugin-src/transformers/partials/index.ts @@ -1,3 +1,4 @@ export * from './transformBlend'; export * from './transformChildren'; export * from './transformDimensionAndPosition'; +export * from './transformSceneNode'; diff --git a/plugin-src/transformers/partials/transformSceneNode.ts b/plugin-src/transformers/partials/transformSceneNode.ts new file mode 100644 index 0000000..f4b24a3 --- /dev/null +++ b/plugin-src/transformers/partials/transformSceneNode.ts @@ -0,0 +1,8 @@ +import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; + +export const transformSceneNode = (node: SceneNodeMixin): Partial => { + return { + blocked: node.locked, + hidden: false // @TODO: check this. it won't export if we hide it + }; +}; diff --git a/plugin-src/transformers/transformEllipseNode.ts b/plugin-src/transformers/transformEllipseNode.ts index d4d5ad2..8d78b93 100644 --- a/plugin-src/transformers/transformEllipseNode.ts +++ b/plugin-src/transformers/transformEllipseNode.ts @@ -1,4 +1,8 @@ -import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials'; +import { + transformBlend, + transformDimensionAndPosition, + transformSceneNode +} from '@plugin/transformers/partials'; import { translateFills } from '@plugin/translators'; import { CircleShape } from '@ui/lib/types/circle/circleShape'; @@ -13,6 +17,7 @@ export const transformEllipseNode = ( name: node.name, fills: translateFills(node.fills, node.width, node.height), ...transformDimensionAndPosition(node, baseX, baseY), + ...transformSceneNode(node), ...transformBlend(node) }; }; diff --git a/plugin-src/transformers/transformFrameNode.ts b/plugin-src/transformers/transformFrameNode.ts index db541f2..031e134 100644 --- a/plugin-src/transformers/transformFrameNode.ts +++ b/plugin-src/transformers/transformFrameNode.ts @@ -1,4 +1,4 @@ -import { transformDimensionAndPosition } from '@plugin/transformers/partials'; +import { transformDimensionAndPosition, transformSceneNode } from '@plugin/transformers/partials'; import { transformChildren } from '@plugin/transformers/partials'; import { translateFills } from '@plugin/translators'; @@ -14,6 +14,7 @@ export const transformFrameNode = async ( name: node.name, fills: translateFills(node.fills, node.width, node.height), ...(await transformChildren(node, baseX, baseY)), - ...transformDimensionAndPosition(node, baseX, baseY) + ...transformDimensionAndPosition(node, baseX, baseY), + ...transformSceneNode(node) }; }; diff --git a/plugin-src/transformers/transformGroupNode.ts b/plugin-src/transformers/transformGroupNode.ts index a07506d..bd499e4 100644 --- a/plugin-src/transformers/transformGroupNode.ts +++ b/plugin-src/transformers/transformGroupNode.ts @@ -1,4 +1,8 @@ -import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials'; +import { + transformBlend, + transformDimensionAndPosition, + transformSceneNode +} from '@plugin/transformers/partials'; import { transformChildren } from '@plugin/transformers/partials'; import { GroupShape } from '@ui/lib/types/group/groupShape'; @@ -11,8 +15,9 @@ export const transformGroupNode = async ( return { type: 'group', name: node.name, - ...transformDimensionAndPosition(node, baseX, baseY), ...(await transformChildren(node, baseX, baseY)), + ...transformDimensionAndPosition(node, baseX, baseY), + ...transformSceneNode(node), ...transformBlend(node) }; }; diff --git a/plugin-src/transformers/transformRectangleNode.ts b/plugin-src/transformers/transformRectangleNode.ts index 275a069..61c3329 100644 --- a/plugin-src/transformers/transformRectangleNode.ts +++ b/plugin-src/transformers/transformRectangleNode.ts @@ -1,4 +1,8 @@ -import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials'; +import { + transformBlend, + transformDimensionAndPosition, + transformSceneNode +} from '@plugin/transformers/partials'; import { translateFills } from '@plugin/translators'; import { RectShape } from '@ui/lib/types/rect/rectShape'; @@ -12,7 +16,8 @@ export const transformRectangleNode = ( type: 'rect', name: node.name, fills: translateFills(node.fills, node.width, node.height), - ...transformBlend(node), - ...transformDimensionAndPosition(node, baseX, baseY) + ...transformDimensionAndPosition(node, baseX, baseY), + ...transformSceneNode(node), + ...transformBlend(node) }; }; diff --git a/plugin-src/transformers/transformTextNode.ts b/plugin-src/transformers/transformTextNode.ts index f03d32a..c4f83cd 100644 --- a/plugin-src/transformers/transformTextNode.ts +++ b/plugin-src/transformers/transformTextNode.ts @@ -1,4 +1,8 @@ -import { transformBlend, transformDimensionAndPosition } from '@plugin/transformers/partials'; +import { + transformBlend, + transformDimensionAndPosition, + transformSceneNode +} from '@plugin/transformers/partials'; import { translateFills, translateTextDecoration, @@ -59,7 +63,8 @@ export const transformTextNode = (node: TextNode, baseX: number, baseY: number): } ] }, - ...transformBlend(node), - ...transformDimensionAndPosition(node, baseX, baseY) + ...transformDimensionAndPosition(node, baseX, baseY), + ...transformSceneNode(node), + ...transformBlend(node) }; };