@logicflow/vue-node-registry 1.2.0 → 1.2.1
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.
- package/README.md +6 -3
- package/dist/index.css +122 -0
- package/es/components/container.d.ts +19 -0
- package/es/components/container.js +27 -0
- package/es/components/container.js.map +1 -0
- package/es/components/titleBar.d.ts +24 -0
- package/es/components/titleBar.js +160 -0
- package/es/components/titleBar.js.map +1 -0
- package/es/index.css +122 -0
- package/es/index.less +1 -0
- package/es/model.d.ts +18 -1
- package/es/model.js +44 -5
- package/es/model.js.map +1 -1
- package/es/registry.d.ts +14 -3
- package/es/registry.js +28 -5
- package/es/registry.js.map +1 -1
- package/es/style/index.css +122 -0
- package/es/style/index.less +140 -0
- package/es/style/raw.d.ts +4 -0
- package/es/style/raw.js +6 -0
- package/es/style/raw.js.map +1 -0
- package/es/utils/size.d.ts +2 -0
- package/es/utils/size.js +14 -0
- package/es/utils/size.js.map +1 -0
- package/es/view.d.ts +9 -0
- package/es/view.js +158 -16
- package/es/view.js.map +1 -1
- package/lib/components/container.d.ts +19 -0
- package/lib/components/container.js +30 -0
- package/lib/components/container.js.map +1 -0
- package/lib/components/titleBar.d.ts +24 -0
- package/lib/components/titleBar.js +163 -0
- package/lib/components/titleBar.js.map +1 -0
- package/lib/index.css +122 -0
- package/lib/index.less +1 -0
- package/lib/model.d.ts +18 -1
- package/lib/model.js +42 -3
- package/lib/model.js.map +1 -1
- package/lib/registry.d.ts +14 -3
- package/lib/registry.js +30 -6
- package/lib/registry.js.map +1 -1
- package/lib/style/index.css +122 -0
- package/lib/style/index.less +140 -0
- package/lib/style/raw.d.ts +4 -0
- package/lib/style/raw.js +9 -0
- package/lib/style/raw.js.map +1 -0
- package/lib/utils/size.d.ts +2 -0
- package/lib/utils/size.js +19 -0
- package/lib/utils/size.js.map +1 -0
- package/lib/view.d.ts +9 -0
- package/lib/view.js +156 -14
- package/lib/view.js.map +1 -1
- package/package.json +10 -5
- package/.turbo/turbo-build$colon$dev.log +0 -10
- package/.turbo/turbo-build.log +0 -34
- package/CHANGELOG.md +0 -217
- package/src/index.ts +0 -4
- package/src/model.ts +0 -64
- package/src/registry.ts +0 -43
- package/src/teleport.ts +0 -155
- package/src/view.ts +0 -109
- package/stats.html +0 -4842
- package/tsconfig.json +0 -20
package/.turbo/turbo-build.log
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @logicflow/vue-node-registry@1.1.5 prebuild /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
|
|
3
|
-
> rss
|
|
4
|
-
|
|
5
|
-
> [prebuild] run-s -s clean:build
|
|
6
|
-
> [clean:build] rimraf dist es lib
|
|
7
|
-
|
|
8
|
-
> @logicflow/vue-node-registry@1.1.5 build /Users/didi/Desktop/github/LogicFlow/packages/vue-node-registry
|
|
9
|
-
> rss
|
|
10
|
-
|
|
11
|
-
> [build] run-p -s build:dev build:umd
|
|
12
|
-
> [build:umd] pnpm run --if-present build:less && rollup -c ../../rollup.config.js --bundleConfigAsCjs
|
|
13
|
-
> [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
|
|
14
|
-
> [build:less] ./scripts/build-less
|
|
15
|
-
> [build:less] ./scripts/build-less
|
|
16
|
-
[36m
|
|
17
|
-
[1m./src/index.ts[22m → [1mdist/index.min.js[22m...[39m
|
|
18
|
-
+----------------------------------------------+
|
|
19
|
-
| |
|
|
20
|
-
| [32m[1mBundle Format:[22m[39m [33mumd[39m |
|
|
21
|
-
| [32m[1mBundle Name:[22m[39m [33mVueNodeRegistry[39m |
|
|
22
|
-
| [32m[1mExternal Globals:[22m[39m |
|
|
23
|
-
| [33m @logicflow/core: Core[39m |
|
|
24
|
-
| [33m @vue/composition-api: VueCompositionApi[39m |
|
|
25
|
-
| [33m vue: Vue[39m |
|
|
26
|
-
| |
|
|
27
|
-
| [32m[1mDestination:[22m[39m [33mdist/index.min.js[39m |
|
|
28
|
-
| [32m[1mBundle Size:[22m[39m [33m390 B[39m |
|
|
29
|
-
| [32m[1mMinified Size:[22m[39m [33m351 B[39m |
|
|
30
|
-
| [32m[1mGZipped Size:[22m[39m [33m200 B[39m |
|
|
31
|
-
| |
|
|
32
|
-
+----------------------------------------------+
|
|
33
|
-
[1m[33m(!) [plugin typescript] @rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.[39m[22m
|
|
34
|
-
[32mcreated [1mdist/index.min.js[22m in [1m5.7s[22m[39m
|
package/CHANGELOG.md
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
# @logicflow/vue-node-registry
|
|
2
|
-
|
|
3
|
-
## 1.2.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @logicflow/core@2.2.0
|
|
9
|
-
|
|
10
|
-
## 1.1.5
|
|
11
|
-
|
|
12
|
-
### Patch Changes
|
|
13
|
-
|
|
14
|
-
- fix: 修复issue反馈的问题
|
|
15
|
-
- fix: 修复extension包引入vue包问题 fix #2277
|
|
16
|
-
- Updated dependencies
|
|
17
|
-
- @logicflow/core@2.1.4
|
|
18
|
-
|
|
19
|
-
## 1.1.4
|
|
20
|
-
|
|
21
|
-
### Patch Changes
|
|
22
|
-
|
|
23
|
-
- Updated dependencies
|
|
24
|
-
- @logicflow/core@2.1.3
|
|
25
|
-
|
|
26
|
-
## 1.1.3
|
|
27
|
-
|
|
28
|
-
### Patch Changes
|
|
29
|
-
|
|
30
|
-
- fix: 修复小地图在vue自定义节点删除一个小地图中全部vue节点消失问题
|
|
31
|
-
|
|
32
|
-
## 1.1.2
|
|
33
|
-
|
|
34
|
-
### Patch Changes
|
|
35
|
-
|
|
36
|
-
- Updated dependencies
|
|
37
|
-
- @logicflow/core@2.1.2
|
|
38
|
-
|
|
39
|
-
## 1.1.1
|
|
40
|
-
|
|
41
|
-
### Patch Changes
|
|
42
|
-
|
|
43
|
-
- fix: 修复点击节点会触发多选的问题和vue-node-registry引入报错问题
|
|
44
|
-
- Updated dependencies
|
|
45
|
-
- @logicflow/core@2.1.1
|
|
46
|
-
|
|
47
|
-
## 1.1.0
|
|
48
|
-
|
|
49
|
-
### Patch Changes
|
|
50
|
-
|
|
51
|
-
- fix: 修复issue反馈的bug&支持小地图展示vue节点
|
|
52
|
-
|
|
53
|
-
## 1.0.18
|
|
54
|
-
|
|
55
|
-
### Patch Changes
|
|
56
|
-
|
|
57
|
-
- Updated dependencies
|
|
58
|
-
- @logicflow/core@2.0.16
|
|
59
|
-
|
|
60
|
-
## 1.0.17
|
|
61
|
-
|
|
62
|
-
### Patch Changes
|
|
63
|
-
|
|
64
|
-
- Updated dependencies
|
|
65
|
-
- @logicflow/core@2.0.15
|
|
66
|
-
|
|
67
|
-
## 1.0.16
|
|
68
|
-
|
|
69
|
-
### Patch Changes
|
|
70
|
-
|
|
71
|
-
- Updated dependencies
|
|
72
|
-
- @logicflow/core@2.0.14
|
|
73
|
-
|
|
74
|
-
## 1.0.15
|
|
75
|
-
|
|
76
|
-
### Patch Changes
|
|
77
|
-
|
|
78
|
-
- Updated dependencies
|
|
79
|
-
- @logicflow/core@2.0.13
|
|
80
|
-
|
|
81
|
-
## 1.0.14
|
|
82
|
-
|
|
83
|
-
### Patch Changes
|
|
84
|
-
|
|
85
|
-
- Updated dependencies
|
|
86
|
-
- @logicflow/core@2.0.12
|
|
87
|
-
|
|
88
|
-
## 1.0.13
|
|
89
|
-
|
|
90
|
-
### Patch Changes
|
|
91
|
-
|
|
92
|
-
- Updated dependencies
|
|
93
|
-
- @logicflow/core@2.0.11
|
|
94
|
-
|
|
95
|
-
## 1.0.12
|
|
96
|
-
|
|
97
|
-
### Patch Changes
|
|
98
|
-
|
|
99
|
-
- fix: 修复issue反馈的bug
|
|
100
|
-
- Updated dependencies
|
|
101
|
-
- @logicflow/core@2.0.10
|
|
102
|
-
|
|
103
|
-
## 1.0.11
|
|
104
|
-
|
|
105
|
-
### Patch Changes
|
|
106
|
-
|
|
107
|
-
- Updated dependencies
|
|
108
|
-
- @logicflow/core@2.0.9
|
|
109
|
-
|
|
110
|
-
## 1.0.10
|
|
111
|
-
|
|
112
|
-
### Patch Changes
|
|
113
|
-
|
|
114
|
-
- release react/vue-node-registry
|
|
115
|
-
|
|
116
|
-
## 1.0.9
|
|
117
|
-
|
|
118
|
-
### Patch Changes
|
|
119
|
-
|
|
120
|
-
- Updated dependencies
|
|
121
|
-
- @logicflow/core@2.0.8
|
|
122
|
-
|
|
123
|
-
## 1.0.8
|
|
124
|
-
|
|
125
|
-
### Patch Changes
|
|
126
|
-
|
|
127
|
-
- fix: 修复一些问题
|
|
128
|
-
- fix: 修复一些问题
|
|
129
|
-
- fix: 修复文本拖拽不符合预期的问题 by ChangeSuger
|
|
130
|
-
- feat: 支持动态修改 Grid 的配置 by ChangeSuger
|
|
131
|
-
- fix: 修复 2.x 与 1.x 下相同的网格线宽,Grid 表现不一致的问题 by ChangeSuger
|
|
132
|
-
- fix: node:dnd-drag 增加事件数据 by HeatonZ
|
|
133
|
-
- fix(extension): 【dynamic-group】修复mousemove和isCollapsed相关问题 by wbccb
|
|
134
|
-
- fix: 修复 windows 系统 node20 环境下样式文件打包失败的问题 by ChangeSuger
|
|
135
|
-
- fix: 修复 node:dnd-drag 事件的类型检查问题 by ChangeSuger
|
|
136
|
-
- fix(example): 修复文档中vue3自定义组件不能正常显示bug by zkt2002
|
|
137
|
-
- fix(core): 在没有拖拽的情况下,Control组件突然销毁,不触发cancelDrag(#1926) by wbccb
|
|
138
|
-
- fix(core): 修复笔记本触摸板点击边事件失效 by wuchenguang1998
|
|
139
|
-
- feat(examples): 添加动画边demo by DymoneLewis
|
|
140
|
-
- fix(core): 类型定义 properties:change 改为 node:properties-change by HeatonZ
|
|
141
|
-
- feat: node-registry 自定义properties类型 by HeatonZ
|
|
142
|
-
- fix(core): 修复 polyline 与多边形节点的交点不正确的问题 by Yuan-ZW
|
|
143
|
-
- Updated dependencies
|
|
144
|
-
- @logicflow/core@2.0.7
|
|
145
|
-
|
|
146
|
-
## 1.0.7
|
|
147
|
-
|
|
148
|
-
### Patch Changes
|
|
149
|
-
|
|
150
|
-
- fix(vue-node-registry): 修复Teleport+KeepAlive场景下DOM重复渲染的问题 close #1768 #1862
|
|
151
|
-
|
|
152
|
-
- Updated dependencies
|
|
153
|
-
- @logicflow/core@2.0.6
|
|
154
|
-
|
|
155
|
-
## 1.0.6
|
|
156
|
-
|
|
157
|
-
### Patch Changes
|
|
158
|
-
|
|
159
|
-
- Updated dependencies
|
|
160
|
-
- @logicflow/core@2.0.5
|
|
161
|
-
|
|
162
|
-
## 1.0.5
|
|
163
|
-
|
|
164
|
-
### Patch Changes
|
|
165
|
-
|
|
166
|
-
- Updated dependencies
|
|
167
|
-
- Updated dependencies
|
|
168
|
-
- @logicflow/core@2.0.4
|
|
169
|
-
|
|
170
|
-
## 1.0.4
|
|
171
|
-
|
|
172
|
-
### Patch Changes
|
|
173
|
-
|
|
174
|
-
- fix: bugs from issues
|
|
175
|
-
|
|
176
|
-
- fix: 移除 vue-node-registry view 中无用 console,close #1856
|
|
177
|
-
|
|
178
|
-
## 1.0.3
|
|
179
|
-
|
|
180
|
-
### Patch Changes: Release 1.0.3 Version
|
|
181
|
-
|
|
182
|
-
- Updated dependencies
|
|
183
|
-
- @logicflow/core@2.0.3
|
|
184
|
-
|
|
185
|
-
## 1.0.2
|
|
186
|
-
|
|
187
|
-
### Patch Changes
|
|
188
|
-
|
|
189
|
-
- Release New Version,移除多余 console
|
|
190
|
-
|
|
191
|
-
- Updated dependencies
|
|
192
|
-
- @logicflow/core@2.0.2
|
|
193
|
-
|
|
194
|
-
## 1.0.1
|
|
195
|
-
|
|
196
|
-
### Patch Changes
|
|
197
|
-
|
|
198
|
-
- Updated dependencies
|
|
199
|
-
- @logicflow/core@2.0.1
|
|
200
|
-
|
|
201
|
-
## 1.0.0
|
|
202
|
-
|
|
203
|
-
### Patch Changes
|
|
204
|
-
|
|
205
|
-
- Release 2.0 New Version 🎉🎉🎉🎉
|
|
206
|
-
- Updated dependencies
|
|
207
|
-
|
|
208
|
-
- @logicflow/core@2.0.0
|
|
209
|
-
|
|
210
|
-
- feat: 开发 vue-node-registry 包用于用户自定义 vue 节点
|
|
211
|
-
|
|
212
|
-
- 通过监听 properties 变化的事件,触发节点的更新
|
|
213
|
-
- 利用 Teleport 将组件内部的一部分模板传送到组件的 DOM 结构外层的位置去
|
|
214
|
-
- 修复 vue-node-registry 包在 vue2 项目中渲染失效的问题
|
|
215
|
-
- 更新 extension 包的 package.json
|
|
216
|
-
- 修复 vue-node-registry 渲染顺序,先 appendChild,再 new Vue
|
|
217
|
-
- 修复渲染自定义节点 new Vue2 实例时未传 el 的问题
|
package/src/index.ts
DELETED
package/src/model.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import LogicFlow, { HtmlNodeModel, IHtmlNodeProperties } from '@logicflow/core'
|
|
2
|
-
import { cloneDeep, isNil } from 'lodash-es'
|
|
3
|
-
|
|
4
|
-
export interface VueCustomProperties extends IHtmlNodeProperties {
|
|
5
|
-
// 形状属性
|
|
6
|
-
width?: number
|
|
7
|
-
height?: number
|
|
8
|
-
radius?: number
|
|
9
|
-
|
|
10
|
-
// 文字位置属性
|
|
11
|
-
refX?: number
|
|
12
|
-
refY?: number
|
|
13
|
-
|
|
14
|
-
// 样式属性
|
|
15
|
-
style?: LogicFlow.CommonTheme
|
|
16
|
-
textStyle?: LogicFlow.TextNodeTheme
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class VueNodeModel<
|
|
20
|
-
P extends VueCustomProperties = VueCustomProperties,
|
|
21
|
-
> extends HtmlNodeModel<P> {
|
|
22
|
-
setAttributes() {
|
|
23
|
-
// DONE: 解决 width、height、radius 为 0 时的问题
|
|
24
|
-
const { width, height, radius } = this.properties
|
|
25
|
-
if (!isNil(width)) {
|
|
26
|
-
this.width = width
|
|
27
|
-
}
|
|
28
|
-
if (!isNil(height)) {
|
|
29
|
-
this.height = height
|
|
30
|
-
}
|
|
31
|
-
if (!isNil(radius)) {
|
|
32
|
-
this.radius = radius
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
getTextStyle(): LogicFlow.TextNodeTheme {
|
|
37
|
-
const { refX = 0, refY = 0, textStyle } = this.properties
|
|
38
|
-
const style = super.getTextStyle()
|
|
39
|
-
|
|
40
|
-
// 通过 transform 重新设置 text 的位置
|
|
41
|
-
return {
|
|
42
|
-
...style,
|
|
43
|
-
...(cloneDeep(textStyle) || {}),
|
|
44
|
-
transform: `matrix(1 0 0 1 ${refX} ${refY})`,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getNodeStyle(): LogicFlow.CommonTheme {
|
|
49
|
-
const style = super.getNodeStyle()
|
|
50
|
-
const {
|
|
51
|
-
style: customNodeStyle,
|
|
52
|
-
// radius = 0, // 第二种方式,设置圆角
|
|
53
|
-
} = this.properties
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
...style,
|
|
57
|
-
...(cloneDeep(customNodeStyle) || {}),
|
|
58
|
-
// rx: radius,
|
|
59
|
-
// ry: radius,
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default VueNodeModel
|
package/src/registry.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import LogicFlow from '@logicflow/core'
|
|
2
|
-
import { VueNodeView } from './view'
|
|
3
|
-
import { VueNodeModel } from './model'
|
|
4
|
-
|
|
5
|
-
import RegisterConfig = LogicFlow.RegisterConfig
|
|
6
|
-
|
|
7
|
-
export type VueNodeConfig = {
|
|
8
|
-
type: string
|
|
9
|
-
component: any
|
|
10
|
-
effect?: (keyof LogicFlow.PropertiesType)[]
|
|
11
|
-
} & Partial<RegisterConfig>
|
|
12
|
-
|
|
13
|
-
export const vueNodesMap: Record<
|
|
14
|
-
string,
|
|
15
|
-
{
|
|
16
|
-
component: any
|
|
17
|
-
effect?: (keyof LogicFlow.PropertiesType)[]
|
|
18
|
-
}
|
|
19
|
-
> = {}
|
|
20
|
-
|
|
21
|
-
export function register(config: VueNodeConfig, lf: LogicFlow) {
|
|
22
|
-
const {
|
|
23
|
-
type,
|
|
24
|
-
component,
|
|
25
|
-
effect,
|
|
26
|
-
view: CustomNodeView,
|
|
27
|
-
model: CustomNodeModel,
|
|
28
|
-
} = config
|
|
29
|
-
|
|
30
|
-
if (!type) {
|
|
31
|
-
throw new Error('You should specify type in config')
|
|
32
|
-
}
|
|
33
|
-
vueNodesMap[type] = {
|
|
34
|
-
component,
|
|
35
|
-
effect,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
lf.register({
|
|
39
|
-
type,
|
|
40
|
-
view: CustomNodeView || VueNodeView,
|
|
41
|
-
model: CustomNodeModel || VueNodeModel,
|
|
42
|
-
})
|
|
43
|
-
}
|
package/src/teleport.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { BaseNodeModel, GraphModel } from '@logicflow/core'
|
|
2
|
-
import {
|
|
3
|
-
defineComponent,
|
|
4
|
-
h,
|
|
5
|
-
createApp,
|
|
6
|
-
reactive,
|
|
7
|
-
isVue3,
|
|
8
|
-
Teleport,
|
|
9
|
-
markRaw,
|
|
10
|
-
Fragment,
|
|
11
|
-
} from 'vue-demi'
|
|
12
|
-
|
|
13
|
-
let active = false
|
|
14
|
-
const appInstances = new Map<string, InstanceType<any>>()
|
|
15
|
-
const appNodesMap = new Map<string, any>() // 用于储存当前流程图节点id当节点都销毁时同时卸载vueApp实例
|
|
16
|
-
const items = reactive<{ [key: string]: any }>({})
|
|
17
|
-
|
|
18
|
-
export function connect(
|
|
19
|
-
id: string,
|
|
20
|
-
component: any,
|
|
21
|
-
container: HTMLDivElement,
|
|
22
|
-
node: BaseNodeModel,
|
|
23
|
-
graph: GraphModel,
|
|
24
|
-
) {
|
|
25
|
-
if (active) {
|
|
26
|
-
if (graph.isMiniMap) {
|
|
27
|
-
createTeleportContainer(container, graph.flowId)
|
|
28
|
-
}
|
|
29
|
-
items[id] = markRaw(
|
|
30
|
-
defineComponent({
|
|
31
|
-
render: () =>
|
|
32
|
-
h(Teleport, { to: container } as any, [
|
|
33
|
-
h(component, { node, graph }),
|
|
34
|
-
]),
|
|
35
|
-
provide: () => ({
|
|
36
|
-
getNode: () => node,
|
|
37
|
-
getGraph: () => graph,
|
|
38
|
-
}),
|
|
39
|
-
}),
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function disconnect(id: string, flowId: string) {
|
|
45
|
-
if (active) {
|
|
46
|
-
delete items[id]
|
|
47
|
-
if (appInstances.has(flowId)) {
|
|
48
|
-
const appNodeList = appNodesMap.get(flowId) || []
|
|
49
|
-
const index = appNodeList.indexOf(id)
|
|
50
|
-
if (index > -1) {
|
|
51
|
-
appNodeList.splice(index, 1)
|
|
52
|
-
if (appNodeList.length === 0) {
|
|
53
|
-
destroyTeleportContainer(flowId)
|
|
54
|
-
} else {
|
|
55
|
-
appNodesMap.set(flowId, appNodeList)
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function isActive() {
|
|
63
|
-
return active
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function getTeleport(): any {
|
|
67
|
-
if (!isVue3) {
|
|
68
|
-
throw new Error('teleport is only available in Vue3')
|
|
69
|
-
}
|
|
70
|
-
active = true
|
|
71
|
-
|
|
72
|
-
return defineComponent({
|
|
73
|
-
props: {
|
|
74
|
-
flowId: {
|
|
75
|
-
type: String,
|
|
76
|
-
required: true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
setup(props) {
|
|
80
|
-
return () => {
|
|
81
|
-
const children: Record<string, any>[] = []
|
|
82
|
-
Object.keys(items).forEach((id) => {
|
|
83
|
-
// https://github.com/didi/LogicFlow/issues/1768
|
|
84
|
-
// 多个不同的VueNodeView都会connect注册到items中,因此items存储了可能有多个flowId流程图的数据
|
|
85
|
-
// 当使用多个LogicFlow时,会创建多个flowId + 同时使用KeepAlive
|
|
86
|
-
// 每一次items改变,会触发不同flowId持有的setup()执行,由于每次setup()执行就是遍历items,因此存在多次重复渲染元素的问题
|
|
87
|
-
// 即items[0]会在Page1的setup()执行,items[0]也会在Page2的setup()执行,从而生成两个items[0]
|
|
88
|
-
|
|
89
|
-
// 比对当前界面显示的flowId,只更新items[当前页面flowId:nodeId]的数据
|
|
90
|
-
// 比如items[0]属于Page1的数据,那么Page2无论active=true/false,都无法执行items[0]
|
|
91
|
-
|
|
92
|
-
if (id.startsWith(props.flowId)) {
|
|
93
|
-
if (appInstances.has(props.flowId)) {
|
|
94
|
-
const appNodeList = appNodesMap.get(props.flowId) || []
|
|
95
|
-
if (!appNodeList.includes(id)) {
|
|
96
|
-
appNodeList.push(id)
|
|
97
|
-
appNodesMap.set(props.flowId, appNodeList)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
children.push(items[id])
|
|
101
|
-
}
|
|
102
|
-
})
|
|
103
|
-
return h(
|
|
104
|
-
Fragment,
|
|
105
|
-
{},
|
|
106
|
-
children.map((item) => h(item)),
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
})
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* 创建并挂载 Teleport 容器组件
|
|
115
|
-
* @param container 目标容器元素
|
|
116
|
-
* @param flowId 当前流程图的唯一标识
|
|
117
|
-
*/
|
|
118
|
-
export function createTeleportContainer(
|
|
119
|
-
container: HTMLElement,
|
|
120
|
-
flowId: string | undefined,
|
|
121
|
-
): void {
|
|
122
|
-
if (!isVue3 || !flowId || !container || !active) return
|
|
123
|
-
|
|
124
|
-
// 获取 Teleport 组件
|
|
125
|
-
const TeleportContainer = getTeleport()
|
|
126
|
-
|
|
127
|
-
// 不重新创建 Teleport 容器组件
|
|
128
|
-
if (appInstances.has(flowId)) {
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// ✅ 1. 创建独立容器放到目标容器中
|
|
133
|
-
const mountPoint = document.createElement('div')
|
|
134
|
-
container.appendChild(mountPoint)
|
|
135
|
-
|
|
136
|
-
// ✅ 2. 创建并挂载 Vue 应用到新容器
|
|
137
|
-
const app = createApp(TeleportContainer, { flowId })
|
|
138
|
-
app.mount(mountPoint)
|
|
139
|
-
|
|
140
|
-
appInstances.set(flowId, app)
|
|
141
|
-
appNodesMap.set(flowId, [])
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* 卸载 Teleport 容器组件
|
|
145
|
-
* @param flowId 需要卸载流程图的唯一标识
|
|
146
|
-
*/
|
|
147
|
-
export function destroyTeleportContainer(flowId: string | undefined): void {
|
|
148
|
-
if (!isVue3 || !flowId || !active) return
|
|
149
|
-
const app = appInstances.get(flowId)
|
|
150
|
-
if (app) {
|
|
151
|
-
app.unmount()
|
|
152
|
-
appInstances.delete(flowId)
|
|
153
|
-
appNodesMap.delete(flowId)
|
|
154
|
-
}
|
|
155
|
-
}
|
package/src/view.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { isVue2, isVue3, createApp, h, Vue2 } from 'vue-demi'
|
|
2
|
-
import { HtmlNode } from '@logicflow/core'
|
|
3
|
-
import { vueNodesMap } from './registry'
|
|
4
|
-
import { isActive, connect, disconnect } from './teleport'
|
|
5
|
-
|
|
6
|
-
export class VueNodeView extends HtmlNode {
|
|
7
|
-
root?: any
|
|
8
|
-
private vm: any
|
|
9
|
-
|
|
10
|
-
getComponentContainer() {
|
|
11
|
-
return this.root
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
protected targetId() {
|
|
15
|
-
return `${this.props.graphModel.flowId}:${this.props.model.id}`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
componentWillUnmount() {
|
|
19
|
-
super.componentWillUnmount()
|
|
20
|
-
this.unmount()
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
setHtml(rootEl: SVGForeignObjectElement) {
|
|
24
|
-
const el = document.createElement('div')
|
|
25
|
-
el.className = 'custom-vue-node-content'
|
|
26
|
-
this.root = el
|
|
27
|
-
rootEl.appendChild(el)
|
|
28
|
-
|
|
29
|
-
this.renderVueComponent()
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
-
confirmUpdate(_rootEl: SVGForeignObjectElement) {
|
|
34
|
-
// TODO: 如有需要,可以先通过继承的方式,自定义该节点的更新逻辑;我们后续会根据实际需求,丰富该功能
|
|
35
|
-
// console.log('_rootEl', _rootEl)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
protected renderVueComponent() {
|
|
39
|
-
this.unmountVueComponent()
|
|
40
|
-
const root = this.getComponentContainer()
|
|
41
|
-
const { model, graphModel } = this.props
|
|
42
|
-
|
|
43
|
-
if (root) {
|
|
44
|
-
const { component } = vueNodesMap[model.type]
|
|
45
|
-
if (component) {
|
|
46
|
-
if (isVue2) {
|
|
47
|
-
const Vue = Vue2 as any
|
|
48
|
-
this.vm = new Vue({
|
|
49
|
-
el: root,
|
|
50
|
-
render(h: any) {
|
|
51
|
-
return h(component, {
|
|
52
|
-
node: model,
|
|
53
|
-
graph: graphModel,
|
|
54
|
-
})
|
|
55
|
-
},
|
|
56
|
-
provide() {
|
|
57
|
-
return {
|
|
58
|
-
getNode: () => model,
|
|
59
|
-
getGraph: () => graphModel,
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
} else if (isVue3) {
|
|
64
|
-
if (isActive()) {
|
|
65
|
-
connect(this.targetId(), component, root, model, graphModel)
|
|
66
|
-
} else {
|
|
67
|
-
this.vm = createApp({
|
|
68
|
-
render() {
|
|
69
|
-
return h(component, {
|
|
70
|
-
node: model,
|
|
71
|
-
graph: graphModel,
|
|
72
|
-
})
|
|
73
|
-
},
|
|
74
|
-
provide() {
|
|
75
|
-
return {
|
|
76
|
-
getNode: () => model,
|
|
77
|
-
getGraph: () => graphModel,
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
})
|
|
81
|
-
this.vm?.mount(root)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
protected unmountVueComponent() {
|
|
89
|
-
const root = this.getComponentContainer()
|
|
90
|
-
if (this.vm) {
|
|
91
|
-
isVue2 && this.vm.$destroy()
|
|
92
|
-
isVue3 && this.vm.unmount()
|
|
93
|
-
this.vm = null
|
|
94
|
-
}
|
|
95
|
-
if (root) {
|
|
96
|
-
root.innerHTML = ''
|
|
97
|
-
}
|
|
98
|
-
return root
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
unmount() {
|
|
102
|
-
if (isActive()) {
|
|
103
|
-
disconnect(this.targetId(), this.props.graphModel.flowId as string)
|
|
104
|
-
}
|
|
105
|
-
this.unmountVueComponent()
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export default VueNodeView
|