@logicflow/extension 2.2.0-alpha.7 → 2.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.
Files changed (125) hide show
  1. package/README.md +16 -0
  2. package/package.json +10 -7
  3. package/.turbo/turbo-build.log +0 -38
  4. package/CHANGELOG.md +0 -1829
  5. package/__test__/bpmn-adapter.test.js +0 -227
  6. package/es/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
  7. package/es/materials/curved-edge/__test__/curved-edge.test.js +0 -18
  8. package/jest.config.js +0 -198
  9. package/lib/materials/curved-edge/__test__/curved-edge.test.d.ts +0 -1
  10. package/lib/materials/curved-edge/__test__/curved-edge.test.js +0 -20
  11. package/rollup.config.js +0 -52
  12. package/src/NodeResize/BasicShape/Ellipse.tsx +0 -22
  13. package/src/NodeResize/BasicShape/Polygon.tsx +0 -24
  14. package/src/NodeResize/BasicShape/Rect.tsx +0 -44
  15. package/src/NodeResize/control/Control.tsx +0 -537
  16. package/src/NodeResize/control/ControlGroup.tsx +0 -76
  17. package/src/NodeResize/control/Util.ts +0 -206
  18. package/src/NodeResize/index.ts +0 -26
  19. package/src/NodeResize/node/DiamondResize.tsx +0 -149
  20. package/src/NodeResize/node/EllipseResize.tsx +0 -140
  21. package/src/NodeResize/node/HtmlResize.tsx +0 -125
  22. package/src/NodeResize/node/RectResize.tsx +0 -126
  23. package/src/NodeResize/node/index.ts +0 -4
  24. package/src/bpmn/constant.ts +0 -56
  25. package/src/bpmn/events/EndEvent.ts +0 -73
  26. package/src/bpmn/events/StartEvent.ts +0 -52
  27. package/src/bpmn/events/index.ts +0 -2
  28. package/src/bpmn/flow/SequenceFlow.ts +0 -25
  29. package/src/bpmn/flow/index.ts +0 -1
  30. package/src/bpmn/gateways/ExclusiveGateway.ts +0 -71
  31. package/src/bpmn/gateways/index.ts +0 -1
  32. package/src/bpmn/getBpmnId.ts +0 -31
  33. package/src/bpmn/index.ts +0 -60
  34. package/src/bpmn/tasks/ServiceTask.ts +0 -63
  35. package/src/bpmn/tasks/UserTask.ts +0 -64
  36. package/src/bpmn/tasks/index.ts +0 -2
  37. package/src/bpmn-adapter/bpmnIds.ts +0 -31
  38. package/src/bpmn-adapter/index.ts +0 -835
  39. package/src/bpmn-adapter/json2xml.ts +0 -127
  40. package/src/bpmn-adapter/xml2json.ts +0 -544
  41. package/src/bpmn-elements/README.md +0 -223
  42. package/src/bpmn-elements/__tests__/definition.test.js +0 -72
  43. package/src/bpmn-elements/index.d.ts +0 -26
  44. package/src/bpmn-elements/index.ts +0 -107
  45. package/src/bpmn-elements/presets/Event/EndEventFactory.ts +0 -114
  46. package/src/bpmn-elements/presets/Event/IntermediateCatchEvent.ts +0 -108
  47. package/src/bpmn-elements/presets/Event/IntermediateThrowEvent.ts +0 -109
  48. package/src/bpmn-elements/presets/Event/StartEventFactory.ts +0 -114
  49. package/src/bpmn-elements/presets/Event/boundaryEventFactory.ts +0 -117
  50. package/src/bpmn-elements/presets/Event/index.ts +0 -14
  51. package/src/bpmn-elements/presets/Flow/flow.d.ts +0 -6
  52. package/src/bpmn-elements/presets/Flow/index.ts +0 -8
  53. package/src/bpmn-elements/presets/Flow/manhattan.ts +0 -691
  54. package/src/bpmn-elements/presets/Flow/sequenceFlow.ts +0 -65
  55. package/src/bpmn-elements/presets/Gateway/gateway.ts +0 -107
  56. package/src/bpmn-elements/presets/Gateway/index.ts +0 -23
  57. package/src/bpmn-elements/presets/Pool/Lane.ts +0 -211
  58. package/src/bpmn-elements/presets/Pool/Pool.ts +0 -284
  59. package/src/bpmn-elements/presets/Pool/index.ts +0 -89
  60. package/src/bpmn-elements/presets/Task/index.ts +0 -122
  61. package/src/bpmn-elements/presets/Task/subProcess.ts +0 -189
  62. package/src/bpmn-elements/presets/Task/task.ts +0 -193
  63. package/src/bpmn-elements/presets/icons.ts +0 -155
  64. package/src/bpmn-elements/utils.ts +0 -52
  65. package/src/bpmn-elements-adapter/README.md +0 -293
  66. package/src/bpmn-elements-adapter/__tests__/adapter_in.test.js +0 -528
  67. package/src/bpmn-elements-adapter/__tests__/adapter_out.test.js +0 -569
  68. package/src/bpmn-elements-adapter/constant.ts +0 -76
  69. package/src/bpmn-elements-adapter/index.ts +0 -1134
  70. package/src/bpmn-elements-adapter/json2xml.ts +0 -105
  71. package/src/bpmn-elements-adapter/xml2json.ts +0 -542
  72. package/src/components/context-menu/index.ts +0 -253
  73. package/src/components/control/index.ts +0 -155
  74. package/src/components/dnd-panel/index.ts +0 -137
  75. package/src/components/highlight/index.ts +0 -227
  76. package/src/components/menu/index.ts +0 -748
  77. package/src/components/mini-map/index.ts +0 -686
  78. package/src/components/selection-select/index.ts +0 -387
  79. package/src/dynamic-group/index.ts +0 -774
  80. package/src/dynamic-group/model.ts +0 -580
  81. package/src/dynamic-group/node.ts +0 -288
  82. package/src/dynamic-group/utils.ts +0 -46
  83. package/src/index.less +0 -1
  84. package/src/index.ts +0 -47
  85. package/src/insert-node-in-polyline/edge.ts +0 -175
  86. package/src/insert-node-in-polyline/index.ts +0 -193
  87. package/src/materials/curved-edge/__test__/curved-edge.test.ts +0 -46
  88. package/src/materials/curved-edge/index.ts +0 -217
  89. package/src/materials/group/GroupNode.ts +0 -437
  90. package/src/materials/group/index.ts +0 -542
  91. package/src/materials/node-selection/index.ts +0 -380
  92. package/src/mindmap/fakerRoot.ts +0 -19
  93. package/src/mindmap/index.ts +0 -328
  94. package/src/mindmap/markContent.ts +0 -81
  95. package/src/mindmap/markContentOption.ts +0 -81
  96. package/src/mindmap/markEntity.ts +0 -82
  97. package/src/mindmap/markRoot.ts +0 -83
  98. package/src/mindmap/theme.ts +0 -11
  99. package/src/pool/LaneModel.ts +0 -226
  100. package/src/pool/LaneView.ts +0 -220
  101. package/src/pool/PoolModel.ts +0 -631
  102. package/src/pool/PoolView.ts +0 -75
  103. package/src/pool/constant.ts +0 -19
  104. package/src/pool/index.ts +0 -621
  105. package/src/pool/utils.ts +0 -46
  106. package/src/rect-label-node/RectLabelNodeView.ts +0 -33
  107. package/src/rect-label-node/index.ts +0 -15
  108. package/src/style/index.less +0 -381
  109. package/src/style/raw.ts +0 -328
  110. package/src/tools/auto-layout/index.ts +0 -282
  111. package/src/tools/flow-path/index.ts +0 -233
  112. package/src/tools/label/Label.tsx +0 -357
  113. package/src/tools/label/LabelModel.ts +0 -83
  114. package/src/tools/label/LabelOverlay.tsx +0 -162
  115. package/src/tools/label/algorithm.ts +0 -42
  116. package/src/tools/label/index.ts +0 -479
  117. package/src/tools/label/mediumEditor.ts +0 -121
  118. package/src/tools/label/utils.ts +0 -395
  119. package/src/tools/proximity-connect/index.ts +0 -435
  120. package/src/tools/snapshot/README.md +0 -145
  121. package/src/tools/snapshot/index.ts +0 -701
  122. package/src/tools/snapshot/utils.ts +0 -163
  123. package/src/turbo-adapter/index.ts +0 -212
  124. package/stats.html +0 -4842
  125. package/tsconfig.json +0 -18
