@logicflow/extension 2.0.18 → 2.0.20

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.
@@ -29,7 +29,7 @@ function getAttributes(obj) {
29
29
  }
30
30
  }
31
31
  catch (error) {
32
- tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, '\'');
32
+ tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, "'");
33
33
  }
34
34
  return tmp;
35
35
  }
@@ -59,18 +59,15 @@ function toXml(obj, name, depth) {
59
59
  else if (type(obj) === '[object Object]') {
60
60
  var keys = Object.keys(obj);
61
61
  var attributes_1 = '';
62
- var children_1 = obj['-json']
63
- ? tn + addSpace(depth + 1) + obj['-json']
64
- : '';
62
+ var children_1 = obj['-json'] ? tn + addSpace(depth + 1) + obj['-json'] : '';
65
63
  str += "".concat(depth === 0 ? '' : prefix, "<").concat(name);
66
64
  keys.forEach(function (k) {
67
65
  k.charAt(0) === '-'
68
66
  ? (attributes_1 += toXml(obj[k], k, depth + 1))
69
67
  : (children_1 += toXml(obj[k], k, depth + 1));
70
68
  });
71
- str
72
- += attributes_1
73
- + (children_1 !== '' ? ">".concat(children_1).concat(prefix, "</").concat(name, ">") : ' />');
69
+ str +=
70
+ attributes_1 + (children_1 !== '' ? ">".concat(children_1).concat(prefix, "</").concat(name, ">") : ' />');
74
71
  }
75
72
  else {
76
73
  str += "".concat(prefix, "<").concat(name, ">").concat(obj.toString(), "</").concat(name, ">");
@@ -94,6 +94,7 @@ var DynamicGroupNodeModel = /** @class */ (function (_super) {
94
94
  this.children = children ? new Set(children) : new Set();
95
95
  this.zIndex = zIndex !== null && zIndex !== void 0 ? zIndex : DEFAULT_BOTTOM_Z_INDEX;
96
96
  this.isCollapsed = isCollapsed !== null && isCollapsed !== void 0 ? isCollapsed : false;
97
+ this.setProperties({ isCollapsed: isCollapsed !== null && isCollapsed !== void 0 ? isCollapsed : false });
97
98
  var expandWidth = width !== null && width !== void 0 ? width : DEFAULT_GROUP_EXPAND_WIDTH;
98
99
  var expandHeight = height !== null && height !== void 0 ? height : DEFAULT_GROUP_EXPAND_HEIGHT;
99
100
  // 初始化分组节点的宽高数据
@@ -182,8 +183,15 @@ var DynamicGroupNodeModel = /** @class */ (function (_super) {
182
183
  */
183
184
  DynamicGroupNodeModel.prototype.toggleCollapse = function (collapse) {
184
185
  var _this = this;
186
+ var graphModel = this.graphModel;
185
187
  var nextCollapseState = !!collapse;
188
+ // DONE: 通过 setProperty 设置 isCollapsed 的值 -> 否则无法触发 node:properties-changed 事件
186
189
  this.isCollapsed = nextCollapseState;
190
+ this.setProperties({ isCollapsed: nextCollapseState });
191
+ graphModel.eventCenter.emit('dynamicGroup:collapse', {
192
+ collapse: nextCollapseState,
193
+ nodeModel: this,
194
+ });
187
195
  // step 1
188
196
  if (nextCollapseState) {
189
197
  this.collapse();
@@ -259,6 +259,7 @@ var DynamicGroupNode = /** @class */ (function (_super) {
259
259
  x: sx,
260
260
  y: sy,
261
261
  onClick: function () {
262
+ // DONE: 抛出折叠或展开事件 -> 在 toggleCollapse 方法中抛出
262
263
  model.toggleCollapse(!model.isCollapsed);
263
264
  },
264
265
  }),
@@ -294,7 +294,7 @@ export var calcLabelPositionOnPolyline = function (point, edge) {
294
294
  y: minY + (maxY - minY) * yDeltaPercent,
295
295
  };
296
296
  return isPointOnEdge
297
- ? (_b = getNewPointAtDistance(points, ratio)) !== null && _b !== void 0 ? _b : point // 函数什么意思
297
+ ? ((_b = getNewPointAtDistance(points, ratio)) !== null && _b !== void 0 ? _b : point) // 函数什么意思
298
298
  : positByPercent;
299
299
  }
300
300
  // 如果文本在凸包的上方或者下方
package/jest.config.js CHANGED
@@ -195,4 +195,4 @@ module.exports = {
195
195
 
196
196
  // Whether to use watchman for file crawling
197
197
  // watchman: true,
198
- };
198
+ }
@@ -33,7 +33,7 @@ function getAttributes(obj) {
33
33
  }
34
34
  }
35
35
  catch (error) {
36
- tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, '\'');
36
+ tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, "'");
37
37
  }
38
38
  return tmp;
39
39
  }
@@ -63,18 +63,15 @@ function toXml(obj, name, depth) {
63
63
  else if (type(obj) === '[object Object]') {
64
64
  var keys = Object.keys(obj);
65
65
  var attributes_1 = '';
66
- var children_1 = obj['-json']
67
- ? tn + addSpace(depth + 1) + obj['-json']
68
- : '';
66
+ var children_1 = obj['-json'] ? tn + addSpace(depth + 1) + obj['-json'] : '';
69
67
  str += "".concat(depth === 0 ? '' : prefix, "<").concat(name);
70
68
  keys.forEach(function (k) {
71
69
  k.charAt(0) === '-'
72
70
  ? (attributes_1 += toXml(obj[k], k, depth + 1))
73
71
  : (children_1 += toXml(obj[k], k, depth + 1));
74
72
  });
75
- str
76
- += attributes_1
77
- + (children_1 !== '' ? ">".concat(children_1).concat(prefix, "</").concat(name, ">") : ' />');
73
+ str +=
74
+ attributes_1 + (children_1 !== '' ? ">".concat(children_1).concat(prefix, "</").concat(name, ">") : ' />');
78
75
  }
79
76
  else {
80
77
  str += "".concat(prefix, "<").concat(name, ">").concat(obj.toString(), "</").concat(name, ">");
@@ -97,6 +97,7 @@ var DynamicGroupNodeModel = /** @class */ (function (_super) {
97
97
  this.children = children ? new Set(children) : new Set();
98
98
  this.zIndex = zIndex !== null && zIndex !== void 0 ? zIndex : DEFAULT_BOTTOM_Z_INDEX;
99
99
  this.isCollapsed = isCollapsed !== null && isCollapsed !== void 0 ? isCollapsed : false;
100
+ this.setProperties({ isCollapsed: isCollapsed !== null && isCollapsed !== void 0 ? isCollapsed : false });
100
101
  var expandWidth = width !== null && width !== void 0 ? width : DEFAULT_GROUP_EXPAND_WIDTH;
101
102
  var expandHeight = height !== null && height !== void 0 ? height : DEFAULT_GROUP_EXPAND_HEIGHT;
102
103
  // 初始化分组节点的宽高数据
@@ -185,8 +186,15 @@ var DynamicGroupNodeModel = /** @class */ (function (_super) {
185
186
  */
186
187
  DynamicGroupNodeModel.prototype.toggleCollapse = function (collapse) {
187
188
  var _this = this;
189
+ var graphModel = this.graphModel;
188
190
  var nextCollapseState = !!collapse;
191
+ // DONE: 通过 setProperty 设置 isCollapsed 的值 -> 否则无法触发 node:properties-changed 事件
189
192
  this.isCollapsed = nextCollapseState;
193
+ this.setProperties({ isCollapsed: nextCollapseState });
194
+ graphModel.eventCenter.emit('dynamicGroup:collapse', {
195
+ collapse: nextCollapseState,
196
+ nodeModel: this,
197
+ });
190
198
  // step 1
191
199
  if (nextCollapseState) {
192
200
  this.collapse();
@@ -262,6 +262,7 @@ var DynamicGroupNode = /** @class */ (function (_super) {
262
262
  x: sx,
263
263
  y: sy,
264
264
  onClick: function () {
265
+ // DONE: 抛出折叠或展开事件 -> 在 toggleCollapse 方法中抛出
265
266
  model.toggleCollapse(!model.isCollapsed);
266
267
  },
267
268
  }),
@@ -305,7 +305,7 @@ var calcLabelPositionOnPolyline = function (point, edge) {
305
305
  y: minY + (maxY - minY) * yDeltaPercent,
306
306
  };
307
307
  return isPointOnEdge
308
- ? (_b = (0, exports.getNewPointAtDistance)(points, ratio)) !== null && _b !== void 0 ? _b : point // 函数什么意思
308
+ ? ((_b = (0, exports.getNewPointAtDistance)(points, ratio)) !== null && _b !== void 0 ? _b : point) // 函数什么意思
309
309
  : positByPercent;
310
310
  }
311
311
  // 如果文本在凸包的上方或者下方
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/extension",
3
- "version": "2.0.18",
3
+ "version": "2.0.20",
4
4
  "description": "LogicFlow Extensions",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "author": "Logicflow-Team",
21
21
  "license": "Apache-2.0",
22
22
  "peerDependencies": {
23
- "@logicflow/core": "2.0.13"
23
+ "@logicflow/core": "2.0.15"
24
24
  },
25
25
  "dependencies": {
26
26
  "@antv/hierarchy": "^0.6.11",
@@ -31,7 +31,7 @@
31
31
  "preact": "^10.17.1",
32
32
  "rangy": "^1.3.1",
33
33
  "vanilla-picker": "^2.12.3",
34
- "@logicflow/core": "2.0.13"
34
+ "@logicflow/core": "2.0.15"
35
35
  },
36
36
  "devDependencies": {
37
37
  "less": "^4.1.1",
@@ -1,26 +1,26 @@
1
1
  type DefinitionConfigType = {
2
- nodes: string[];
3
- definition: EventDefinitionType[] | TaskDefinitionType[];
4
- };
2
+ nodes: string[]
3
+ definition: EventDefinitionType[] | TaskDefinitionType[]
4
+ }
5
5
 
6
6
  type DefinitionPropertiesType = {
7
- definitionType: string;
8
- timerType?: TimerType;
9
- timerValue?: string;
10
- [key: string]: any;
11
- };
7
+ definitionType: string
8
+ timerType?: TimerType
9
+ timerValue?: string
10
+ [key: string]: any
11
+ }
12
12
 
13
13
  type EventDefinitionType = {
14
- type: string;
15
- icon: string | Object;
16
- toJSON: Function;
17
- properties: DefinitionPropertiesType;
18
- [key: string]: any;
19
- };
14
+ type: string
15
+ icon: string | Object
16
+ toJSON: Function
17
+ properties: DefinitionPropertiesType
18
+ [key: string]: any
19
+ }
20
20
 
21
21
  type TaskDefinitionType = {
22
- type: string;
23
- [key: string]: any;
24
- };
22
+ type: string
23
+ [key: string]: any
24
+ }
25
25
 
26
- type TimerType = 'timerCycle' | 'timerDate' | 'timerDuration';
26
+ type TimerType = 'timerCycle' | 'timerDate' | 'timerDuration'
@@ -1,6 +1,6 @@
1
1
  export type BBoxType = {
2
- minX: number;
3
- minY: number;
4
- maxX: number;
5
- maxY: number;
2
+ minX: number
3
+ minY: number
4
+ maxX: number
5
+ maxY: number
6
6
  }
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable no-new */
4
4
  /* eslint-disable no-undef */
5
5
  /* eslint-disable no-tabs */
6
- import { BPMNAdapter } from '..';
6
+ import { BPMNAdapter } from '..'
7
7
 
8
8
  describe('Test BPMNAdapter: import xml', () => {
9
9
  const graphData = {
@@ -349,7 +349,7 @@ describe('Test BPMNAdapter: import xml', () => {
349
349
  ],
350
350
  },
351
351
  ],
352
- };
352
+ }
353
353
  const xml = ` <bpmn:definitions id="Definitions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://logic-flow.org" exporter="logicflow" exporterVersion="1.2.10">
354
354
  <bpmn:process isExecutable="true" id="Process">
355
355
  <bpmn:startEvent id="Event_0rqndvp" name="开始" />
@@ -511,16 +511,18 @@ describe('Test BPMNAdapter: import xml', () => {
511
511
  </bpmndi:BPMNShape>
512
512
  </bpmndi:BPMNPlane>
513
513
  </bpmndi:BPMNDiagram>
514
- </bpmn:definitions>`;
515
- const lf = {};
516
- const adapter = new BPMNAdapter({ lf });
514
+ </bpmn:definitions>`
515
+ const lf = {}
516
+ const adapter = new BPMNAdapter({ lf })
517
517
 
518
518
  // 导入时会处理内部会出boundaryEvents(配合Bpmn节点插件中的task、subProcess使用)但是在这里不需要,所以需要extraProps来过滤掉它
519
519
  it('should convert bpmn to graph data', () => {
520
- expect(adapter.adapterXmlIn(xml, {
521
- excludeFields: {
522
- in: ['properties.boundaryEvents'],
523
- },
524
- })).toEqual(graphData);
525
- });
526
- });
520
+ expect(
521
+ adapter.adapterXmlIn(xml, {
522
+ excludeFields: {
523
+ in: ['properties.boundaryEvents'],
524
+ },
525
+ }),
526
+ ).toEqual(graphData)
527
+ })
528
+ })
@@ -3,7 +3,7 @@
3
3
  /* eslint-disable no-new */
4
4
  /* eslint-disable no-undef */
5
5
  /* eslint-disable no-tabs */
6
- import { BPMNAdapter } from '..';
6
+ import { BPMNAdapter } from '..'
7
7
 
8
8
  describe('Test BPMNAdapter: export xml', () => {
9
9
  const graphData = {
@@ -397,7 +397,7 @@ describe('Test BPMNAdapter: export xml', () => {
397
397
  ],
398
398
  },
399
399
  ],
400
- };
400
+ }
401
401
  const xml = ` <bpmn:definitions id="Definitions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" targetNamespace="http://logic-flow.org" exporter="logicflow" exporterVersion="1.2.10">
402
402
  <bpmn:process isExecutable="true" id="Process">
403
403
  <bpmn:startEvent id="Event_0rqndvp" name="开始" />
@@ -559,11 +559,11 @@ describe('Test BPMNAdapter: export xml', () => {
559
559
  </bpmndi:BPMNShape>
560
560
  </bpmndi:BPMNPlane>
561
561
  </bpmndi:BPMNDiagram>
562
- </bpmn:definitions>`;
563
- const lf = {};
564
- const adapter = new BPMNAdapter({ lf });
562
+ </bpmn:definitions>`
563
+ const lf = {}
564
+ const adapter = new BPMNAdapter({ lf })
565
565
 
566
566
  it('should transform logic-flow graph data to bpmn xml', () => {
567
- expect(adapter.adapterXmlOut(graphData)).toEqual(xml);
568
- });
569
- });
567
+ expect(adapter.adapterXmlOut(graphData)).toEqual(xml)
568
+ })
569
+ })
@@ -1,52 +1,52 @@
1
1
  export const StartEventConfig = {
2
2
  width: 40,
3
3
  height: 40,
4
- };
4
+ }
5
5
 
6
6
  export const EndEventConfig = {
7
7
  width: 40,
8
8
  height: 40,
9
- };
9
+ }
10
10
 
