@logicflow/extension 1.1.20 → 1.2.0-alpha.10

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 (101) hide show
  1. package/cjs/NodeResize/Control/Control.js +21 -17
  2. package/cjs/NodeResize/Control/Util.js +11 -11
  3. package/cjs/NodeResize/Node/DiamondResize.js +10 -8
  4. package/cjs/NodeResize/Node/EllipseResize.js +10 -8
  5. package/cjs/NodeResize/Node/HtmlResize.js +10 -8
  6. package/cjs/NodeResize/Node/RectResize.js +10 -8
  7. package/cjs/bpmn-adapter/index.js +124 -76
  8. package/cjs/bpmn-adapter/json2xml.js +5 -2
  9. package/cjs/bpmn-adapter/xml2json.js +38 -284
  10. package/cjs/components/context-menu/index.js +2 -2
  11. package/cjs/components/control/index.js +16 -16
  12. package/cjs/components/menu/index.js +32 -32
  13. package/cjs/components/mini-map/index.js +2 -2
  14. package/cjs/components/selection-select/index.js +27 -7
  15. package/cjs/index.js +1 -0
  16. package/cjs/insert-node-in-polyline/edge.js +4 -4
  17. package/cjs/insert-node-in-polyline/index.js +1 -1
  18. package/cjs/locale/en-locale/en.js +22 -0
  19. package/cjs/locale/en-locale/index.js +29 -0
  20. package/cjs/locale/locale.js +19 -0
  21. package/cjs/materials/group/GroupNode.js +24 -14
  22. package/cjs/materials/group/index.js +3 -3
  23. package/cjs/tools/auto-layout/index.js +9 -9
  24. package/es/NodeResize/Control/Control.d.ts +1 -1
  25. package/es/NodeResize/Control/Control.js +22 -18
  26. package/es/NodeResize/Control/Util.d.ts +3 -3
  27. package/es/NodeResize/Control/Util.js +7 -7
  28. package/es/NodeResize/Node/DiamondResize.d.ts +1 -1
  29. package/es/NodeResize/Node/DiamondResize.js +10 -8
  30. package/es/NodeResize/Node/EllipseResize.d.ts +1 -1
  31. package/es/NodeResize/Node/EllipseResize.js +10 -8
  32. package/es/NodeResize/Node/HtmlResize.d.ts +1 -1
  33. package/es/NodeResize/Node/HtmlResize.js +10 -8
  34. package/es/NodeResize/Node/RectResize.d.ts +1 -1
  35. package/es/NodeResize/Node/RectResize.js +10 -8
  36. package/es/bpmn-adapter/index.d.ts +41 -33
  37. package/es/bpmn-adapter/index.js +124 -76
  38. package/es/bpmn-adapter/json2xml.js +5 -2
  39. package/es/bpmn-adapter/xml2json.js +38 -284
  40. package/es/components/context-menu/index.js +2 -2
  41. package/es/components/control/index.d.ts +2 -3
  42. package/es/components/control/index.js +16 -16
  43. package/es/components/menu/index.d.ts +2 -3
  44. package/es/components/menu/index.js +32 -32
  45. package/es/components/mini-map/index.js +2 -2
  46. package/es/components/selection-select/index.d.ts +2 -1
  47. package/es/components/selection-select/index.js +27 -7
  48. package/es/index.d.ts +1 -0
  49. package/es/index.js +1 -0
  50. package/es/insert-node-in-polyline/edge.d.ts +3 -3
  51. package/es/insert-node-in-polyline/edge.js +3 -3
  52. package/es/insert-node-in-polyline/index.js +2 -2
  53. package/es/locale/en-locale/en.d.ts +19 -0
  54. package/es/locale/en-locale/en.js +19 -0
  55. package/es/locale/en-locale/index.d.ts +9 -0
  56. package/es/locale/en-locale/index.js +26 -0
  57. package/es/locale/locale.d.ts +6 -0
  58. package/es/locale/locale.js +16 -0
  59. package/es/materials/group/GroupNode.d.ts +1 -1
  60. package/es/materials/group/GroupNode.js +24 -14
  61. package/es/materials/group/index.d.ts +1 -1
  62. package/es/materials/group/index.js +3 -3
  63. package/es/tools/auto-layout/index.d.ts +2 -2
  64. package/es/tools/auto-layout/index.js +9 -9
  65. package/lib/AutoLayout.js +1 -1
  66. package/lib/BpmnAdapter.js +1 -1
  67. package/lib/BpmnElement.js +1 -1
  68. package/lib/ContextMenu.js +1 -1
  69. package/lib/Control.js +1 -1
  70. package/lib/CurvedEdge.js +1 -1
  71. package/lib/DndPanel.js +1 -1
  72. package/lib/EnLocale.js +1 -0
  73. package/lib/FlowPath.js +1 -1
  74. package/lib/Group.js +1 -1
  75. package/lib/Highlight.js +1 -1
  76. package/lib/InsertNodeInPolyline.js +1 -1
  77. package/lib/Menu.js +1 -1
  78. package/lib/MiniMap.js +1 -1
  79. package/lib/NodeResize.js +1 -1
  80. package/lib/RectLabelNode.js +1 -1
  81. package/lib/SelectionSelect.js +1 -1
  82. package/lib/Snapshot.js +1 -1
  83. package/lib/TurboAdapter.js +1 -1
  84. package/lib/lfJson2Xml.js +1 -1
  85. package/lib/lfXml2Json.js +1 -1
  86. package/package.json +2 -2
  87. package/types/NodeResize/Control/Control.d.ts +1 -1
  88. package/types/NodeResize/Control/Util.d.ts +3 -3
  89. package/types/NodeResize/Node/DiamondResize.d.ts +1 -1
  90. package/types/NodeResize/Node/EllipseResize.d.ts +1 -1
  91. package/types/NodeResize/Node/HtmlResize.d.ts +1 -1
  92. package/types/NodeResize/Node/RectResize.d.ts +1 -1
  93. package/types/bpmn-adapter/index.d.ts +41 -33
  94. package/types/components/control/index.d.ts +2 -3
  95. package/types/components/menu/index.d.ts +2 -3
  96. package/types/components/selection-select/index.d.ts +2 -1
  97. package/types/index.d.ts +1 -0
  98. package/types/insert-node-in-polyline/edge.d.ts +3 -3
  99. package/types/materials/group/GroupNode.d.ts +1 -1
  100. package/types/materials/group/index.d.ts +1 -1
  101. package/types/tools/auto-layout/index.d.ts +2 -2
