index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var __rest = (this && this.__rest) || function (s, e) {
  2. var t = {};
  3. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4. t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  6. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  8. t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { Registry } from '../registry';
  13. import { ToolsView } from '../../view/tool';
  14. import { Button } from './button';
  15. import { Boundary } from './boundary';
  16. import { Vertices } from './vertices';
  17. import { Segments } from './segments';
  18. import { SourceAnchor, TargetAnchor } from './anchor';
  19. import { SourceArrowhead, TargetArrowhead } from './arrowhead';
  20. import { CellEditor } from './editor';
  21. export var NodeTool;
  22. (function (NodeTool) {
  23. NodeTool.presets = {
  24. boundary: Boundary,
  25. button: Button,
  26. 'button-remove': Button.Remove,
  27. 'node-editor': CellEditor.NodeEditor,
  28. };
  29. NodeTool.registry = Registry.create({
  30. type: 'node tool',
  31. process(name, options) {
  32. if (typeof options === 'function') {
  33. return options;
  34. }
  35. let parent = ToolsView.ToolItem;
  36. const { inherit } = options, others = __rest(options, ["inherit"]);
  37. if (inherit) {
  38. const base = this.get(inherit);
  39. if (base == null) {
  40. this.onNotFound(inherit, 'inherited');
  41. }
  42. else {
  43. parent = base;
  44. }
  45. }
  46. if (others.name == null) {
  47. others.name = name;
  48. }
  49. return parent.define.call(parent, others);
  50. },
  51. });
  52. NodeTool.registry.register(NodeTool.presets, true);
  53. })(NodeTool || (NodeTool = {}));
  54. export var EdgeTool;
  55. (function (EdgeTool) {
  56. EdgeTool.presets = {
  57. boundary: Boundary,
  58. vertices: Vertices,
  59. segments: Segments,
  60. button: Button,
  61. 'button-remove': Button.Remove,
  62. 'source-anchor': SourceAnchor,
  63. 'target-anchor': TargetAnchor,
  64. 'source-arrowhead': SourceArrowhead,
  65. 'target-arrowhead': TargetArrowhead,
  66. 'edge-editor': CellEditor.EdgeEditor,
  67. };
  68. EdgeTool.registry = Registry.create({
  69. type: 'edge tool',
  70. process(name, options) {
  71. if (typeof options === 'function') {
  72. return options;
  73. }
  74. let parent = ToolsView.ToolItem;
  75. const { inherit } = options, others = __rest(options, ["inherit"]);
  76. if (inherit) {
  77. const base = this.get(inherit);
  78. if (base == null) {
  79. this.onNotFound(inherit, 'inherited');
  80. }
  81. else {
  82. parent = base;
  83. }
  84. }
  85. if (others.name == null) {
  86. others.name = name;
  87. }
  88. return parent.define.call(parent, others);
  89. },
  90. });
  91. EdgeTool.registry.register(EdgeTool.presets, true);
  92. })(EdgeTool || (EdgeTool = {}));
  93. //# sourceMappingURL=index.js.map