11
11
  export const BoundaryEventConfig = {
12
12
  width: 100,
13
13
  height: 80,
14
- };
14
+ }
15
15
 
16
16
  export const IntermediateEventConfig = {
17
17
  width: 100,
18
18
  height: 80,
19
- };
19
+ }
20
20
 
21
21
  export const ParallelGatewayConfig = {
22
22
  width: 100,
23
23
  height: 80,
24
- };
24
+ }
25
25
 
26
26
  export const InclusiveGatewayConfig = {
27
27
  width: 100,
28
28
  height: 80,
29
- };
29
+ }
30
30
 
31
31
  export const ExclusiveGatewayConfig = {
32
32
  width: 100,
33
33
  height: 80,
34
- };
34
+ }
35
35
 
36
36
  export const ServiceTaskConfig = {
37
37
  width: 100,
38
38
  height: 80,
39
- };
39
+ }
40
40
 
41
41
  export const UserTaskConfig = {
42
42
  width: 100,
43
43
  height: 80,
44
- };
44
+ }
45
45
 
46
46
  export const SubProcessConfig = {
47
47
  width: 100,
48
48
  height: 80,
49
- };
49
+ }
50
50
 
51
51
  export const theme = {
52
52
  rect: {
@@ -73,4 +73,4 @@ export const theme = {
73
73
  radius: 3,
74
74
  },
75
75
  },
76
- };
76
+ }
@@ -1,91 +1,91 @@
1
1
  /* eslint-disable guard-for-in */
