|
1 | 1 | import { CSSProperties } from "react"; |
2 | | -import { Node } from "react-flow-renderer"; |
| 2 | +import {Node, XYPosition} from "react-flow-renderer"; |
3 | 3 | import Color from "color"; |
| 4 | +import {NodeDimensions} from "./NodeContent"; |
4 | 5 |
|
5 | | -type IStickyNote = { |
| 6 | +/** A sticky note for display in the UI as returned from the backend. */ |
| 7 | +export interface StickyNote { |
6 | 8 | id: string; |
7 | 9 | content: string; |
8 | 10 | color: string; |
9 | | - position: number[]; |
10 | | - dimension: number[]; |
11 | | -}; |
| 11 | + position: XYPosition & NodeDimensions; |
| 12 | +} |
12 | 13 |
|
13 | 14 | /** |
14 | 15 | * 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 |
16 | 17 | * @param node |
17 | | - * @returns {IStickyNote} |
| 18 | + * @returns {StickyNote} |
18 | 19 | */ |
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 | +}; |
26 | 28 |
|
27 | 29 | /** |
28 | 30 | * takes in a hex color string and returns |
|
0 commit comments