@logicflow/core 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +32 -0
  2. package/dist/docs/api/logicflow-constructor/index.en.md +106 -0
  3. package/dist/docs/api/logicflow-constructor/index.zh.md +106 -0
  4. package/dist/docs/api/logicflow-constructor/use.en.md +61 -0
  5. package/dist/docs/api/logicflow-constructor/use.zh.md +61 -0
  6. package/dist/docs/api/logicflow-instance/canvas.en.md +197 -0
  7. package/dist/docs/api/logicflow-instance/canvas.zh.md +199 -0
  8. package/dist/docs/api/logicflow-instance/edge.en.md +273 -0
  9. package/dist/docs/api/logicflow-instance/edge.zh.md +273 -0
  10. package/dist/docs/api/logicflow-instance/edit-config.en.md +59 -0
  11. package/dist/docs/api/logicflow-instance/edit-config.zh.md +59 -0
  12. package/dist/docs/api/logicflow-instance/element.en.md +375 -0
  13. package/dist/docs/api/logicflow-instance/element.zh.md +379 -0
  14. package/dist/docs/api/logicflow-instance/event.en.md +326 -0
  15. package/dist/docs/api/logicflow-instance/event.zh.md +406 -0
  16. package/dist/docs/api/logicflow-instance/history.en.md +38 -0
  17. package/dist/docs/api/logicflow-instance/history.zh.md +38 -0
  18. package/dist/docs/api/logicflow-instance/index.en.md +41 -0
  19. package/dist/docs/api/logicflow-instance/index.zh.md +41 -0
  20. package/dist/docs/api/logicflow-instance/node.en.md +308 -0
  21. package/dist/docs/api/logicflow-instance/node.zh.md +308 -0
  22. package/dist/docs/api/logicflow-instance/register.en.md +76 -0
  23. package/dist/docs/api/logicflow-instance/register.zh.md +76 -0
  24. package/dist/docs/api/logicflow-instance/render-and-data.en.md +179 -0
  25. package/dist/docs/api/logicflow-instance/render-and-data.zh.md +181 -0
  26. package/dist/docs/api/logicflow-instance/text.en.md +60 -0
  27. package/dist/docs/api/logicflow-instance/text.zh.md +60 -0
  28. package/dist/docs/api/logicflow-instance/theme.en.md +179 -0
  29. package/dist/docs/api/logicflow-instance/theme.zh.md +179 -0
  30. package/dist/docs/api/runtime-model/edgeModel.en.md +29 -0
  31. package/dist/docs/api/runtime-model/edgeModel.zh.md +325 -0
  32. package/dist/docs/api/runtime-model/graphModel.en.md +275 -0
  33. package/dist/docs/api/runtime-model/graphModel.zh.md +1153 -0
  34. package/dist/docs/api/runtime-model/nodeModel.en.md +37 -0
  35. package/dist/docs/api/runtime-model/nodeModel.zh.md +644 -0
  36. package/dist/docs/api/type/MainTypes.en.md +598 -0
  37. package/dist/docs/api/type/MainTypes.zh.md +867 -0
  38. package/dist/docs/api/type/Theme.en.md +187 -0
  39. package/dist/docs/api/type/Theme.zh.md +187 -0
  40. package/dist/docs/api/type/canvas-types.en.md +25 -0
  41. package/dist/docs/api/type/canvas-types.zh.md +25 -0
  42. package/dist/docs/api/type/index.en.md +96 -0
  43. package/dist/docs/api/type/index.zh.md +99 -0
  44. package/dist/docs/api/type/node-types.en.md +21 -0
  45. package/dist/docs/api/type/node-types.zh.md +21 -0
  46. package/dist/docs/api/type/plugin-types.en.md +24 -0
  47. package/dist/docs/api/type/plugin-types.zh.md +24 -0
  48. package/dist/docs/index.md +11 -0
  49. package/dist/docs/tutorial/about.en.md +38 -0
  50. package/dist/docs/tutorial/about.zh.md +65 -0
  51. package/dist/docs/tutorial/advanced/dnd.en.md +62 -0
  52. package/dist/docs/tutorial/advanced/dnd.zh.md +52 -0
  53. package/dist/docs/tutorial/advanced/edge.en.md +64 -0
  54. package/dist/docs/tutorial/advanced/edge.zh.md +66 -0
  55. package/dist/docs/tutorial/advanced/keyboard.en.md +70 -0
  56. package/dist/docs/tutorial/advanced/keyboard.zh.md +67 -0
  57. package/dist/docs/tutorial/advanced/node.en.md +338 -0
  58. package/dist/docs/tutorial/advanced/node.zh.md +338 -0
  59. package/dist/docs/tutorial/advanced/react.en.md +106 -0
  60. package/dist/docs/tutorial/advanced/react.zh.md +114 -0
  61. package/dist/docs/tutorial/advanced/silent-mode.en.md +75 -0
  62. package/dist/docs/tutorial/advanced/silent-mode.zh.md +71 -0
  63. package/dist/docs/tutorial/advanced/snapline.en.md +54 -0
  64. package/dist/docs/tutorial/advanced/vue.en.md +249 -0
  65. package/dist/docs/tutorial/advanced/vue.zh.md +248 -0
  66. package/dist/docs/tutorial/ai.en.md +64 -0
  67. package/dist/docs/tutorial/ai.zh.md +64 -0
  68. package/dist/docs/tutorial/basic/background.en.md +50 -0
  69. package/dist/docs/tutorial/basic/canvas.en.md +164 -0
  70. package/dist/docs/tutorial/basic/canvas.zh.md +183 -0
  71. package/dist/docs/tutorial/basic/class.en.md +106 -0
  72. package/dist/docs/tutorial/basic/class.zh.md +103 -0
  73. package/dist/docs/tutorial/basic/edge.en.md +151 -0
  74. package/dist/docs/tutorial/basic/edge.zh.md +152 -0
  75. package/dist/docs/tutorial/basic/event.en.md +70 -0
  76. package/dist/docs/tutorial/basic/event.zh.md +66 -0
  77. package/dist/docs/tutorial/basic/grid.en.md +77 -0
  78. package/dist/docs/tutorial/basic/node.en.md +358 -0
  79. package/dist/docs/tutorial/basic/node.zh.md +318 -0
  80. package/dist/docs/tutorial/basic/theme.en.md +154 -0
  81. package/dist/docs/tutorial/basic/theme.zh.md +157 -0
  82. package/dist/docs/tutorial/extension/adapter.en.md +446 -0
  83. package/dist/docs/tutorial/extension/adapter.zh.md +429 -0
  84. package/dist/docs/tutorial/extension/bpmn-element.en.md +1427 -0
  85. package/dist/docs/tutorial/extension/bpmn-element.zh.md +1472 -0
  86. package/dist/docs/tutorial/extension/control.en.md +117 -0
  87. package/dist/docs/tutorial/extension/control.zh.md +118 -0
  88. package/dist/docs/tutorial/extension/curved-edge.en.md +46 -0
  89. package/dist/docs/tutorial/extension/curved-edge.zh.md +46 -0
  90. package/dist/docs/tutorial/extension/custom.en.md +142 -0
  91. package/dist/docs/tutorial/extension/custom.zh.md +138 -0
  92. package/dist/docs/tutorial/extension/dnd-panel.en.md +109 -0
  93. package/dist/docs/tutorial/extension/dnd-panel.zh.md +109 -0
  94. package/dist/docs/tutorial/extension/dynamic-group.en.md +606 -0
  95. package/dist/docs/tutorial/extension/dynamic-group.zh.md +606 -0
  96. package/dist/docs/tutorial/extension/group.en.md +217 -0
  97. package/dist/docs/tutorial/extension/group.zh.md +209 -0
  98. package/dist/docs/tutorial/extension/highlight.en.md +50 -0
  99. package/dist/docs/tutorial/extension/highlight.zh.md +50 -0
  100. package/dist/docs/tutorial/extension/insert-node-in-polyline.en.md +52 -0
  101. package/dist/docs/tutorial/extension/insert-node-in-polyline.zh.md +47 -0
  102. package/dist/docs/tutorial/extension/intro.en.md +72 -0
  103. package/dist/docs/tutorial/extension/intro.zh.md +95 -0
  104. package/dist/docs/tutorial/extension/label.en.md +136 -0
  105. package/dist/docs/tutorial/extension/label.zh.md +135 -0
  106. package/dist/docs/tutorial/extension/layout.en.md +156 -0
  107. package/dist/docs/tutorial/extension/layout.zh.md +156 -0
  108. package/dist/docs/tutorial/extension/menu.en.md +319 -0
  109. package/dist/docs/tutorial/extension/menu.zh.md +377 -0
  110. package/dist/docs/tutorial/extension/minimap.en.md +164 -0
  111. package/dist/docs/tutorial/extension/minimap.zh.md +180 -0
  112. package/dist/docs/tutorial/extension/node-resize.en.md +199 -0
  113. package/dist/docs/tutorial/extension/node-resize.zh.md +221 -0
  114. package/dist/docs/tutorial/extension/pool.en.md +227 -0
  115. package/dist/docs/tutorial/extension/pool.zh.md +227 -0
  116. package/dist/docs/tutorial/extension/proximity-connect.en.md +104 -0
  117. package/dist/docs/tutorial/extension/proximity-connect.zh.md +107 -0
  118. package/dist/docs/tutorial/extension/selection.en.md +166 -0
  119. package/dist/docs/tutorial/extension/selection.zh.md +150 -0
  120. package/dist/docs/tutorial/extension/snapshot.en.md +276 -0
  121. package/dist/docs/tutorial/extension/snapshot.zh.md +276 -0
  122. package/dist/docs/tutorial/get-started.en.md +501 -0
  123. package/dist/docs/tutorial/get-started.zh.md +139 -0
  124. package/dist/docs/tutorial/update.en.md +213 -0
  125. package/dist/docs/tutorial/update.zh.md +212 -0
  126. package/package.json +5 -3
  127. package/scripts/postinstall-ai-prompt.js +67 -0