2
2
  function type(obj: any) {
3
- return Object.prototype.toString.call(obj);
3
+ return Object.prototype.toString.call(obj)
4
4
  }
5
5
 
6
6
  function addSpace(depth: number) {
7
- return ' '.repeat(depth);
7
+ return ' '.repeat(depth)
8
8
  }
9
9
 
10
10
  function handleAttributes(obj: any): any {
11
11
  if (type(obj) === '[object Object]') {
12
12
  return Object.keys(obj).reduce((tmp: any, key: string) => {
13
- let tmpKey = key;
13
+ let tmpKey = key
14
14
  if (key.charAt(0) === '-') {
15
- tmpKey = key.substring(1);
15
+ tmpKey = key.substring(1)
16
16
  }
17
- tmp[tmpKey] = handleAttributes(obj[key]);
18
- return tmp;
19
- }, {});
20
- } if (Array.isArray(obj)) {
21
- return obj.map((item) => handleAttributes(item));
17
+ tmp[tmpKey] = handleAttributes(obj[key])
18
+ return tmp
19
+ }, {})
22
20
  }
23
- return obj;
21
+ if (Array.isArray(obj)) {
22
+ return obj.map((item) => handleAttributes(item))
23
+ }
24
+ return obj
24
25
  }
25
26
 
