From a5d4f4a007f19ab04b986479e4767862d7df469d Mon Sep 17 00:00:00 2001 From: AykutSarac Date: Sat, 9 Apr 2022 14:22:00 +0300 Subject: [PATCH] add node positions to element --- .../LiveEditor/CustomNode/ObjectNode.tsx | 11 ++++++++++- src/containers/LiveEditor/CustomNode/TextNode.tsx | 4 +++- src/containers/LiveEditor/CustomNode/index.tsx | 14 +++++++++++++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/containers/LiveEditor/CustomNode/ObjectNode.tsx b/src/containers/LiveEditor/CustomNode/ObjectNode.tsx index 3845b5c..1c71d9d 100644 --- a/src/containers/LiveEditor/CustomNode/ObjectNode.tsx +++ b/src/containers/LiveEditor/CustomNode/ObjectNode.tsx @@ -6,6 +6,8 @@ const ObjectNode: React.FC> = ({ width, height, value, + x, + y }) => { return ( @@ -15,7 +17,14 @@ const ObjectNode: React.FC> = ({ (val, idx) => val[1] && ( - {val[0]}: + + {val[0]}:{" "} + {val[1]} ) diff --git a/src/containers/LiveEditor/CustomNode/TextNode.tsx b/src/containers/LiveEditor/CustomNode/TextNode.tsx index d30ae5b..86938e1 100644 --- a/src/containers/LiveEditor/CustomNode/TextNode.tsx +++ b/src/containers/LiveEditor/CustomNode/TextNode.tsx @@ -7,12 +7,14 @@ const TextNode: React.FC> = ({ height, value, isParent = false, + x, + y }) => { return ( - {value} + {value} diff --git a/src/containers/LiveEditor/CustomNode/index.tsx b/src/containers/LiveEditor/CustomNode/index.tsx index 4698466..240a0b4 100644 --- a/src/containers/LiveEditor/CustomNode/index.tsx +++ b/src/containers/LiveEditor/CustomNode/index.tsx @@ -8,6 +8,8 @@ export interface CustomNodeProps { height: number; value: T; isParent?: boolean; + x: number; + y: number; } const baseLabelStyle = { @@ -34,7 +36,15 @@ export const CustomNode = (nodeProps: NodeProps) => { if (data.text instanceof Object) { const entries = Object.entries(data.text); - return ; + return ( + + ); } return ( @@ -43,6 +53,8 @@ export const CustomNode = (nodeProps: NodeProps) => { width={width} height={height} value={data.text} + x={nodeProps.x} + y={nodeProps.y} /> ); }}