Skip to content

Commit 7a75061

Browse files
committed
Refactor StickyNote to have a combined position and dimension object instead of two number arrays
1 parent aabf710 commit 7a75061

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
88

99
### Added
1010

11-
- Added custom icon for "Concatenate to file" operator (CMEM-6476).
11+
- Added custom icon for "Concatenate to file" operator (CMEM-6476).
1212
- `CntentGroup` component
1313
- Manage display of a grouped content section.
1414
- Add info, actions and context annotations by using its properties.
@@ -25,6 +25,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
2525
- `resizeDirections` to specifiy the axis that can be used to resize the node
2626
- `resizeMaxDimensions` to add maximum values for resizing height/width
2727

28+
### Changed
29+
30+
- StickyNote data structure: Refactored position and dimension (breaking change)
31+
2832
## [24.0.1] - 2025-02-06
2933

3034
### Changed

src/extensions/react-flow/nodes/NodeContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type NodeContentHandleNextProps = HandleNextProps;
2222

2323
export type NodeContentHandleProps = NodeContentHandleLegacyProps | NodeContentHandleNextProps;
2424

25-
type NodeDimensions = {
25+
export type NodeDimensions = {
2626
width?: number;
2727
height?: number;
2828
};

src/extensions/react-flow/nodes/nodeUtils.tsx

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,30 @@
11
import { CSSProperties } from "react";
2-
import { Node } from "react-flow-renderer";
2+
import {Node, XYPosition} from "react-flow-renderer";
33
import Color from "color";
4+
import {NodeDimensions} from "./NodeContent";
45

5-
type IStickyNote = {
6+
/** A sticky note for display in the UI as returned from the backend. */
7+
export interface StickyNote {
68
id: string;
79
content: string;
810
color: string;
9-
position: number[];
10-
dimension: number[];
11-
};
11+
position: XYPosition & NodeDimensions;
12+
}
1213

1314
/**
1415
* converts a react-flow node with
15-
* type = "stickynote" to IStickyNote type compatible with the backend
16+
* type = "stickynote" to StickyNote type compatible with the backend
1617
* @param node
17-
* @returns {IStickyNote}
18+
* @returns {StickyNote}
1819
*/
19-
const transformNodeToStickyNode = (node: Node<any>): IStickyNote => ({
20-
id: node.id,
21-
content: node.data.businessData.stickyNote!,
22-
position: [node.position.x, node.position.y],
23-
dimension: [node.data.nodeDimensions?.width!, node.data.nodeDimensions?.height!],
24-
color: node.data.style?.borderColor!,
25-
});
20+
const transformNodeToStickyNode = (node: Node<any>): StickyNote => {
21+
return {
22+
id: node.id,
23+
content: node.data.businessData.stickyNote!,
24+
position: {x: node.position.x, y: node.position.y, width: node.data.nodeDimensions?.width, height: node.data.nodeDimensions?.height},
25+
color: node.data.style?.borderColor!,
26+
}
27+
};
2628

2729
/**
2830
* takes in a hex color string and returns

0 commit comments

Comments
 (0)