26
27
  function getAttributes(obj: any) {
27
- let tmp = obj;
28
+ let tmp = obj
28
29
  try {
29
30
  if (typeof tmp !== 'string') {
30
- tmp = JSON.parse(obj);
31
+ tmp = JSON.parse(obj)
31
32
  }
32
33
  } catch (error) {
33
- tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, '\'');
34
+ tmp = JSON.stringify(handleAttributes(obj)).replace(/"/g, "'")
34
35
  }
35
- return tmp;
36
+ return tmp
36
37
  }
37
38
 
38
- const tn = '\t\n';
39
+ const tn = '\t\n'
39
40
 
40
41
  // @see issue https://github.com/didi/LogicFlow/issues/718, refactoring of function toXml
41
42
  function toXml(obj: any, name: string, depth: number) {
42
- const frontSpace = addSpace(depth);
43
- let str = '';
44
- const prefix = tn + frontSpace;
45
- if (name === '-json') return '';
43
+ const frontSpace = addSpace(depth)
44
+ let str = ''
45
+ const prefix = tn + frontSpace
46
+ if (name === '-json') return ''
46
47
  if (name === '#text') {
47
- return prefix + obj;
48
- } if (name === '#cdata-section') {
49
- return `${prefix}<![CDATA[${obj}]]>`;
50
- } if (name === '#comment') {
51
- return `${prefix}<!--${obj}-->`;
48
+ return prefix + obj
49
+ }
50
+ if (name === '#cdata-section') {
51
+ return `${prefix}<![CDATA[${obj}]]>`
52
+ }
53
+ if (name === '#comment') {
54
+ return `${prefix}<!--${obj}-->`
52
55
  }
53
56
  if (`${name}`.charAt(0) === '-') {
54
- return ` ${name.substring(1)}="${getAttributes(obj)}"`;
57
+ return ` ${name.substring(1)}="${getAttributes(obj)}"`
55
58
  }
56
59
  if (Array.isArray(obj)) {
57
- str += obj.map((item) => toXml(item, name, depth + 1)).join('');
60
+ str += obj.map((item) => toXml(item, name, depth + 1)).join('')
58
61
  } else if (type(obj) === '[object Object]') {
59
- const keys = Object.keys(obj);
60
- let attributes = '';
61
- let children = obj['-json']
62
- ? tn + addSpace(depth + 1) + obj['-json']
63
- : '';
62
+ const keys = Object.keys(obj)
63
+ let attributes = ''
64
+ let children = obj['-json'] ? tn + addSpace(depth + 1) + obj['-json'] : ''
64
65
 
65
- str += `${depth === 0 ? '' : prefix}<${name}`;
66
+ str += `${depth === 0 ? '' : prefix}<${name}`
66
67
 
67
68
  keys.forEach((k) => {
68
69
  k.charAt(0) === '-'
69
70
  ? (attributes += toXml(obj[k], k, depth + 1))
70
- : (children += toXml(obj[k], k, depth + 1));
71
- });
71
+ : (children += toXml(obj[k], k, depth + 1))
72
+ })
72
73
 