@@ -0,0 +1,164 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Plug-in functionality
5
+ order: 3
6
+ title: MiniMap
7
+ order: 4
8
+ toc: content
9
+ ---
10
+
11
+ <style>
12
+ table td:first-of-type {
13
+ word-break: normal;
14
+ }
15
+ </style>
16
+
17
+ LogicFlow's canvas MiniMap is a thumbnail view that helps users quickly navigate and locate different areas of large or complex diagrams.
18
+
19
+ This article covers the latest syntax for version 2.0. For versions before 2.0, please visit the [old version](https://docs.logic-flow.cn/docs/#/zh/guide/extension/component-minimap).
20
+
21
+ ## Demonstration
22
+
23
+ <code id="react-portal" src="@/src/tutorial/extension/mini-map"></code>
24
+
25
+ ## Usage
26
+
27
+ ### 1. Registration
28
+
29
+ There are two registration methods: global registration and local registration. The difference is that global registration allows every `lf` instance to use it.
30
+
31
+ ```tsx | pure
32
+ import LogicFlow from "@logicflow/core";
33
+ import { MiniMap } from "@logicflow/extension";
34
+
35
+ // Global registration
36
+ LogicFlow.use(MiniMap);
37
+
38
+ // Local registration
39
+ const lf = new LogicFlow({
40
+ ...config,
41
+ plugins: [MiniMap]
42
+ });
43
+ ```
44
+
45
+ ### 2. Configuration
46
+
47
+ When initializing the `lf` instance, you can customize the MiniMap's capabilities through `pluginsOptions`.
48
+
49
+ ```tsx | pure
50
+ const miniMapOptions: MiniMap.MiniMapOption = {
51
+ ...options
52
+ }
53
+
54
+ const lf = new LogicFlow({
55
+ ...config,
56
+ plugins: [MiniMap],
57
+ pluginsOptions: {
58
+ miniMap: miniMapOptions,
59
+ },
60
+ });
61
+ ```
62
+
63
+ The `miniMapOptions` configuration is as follows:
64
+
65
+ | Property Name | Type | Default Value | Required | Description |
66
+ | --------------- | ------- | ------------- | -------- | ----------------------------------------------------------------------------------------------------- |
67
+ | width | number | 150 | - | The width of the canvas in the MiniMap |
68
+ | height | number | 220 | - | The height of the canvas in the MiniMap |
69
+ | showEdge | boolean | false | - | Whether to render edges in the MiniMap |
70
+ | headerTitle | string | Navigation | - | The text content of the MiniMap's title bar; defaults to not showing |
71
+ | isShowHeader | boolean | false | - | Whether to show the MiniMap's title bar |
72
+ | isShowCloseIcon | boolean | false | - | Whether to show the close button |
73
+ | leftPosition | number | - | - | The left margin of the MiniMap from the canvas's left boundary; takes precedence over `rightPosition` |
74
+ | rightPosition | number | 0 | - | The right margin of the MiniMap from the canvas's right boundary; lower priority than `leftPosition` |
75
+ | topPosition | number | - | - | The top margin of the MiniMap from the canvas's top boundary; takes precedence over `bottomPosition` |
76
+ | bottomPosition | number | 0 | - | The bottom margin of the MiniMap from the canvas's bottom boundary; lower priority than `topPosition` |
77
+
78
+ ## API
79
+
80
+ ### show
81
+
82
+ By default, the MiniMap is not displayed after being included; you need to manually enable it.
83
+
84
+ ```tsx | pure
85
+ lf.extension.miniMap.show(left?: number, top?: number): void
86
+ ```
87
+
88
+ `show()` supports passing `left` and `top` style properties to determine the MiniMap's position relative to the top-left corner of the canvas. If not provided, it defaults to the bottom-right corner of the canvas.
89
+
90
+ Providing only `left` and `top` values allows integration with the `lf.getPointByClient` API. For more flexible styling, you can directly set styles via class names:
91
+
92
+ - `lf-mini-map` - MiniMap root element
93
+ - `lf-mini-map-header` - MiniMap header element
94
+ - `lf-mini-map-graph` - MiniMap canvas element
95
+ - `lf-mini-map-close` - MiniMap close icon element
96
+
97
+ :::warning
98
+ `MiniMap.show()` must be called after `lf.render()`. Otherwise, the console will always show a warning.
99
+ :::
100
+
101
+ ### hide
102
+
103
+ Hide the MiniMap.
104
+
105
+ ```tsx | pure
106
+ lf.extension.miniMap.hide(): void
107
+ ```
108
+
109
+ ### reset
110
+
111
+ Reset the MiniMap's zoom and translation, essentially resetting the canvas's zoom and translation.
112
+
113
+ ```tsx | pure
114
+ lf.extension.miniMap.reset(): void
115
+ ```
116
+
117
+ Internal implementation:
118
+
119
+ ```tsx | pure
120
+ lf.resetTranslate()
121
+ lf.resetZoom()
122
+ ```
123
+
124
+ ### updatePosition
125
+
126
+ Update the MiniMap's position on the canvas.
127
+
128
+ ```tsx | pure
129
+ lf.extension.miniMap.updatePosition(MiniMapPosition): void
130
+ ```
131
+
132
+ `MiniMapPosition` parameter is as follows:
133
+
134
+ ```tsx | pure
135
+ export type AbsolutePosition = Partial<
136
+ Record<'left' | 'right' | 'top' | 'bottom', number>
137
+ >
138
+
139
+ export type MiniMapPosition =
140
+ | 'left-top' // Indicates the MiniMap is located at the top-left corner of the container
141
+ | 'right-top' // Indicates the MiniMap is located at the top-right corner of the container
142
+ | 'left-bottom' // Indicates the MiniMap is located at the bottom-left corner of the container
143
+ | 'right-bottom' // Indicates the MiniMap is located at the bottom-right corner of the container
144
+ | AbsolutePosition // Custom position of the MiniMap on the canvas
145
+ ```
146
+
147
+ ### setShowEdge
148
+
149
+ Set whether the edges are displayed in the MiniMap's canvas.
150
+
151
+ ```tsx | pure
152
+ lf.extension.miniMap.setShowEdge(showEdge: boolean): void
153
+ ```
154
+
155
+ `showEdge`: `true` to display, `false` to hide.
156
+
157
+ ## Events
158
+
159
+ MiniMap events.
160
+
161
+ | Event Name | Description | Event Object |
162
+ | ------------- | -------------- | ------------ |
163
+ | miniMap:close | MiniMap hidden | {} |
164
+
@@ -0,0 +1,180 @@
1
+ ---
2
+ nav: 指南
3
+ group:
4
+ title: 插件功能
5
+ order: 3
6
+ title: 小地图 (MiniMap)
7
+ order: 4
8
+ toc: content
9
+ ---
10
+
11
+ <style>
12
+ table td:first-of-type {
13
+ word-break: normal;
14
+ }
15
+ </style>
16
+
17
+ LogicFlow 的画布小地图是一个缩略图视图,帮助用户快速导航和定位大型或复杂图表的不同区域。
18
+
19
+ 本文是 2.0 版本最新语法,2.0 版本以前请移步<a href="https://docs.logic-flow.cn/docs/#/zh/guide/extension/component-minimap" target="_blank">旧版</a>。
20
+
21
+ ## 演示
22
+
23
+ <code id="react-portal" src="@/src/tutorial/extension/mini-map"></code>
24
+
25
+ ## 使用
26
+
27
+ ### 1. 注册
28
+
29
+ 两种注册方式,全局注册和局部注册,区别是全局注册每一个 `lf` 实例都可以使用。
30
+
31
+ ```tsx | pure
32
+ import LogicFlow from "@logicflow/core";
33
+ import { MiniMap } from "@logicflow/extension";
34
+
35
+ // 全局注册
36
+ LogicFlow.use(MiniMap);
37
+
38
+ // 局部注册
39
+ const lf = new LogicFlow({
40
+ ...config,
41
+ plugins: [MiniMap]
42
+ });
43
+
44
+ ```
45
+
46
+ ### 2. 配置
47
+
48
+ 在初始化 `lf` 实例时可以通过 `pluginsOptions` 自定义配置 mini-map 的能力。
49
+
50
+ ```tsx | pure
51
+
52
+ const miniMapOptions: MiniMap.MiniMapOption = {
53
+ ...options
54
+ }
55
+
56
+ const lf = new LogicFlow({
57
+ ...config,
58
+ plugins: [MiniMap],
59
+ pluginsOptions: {
60
+ miniMap: miniMapOptions,
61
+ },
62
+ });
63
+
64
+ ```
65
+
66
+ `miniMapOptions` 配置如下:
67
+
68
+ | 属性名 | 类型 | 默认值 | 必填 | 描述 |
69
+ | --------------- | ------- | ------ | ---- | ------------------------------------------------------ |
70
+ | width | number | 150 | - | 小地图中画布的宽度 |
71
+ | height | number | 220 | - | 小地图中画布的高度 |
72
+ | showEdge | boolean | false | - | 在小地图的画布中是否渲染边 |
73
+ | headerTitle | string | 导航 | - | 小地图标题栏的文本内容,默认不显示 |
74
+ | isShowHeader | boolean | false | - | 是否显示小地图的标题栏 |
75
+ | isShowCloseIcon | boolean | false | - | 是否显示关闭按钮 |
76
+ | leftPosition | number | - | - | 小地图与画布左边界的左边距,优先级高于`rightPosition` |
77
+ | rightPosition | number | 0 | - | 小地图与画布右边界的右边距,优先级低于`leftPosition` |
78
+ | topPosition | number | - | - | 小地图与画布上边界的上边距,优先级高于`bottomPosition` |
79
+ | bottomPosition | number | 0 | - | 小地图与画布下边界的下边距,优先级低于`topPosition` |
80
+
81
+ ## API
82
+
83
+ ### show
84
+
85
+ 引入 mini-map 后默认不展示,需要手动开启显示。
86
+
87
+ ```tsx | pure
88
+
89
+ lf.extension.miniMap.show(left?: number, top?: number): void
90
+
91
+ ```
92
+
93
+ `show()` 支持传入样式属性 left 和 top 的值,用来确定 mini-map 在画布中相对于左上角的位置,不传默认显示在画布右下角。
94
+
95
+ 只提供 left 和 top 这两个值是因为可以与`lf.getPointByClient` API 配合使用,如果想实现更加灵活的样式,可以直接通过类名设置样式。
96
+
97
+ - `lf-mini-map` - mini-map 根元素
98
+ - `lf-mini-map-header` - mini-map 头部元素
99
+ - `lf-mini-map-graph` - mini-map 画布元素
100
+ - `lf-mini-map-close` - mini-map 关闭图标元素
101
+
102
+ :::warning
103
+ `MiniMap.show()`必须在`lf.render()`后调用。否则控制台会一直有警告
104
+ :::
105
+
106
+ ### hide
107
+
108
+ 隐藏 mini-map。
109
+
110
+ ```tsx | pure
111
+
112
+ lf.extension.miniMap.hide(): void
113
+
114
+ ```
115
+
116
+ ### reset
117
+
118
+ 重置 mini-map 的缩放和平移,本质是重置画布的缩放和平移。
119
+
120
+ ```tsx | pure
121
+
122
+ lf.extension.miniMap.reset(): void
123
+
124
+ ```
125
+
126
+ 内部实现:
127
+
128
+ ```tsx | pure
129
+
130
+ lf.resetTranslate()
131
+ lf.resetZoom()
132
+
133
+ ```
134
+
135
+ ### updatePosition
136
+
137
+ 更新小地图在画布中的位置。
138
+
139
+ ```tsx | pure
140
+
141
+ lf.extension.miniMap.updatePosition(MiniMapPosition): void
142
+
143
+ ```
144
+
145
+ `MiniMapPosition` 参数如下:
146
+
147
+ ```tsx | pure
148
+
149
+ export type AbsolutePosition = Partial<
150
+ Record<'left' | 'right' | 'top' | 'bottom', number>
151
+ >
152
+
153
+ export type MiniMapPosition =
154
+ | 'left-top' // 表示迷你地图位于容器的左上角
155
+ | 'right-top' // 表示迷你地图位于容器的右上角
156
+ | 'left-bottom' // 表示迷你地图位于容器的左下角
157
+ | 'right-bottom' // 表示迷你地图位于容器的右下角。
158
+ | AbsolutePosition // 自定义小地图在画布上的位置
159
+
160
+ ```
161
+
162
+ ### setShowEdge
163
+
164
+ 设置小地图的画布中是否显示边。
165
+
166
+ ```tsx | pure
167
+
168
+ lf.extension.miniMap.setShowEdge(showEdge: boolean): void
169
+
170
+ ```
171
+
172
+ `showEdge`: `true` 显示,`false` 隐藏。
173
+
174
+ ## 事件
175
+
176
+ mini-map 事件。
177
+
178
+ | 事件名 | 说明 | 事件对象 |
179
+ | ------------- | ---------- | -------- |
180
+ | miniMap:close | 小地图隐藏 | {} |
@@ -0,0 +1,199 @@
1
+ ---
2
+ nav: Guide
3
+ group:
4
+ title: Plug-in functionality
5
+ order: 3
6
+ title: NodeResize
7
+ order: 16
8
+ toc: content
9
+ tag: Deprecated
10
+ ---
11
+
12
+ ## Use
13
+
14
+ LogicFlow provides `RectResize`, `EllipseResize`, `DiamondResize`, `HtmlResize` in the extension package, each node has `view` and `model` attributes. The scaling of nodes is also achieved by using LogicFlow's custom node mechanism, which allows developers to inherit from these 4 types of nodes that can be scaled to achieve node scaling.
15
+
16
+ For example, if we need a rectangle that can be scaled, when we didn't support node scaling before, we customize the node in the following way:
17
+
18
+ ```tsx | pure
19
+ import { RectNode, RectNodeModel } from '@logicflow/core'
20
+
21
+ class CustomNode extends RectNode {
22
+ }
23
+
24
+ class CustomNodeModel extends RectNodeModel {
25
+ }
26
+
27
+ export default {
28
+ type: 'custom-node',
29
+ model: CustomNodeModel,
30
+ view: CustomNode,
31
+ }
32
+ ```
33
+
34
+ If we expect the custom node to be scaled, then change it to:
35
+
36
+ ```tsx | pure
37
+ import { RectResize } from '@logicflow/extension'
38
+
39
+ class CustomNode extends RectResize.view {
40
+ }
41
+
42
+ class CustomNodeModel extends RectResize.model {
43
+ }
44
+
45
+ export default {
46
+ type: 'custom-node',
47
+ model: CustomNodeModel,
48
+ view: CustomNode,
49
+ }
50
+ ```
51
+
52
+ ### Setting shape attributes of a node
53
+
54
+ LogicFlow calls the attributes of a node such as width, height, radius, etc. as [ShapeAttributes](../../api/runtime-model/nodeModel.en.md#shape-attributes), we can override the [initNodeData](../../api/runtime-model/nodeModel.en.md#initnodedata) or [ setAttributes](../../api/runtime-model/nodeModel.en.md#setattributes) methods to set the shape attributes of a node. But when the node can be scaled, we can't set the width and height in `setAttributes`, only in `initNodeData`.
55
+
56
+ ```tsx | pure
57
+ class ResizableRectModel extends RectResize.model {
58
+ initNodeData(data) {
59
+ super.initNodeData(data);
60
+ this.width = 100;
61
+ this.height = 40;
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### Customizing the view of a node
67
+
68
+ As mentioned in Customizing Nodes, for nodes with complex style attributes, we can override the `getShape` method in `view` to achieve the real rendered appearance of the custom node. However, since custom nodes need to populate the node's appearance with adjustment points for scaling, we need to override `getResizeShape`, not `getShape`, for the view of a custom scalable node.
69
+
70
+ ```tsx | pure
71
+ import { RectResize } from "@logicflow/extension";
72
+
73
+ class ResizableRectModel extends RectResize.model {
74
+ initNodeData(data) {
75
+ super.initNodeData(data);
76
+ this.width = 100;
77
+ this.height = 40;
78
+ this.text.draggable = true;
79
+ }
80
+ }
81
+ class ResizableRectView extends RectResize.view {
82
+ getResizeShape() {
83
+ const { model } = this.props;
84
+ const { x, y, width, height, radius, properties } = model;
85
+ const style = model.getNodeStyle();
86
+ return h("g", {}, [
87
+ h("rect", {
88
+ ...style,
89
+ x: x - width / 2,
90
+ y: y - height / 2,
91
+ rx: radius,
92
+ ry: radius,
93
+ width,
94
+ height,
95
+ }),
96
+ ]);
97
+ }
98
+ }
99
+
100
+ export default {
101
+ type: "resizable-rect",
102
+ view: ResizableRectView,
103
+ model: ResizableRectModel,
104
+ };
105
+ ```
106
+
107
+ :::info{title=tip}
108
+ For nodes that inherit `HtmlResize`, customize `view` by continuing to use the `setHtml` method of the `view` of the custom HTML node.
109
+ :::
110
+
111
+ ## Event `node:resize` is thrown after node resizing.
112
+
113
+ Throw event `node:resize` after node resizing, the data include node position and node size before and after node resizing, the data is {preData, data}, the details are as follows.
114
+ | Name | Type | Description |
115
+ | :-------- | :----- | :---------------------------------- |
116
+ | id | string | Node id |
117
+ | type | string | Node type |
118
+ | modelType | string | Node graph type, internally defined |
119
+ | x | number | Node center x-axis coordinates |
120
+ | y | number | Node center y-axis coordinate |
121
+ | rx | number | x-axis radius (ellipse, rhombus) |
122
+ | ry | number | y-axis radius (ellipse, diamond) |
123
+ | width | number | Node width (rectangle) |
124
+ | height | number | Node height (rectangle) |
125
+
126
+ ```tsx | pure
127
+ lf.on("node:resize", ({ preData, data }) => {
128
+ console.log(preData, data);
129
+ });
130
+ ```
131
+
132
+ ## Setting the maximum and minimum values for zoom-in and zoom-out
133
+
134
+ After `v1.1.8`, the zoom-in/zoom-out of a node supports setting the maximum and minimum values.
135
+
136
+ ```tsx | pure
137
+ class ResizableRectModel extends RectResize.model {
138
+ initNodeData(data) {
139
+ super.initNodeData(data);
140
+ this.width = 100;
141
+ this.height = 40;
142
+ this.maxWidth = 400;
143
+ this.maxHeight = 400;
144
+ }
145
+ }
146
+ ```
147
+
148
+ ## Setting the adjustment default distance for zooming in and out
149
+
150
+ After `v1.1.8`, it is supported to set the `girdSize` property of a node, which is used to control how much distance to move the mouse before starting to zoom the node.
151
+
152
+ ```tsx | pure
153
+ class ResizableRectModel extends RectResize.model {
154
+ initNodeData(data) {
155
+ super.initNodeData(data);
156
+ this.gridSize = 400;
157
+ }
158
+ }
159
+ ```
160
+ :::info{title=gridSize on node scaling}
161
+ In most cases, to keep the nodes `neat` and to facilitate top/bottom/right/left/right alignment between nodes. `logicflow` defaults to change the size of nodes when zooming in and out, only when the mouse movement distance reaches twice the `gridSize` passed to the initialization canvas. But this has the disadvantage of a laggy feeling when adjusting. You can set the `gridSize` of each node individually without changing the initialized `gridSize` to make zooming in and out smoother.
162
+ :::
163
+
164
+ ## Settings to adjust the border style
165
+
166
+ The resizable node displays a dashed box against the node when it is selected (the rectangle does not). Customizing its style can be achieved by overriding the `getResizeOutlineStyle` method.
167
+
168
+ ```tsx | pure
169
+ class ResizableRectModel extends RectResize.model {
170
+ getResizeOutlineStyle() {
171
+ return {
172
+ stroke: "#000000",
173
+ strokeWidth: 1,
174
+ strokeDasharray: "3,3",
175
+ };
176
+ }
177
+ }
178
+ ```
179
+
180
+ ## Setting the resize point style
181
+
182
+ When the zoom-in/zoom-out node is selected, action points for resizing the node are generated at the four corners of the dashed box, which can be customized by overriding the `getControlPointStyle` method.
183
+
184
+ ```tsx | pure
185
+ class ResizableRectModel extends RectResize.model {
186
+ getControlPointStyle() {
187
+ return {
188
+ width: 7,
189
+ height: 7,
190
+ fill: "#FFFFFF",
191
+ stroke: "#000000",
192
+ };
193
+ }
194
+ }
195
+ ```
196
+
197
+ address: [https://codesandbox.io/s/prod-resonance-ztpvtv](https://codesandbox.io/s/prod-resonance-ztpvtv?file=/step_26_nodeResize/index.js)
198
+
199
+ <a href="https://codesandbox.io/embed/prod-resonance-ztpvtv?fontsize=14&hidenavigation=1&theme=dark&view=preview" target="_blank"> Go to CodeSandbox for examples </a>