@@ -1,89 +0,0 @@
1
- import LogicFlow from '@logicflow/core'
2
- import PoolNode from './Pool'
3
- import LaneNode from './Lane'
4
-
5
- export function laneToJSON(data: any) {
6
- return `<bpmn:participant id="${data.id}" name="${data.name}" processRef="${data.properties.processRef}"/>`
7
- }
8
-
9
- export function poolToJSON(data: any) {
10
- return `<bpmn:collaboration id="${data.id}">
11
- ${data.children.map((child: any) => child.toJSON(child)).join('\t\n')}
12
- </bpmn:collaboration>`
13
- }
14
-
15
- function poolEvent(lf: any) {
16
- const selectAll = () => {
17
- const { nodes = [], edges = [] } = lf.getGraphData()
18
- nodes.forEach((node: any) => {
19
- const { id } = node
20
- if (id) {
21
- lf.selectElementById(id)
22
- }
23
- })
24
- edges.forEach((edge: any) => {
25
- const { id } = edge
26
- if (id) {
27
- lf.selectElementById(id)
28
- }
29
- })
30
- return false
31
- }
32
-
33
- lf.keyboard.on('cmd + a', selectAll)
34
- lf.keyboard.on('ctrl + a', selectAll)
35
- lf.on('node:dnd-add, edge:add', ({ data }: any) => {
36
- const { x, y, type, id } = data
37
- if (type === 'pool') {
38
- lf.setProperties(data.id, {})
39
- const poolModel = lf.getNodeModelById(id)
40
- const { width, height } = poolModel
41
- const { id: laneId } = lf.addNode({
42
- type: 'lane',
43
- properties: {
44
- nodeSize: {
45
- width: width - 30,
46
- height,
47
- },
48
- },
49
- x: x + 15,
50
- y,
51
- })
52
- poolModel.addChild(laneId)
53
- }
54
- })
55
- lf.on('node:resize', ({ preData, data }: any) => {
56
- const { id, type } = preData
57
- const deltaHeight = data.height - preData.height
58
- // const resizeDir = data.y - preData.y > 0 ? 'below': 'above'
59
- // 节点高度变高,y下移, 方向为below
60
- // 节点高度变高, y上移, 方向为above
61
- // 节点高度变小, y下移, 方向为above
62
- // 节点高度变小, y上移,方向为below
63
- let resizeDir = 'below'
64
- if (deltaHeight > 0 && data.y - preData.y < 0) {
65
- resizeDir = 'above'
66
- } else if (deltaHeight < 0 && data.y - preData.y > 0) {
67
- resizeDir = 'above'
68
- }
69
- if (type === 'pool') {
70
- // 泳池缩放,泳道一起调整
71
- lf.getNodeModelById(id).resizeChildren({
72
- resizeDir,
73
- deltaHeight,
74
- })
75
- } else if (type === 'lane') {
76
- // 泳道缩放, 调整泳池
77
- const groupId = lf.extension.group.nodeGroupMap.get(id)
78
- if (groupId) {
79
- lf.getNodeModelById(groupId).resize(id, data)
80
- }
81
- }
82
- })
83
- }
84
-
85
- export const registerPoolNodes = (lf: LogicFlow) => {
86
- lf.register(PoolNode)
87
- lf.register(LaneNode)
88
- poolEvent(lf)
89
- }
@@ -1,122 +0,0 @@
1
- import LogicFlow from '@logicflow/core'
2
- import { serviceTaskIcon, userTaskIcon } from '../icons'
3
- import { TaskNodeFactory } from './task'
4
- import { SubProcessFactory } from './subProcess'
5
-
6
- function boundaryEvent(lf: any) {
7
- lf.on('node:drag,node:dnd-drag', checkAppendBoundaryEvent)
8
- lf.on('node:drop,node:dnd-add', appendBoundaryEvent)
9
- lf.graphModel.addNodeMoveRules(
10
- (
11
- model: { isTaskNode: any; boundaryEvents: any },
12
- deltaX: any,
13
- deltaY: any,
14
- ) => {
15
- if (model.isTaskNode) {
16
- // 如果移动的是分组,那么分组的子节点也跟着移动。
17
- const nodeIds = model.boundaryEvents
18
- lf.graphModel.moveNodes(nodeIds, deltaX, deltaY, true)
19
- return true
20
- }
21
- return true
22
- },
23
- )
24
-
25
- function appendBoundaryEvent(this: any, { data }: any) {
26
- const { type, id } = data
27
- if (type !== 'bpmn:boundaryEvent') {
28
- return
29
- }
30
- const { nodes } = lf.graphModel
31
- for (const node of nodes) {
32
- if (node.isTaskNode) {
33
- let nodeId = null
34
- if ((nodeId = isBoundaryEventCloseToTask(node, data)) !== null) {
35
- const eventModel = lf.graphModel.getNodeModelById(id)
36
- const nodeModel = lf.graphModel.getNodeModelById(nodeId)
37
- const { attachedToRef } = eventModel.properties
38
- if (attachedToRef && attachedToRef !== nodeId) {
39
- lf.graphModel
40
- .getNodeModelById(attachedToRef)
41
- .deleteBoundaryEvent(id)
42
- }
43
- nodeModel.addBoundaryEvent(id)
44
- return
45
- }
46
- }
47
- }
48
- }
49
-
50
- // 判断此节点是否在某个节点的边界上
51
- // 如果在,且这个节点model存在属性isTaskNode,则调用这个方法
52
- function checkAppendBoundaryEvent(this: any, { data }: any) {
53
- const { type } = data
54
- if (type !== 'bpmn:boundaryEvent') {
55
- return
56
- }
57
- const { nodes } = lf.graphModel
58
- for (const node of nodes) {
59
- if (node.isTaskNode) {
60
- if (isBoundaryEventCloseToTask(node, data)) {
61
- // 同时只允许在一个节点的边界上
62
- node.setTouching(true)
63
- } else {
64
- node.setTouching(false)
65
- }
66
- }
67
- }
68
- }
69
-
70
- function isBoundaryEventCloseToTask(task: any, event: any) {
71
- const offset = 5
72
- const { x: tx, y: ty, width: twidth, height: theight, id } = task
73
- const bbox = {
74
- minX: tx - twidth / 2,
75
- maxX: tx + twidth / 2,
76
- minY: ty - theight / 2,
77
- maxY: ty + theight / 2,
78
- }
79
- const { x: bx, y: by } = event
80
- const outerBBox = {
81
- minX: bbox.minX - offset,
82
- maxX: bbox.maxX + offset,
83
- minY: bbox.minY - offset,
84
- maxY: bbox.maxY + offset,
85
- }
86
- const innerBBox = {
87
- minX: bbox.minX + offset,
88
- maxX: bbox.maxX - offset,
89
- minY: bbox.minY + offset,
90
- maxY: bbox.maxY - offset,
91
- }
92
- if (
93
- bx > outerBBox.minX &&
94
- bx < outerBBox.maxX &&
95
- by > outerBBox.minY &&
96
- by < outerBBox.maxY
97
- ) {
98
- if (
99
- !(
100
- bx > innerBBox.minX &&
101
- bx < innerBBox.maxX &&
102
- by > innerBBox.minY &&
103
- by < innerBBox.maxY
104
- )
105
- ) {
106
- return id
107
- }
108
- }
109
- return null
110
- }
111
- }
112
-
113
- export function registerTaskNodes(lf: LogicFlow) {
114
- const ServiceTask = TaskNodeFactory('bpmn:serviceTask', serviceTaskIcon)
115
- const UserTask = TaskNodeFactory('bpmn:userTask', userTaskIcon)
116
-
117
- lf.register(ServiceTask)
118
- lf.register(UserTask)
119
- lf.register(SubProcessFactory())
120
-
121
- boundaryEvent(lf)
122
- }
@@ -1,189 +0,0 @@
1
- import { h } from '@logicflow/core'
2
- import { GroupNode, GroupNodeModel } from '../../../materials/group'
3
-
4
- export function SubProcessFactory(): {
5
- type: string
6
- model: any
7
- view: any
8
- } {
9
- class view extends GroupNode {
10
- getFoldIcon() {
11
- const { model } = this.props
12
- const { x, y, width, height, properties, foldable } =
13
- model as GroupNodeModel
14
- const foldX = model.x - model.width / 2 + 5
15
- const foldY = model.y - model.height / 2 + 5
16
- if (!foldable) return null
17
- const iconIcon = h('path', {
18
- fill: 'none',
19
- stroke: '#818281',
20
- strokeWidth: 2,
21
- 'pointer-events': 'none',
22
- d: properties.isFolded
23
- ? `M ${foldX + 3},${foldY + 6} ${foldX + 11},${foldY + 6} M${
24
- foldX + 7
25
- },${foldY + 2} ${foldX + 7},${foldY + 10}`
26
- : `M ${foldX + 3},${foldY + 6} ${foldX + 11},${foldY + 6} `,
27
- })
28
- return h('g', {}, [
29
- h('rect', {
30
- height: 12,
31
- width: 14,
32
- rx: 2,
33
- ry: 2,
34
- strokeWidth: 1,
35
- fill: '#F4F5F6',
36
- stroke: '#CECECE',
37
- cursor: 'pointer',
38
- x: x - width / 2 + 5,
39
- y: y - height / 2 + 5,
40
- onClick: (e: any) => {
41
- e.stopPropagation()
42
- ;(model as GroupNodeModel).foldGroup?.(!properties.isFolded)
43
- },
44
- }),
45
- iconIcon,
46
- ])
47
- }
48
-
49
- getResizeShape() {
50
- const { model } = this.props
51
- const { x, y, width, height } = model
52
- const style = model.getNodeStyle()
53
- const foldRectAttrs = {
54
- ...style,
55
- x: x - width / 2,
56
- y: y - height / 2,
57
- width,
58
- height,
59
- stroke: 'black',
60
- strokeWidth: 2,
61
- strokeDasharray: '0 0',
62
- }
63
- return h('g', {}, [
64
- // this.getAddAbleShape(),
65
- h('rect', { ...foldRectAttrs }),
66
- this.getFoldIcon(),
67
- ])
68
- }
69
- }
70
-
71
- class model extends GroupNodeModel {
72
- boundaryEvents: any
73
-
74
- initNodeData(data: {
75
- width: number
76
- height: number
77
- properties: Record<string, any>
78
- }) {
79
- super.initNodeData(data)
80
- this.foldable = true
81
- // this.isFolded = true;
82
- this.resizable = true
83
- this.width = 400
84
- this.height = 200
85
- // 根据 properties中的配置重设 宽高
86
- this.resetWidthHeight()
87
- this.isTaskNode = true // 标识此节点是任务节点,可以被附件边界事件
88
- this.boundaryEvents = [] // 记录自己附加的边界事件
89
- }
90
-
91
- // 自定义根据properties.iniProp
92
- resetWidthHeight() {
93
- const width = (this.properties.iniProp as any)?.width
94
- const height = (this.properties.iniProp as any)?.height
95
- width && (this.width = width)
96
- height && (this.height = height)
97
- }
98
-
99
- getNodeStyle() {
100
- const style = super.getNodeStyle()
101
- style.stroke = '#989891'
102
- style.strokeWidth = 1
103
- style.strokeDasharray = '3 3'
104
- if (this.isSelected) {
105
- style.stroke = 'rgb(124, 15, 255)'
106
- }
107
- // isBoundaryEventTouchingTask属性用于标识拖动边界节点是否靠近此节点
108
- // 如果靠近,则高亮提示
109
- // style.fill = 'rgb(255, 230, 204)';
110
- const { isBoundaryEventTouchingTask } = this.properties
111
- if (isBoundaryEventTouchingTask) {
112
- style.stroke = '#00acff'
113
- style.strokeWidth = 2
114
- }
115
-
116
- return style
117
- }
118
-
119
- addChild(id: string) {
120
- const model = this.graphModel.getElement(id)
121
- model?.setProperties({
122
- parent: this.id,
123
- })
124
- super.addChild(id)
125
- }
126
-
127
- // 隐藏锚点而不是设置锚点数为0
128
- // 因为分组内部节点与外部节点相连时,
129
- // 如果折叠分组,需要分组代替内部节点与外部节点相连。
130
- getAnchorStyle() {
131
- const style = super.getAnchorStyle()
132
- style.stroke = '#000'
133
- style.fill = '#fff'
134
- if (!style.hover) {
135
- style.hover = {}
136
- }
137
- style.hover.stroke = 'transparent'
138
- return style
139
- }
140
-
141
- getOutlineStyle() {
142
- const style = super.getOutlineStyle()
143
- style.stroke = 'transparent'
144
- if (!style.hover) {
145
- style.hover = {}
146
- }
147
- style.hover.stroke = 'transparent'
148
- return style
149
- }
150
-
151
- /**
152
- * 提供方法给插件在判断此节点被拖动边界事件节点靠近时调用,从而触发高亮
153
- */
154
- setTouching(flag: boolean) {
155
- this.setProperty('isBoundaryEventTouchingTask', flag)
156
- }
157
-
158
- /**
159
- * 附加后记录被附加的边界事件节点Id
160
- */
161
- addBoundaryEvent(nodeId: string) {
162
- this.setTouching(false)
163
- if (this.boundaryEvents.find((item: string) => item === nodeId)) {
164
- return false
165
- }
166
- const boundaryEvent = this.graphModel.getNodeModelById(nodeId)
167
- boundaryEvent?.setProperties({
168
- attachedToRef: this.id,
169
- })
170
- this.boundaryEvents.push(nodeId)
171
- return true
172
- }
173
-
174
- /**
175
- * 被附加的边界事件节点被删除时,移除记录
176
- */
177
- deleteBoundaryEvent(nodeId: string) {
178
- this.boundaryEvents = this.boundaryEvents.filter(
179
- (item: string) => item !== nodeId,
180
- )
181
- }
182
- }
183
-
184
- return {
185
- type: 'bpmn:subProcess',
186
- view,
187
- model,
188
- }
189
- }
@@ -1,193 +0,0 @@
1
- import LogicFlow, {
2
- h,
3
- GraphModel,
4
- RectNode,
5
- RectNodeModel,
6
- } from '@logicflow/core'
7
- import { parallelMarker, sequentialMarker, loopMarker } from '../icons'
8
- import { genBpmnId, groupRule } from '../../utils'
9
-
10
- import NodeConfig = LogicFlow.NodeConfig
11
-
12
- export const multiInstanceIcon: any = {
13
- parallel: parallelMarker,
14
- sequential: sequentialMarker,
15
- loop: loopMarker,
16
- }
17
-
18
- type TaskType = {
19
- multiInstanceType: string
20
- properties: Record<string, any>
21
- [key: string]: any
22
- }
23
-
24
- /**
25
- * @param type 任务节点的type, 对应其XML定义中的节点名,如<bpmn:userTask /> 其type为bpmn:userTask
26
- * @param icon 任务节点左上角的图标,可以是svg path,也可以是h函数生成的svg
27
- * @param props (可选) 任务节点的属性
28
- * @returns { type: string, model: any, view: any }
29
- */
30
- export function TaskNodeFactory(
31
- type: string,
32
- icon: string | any[],
33
- props?: any,
34
- ): {
35
- type: string
36
- model: any
37
- view: any
38
- } {
39
- class view extends RectNode {
40
- getLabelShape() {
41
- // @ts-ignore
42
- const { model } = this.props
43
- const { x, y, width, height } = model
44
- const style = model.getNodeStyle()
45
- const i = Array.isArray(icon)
46
- ? h(
47
- 'g',
48
- {
49
- transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
50
- },
51
- ...icon,
52
- )
53
- : h('path', {
54
- fill: style.stroke,
55
- d: icon,
56
- })
57
- return h(
58
- 'svg',
59
- {
60
- x: x - width / 2 + 5,
61
- y: y - height / 2 + 5,
62
- width: 25,
63
- height: 25,
64
- viewBox: '0 0 1274 1024',
65
- },
66
- i,
67
- )
68
- }
69
-
70
- getShape() {
71
- // @ts-ignore
72
- const { model } = this.props
73
- const { x, y, width, height, radius, properties } = model
74
- const style = model.getNodeStyle()
75
- return h('g', {}, [
76
- h('rect', {
77
- ...style,
78
- x: x - width / 2,
79
- y: y - height / 2,
80
- rx: radius,
81
- ry: radius,
82
- width,
83
- height,
84
- opacity: 0.95,
85
- }),
86
- this.getLabelShape(),
87
- h(
88
- 'g',
89
- {
90
- transform: `matrix(1 0 0 1 ${x - width / 2} ${y - height / 2})`,
91
- },
92
- h('path', {
93
- fill: 'white',
94
- strokeLinecap: 'round',
95
- strokeLinejoin: 'round',
96
- stroke: 'rgb(34, 36, 42)',
97
- strokeWidth: '2',
98
- d: multiInstanceIcon[properties.multiInstanceType as any] || '', // TODO: 确认 properties.multiInstanceType 的类型
99
- }),
100
- ),
101
- ])
102
- }
103
- }
104
-
105
- class model extends RectNodeModel {
106
- boundaryEvents: any // TODO: 确认该属性类型,可移除查看其导致的问题
107
-
108
- constructor(data: NodeConfig, graphModel: GraphModel) {
109
- if (!data.id) {
110
- data.id = `Activity_${genBpmnId()}`
111
- }
112
- const properties: TaskType = {
113
- ...(props || {}),
114
- ...data.properties,
115
- // multiInstanceType: '',
116
- // panels: ['multiInstance'],
117
- }
118
- data.properties = properties
119
- super(data, graphModel)
120
- properties?.boundaryEvents?.forEach((id: string) => {
121
- this.addBoundaryEvent(id)
122
- })
123
- this.deleteProperty('boundaryEvents')
124
- groupRule.call(this)
125
- }
126
-
127
- initNodeData(data: any) {
128
- super.initNodeData(data)
129
- this.isTaskNode = true // 标识此节点是任务节点,可以被附件边界事件
130
- this.boundaryEvents = [] // 记录自己附加的边界事件
131
- }
132
-
133
- getNodeStyle() {
134
- const style = super.getNodeStyle()
135
- // isBoundaryEventTouchingTask属性用于标识拖动边界节点是否靠近此节点
136
- // 如果靠近,则高亮提示
137
- // style.fill = 'rgb(255, 230, 204)';
138
- const { isBoundaryEventTouchingTask } = this.properties
139
- if (isBoundaryEventTouchingTask) {
140
- style.stroke = '#00acff'
141
- style.strokeWidth = 2
142
- }
143
- return style
144
- }
145
-
146
- getOutlineStyle() {
147
- const style = super.getOutlineStyle()
148
- style.stroke = 'transparent'
149
- !style.hover && (style.hover = {})
150
- style.hover.stroke = 'transparent'
151
- return style
152
- }
153
-
154
- /**
155
- * 提供方法给插件在判断此节点被拖动边界事件节点靠近时调用,从而触发高亮
156
- */
157
- setTouching(flag: boolean) {
158
- this.setProperty('isBoundaryEventTouchingTask', flag)
159
- }
160
-
161
- /**
162
- * 附加后记录被附加的边界事件节点Id
163
- */
164
- addBoundaryEvent(nodeId: string) {
165
- this.setTouching(false)
166
- if (this.boundaryEvents.find((item: string) => item === nodeId)) {
167
- return false
168
- }
169
- const boundaryEvent = this.graphModel.getNodeModelById(nodeId)
170
- boundaryEvent?.setProperties({
171
- attachedToRef: this.id,
172
- })
173
- this.boundaryEvents.push(nodeId)
174
- return true
175
- }
176
-
177
- /**
178
- * 被附加的边界事件节点被删除时,移除记录
179
- */
180
- deleteBoundaryEvent(nodeId: string) {
181
- this.boundaryEvents = this.boundaryEvents.filter(
182
- (item: string) => item !== nodeId,
183
- )
184
- }
185
- }
186
-
187
- // @ts-ignore
188
- return {
189
- type,
190
- view,
191
- model,
192
- }
193
- }