73
- str
74
- += attributes
75
- + (children !== '' ? `>${children}${prefix}</${name}>` : ' />');
74
+ str +=
75
+ attributes + (children !== '' ? `>${children}${prefix}</${name}>` : ' />')
76
76
  } else {
77
- str += `${prefix}<${name}>${obj.toString()}</${name}>`;
77
+ str += `${prefix}<${name}>${obj.toString()}</${name}>`
78
78
  }
79
79
 
80
- return str;
80
+ return str
81
81
  }
82
82
 
83
83
  function lfJson2Xml(obj: any) {
84
- let xmlStr = '';
84
+ let xmlStr = ''
85
85
  for (const key in obj) {
86
- xmlStr += toXml(obj[key], key, 0);
86
+ xmlStr += toXml(obj[key], key, 0)
87
87
  }
88
- return xmlStr;
88
+ return xmlStr
89
89
  }
90
90
 
91
- export { lfJson2Xml, handleAttributes };
91
+ export { lfJson2Xml, handleAttributes }
@@ -134,6 +134,7 @@ export class DynamicGroupNodeModel extends RectNodeModel<IGroupNodeProperties> {
134
134
  this.children = children ? new Set(children) : new Set()
135
135
  this.zIndex = zIndex ?? DEFAULT_BOTTOM_Z_INDEX
136
136
  this.isCollapsed = isCollapsed ?? false
137
+ this.setProperties({ isCollapsed: isCollapsed ?? false })
137
138
 
138
139
  const expandWidth = width ?? DEFAULT_GROUP_EXPAND_WIDTH
139
140
  const expandHeight = height ?? DEFAULT_GROUP_EXPAND_HEIGHT
@@ -249,8 +250,17 @@ export class DynamicGroupNodeModel extends RectNodeModel<IGroupNodeProperties> {
249
250
  * @param collapse {boolean} true -> 折叠;false -> 展开
250
251
  */
251
252
  toggleCollapse(collapse?: boolean) {
253
+ const { graphModel } = this
252
254
  const nextCollapseState = !!collapse
255
+ // DONE: 通过 setProperty 设置 isCollapsed 的值 -> 否则无法触发 node:properties-changed 事件
253
256
  this.isCollapsed = nextCollapseState
257
+ this.setProperties({ isCollapsed: nextCollapseState })
258
+
259
+ graphModel.eventCenter.emit('dynamicGroup:collapse', {
260
+ collapse: nextCollapseState,
261
+ nodeModel: this,
262
+ })
263
+
254
264
  // step 1
255
265
  if (nextCollapseState) {
256
266
  this.collapse()
@@ -268,6 +268,7 @@ export class DynamicGroupNode<
268
268
  x: sx,
269
269
  y: sy,
270
270
  onClick: () => {
271
+ // DONE: 抛出折叠或展开事件 -> 在 toggleCollapse 方法中抛出
271
272
  model.toggleCollapse(!model.isCollapsed)
272
273
  },
273
274
  }),
@@ -1,43 +1,46 @@
1
- import { getCurvedEdgePath } from '../index';
1
+ import { getCurvedEdgePath } from '../index'
2
2
 
3
3
  describe('test curved edge ', () => {
4
4
  test('path calculation', () => {
5
- const radius = 5;
5
+ const radius = 5
6
6
 
7
- const points1 = '460,150 670,150';
8
- const path1 = 'M460 150 L 670 150';
7
+ const points1 = '460,150 670,150'
8
+ const path1 = 'M460 150 L 670 150'
9
9
  expect(
10
10
  getCurvedEdgePath(
11
11
  points1.split(' ').map((p) => p.split(',').map((a) => +a)),
12
12
  radius,
13
13
  ),
14
- ).toBe(path1);
14
+ ).toBe(path1)
15
15
 
16
- const points2 = '510,250 540,250 540,175 490,175 490,100 520,100';
17
- const path2 = 'M510 250L 510 250L 535 250 Q 540 250 540 245L 540 245L 540 180 Q 540 175 535 175L 535 175L 495 175 Q 490 175 490 170L 490 170L 490 105 Q 490 100 495 100L 520 100';
16
+ const points2 = '510,250 540,250 540,175 490,175 490,100 520,100'
17
+ const path2 =
18
+ 'M510 250L 510 250L 535 250 Q 540 250 540 245L 540 245L 540 180 Q 540 175 535 175L 535 175L 495 175 Q 490 175 490 170L 490 170L 490 105 Q 490 100 495 100L 520 100'
18
19
  expect(
19
20
  getCurvedEdgePath(
20
21
  points2.split(' ').map((p) => p.split(',').map((a) => +a)),
21
22
  radius,
22
23
  ),
23
- ).toBe(path2);
24
+ ).toBe(path2)
24
25
 
25
- const points3 = '690,120 720,120 720,50 560,50 560,260 690,260';
26
- const path3 = 'M690 120L 690 120L 715 120 Q 720 120 720 115L 720 115L 720 55 Q 720 50 715 50L 715 50L 565 50 Q 560 50 560 55L 560 55L 560 255 Q 560 260 565 260L 690 260';
26
+ const points3 = '690,120 720,120 720,50 560,50 560,260 690,260'
27
+ const path3 =
28
+ 'M690 120L 690 120L 715 120 Q 720 120 720 115L 720 115L 720 55 Q 720 50 715 50L 715 50L 565 50 Q 560 50 560 55L 560 55L 560 255 Q 560 260 565 260L 690 260'
27
29
  expect(
28
30
  getCurvedEdgePath(
29
31
  points3.split(' ').map((p) => p.split(',').map((a) => +a)),
30
32
  radius,
31
33
  ),
32
- ).toBe(path3);
34
+ ).toBe(path3)
33
35
 
34
- const point4 = '690,180 690,210 660,210 660,190 630,190 630,220';
35
- const path4 = 'M690 180L 690 180L 690 205 Q 690 210 685 210L 685 210L 665 210 Q 660 210 660 205L 660 205L 660 195 Q 660 190 655 190L 655 190L 635 190 Q 630 190 630 195L 630 220';
36
+ const point4 = '690,180 690,210 660,210 660,190 630,190 630,220'
37
+ const path4 =
38
+ 'M690 180L 690 180L 690 205 Q 690 210 685 210L 685 210L 665 210 Q 660 210 660 205L 660 205L 660 195 Q 660 190 655 190L 655 190L 635 190 Q 630 190 630 195L 630 220'
36
39
  expect(
37
40
  getCurvedEdgePath(
38
41
  point4.split(' ').map((p) => p.split(',').map((a) => +a)),
39
42
  radius,
40
43
  ),
41
- ).toBe(path4);
42
- });
43
- });
44
+ ).toBe(path4)
45
+ })
46
+ })
@@ -350,7 +350,7 @@ export const calcLabelPositionOnPolyline = (
350
350
  y: minY + (maxY - minY) * yDeltaPercent,
351
351
  }
352
352
  return isPointOnEdge
353
- ? getNewPointAtDistance(points, ratio) ?? point // 函数什么意思
353
+ ? (getNewPointAtDistance(points, ratio) ?? point) // 函数什么意思
354
354
  : positByPercent
355
355
  }
356
356
  // 如果文本在凸包的上方或者下方