@@ -38,26 +38,26 @@ XML.ObjTree.prototype.parseXML = function (xml) {
38
38
  };
39
39
  // method: parseHTTP( url, options, callback )
40
40
  XML.ObjTree.prototype.parseHTTP = function (url, options, callback) {
41
- var myopt = {};
41
+ var myOpt = {};
42
42
  for (var key in options) {
43
- myopt[key] = options[key]; // copy object
43
+ myOpt[key] = options[key]; // copy object
44
44
  }
45
- if (!myopt.method) {
46
- if (typeof (myopt.postBody) == "undefined" &&
47
- typeof (myopt.postbody) == "undefined" &&
48
- typeof (myopt.parameters) == "undefined") {
49
- myopt.method = "get";
45
+ if (!myOpt.method) {
46
+ if (typeof (myOpt.postBody) == "undefined" &&
47
+ typeof (myOpt.postbody) == "undefined" &&
48
+ typeof (myOpt.parameters) == "undefined") {
49
+ myOpt.method = "get";
50
50
  }
51
51
  else {
52
- myopt.method = "post";
52
+ myOpt.method = "post";
53
53
  }
54
54
  }
55
55
  if (callback) {
56
- myopt.asynchronous = true; // async-mode
56
+ myOpt.asynchronous = true; // async-mode
57
57
  var __this = this;
58
58
  var __func = callback;
59
- var __save = myopt.onComplete;
60
- myopt.onComplete = function (trans) {
59
+ var __save = myOpt.onComplete;
60
+ myOpt.onComplete = function (trans) {
61
61
  var tree;
62
62
  if (trans && trans.responseXML && trans.responseXML.documentElement) {
63
63
  tree = __this.parseDOM(trans.responseXML.documentElement);
@@ -68,17 +68,17 @@ XML.ObjTree.prototype.parseHTTP = function (url, options, callback) {
68
68
  };
69
69
  }
70
70
  else {
71
- myopt.asynchronous = false; // sync-mode
71
+ myOpt.asynchronous = false;
72
72
  }
73
73
  var trans;
74
74
  if (typeof (HTTP) != "undefined" && HTTP.Request) {
75
- myopt.uri = url;
76
- var req = new HTTP.Request(myopt); // JSAN
75
+ myOpt.uri = url;
76
+ var req = new HTTP.Request(myOpt);
77
77
  if (req)
78
78
  trans = req.transport;
79
79
  }
80
80
  else if (typeof (Ajax) != "undefined" && Ajax.Request) {
81
- var req = new Ajax.Request(url, myopt); // ptorotype.js
81
+ var req = new Ajax.Request(url, myOpt);
82
82
  if (req)
83
83
  trans = req.transport;
84
84
  }
@@ -88,7 +88,7 @@ XML.ObjTree.prototype.parseHTTP = function (url, options, callback) {
88
88
  return this.parseDOM(trans.responseXML.documentElement);
89
89
  }
90
90
  };
91
- // method: parseDOM( documentroot )
91
+ // method: parseDOM( document root )
92
92
  XML.ObjTree.prototype.parseDOM = function (root) {
93
93
  if (!root)
94
94
  return;
@@ -122,11 +122,11 @@ XML.ObjTree.prototype.parseElement = function (elem) {
122
122
  return; // ignore white spaces
123
123
  return elem.nodeValue;
124
124
  }
125
- var retval;
125
+ var retVal;
126
126
  var cnt = {};
127
127
  // parse attributes
128
128
  if (elem.attributes && elem.attributes.length) {
129
- retval = {};
129
+ retVal = {};
130
130
  for (var i = 0; i < elem.attributes.length; i++) {
131
131
  var key = elem.attributes[i].nodeName;
132
132
  if (typeof (key) != "string")
@@ -138,30 +138,30 @@ XML.ObjTree.prototype.parseElement = function (elem) {
138
138
  if (typeof (cnt[key]) == "undefined")
139
139
  cnt[key] = 0;
140
140
  cnt[key]++;
141
- this.addNode(retval, key, cnt[key], val);
141
+ this.addNode(retVal, key, cnt[key], val);
142
142
  }
143
143
  }
144
144
  // parse child nodes (recursive)
145
145
  if (elem.childNodes && elem.childNodes.length) {
146
- var textonly = true;
147
- if (retval)
148
- textonly = false; // some attributes exists
149
- for (var i = 0; i < elem.childNodes.length && textonly; i++) {
150
- var ntype = elem.childNodes[i].nodeType;
151
- if (ntype == 3 || ntype == 4)
146
+ var textOnly = true;
147
+ if (retVal)
148
+ textOnly = false; // some attributes exists
149
+ for (var i = 0; i < elem.childNodes.length && textOnly; i++) {
150
+ var nType = elem.childNodes[i].nodeType;
151
+ if (nType == 3 || nType == 4)
152
152
  continue;
153
- textonly = false;
153
+ textOnly = false;
154
154
  }
155
- if (textonly) {
156
- if (!retval)
157
- retval = "";
155
+ if (textOnly) {
156
+ if (!retVal)
157
+ retVal = "";
158
158
  for (var i = 0; i < elem.childNodes.length; i++) {
159
- retval += elem.childNodes[i].nodeValue;
159
+ retVal += elem.childNodes[i].nodeValue;
160
160
  }
161
161
  }
162
162
  else {
163
- if (!retval)
164
- retval = {};
163
+ if (!retVal)
164
+ retVal = {};
165
165
  for (var i = 0; i < elem.childNodes.length; i++) {
166
166
  var key = elem.childNodes[i].nodeName;
167
167
  if (typeof (key) != "string")
@@ -172,23 +172,23 @@ XML.ObjTree.prototype.parseElement = function (elem) {
172
172
  if (typeof (cnt[key]) == "undefined")
173
173
  cnt[key] = 0;
174
174
  cnt[key]++;
175
- this.addNode(retval, key, cnt[key], val);
175
+ this.addNode(retVal, key, cnt[key], val);
176
176
  }
177
177
  }
178
178
  }
179
- return retval;
179
+ return retVal;
180
180
  };
181
181
  // method: addNode( hash, key, count, value )
182
- XML.ObjTree.prototype.addNode = function (hash, key, cnts, val) {
182
+ XML.ObjTree.prototype.addNode = function (hash, key, counts, val) {
183
183
  if (this.__force_array[key]) {
184
- if (cnts == 1)
184
+ if (counts == 1)
185
185
  hash[key] = [];
186
186
  hash[key][hash[key].length] = val; // push
187
187
  }
188
- else if (cnts == 1) { // 1st sibling
188
+ else if (counts == 1) { // 1st sibling
189
189
  hash[key] = val;
190
190
  }
191
- else if (cnts == 2) { // 2nd sibling
191
+ else if (counts == 2) { // 2nd sibling
192
192
  hash[key] = [hash[key], val];
193
193
  }
194
194
  else { // 3rd sibling and more
@@ -277,252 +277,6 @@ XML.ObjTree.prototype.scalar_to_xml = function (name, text) {
277
277
  XML.ObjTree.prototype.xml_escape = function (text) {
278
278
  return text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
279
279
  };
280
- /*
281
- // ========================================================================
282
-
283
- =head1 NAME
284
-
285
- XML.ObjTree -- XML source code from/to JavaScript object like E4X
286
-
287
- =head1 SYNOPSIS
288
-
289
- var xotree = new XML.ObjTree();
290
- var tree1 = {
291
- root: {
292
- node: "Hello, World!"
293
- }
294
- };
295
- var xml1 = xotree.writeXML( tree1 ); // object tree to XML source
296
- alert( "xml1: "+xml1 );
297
-
298
- var xml2 = '<?xml version="1.0"?><response><error>0</error></response>';
299
- var tree2 = xotree.parseXML( xml2 ); // XML source to object tree
300
- alert( "error: "+tree2.response.error );
301
-
302
- =head1 DESCRIPTION
303
-
304
- XML.ObjTree class is a parser/generater between XML source code
305
- and JavaScript object like E4X, ECMAScript for XML.
306
- This is a JavaScript version of the XML::TreePP module for Perl.
307
- This also works as a wrapper for XMLHTTPRequest and successor to JKL.ParseXML class
308
- when this is used with prototype.js or JSAN's HTTP.Request class.
309
-
310
- =head2 JavaScript object tree format
311
-
312
- A sample XML source:
313
-
314
- <?xml version="1.0" encoding="UTF-8"?>
315
- <family name="Kawasaki">
316
- <father>Yasuhisa</father>
317
- <mother>Chizuko</mother>
318
- <children>
319
- <girl>Shiori</girl>
320
- <boy>Yusuke</boy>
321
- <boy>Kairi</boy>
322
- </children>
323
- </family>
324
-
325
- Its JavaScript object tree like JSON/E4X:
326
-
327
- {
328
- 'family': {
329
- '-name': 'Kawasaki',
330
- 'father': 'Yasuhisa',
331
- 'mother': 'Chizuko',
332
- 'children': {
333
- 'girl': 'Shiori'
334
- 'boy': [
335
- 'Yusuke',
336
- 'Kairi'
337
- ]
338
- }
339
- }
340
- };
341
-
342
- Each elements are parsed into objects:
343
-
344
- tree.family.father; # the father's given name.
345
-
346
- Prefix '-' is inserted before every attributes' name.
347
-
348
- tree.family["-name"]; # this family's family name
349
-
350
- A array is used because this family has two boys.
351
-
352
- tree.family.children.boy[0]; # first boy's name
353
- tree.family.children.boy[1]; # second boy's name
354
- tree.family.children.girl; # (girl has no other sisiters)
355
-
356
- =head1 METHODS
357
-
358
- =head2 xotree = new XML.ObjTree()
359
-
360
- This constructor method returns a new XML.ObjTree object.
361
-
362
- =head2 xotree.force_array = [ "rdf:li", "item", "-xmlns" ];
363
-
364
- This property allows you to specify a list of element names
365
- which should always be forced into an array representation.
366
- The default value is null, it means that context of the elements
367
- will determine to make array or to keep it scalar.
368
-
369
- =head2 xotree.attr_prefix = '@';
370
-
371
- This property allows you to specify a prefix character which is
372
- inserted before each attribute names.
373
- Instead of default prefix '-', E4X-style prefix '@' is also available.
374
- The default character is '-'.
375
- Or set '@' to access attribute values like E4X, ECMAScript for XML.
376
- The length of attr_prefix must be just one character and not be empty.
377
-
378
- =head2 tree = xotree.parseXML( xmlsrc );
379
-
380
- This method loads an XML document using the supplied string
381
- and returns its JavaScript object converted.
382
-
383
- =head2 tree = xotree.parseDOM( domnode );
384
-
385
- This method parses a DOM tree (ex. responseXML.documentElement)
386
- and returns its JavaScript object converted.
387
-
388
- =head2 tree = xotree.parseHTTP( url, options );
389
-
390
- This method loads a XML file from remote web server
391
- and returns its JavaScript object converted.
392
- XMLHTTPRequest's synchronous mode is always used.
393
- This mode blocks the process until the response is completed.
394
-
395
- First argument is a XML file's URL
396
- which must exist in the same domain as parent HTML file's.
397
- Cross-domain loading is not available for security reasons.
398
-
399
- Second argument is options' object which can contains some parameters:
400
- method, postBody, parameters, onLoading, etc.
401
-
402
- This method requires JSAN's L<HTTP.Request> class or prototype.js's Ajax.Request class.
403
-
404
- =head2 xotree.parseHTTP( url, options, callback );
405
-
406
- If a callback function is set as third argument,
407
- XMLHTTPRequest's asynchronous mode is used.
408
-
409
- This mode calls a callback function with XML file's JavaScript object converted
410
- after the response is completed.
411
-
412
- =head2 xmlsrc = xotree.writeXML( tree );
413
-
414
- This method parses a JavaScript object tree
415
- and returns its XML source generated.
416
-
417
- =head1 EXAMPLES
418
-
419
- =head2 Text node and attributes
420
-
421
- If a element has both of a text node and attributes
422
- or both of a text node and other child nodes,
423
- text node's value is moved to a special node named "#text".
424
-
425
- var xotree = new XML.ObjTree();
426
- var xmlsrc = '<span class="author">Kawasaki Yusuke</span>';
427
- var tree = xotree.parseXML( xmlsrc );
428
- var class = tree.span["-class"]; # attribute
429
- var name = tree.span["#text"]; # text node
430
-
431
- =head2 parseHTTP() method with HTTP-GET and sync-mode
432
-
433
- HTTP/Request.js or prototype.js must be loaded before calling this method.
434
-
435
- var xotree = new XML.ObjTree();
436
- var url = "http://example.com/index.html";
437
- var tree = xotree.parseHTTP( url );
438
- xotree.attr_prefix = '@'; // E4X-style
439
- alert( tree.html["@lang"] );
440
-
441
- This code shows C<lang=""> attribute from a X-HTML source code.
442
-
443
- =head2 parseHTTP() method with HTTP-POST and async-mode
444
-
445
- Third argument is a callback function which is called on onComplete.
446
-
447
- var xotree = new XML.ObjTree();
448
- var url = "http://example.com/mt-tb.cgi";
449
- var opts = {
450
- postBody: "title=...&excerpt=...&url=...&blog_name=..."
451
- };
452
- var func = function ( tree ) {
453
- alert( tree.response.error );
454
- };
455
- xotree.parseHTTP( url, opts, func );
456
-
457
- This code send a trackback ping and shows its response code.
458
-
459
- =head2 Simple RSS reader
460
-
461
- This is a RSS reader which loads RDF file and displays all items.
462
-
463
- var xotree = new XML.ObjTree();
464
- xotree.force_array = [ "rdf:li", "item" ];
465
- var url = "http://example.com/news-rdf.xml";
466
- var func = function( tree ) {
467
- var elem = document.getElementById("rss_here");
468
- for( var i=0; i<tree["rdf:RDF"].item.length; i++ ) {
469
- var divtag = document.createElement( "div" );
470
- var atag = document.createElement( "a" );
471
- atag.href = tree["rdf:RDF"].item[i].link;
472
- var title = tree["rdf:RDF"].item[i].title;
473
- var tnode = document.createTextNode( title );
474
- atag.appendChild( tnode );
475
- divtag.appendChild( atag );
476
- elem.appendChild( divtag );
477
- }
478
- };
479
- xotree.parseHTTP( url, {}, func );
480
-
481
- =head2 XML-RPC using writeXML, prototype.js and parseDOM
482
-
483
- If you wish to use prototype.js's Ajax.Request class by yourself:
484
-
485
- var xotree = new XML.ObjTree();
486
- var reqtree = {
487
- methodCall: {
488
- methodName: "weblogUpdates.ping",
489
- params: {
490
- param: [
491
- { value: "Kawa.net xp top page" }, // 1st param
492
- { value: "http://www.kawa.net/" } // 2nd param
493
- ]
494
- }
495
- }
496
- };
497
- var reqxml = xotree.writeXML( reqtree ); // JS-Object to XML code
498
- var url = "http://example.com/xmlrpc";
499
- var func = function( req ) {
500
- var resdom = req.responseXML.documentElement;
501
- xotree.force_array = [ "member" ];
502
- var restree = xotree.parseDOM( resdom ); // XML-DOM to JS-Object
503
- alert( restree.methodResponse.params.param.value.struct.member[0].value.string );
504
- };
505
- var opt = {
506
- method: "post",
507
- postBody: reqxml,
508
- asynchronous: true,
509
- onComplete: func
510
- };
511
- new Ajax.Request( url, opt );
512
-
513
- =head1 AUTHOR
514
-
515
- Yusuke Kawasaki http://www.kawa.net/
516
- =head1 COPYRIGHT AND LICENSE
517
-
518
- Copyright (c) 2005-2006 Yusuke Kawasaki. All rights reserved.
519
- This program is free software; you can redistribute it and/or
520
- modify it under the Artistic license. Or whatever license I choose,
521
- which I will do instead of keeping this documentation like it is.
522
-
523
- =cut
524
- // ========================================================================
525
- */
526
280
  var lfXml2Json = function (xmlData) {
527
281
  return new XML.ObjTree().parseXML(xmlData);
528
282
  };
@@ -177,8 +177,8 @@ var ContextMenu = /** @class */ (function () {
177
177
  var leftTopY = y - node.y / 2 - 20;
178
178
  var rightBottomX = node.x + nodeModel.width + NEXT_X_DISTANCE;
179
179
  var rightBottomY = y + node.y / 2 + 20;
180
- var exsitElements = this.lf.getAreaElement([leftTopX, leftTopY], [rightBottomX, rightBottomY]);
181
- if (exsitElements.length) {
180
+ var existElements = this.lf.getAreaElement([leftTopX, leftTopY], [rightBottomX, rightBottomY]);
181
+ if (existElements.length) {
182
182
  y = y + NEXT_Y_DISTANCE;
183
183
  this.addNode(node, y);
184
184
  return;
@@ -22,15 +22,16 @@ var __spread = (this && this.__spread) || function () {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.Control = void 0;
24
24
  var Control = /** @class */ (function () {
25
- function Control(_a) {
25
+ function Control(args) {
26
26
  var _this = this;
27
- var lf = _a.lf;
27
+ this.lf = args.lf;
28
+ this.LogicFlow = args.LogicFlow;
28
29
  this.controlItems = [
29
30
  {
30
31
  key: 'zoom-out',
31
32
  iconClass: 'lf-control-zoomOut',
32
- title: '缩小流程图',
33
- text: '缩小',
33
+ title: this.LogicFlow.t('缩小流程图'),
34
+ text: this.LogicFlow.t('缩小'),
34
35
  onClick: function () {
35
36
  _this.lf.zoom(false);
36
37
  },
@@ -38,8 +39,8 @@ var Control = /** @class */ (function () {
38
39
  {
39
40
  key: 'zoom-in',
40
41
  iconClass: 'lf-control-zoomIn',
41
- title: '放大流程图',
42
- text: '放大',
42
+ title: this.LogicFlow.t('放大流程图'),
43
+ text: this.LogicFlow.t('放大'),
43
44
  onClick: function () {
44
45
  _this.lf.zoom(true);
45
46
  },
@@ -47,8 +48,8 @@ var Control = /** @class */ (function () {
47
48
  {
48
49
  key: 'reset',
49
50
  iconClass: 'lf-control-fit',
50
- title: '恢复流程原有尺寸',
51
- text: '适应',
51
+ title: this.LogicFlow.t('恢复流程原有尺寸'),
52
+ text: this.LogicFlow.t('适应'),
52
53
  onClick: function () {
53
54
  _this.lf.resetZoom();
54
55
  },
@@ -56,8 +57,8 @@ var Control = /** @class */ (function () {
56
57
  {
57
58
  key: 'undo',
58
59
  iconClass: 'lf-control-undo',
59
- title: '回到上一步',
60
- text: '上一步',
60
+ title: this.LogicFlow.t('回到上一步'),
61
+ text: this.LogicFlow.t('上一步'),
61
62
  onClick: function () {
62
63
  _this.lf.undo();
63
64
  },
@@ -65,14 +66,13 @@ var Control = /** @class */ (function () {
65
66
  {
66
67
  key: 'redo',
67
68
  iconClass: 'lf-control-redo',
68
- title: '移到下一步',
69
- text: '下一步',
69
+ title: this.LogicFlow.t('移到下一步'),
70
+ text: this.LogicFlow.t('下一步'),
70
71
  onClick: function () {
71
72
  _this.lf.redo();
72
73
  },
73
74
  },
74
75
  ];
75
- this.lf = lf;
76
76
  }
77
77
  Control.prototype.render = function (lf, domContainer) {
78
78
  this.destroy();
@@ -113,14 +113,14 @@ var Control = /** @class */ (function () {
113
113
  text.title = item.title;
114
114
  text.innerText = item.text;
115
115
  itemContainer.append(icon, text);
116
- switch (item.text) {
117
- case '上一步':
116
+ switch (item.key) {
117
+ case 'undo':
118
118
  _this.lf.on('history:change', function (_a) {
119
119
  var undoAble = _a.data.undoAble;
120
120
  itemContainer.className = undoAble ? NORMAL : DISABLED;
121
121
  });
122
122
  break;
123
- case '下一步':
123
+ case 'redo':
124
124
  _this.lf.on('history:change', function (_a) {
125
125
  var redoAble = _a.data.redoAble;
126
126
  itemContainer.className = redoAble ? NORMAL : DISABLED;
@@ -21,16 +21,16 @@ var __spread = (this && this.__spread) || function () {
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.Menu = void 0;
24
- var DefalutNodeMenuKey = 'lf:defaultNodeMenu';
25
- var DefalutEdgeMenuKey = 'lf:defaultEdgeMenu';
26
- var DefalutGraphMenuKey = 'lf:defaultGraphMenu';
27
- var DefalutSelectionMenuKey = 'lf:defaultSelectionMenu';
24
+ var DefaultNodeMenuKey = 'lf:defaultNodeMenu';
25
+ var DefaultEdgeMenuKey = 'lf:defaultEdgeMenu';
26
+ var DefaultGraphMenuKey = 'lf:defaultGraphMenu';
27
+ var DefaultSelectionMenuKey = 'lf:defaultSelectionMenu';
28
28
  var Menu = /** @class */ (function () {
29
- function Menu(_a) {
29
+ function Menu(args) {
30
30
  var _this = this;
31
- var lf = _a.lf;
32
31
  this.__menuDOM = document.createElement('ul');
33
- this.lf = lf;
32
+ this.lf = args.lf;
33
+ this.LogicFlow = args.LogicFlow;
34
34
  this.menuTypeMap = new Map();
35
35
  this.init();
36
36
  this.lf.setMenuConfig = function (config) {
@@ -48,46 +48,46 @@ var Menu = /** @class */ (function () {
48
48
  */
49
49
  Menu.prototype.init = function () {
50
50
  var _this = this;
51
- var defalutNodeMenu = [
51
+ var defaultNodeMenu = [
52
52
  {
53
- text: '删除',
53
+ text: this.LogicFlow.t('删除'),
54
54
  callback: function (node) {
55
55
  _this.lf.deleteNode(node.id);
56
56
  },
57
57
  },
58
58
  {
59
- text: '编辑文本',
59
+ text: this.LogicFlow.t('编辑文本'),
60
60
  callback: function (node) {
61
61
  _this.lf.graphModel.editText(node.id);
62
62
  },
63
63
  },
64
64
  {
65
- text: '复制',
65
+ text: this.LogicFlow.t('复制'),
66
66
  callback: function (node) {
67
67
  _this.lf.cloneNode(node.id);
68
68
  },
69
69
  },
70
70
  ];
71
- this.menuTypeMap.set(DefalutNodeMenuKey, defalutNodeMenu);
71
+ this.menuTypeMap.set(DefaultNodeMenuKey, defaultNodeMenu);
72
72
  var defaultEdgeMenu = [
73
73
  {
74
- text: '删除',
74
+ text: this.LogicFlow.t('删除'),
75
75
  callback: function (edge) {
76
76
  _this.lf.deleteEdge(edge.id);
77
77
  },
78
78
  },
79
79
  {
80
- text: '编辑文本',
80
+ text: this.LogicFlow.t('编辑文本'),
81
81
  callback: function (edge) {
82
82
  _this.lf.graphModel.editText(edge.id);
83
83
  },
84
84
  },
85
85
  ];
86
- this.menuTypeMap.set(DefalutEdgeMenuKey, defaultEdgeMenu);
87
- this.menuTypeMap.set(DefalutGraphMenuKey, []);
88
- var DefalutSelectionMenu = [
86
+ this.menuTypeMap.set(DefaultEdgeMenuKey, defaultEdgeMenu);
87
+ this.menuTypeMap.set(DefaultGraphMenuKey, []);
88
+ var DefaultSelectionMenu = [
89
89
  {
90
- text: '删除',
90
+ text: this.LogicFlow.t('删除'),
91
91
  callback: function (elements) {
92
92
  _this.lf.clearSelectElements();
93
93
  elements.edges.forEach(function (edge) { return _this.lf.deleteEdge(edge.id); });
@@ -95,7 +95,7 @@ var Menu = /** @class */ (function () {
95
95
  },
96
96
  },
97
97
  ];
98
- this.menuTypeMap.set(DefalutSelectionMenuKey, DefalutSelectionMenu);
98
+ this.menuTypeMap.set(DefaultSelectionMenuKey, DefaultSelectionMenu);
99
99
  };
100
100
  Menu.prototype.render = function (lf, container) {
101
101
  var _this = this;
@@ -142,7 +142,7 @@ var Menu = /** @class */ (function () {
142
142
  menuList = typeMenus;
143
143
  }
144
144
  else { // 最后取全局默认
145
- menuList = _this.menuTypeMap.get(DefalutNodeMenuKey);
145
+ menuList = _this.menuTypeMap.get(DefaultNodeMenuKey);
146
146
  }
147
147
  _this.__currentData = data;
148
148
  _this.showMenu(x, y, menuList);
@@ -162,20 +162,20 @@ var Menu = /** @class */ (function () {
162
162
  menuList = typeMenus;
163
163
  }
164
164
  else { // 最后取全局默认
165
- menuList = _this.menuTypeMap.get(DefalutEdgeMenuKey);
165
+ menuList = _this.menuTypeMap.get(DefaultEdgeMenuKey);
166
166
  }
167
167
  _this.__currentData = data;
168
168
  _this.showMenu(x, y, menuList);
169
169
  });
170
170
  this.lf.on('blank:contextmenu', function (_a) {
171
171
  var position = _a.position;
172
- var menuList = _this.menuTypeMap.get(DefalutGraphMenuKey);
172
+ var menuList = _this.menuTypeMap.get(DefaultGraphMenuKey);
173
173
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
174
174
  _this.showMenu(x, y, menuList);
175
175
  });
176
176
  this.lf.on('selection:contextmenu', function (_a) {
177
177
  var data = _a.data, position = _a.position;
178
- var menuList = _this.menuTypeMap.get(DefalutSelectionMenuKey);
178
+ var menuList = _this.menuTypeMap.get(DefaultSelectionMenuKey);
179
179
  var _b = position.domOverlayPosition, x = _b.x, y = _b.y;
180
180
  _this.__currentData = data;
181
181
  _this.showMenu(x, y, menuList);
@@ -256,13 +256,13 @@ var Menu = /** @class */ (function () {
256
256
  }
257
257
  // node
258
258
  config.nodeMenu !== undefined
259
- && this.menuTypeMap.set(DefalutNodeMenuKey, config.nodeMenu ? config.nodeMenu : []);
259
+ && this.menuTypeMap.set(DefaultNodeMenuKey, config.nodeMenu ? config.nodeMenu : []);
260
260
  // edge
261
261
  config.edgeMenu !== undefined
262
- && this.menuTypeMap.set(DefalutEdgeMenuKey, config.edgeMenu ? config.edgeMenu : []);
262
+ && this.menuTypeMap.set(DefaultEdgeMenuKey, config.edgeMenu ? config.edgeMenu : []);
263
263
  // graph
264
264
  config.graphMenu !== undefined
265
- && this.menuTypeMap.set(DefalutGraphMenuKey, config.graphMenu ? config.graphMenu : []);
265
+ && this.menuTypeMap.set(DefaultGraphMenuKey, config.graphMenu ? config.graphMenu : []);
266
266
  };
267
267
  // 在默认菜单后面追加菜单项
268
268
  Menu.prototype.addMenuConfig = function (config) {
@@ -271,16 +271,16 @@ var Menu = /** @class */ (function () {
271
271
  }
272
272
  // 追加项时,只支持数组类型,对false不做操作
273
273
  if (Array.isArray(config.nodeMenu)) {
274
- var menuList = this.menuTypeMap.get(DefalutNodeMenuKey);
275
- this.menuTypeMap.set(DefalutNodeMenuKey, menuList.concat(config.nodeMenu));
274
+ var menuList = this.menuTypeMap.get(DefaultNodeMenuKey);
275
+ this.menuTypeMap.set(DefaultNodeMenuKey, menuList.concat(config.nodeMenu));
276
276
  }
277
277
  if (Array.isArray(config.edgeMenu)) {
278
- var menuList = this.menuTypeMap.get(DefalutEdgeMenuKey);
279
- this.menuTypeMap.set(DefalutEdgeMenuKey, menuList.concat(config.edgeMenu));
278
+ var menuList = this.menuTypeMap.get(DefaultEdgeMenuKey);
279
+ this.menuTypeMap.set(DefaultEdgeMenuKey, menuList.concat(config.edgeMenu));
280
280
  }
281
281
  if (Array.isArray(config.graphMenu)) {
282
- var menuList = this.menuTypeMap.get(DefalutGraphMenuKey);
283
- this.menuTypeMap.set(DefalutGraphMenuKey, menuList.concat(config.graphMenu));
282
+ var menuList = this.menuTypeMap.get(DefaultGraphMenuKey);
283
+ this.menuTypeMap.set(DefaultGraphMenuKey, menuList.concat(config.graphMenu));
284
284
  }
285
285
  };
286
286
  /**