@logicflow/extension 2.0.6 → 2.0.8

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.
@@ -1,3 +1,8 @@
1
1
  declare function handleAttributes(o: any): any;
2
+ /**
3
+ * json 转 xml
4
+ * @param o object
5
+ * @returns
6
+ */
2
7
  declare function lfJson2Xml(o: Object): string;
3
8
  export { lfJson2Xml, handleAttributes };
@@ -40,6 +40,10 @@ var tn = '\t\n';
40
40
  // @see issue https://github.com/didi/LogicFlow/issues/718, refactoring of function toXml
41
41
  function toXml(obj, name, depth) {
42
42
  var frontSpace = addSpace(depth);
43
+ // 假值除 0、false 外 -> 直接返回空元素 <prop />
44
+ if (obj !== 0 && obj !== false && !obj) {
45
+ return tn + frontSpace + "<".concat(name, " />");
46
+ }
43
47
  var str = '';
44
48
  if (name === '#text') {
45
49
  return tn + frontSpace + obj;
@@ -79,6 +83,11 @@ function toXml(obj, name, depth) {
79
83
  }
80
84
  return str;
81
85
  }
86
+ /**
87
+ * json 转 xml
88
+ * @param o object
89
+ * @returns
90
+ */
82
91
  function lfJson2Xml(o) {
83
92
  var xmlStr = '';
84
93
  for (var m in o) {
@@ -1,2 +1,7 @@
1
+ /**
2
+ * xml 转 json
3
+ * @param xmlData
4
+ * @returns
5
+ */
1
6
  declare const lfXml2Json: (xmlData: any) => any;
2
7
  export { lfXml2Json };
@@ -543,6 +543,11 @@ which I will do instead of keeping this documentation like it is.
543
543
  =cut
544
544
  // ========================================================================
545
545
  */
546
+ /**
547
+ * xml 转 json
548
+ * @param xmlData
549
+ * @returns
550
+ */
546
551
  var lfXml2Json = function (xmlData) {
547
552
  return new XML.ObjTree().parseXML(xmlData);
548
553
  };
@@ -237,6 +237,7 @@ var Label = /** @class */ (function () {
237
237
  var data = _a.data;
238
238
  var element = graphModel.getElement(data.id);
239
239
  if (element) {
240
+ _this.rewriteInnerMethods(element);
240
241
  var formatedLabel = _this.formatConfig(graphModel, data);
241
242
  element.setProperty('_label', formatedLabel);
242
243
  }
@@ -1,3 +1,8 @@
1
1
  declare function handleAttributes(o: any): any;
2
+ /**
3
+ * json 转 xml
4
+ * @param o object
5
+ * @returns
6
+ */
2
7
  declare function lfJson2Xml(o: Object): string;
3
8
  export { lfJson2Xml, handleAttributes };
@@ -44,6 +44,10 @@ var tn = '\t\n';
44
44
  // @see issue https://github.com/didi/LogicFlow/issues/718, refactoring of function toXml
45
45
  function toXml(obj, name, depth) {
46
46
  var frontSpace = addSpace(depth);
47
+ // 假值除 0、false 外 -> 直接返回空元素 <prop />
48
+ if (obj !== 0 && obj !== false && !obj) {
49
+ return tn + frontSpace + "<".concat(name, " />");
50
+ }
47
51
  var str = '';
48
52
  if (name === '#text') {
49
53
  return tn + frontSpace + obj;
@@ -83,6 +87,11 @@ function toXml(obj, name, depth) {
83
87
  }
84
88
  return str;
85
89
  }
90
+ /**
91
+ * json 转 xml
92
+ * @param o object
93
+ * @returns
94
+ */
86
95
  function lfJson2Xml(o) {
87
96
  var xmlStr = '';
88
97
  for (var m in o) {
@@ -1,2 +1,7 @@
1
+ /**
2
+ * xml 转 json
3
+ * @param xmlData
4
+ * @returns
5
+ */
1
6
  declare const lfXml2Json: (xmlData: any) => any;
2
7
  export { lfXml2Json };
@@ -546,6 +546,11 @@ which I will do instead of keeping this documentation like it is.
546
546
  =cut
547
547
  // ========================================================================
548
548
  */
549
+ /**
550
+ * xml 转 json
551
+ * @param xmlData
552
+ * @returns
553
+ */
549
554
  var lfXml2Json = function (xmlData) {
550
555
  return new XML.ObjTree().parseXML(xmlData);
551
556
  };
@@ -243,6 +243,7 @@ var Label = /** @class */ (function () {
243
243
  var data = _a.data;
244
244
  var element = graphModel.getElement(data.id);
245
245
  if (element) {
246
+ _this.rewriteInnerMethods(element);
246
247
  var formatedLabel = _this.formatConfig(graphModel, data);
247
248
  element.setProperty('_label', formatedLabel);
248
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/extension",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
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.3"
23
+ "@logicflow/core": "2.0.4"
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.3"
34
+ "@logicflow/core": "2.0.4"
35
35
  },
36
36
  "devDependencies": {
37
37
  "less": "^4.1.1",
@@ -43,6 +43,12 @@ const tn = '\t\n'
43
43
  // @see issue https://github.com/didi/LogicFlow/issues/718, refactoring of function toXml
44
44
  function toXml(obj: string | any[] | Object, name: string, depth: number) {
45
45
  const frontSpace = addSpace(depth)
46
+
47
+ // 假值除 0、false 外 -> 直接返回空元素 <prop />
48
+ if (obj !== 0 && obj !== false && !obj) {
49
+ return tn + frontSpace + `<${name} />`
50
+ }
51
+
46
52
  let str = ''
47
53
  if (name === '#text') {
48
54
  return tn + frontSpace + obj
@@ -79,6 +85,11 @@ function toXml(obj: string | any[] | Object, name: string, depth: number) {
79
85
  return str
80
86
  }
81
87
 
88
+ /**
89
+ * json 转 xml
90
+ * @param o object
91
+ * @returns
92
+ */
82
93
  function lfJson2Xml(o: Object) {
83
94
  let xmlStr = ''
84
95
  for (var m in o) {
@@ -537,6 +537,11 @@ which I will do instead of keeping this documentation like it is.
537
537
  // ========================================================================
538
538
  */
539
539
 
540
+ /**
541
+ * xml 转 json
542
+ * @param xmlData
543
+ * @returns
544
+ */
540
545
  const lfXml2Json = (xmlData) => {
541
546
  return new XML.ObjTree().parseXML(xmlData)
542
547
  }
@@ -52,18 +52,18 @@ function poolEvent(lf: any) {
52
52
  poolModel.addChild(laneId)
53
53
  }
54
54
  })
55
- lf.on('node:resize', ({ oldNodeSize, newNodeSize }: any) => {
56
- const { id, type } = oldNodeSize
57
- const deltaHeight = newNodeSize.height - oldNodeSize.height
58
- // const resizeDir = newNodeSize.y - oldNodeSize.y > 0 ? 'below': 'above'
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
59
  // 节点高度变高,y下移, 方向为below
60
60
  // 节点高度变高, y上移, 方向为above
61
61
  // 节点高度变小, y下移, 方向为above
62
62
  // 节点高度变小, y上移,方向为below
63
63
  let resizeDir = 'below'
64
- if (deltaHeight > 0 && newNodeSize.y - oldNodeSize.y < 0) {
64
+ if (deltaHeight > 0 && data.y - preData.y < 0) {
65
65
  resizeDir = 'above'
66
- } else if (deltaHeight < 0 && newNodeSize.y - oldNodeSize.y > 0) {
66
+ } else if (deltaHeight < 0 && data.y - preData.y > 0) {
67
67
  resizeDir = 'above'
68
68
  }
69
69
  if (type === 'pool') {
@@ -76,7 +76,7 @@ function poolEvent(lf: any) {
76
76
  // 泳道缩放, 调整泳池
77
77
  const groupId = lf.extension.group.nodeGroupMap.get(id)
78
78
  if (groupId) {
79
- lf.getNodeModelById(groupId).resize(id, newNodeSize)
79
+ lf.getNodeModelById(groupId).resize(id, data)
80
80
  }
81
81
  }
82
82
  })
@@ -38,9 +38,8 @@ export function SubProcessFactory(): {
38
38
  x: x - width / 2 + 5,
39
39
  y: y - height / 2 + 5,
40
40
  onClick: (e: any) => {
41
- e
42
- .stopPropagation()(model as GroupNodeModel)
43
- .foldGroup?.(!properties.isFolded)
41
+ e.stopPropagation()
42
+ ;(model as GroupNodeModel).foldGroup?.(!properties.isFolded)
44
43
  },
45
44
  }),
46
45
  iconIcon,
@@ -114,7 +114,7 @@ export class Label implements Extension {
114
114
  // 3. 字符串或者为空的话就是 string 类型,基于 text 的数据合成 LabelConfig 信息(主要复用 text 的 x,y 信息)
115
115
  const config: LabelConfig = {
116
116
  ...text,
117
- content: curLabelConfig || text.value,
117
+ content: curLabelConfig || text?.value,
118
118
  draggable:
119
119
  element.BaseType === 'edge' ? edgeTextDraggable : nodeTextDraggable,
120
120
  }
@@ -331,9 +331,10 @@ export class Label implements Extension {
331
331
  model.setProperty('_label', newLabelConfig)
332
332
  })
333
333
  // 监听元素新增事件,元素label格式化
334
- eventCenter.on('node:add,edge:add', ({ data }) => {
334
+ eventCenter.on('node:dnd-add,node:add,edge:add', ({ data }) => {
335
335
  const element = graphModel.getElement(data.id)
336
336
  if (element) {
337
+ this.rewriteInnerMethods(element)
337
338
  const formatedLabel = this.formatConfig(graphModel, data)
338
339
  element.setProperty('_label', formatedLabel)
339
340
  }