react-design-editor 0.0.50 → 0.0.51
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.
- package/dist/react-design-editor.js +7739 -7114
- package/dist/react-design-editor.min.js +1 -1
- package/dist/react-design-editor.min.js.LICENSE.txt +2 -0
- package/lib/Canvas.d.ts +18 -18
- package/lib/Canvas.js +172 -172
- package/lib/CanvasObject.d.ts +10 -10
- package/lib/CanvasObject.js +96 -96
- package/lib/constants/code.d.ts +19 -19
- package/lib/constants/code.js +22 -22
- package/lib/constants/defaults.d.ts +38 -38
- package/lib/constants/defaults.js +69 -69
- package/lib/constants/index.d.ts +3 -3
- package/lib/constants/index.js +26 -26
- package/lib/handlers/AlignmentHandler.d.ts +18 -18
- package/lib/handlers/AlignmentHandler.js +58 -58
- package/lib/handlers/AnimationHandler.d.ts +50 -50
- package/lib/handlers/AnimationHandler.js +346 -346
- package/lib/handlers/ChartHandler.d.ts +8 -8
- package/lib/handlers/ChartHandler.js +8 -8
- package/lib/handlers/ContextmenuHandler.d.ts +28 -28
- package/lib/handlers/ContextmenuHandler.js +65 -65
- package/lib/handlers/CropHandler.d.ts +43 -43
- package/lib/handlers/CropHandler.js +261 -261
- package/lib/handlers/CustomHandler.d.ts +7 -7
- package/lib/handlers/CustomHandler.js +10 -10
- package/lib/handlers/DrawingHandler.d.ts +28 -28
- package/lib/handlers/DrawingHandler.js +318 -318
- package/lib/handlers/ElementHandler.d.ts +80 -80
- package/lib/handlers/ElementHandler.js +154 -154
- package/lib/handlers/EventHandler.d.ts +170 -170
- package/lib/handlers/EventHandler.js +880 -880
- package/lib/handlers/FiberHandler.d.ts +6 -6
- package/lib/handlers/FiberHandler.js +23 -23
- package/lib/handlers/GridHandler.d.ts +19 -19
- package/lib/handlers/GridHandler.js +77 -77
- package/lib/handlers/GuidelineHandler.d.ts +61 -61
- package/lib/handlers/GuidelineHandler.js +315 -315
- package/lib/handlers/Handler.d.ts +618 -618
- package/lib/handlers/Handler.js +1645 -1645
- package/lib/handlers/ImageHandler.d.ts +307 -307
- package/lib/handlers/ImageHandler.js +528 -528
- package/lib/handlers/InteractionHandler.d.ts +45 -45
- package/lib/handlers/InteractionHandler.js +168 -164
- package/lib/handlers/LinkHandler.d.ts +115 -115
- package/lib/handlers/LinkHandler.js +247 -247
- package/lib/handlers/NodeHandler.d.ts +50 -50
- package/lib/handlers/NodeHandler.js +274 -274
- package/lib/handlers/PortHandler.d.ts +22 -22
- package/lib/handlers/PortHandler.js +179 -179
- package/lib/handlers/ShortcutHandler.d.ts +119 -119
- package/lib/handlers/ShortcutHandler.js +151 -151
- package/lib/handlers/TooltipHandler.d.ts +33 -33
- package/lib/handlers/TooltipHandler.js +91 -91
- package/lib/handlers/TransactionHandler.d.ts +59 -59
- package/lib/handlers/TransactionHandler.js +137 -137
- package/lib/handlers/WorkareaHandler.d.ts +43 -43
- package/lib/handlers/WorkareaHandler.js +354 -354
- package/lib/handlers/ZoomHandler.d.ts +48 -48
- package/lib/handlers/ZoomHandler.js +143 -143
- package/lib/handlers/index.d.ts +23 -23
- package/lib/handlers/index.js +48 -48
- package/lib/index.d.ts +6 -6
- package/lib/index.js +20 -20
- package/lib/objects/Arrow.d.ts +2 -2
- package/lib/objects/Arrow.js +40 -40
- package/lib/objects/Chart.d.ts +10 -10
- package/lib/objects/Chart.js +117 -117
- package/lib/objects/CirclePort.d.ts +2 -2
- package/lib/objects/CirclePort.js +28 -28
- package/lib/objects/Cube.d.ts +5 -5
- package/lib/objects/Cube.js +71 -71
- package/lib/objects/CurvedLink.d.ts +2 -2
- package/lib/objects/CurvedLink.js +51 -51
- package/lib/objects/Element.d.ts +13 -13
- package/lib/objects/Element.js +77 -77
- package/lib/objects/Gif.d.ts +3 -3
- package/lib/objects/Gif.js +41 -41
- package/lib/objects/Iframe.d.ts +9 -9
- package/lib/objects/Iframe.js +63 -63
- package/lib/objects/Line.d.ts +2 -2
- package/lib/objects/Line.js +24 -24
- package/lib/objects/Link.d.ts +15 -15
- package/lib/objects/Link.js +107 -107
- package/lib/objects/Node.d.ts +59 -59
- package/lib/objects/Node.js +271 -271
- package/lib/objects/OrthogonalLink.d.ts +2 -2
- package/lib/objects/OrthogonalLink.js +54 -54
- package/lib/objects/Port.d.ts +12 -12
- package/lib/objects/Port.js +28 -28
- package/lib/objects/Svg.d.ts +12 -12
- package/lib/objects/Svg.js +93 -93
- package/lib/objects/Video.d.ts +14 -14
- package/lib/objects/Video.js +113 -113
- package/lib/objects/index.d.ts +15 -15
- package/lib/objects/index.js +32 -32
- package/lib/utils/ObjectUtil.d.ts +408 -408
- package/lib/utils/ObjectUtil.js +13 -13
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +13 -13
- package/package.json +1 -1
package/lib/objects/Node.js
CHANGED
|
@@ -1,271 +1,271 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEllipsis = exports.DESCRIPTIONS = exports.OUT_PORT_TYPE = exports.NODE_COLORS = void 0;
|
|
7
|
-
const fabric_1 = require("fabric");
|
|
8
|
-
const i18next_1 = __importDefault(require("i18next"));
|
|
9
|
-
const uuidv4_1 = require("uuidv4");
|
|
10
|
-
const Port_1 = __importDefault(require("./Port"));
|
|
11
|
-
exports.NODE_COLORS = {
|
|
12
|
-
TRIGGER: {
|
|
13
|
-
fill: '#48C9B0',
|
|
14
|
-
border: '#1ABC9C',
|
|
15
|
-
},
|
|
16
|
-
LOGIC: {
|
|
17
|
-
fill: '#AF7AC5',
|
|
18
|
-
border: '#9B59B6',
|
|
19
|
-
},
|
|
20
|
-
DATA: {
|
|
21
|
-
fill: '#5DADE2',
|
|
22
|
-
border: '#3498DB',
|
|
23
|
-
},
|
|
24
|
-
ACTION: {
|
|
25
|
-
fill: '#F5B041',
|
|
26
|
-
border: 'rgb(243, 156, 18)',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
exports.OUT_PORT_TYPE = {
|
|
30
|
-
SINGLE: 'SINGLE',
|
|
31
|
-
STATIC: 'STATIC',
|
|
32
|
-
DYNAMIC: 'DYNAMIC',
|
|
33
|
-
BROADCAST: 'BROADCAST',
|
|
34
|
-
NONE: 'NONE',
|
|
35
|
-
};
|
|
36
|
-
exports.DESCRIPTIONS = {
|
|
37
|
-
script: i18next_1.default.t('common.name'),
|
|
38
|
-
template: i18next_1.default.t('common.name'),
|
|
39
|
-
json: i18next_1.default.t('common.name'),
|
|
40
|
-
cron: i18next_1.default.t('common.name'),
|
|
41
|
-
};
|
|
42
|
-
exports.getEllipsis = (text, length) => {
|
|
43
|
-
if (!length) {
|
|
44
|
-
return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(text)
|
|
45
|
-
? text.length > 8
|
|
46
|
-
? text.substring(0, 8).concat('...')
|
|
47
|
-
: text
|
|
48
|
-
: text.length > 15
|
|
49
|
-
? text.substring(0, 15).concat('...')
|
|
50
|
-
: text;
|
|
51
|
-
}
|
|
52
|
-
return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(text)
|
|
53
|
-
? text.length > length / 2
|
|
54
|
-
? text.substring(0, length / 2).concat('...')
|
|
55
|
-
: text
|
|
56
|
-
: text.length > length
|
|
57
|
-
? text.substring(0, length).concat('...')
|
|
58
|
-
: text;
|
|
59
|
-
};
|
|
60
|
-
const Node = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
61
|
-
type: 'node',
|
|
62
|
-
superType: 'node',
|
|
63
|
-
initialize(options) {
|
|
64
|
-
options = options || {};
|
|
65
|
-
const icon = new fabric_1.fabric.IText(options.icon || '\uE174', {
|
|
66
|
-
fontFamily: 'Font Awesome 5 Free',
|
|
67
|
-
fontWeight: 900,
|
|
68
|
-
fontSize: 20,
|
|
69
|
-
fill: 'rgba(255, 255, 255, 0.8)',
|
|
70
|
-
});
|
|
71
|
-
let name = 'Default Node';
|
|
72
|
-
if (options.name) {
|
|
73
|
-
name = exports.getEllipsis(options.name, 18);
|
|
74
|
-
}
|
|
75
|
-
this.label = new fabric_1.fabric.Text(name || 'Default Node', {
|
|
76
|
-
fontSize: 16,
|
|
77
|
-
fontFamily: 'polestar',
|
|
78
|
-
fontWeight: 500,
|
|
79
|
-
fill: 'rgba(255, 255, 255, 0.8)',
|
|
80
|
-
});
|
|
81
|
-
const rect = new fabric_1.fabric.Rect({
|
|
82
|
-
rx: 10,
|
|
83
|
-
ry: 10,
|
|
84
|
-
width: 200,
|
|
85
|
-
height: 40,
|
|
86
|
-
fill: options.fill || 'rgba(0, 0, 0, 0.3)',
|
|
87
|
-
stroke: options.stroke || 'rgba(0, 0, 0, 0)',
|
|
88
|
-
strokeWidth: 2,
|
|
89
|
-
});
|
|
90
|
-
this.errorFlag = new fabric_1.fabric.IText('\uf071', {
|
|
91
|
-
fontFamily: 'Font Awesome 5 Free',
|
|
92
|
-
fontWeight: 900,
|
|
93
|
-
fontSize: 14,
|
|
94
|
-
fill: 'rgba(255, 0, 0, 0.8)',
|
|
95
|
-
visible: options.errors,
|
|
96
|
-
});
|
|
97
|
-
const node = [rect, icon, this.label, this.errorFlag];
|
|
98
|
-
const option = Object.assign({}, options, {
|
|
99
|
-
id: options.id || uuidv4_1.uuid(),
|
|
100
|
-
width: 200,
|
|
101
|
-
height: 40,
|
|
102
|
-
originX: 'left',
|
|
103
|
-
originY: 'top',
|
|
104
|
-
hasRotatingPoint: false,
|
|
105
|
-
hasControls: false,
|
|
106
|
-
});
|
|
107
|
-
this.callSuper('initialize', node, option);
|
|
108
|
-
icon.set({
|
|
109
|
-
top: icon.top + 10,
|
|
110
|
-
left: icon.left + 10,
|
|
111
|
-
});
|
|
112
|
-
this.label.set({
|
|
113
|
-
top: this.label.top + this.label.height / 2 + 4,
|
|
114
|
-
left: this.label.left + 35,
|
|
115
|
-
});
|
|
116
|
-
this.errorFlag.set({
|
|
117
|
-
left: rect.left,
|
|
118
|
-
top: rect.top,
|
|
119
|
-
visible: options.errors,
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
toObject() {
|
|
123
|
-
return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
|
|
124
|
-
id: this.get('id'),
|
|
125
|
-
name: this.get('name'),
|
|
126
|
-
icon: this.get('icon'),
|
|
127
|
-
description: this.get('description'),
|
|
128
|
-
superType: this.get('superType'),
|
|
129
|
-
configuration: this.get('configuration'),
|
|
130
|
-
nodeClazz: this.get('nodeClazz'),
|
|
131
|
-
descriptor: this.get('descriptor'),
|
|
132
|
-
borderColor: this.get('borderColor'),
|
|
133
|
-
borderScaleFactor: this.get('borderScaleFactor'),
|
|
134
|
-
dblclick: this.get('dblclick'),
|
|
135
|
-
deletable: this.get('deletable'),
|
|
136
|
-
cloneable: this.get('cloneable'),
|
|
137
|
-
fromPort: this.get('fromPort'),
|
|
138
|
-
toPort: this.get('toPort'),
|
|
139
|
-
});
|
|
140
|
-
},
|
|
141
|
-
defaultPortOption() {
|
|
142
|
-
const { type } = this.descriptor;
|
|
143
|
-
return {
|
|
144
|
-
nodeId: this.id,
|
|
145
|
-
hasBorders: false,
|
|
146
|
-
hasControls: false,
|
|
147
|
-
hasRotatingPoint: false,
|
|
148
|
-
selectable: false,
|
|
149
|
-
originX: 'center',
|
|
150
|
-
originY: 'center',
|
|
151
|
-
lockScalingX: true,
|
|
152
|
-
lockScalingY: true,
|
|
153
|
-
superType: 'port',
|
|
154
|
-
originFill: 'rgba(0, 0, 0, 0.1)',
|
|
155
|
-
hoverFill: 'rgba(0, 0, 0, 0.1)',
|
|
156
|
-
selectFill: 'rgba(0, 0, 0, 0.1)',
|
|
157
|
-
fill: 'rgba(0, 0, 0, 0.1)',
|
|
158
|
-
hoverCursor: 'pointer',
|
|
159
|
-
strokeWidth: 2,
|
|
160
|
-
stroke: this.descriptor ? exports.NODE_COLORS[type].border : 'rgba(0, 0, 0, 1)',
|
|
161
|
-
width: 10,
|
|
162
|
-
height: 10,
|
|
163
|
-
links: [],
|
|
164
|
-
enabled: true,
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
toPortOption() {
|
|
168
|
-
return {
|
|
169
|
-
...this.defaultPortOption(),
|
|
170
|
-
};
|
|
171
|
-
},
|
|
172
|
-
fromPortOption() {
|
|
173
|
-
return {
|
|
174
|
-
...this.defaultPortOption(),
|
|
175
|
-
angle: 45,
|
|
176
|
-
};
|
|
177
|
-
},
|
|
178
|
-
createToPort(left, top) {
|
|
179
|
-
if (this.descriptor.inEnabled) {
|
|
180
|
-
this.toPort = new Port_1.default({
|
|
181
|
-
id: 'defaultInPort',
|
|
182
|
-
type: 'toPort',
|
|
183
|
-
...this.toPortOption(),
|
|
184
|
-
left,
|
|
185
|
-
top,
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
return this.toPort;
|
|
189
|
-
},
|
|
190
|
-
createFromPort(left, top) {
|
|
191
|
-
if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.BROADCAST) {
|
|
192
|
-
this.fromPort = this.broadcastPort({ ...this.fromPortOption(), left, top });
|
|
193
|
-
}
|
|
194
|
-
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.STATIC) {
|
|
195
|
-
this.fromPort = this.staticPort({ ...this.fromPortOption(), left, top });
|
|
196
|
-
}
|
|
197
|
-
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.DYNAMIC) {
|
|
198
|
-
this.fromPort = this.dynamicPort({ ...this.fromPortOption(), left, top });
|
|
199
|
-
}
|
|
200
|
-
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.NONE) {
|
|
201
|
-
this.fromPort = [];
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
this.fromPort = this.singlePort({ ...this.fromPortOption(), left, top });
|
|
205
|
-
}
|
|
206
|
-
return this.fromPort;
|
|
207
|
-
},
|
|
208
|
-
singlePort(portOption) {
|
|
209
|
-
const fromPort = new Port_1.default({
|
|
210
|
-
id: 'defaultFromPort',
|
|
211
|
-
type: 'fromPort',
|
|
212
|
-
...portOption,
|
|
213
|
-
});
|
|
214
|
-
return [fromPort];
|
|
215
|
-
},
|
|
216
|
-
staticPort(portOption) {
|
|
217
|
-
return this.descriptor.outPorts.map((outPort, i) => {
|
|
218
|
-
return new Port_1.default({
|
|
219
|
-
id: outPort,
|
|
220
|
-
type: 'fromPort',
|
|
221
|
-
...portOption,
|
|
222
|
-
left: i === 0 ? portOption.left - 20 : portOption.left + 20,
|
|
223
|
-
top: portOption.top,
|
|
224
|
-
leftDiff: i === 0 ? -20 : 20,
|
|
225
|
-
fill: i === 0 ? 'rgba(0, 255, 0, 0.3)' : 'rgba(255, 0, 0, 0.3)',
|
|
226
|
-
originFill: i === 0 ? 'rgba(0, 255, 0, 0.3)' : 'rgba(255, 0, 0, 0.3)',
|
|
227
|
-
hoverFill: i === 0 ? 'rgba(0, 255, 0, 1)' : 'rgba(255, 0, 0, 1)',
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
},
|
|
231
|
-
dynamicPort(_portOption) {
|
|
232
|
-
return [];
|
|
233
|
-
},
|
|
234
|
-
broadcastPort(portOption) {
|
|
235
|
-
return this.singlePort(portOption);
|
|
236
|
-
},
|
|
237
|
-
setErrors(errors) {
|
|
238
|
-
this.set({
|
|
239
|
-
errors,
|
|
240
|
-
});
|
|
241
|
-
if (errors) {
|
|
242
|
-
this.errorFlag.set({
|
|
243
|
-
visible: true,
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
this.errorFlag.set({
|
|
248
|
-
visible: false,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
},
|
|
252
|
-
duplicate() {
|
|
253
|
-
const options = this.toObject();
|
|
254
|
-
options.id = uuidv4_1.uuid();
|
|
255
|
-
options.name = `${options.name}_clone`;
|
|
256
|
-
return new Node(options);
|
|
257
|
-
},
|
|
258
|
-
_render(ctx) {
|
|
259
|
-
this.callSuper('_render', ctx);
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
Node.fromObject = (options, callback) => {
|
|
263
|
-
return callback(new Node(options));
|
|
264
|
-
};
|
|
265
|
-
// @ts-ignore
|
|
266
|
-
window.fabric.FromPort = Port_1.default;
|
|
267
|
-
// @ts-ignore
|
|
268
|
-
window.fabric.ToPort = Port_1.default;
|
|
269
|
-
// @ts-ignore
|
|
270
|
-
window.fabric.Node = Node;
|
|
271
|
-
exports.default = Node;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getEllipsis = exports.DESCRIPTIONS = exports.OUT_PORT_TYPE = exports.NODE_COLORS = void 0;
|
|
7
|
+
const fabric_1 = require("fabric");
|
|
8
|
+
const i18next_1 = __importDefault(require("i18next"));
|
|
9
|
+
const uuidv4_1 = require("uuidv4");
|
|
10
|
+
const Port_1 = __importDefault(require("./Port"));
|
|
11
|
+
exports.NODE_COLORS = {
|
|
12
|
+
TRIGGER: {
|
|
13
|
+
fill: '#48C9B0',
|
|
14
|
+
border: '#1ABC9C',
|
|
15
|
+
},
|
|
16
|
+
LOGIC: {
|
|
17
|
+
fill: '#AF7AC5',
|
|
18
|
+
border: '#9B59B6',
|
|
19
|
+
},
|
|
20
|
+
DATA: {
|
|
21
|
+
fill: '#5DADE2',
|
|
22
|
+
border: '#3498DB',
|
|
23
|
+
},
|
|
24
|
+
ACTION: {
|
|
25
|
+
fill: '#F5B041',
|
|
26
|
+
border: 'rgb(243, 156, 18)',
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
exports.OUT_PORT_TYPE = {
|
|
30
|
+
SINGLE: 'SINGLE',
|
|
31
|
+
STATIC: 'STATIC',
|
|
32
|
+
DYNAMIC: 'DYNAMIC',
|
|
33
|
+
BROADCAST: 'BROADCAST',
|
|
34
|
+
NONE: 'NONE',
|
|
35
|
+
};
|
|
36
|
+
exports.DESCRIPTIONS = {
|
|
37
|
+
script: i18next_1.default.t('common.name'),
|
|
38
|
+
template: i18next_1.default.t('common.name'),
|
|
39
|
+
json: i18next_1.default.t('common.name'),
|
|
40
|
+
cron: i18next_1.default.t('common.name'),
|
|
41
|
+
};
|
|
42
|
+
exports.getEllipsis = (text, length) => {
|
|
43
|
+
if (!length) {
|
|
44
|
+
return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(text)
|
|
45
|
+
? text.length > 8
|
|
46
|
+
? text.substring(0, 8).concat('...')
|
|
47
|
+
: text
|
|
48
|
+
: text.length > 15
|
|
49
|
+
? text.substring(0, 15).concat('...')
|
|
50
|
+
: text;
|
|
51
|
+
}
|
|
52
|
+
return /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/.test(text)
|
|
53
|
+
? text.length > length / 2
|
|
54
|
+
? text.substring(0, length / 2).concat('...')
|
|
55
|
+
: text
|
|
56
|
+
: text.length > length
|
|
57
|
+
? text.substring(0, length).concat('...')
|
|
58
|
+
: text;
|
|
59
|
+
};
|
|
60
|
+
const Node = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
|
|
61
|
+
type: 'node',
|
|
62
|
+
superType: 'node',
|
|
63
|
+
initialize(options) {
|
|
64
|
+
options = options || {};
|
|
65
|
+
const icon = new fabric_1.fabric.IText(options.icon || '\uE174', {
|
|
66
|
+
fontFamily: 'Font Awesome 5 Free',
|
|
67
|
+
fontWeight: 900,
|
|
68
|
+
fontSize: 20,
|
|
69
|
+
fill: 'rgba(255, 255, 255, 0.8)',
|
|
70
|
+
});
|
|
71
|
+
let name = 'Default Node';
|
|
72
|
+
if (options.name) {
|
|
73
|
+
name = exports.getEllipsis(options.name, 18);
|
|
74
|
+
}
|
|
75
|
+
this.label = new fabric_1.fabric.Text(name || 'Default Node', {
|
|
76
|
+
fontSize: 16,
|
|
77
|
+
fontFamily: 'polestar',
|
|
78
|
+
fontWeight: 500,
|
|
79
|
+
fill: 'rgba(255, 255, 255, 0.8)',
|
|
80
|
+
});
|
|
81
|
+
const rect = new fabric_1.fabric.Rect({
|
|
82
|
+
rx: 10,
|
|
83
|
+
ry: 10,
|
|
84
|
+
width: 200,
|
|
85
|
+
height: 40,
|
|
86
|
+
fill: options.fill || 'rgba(0, 0, 0, 0.3)',
|
|
87
|
+
stroke: options.stroke || 'rgba(0, 0, 0, 0)',
|
|
88
|
+
strokeWidth: 2,
|
|
89
|
+
});
|
|
90
|
+
this.errorFlag = new fabric_1.fabric.IText('\uf071', {
|
|
91
|
+
fontFamily: 'Font Awesome 5 Free',
|
|
92
|
+
fontWeight: 900,
|
|
93
|
+
fontSize: 14,
|
|
94
|
+
fill: 'rgba(255, 0, 0, 0.8)',
|
|
95
|
+
visible: options.errors,
|
|
96
|
+
});
|
|
97
|
+
const node = [rect, icon, this.label, this.errorFlag];
|
|
98
|
+
const option = Object.assign({}, options, {
|
|
99
|
+
id: options.id || uuidv4_1.uuid(),
|
|
100
|
+
width: 200,
|
|
101
|
+
height: 40,
|
|
102
|
+
originX: 'left',
|
|
103
|
+
originY: 'top',
|
|
104
|
+
hasRotatingPoint: false,
|
|
105
|
+
hasControls: false,
|
|
106
|
+
});
|
|
107
|
+
this.callSuper('initialize', node, option);
|
|
108
|
+
icon.set({
|
|
109
|
+
top: icon.top + 10,
|
|
110
|
+
left: icon.left + 10,
|
|
111
|
+
});
|
|
112
|
+
this.label.set({
|
|
113
|
+
top: this.label.top + this.label.height / 2 + 4,
|
|
114
|
+
left: this.label.left + 35,
|
|
115
|
+
});
|
|
116
|
+
this.errorFlag.set({
|
|
117
|
+
left: rect.left,
|
|
118
|
+
top: rect.top,
|
|
119
|
+
visible: options.errors,
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
toObject() {
|
|
123
|
+
return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
|
|
124
|
+
id: this.get('id'),
|
|
125
|
+
name: this.get('name'),
|
|
126
|
+
icon: this.get('icon'),
|
|
127
|
+
description: this.get('description'),
|
|
128
|
+
superType: this.get('superType'),
|
|
129
|
+
configuration: this.get('configuration'),
|
|
130
|
+
nodeClazz: this.get('nodeClazz'),
|
|
131
|
+
descriptor: this.get('descriptor'),
|
|
132
|
+
borderColor: this.get('borderColor'),
|
|
133
|
+
borderScaleFactor: this.get('borderScaleFactor'),
|
|
134
|
+
dblclick: this.get('dblclick'),
|
|
135
|
+
deletable: this.get('deletable'),
|
|
136
|
+
cloneable: this.get('cloneable'),
|
|
137
|
+
fromPort: this.get('fromPort'),
|
|
138
|
+
toPort: this.get('toPort'),
|
|
139
|
+
});
|
|
140
|
+
},
|
|
141
|
+
defaultPortOption() {
|
|
142
|
+
const { type } = this.descriptor;
|
|
143
|
+
return {
|
|
144
|
+
nodeId: this.id,
|
|
145
|
+
hasBorders: false,
|
|
146
|
+
hasControls: false,
|
|
147
|
+
hasRotatingPoint: false,
|
|
148
|
+
selectable: false,
|
|
149
|
+
originX: 'center',
|
|
150
|
+
originY: 'center',
|
|
151
|
+
lockScalingX: true,
|
|
152
|
+
lockScalingY: true,
|
|
153
|
+
superType: 'port',
|
|
154
|
+
originFill: 'rgba(0, 0, 0, 0.1)',
|
|
155
|
+
hoverFill: 'rgba(0, 0, 0, 0.1)',
|
|
156
|
+
selectFill: 'rgba(0, 0, 0, 0.1)',
|
|
157
|
+
fill: 'rgba(0, 0, 0, 0.1)',
|
|
158
|
+
hoverCursor: 'pointer',
|
|
159
|
+
strokeWidth: 2,
|
|
160
|
+
stroke: this.descriptor ? exports.NODE_COLORS[type].border : 'rgba(0, 0, 0, 1)',
|
|
161
|
+
width: 10,
|
|
162
|
+
height: 10,
|
|
163
|
+
links: [],
|
|
164
|
+
enabled: true,
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
toPortOption() {
|
|
168
|
+
return {
|
|
169
|
+
...this.defaultPortOption(),
|
|
170
|
+
};
|
|
171
|
+
},
|
|
172
|
+
fromPortOption() {
|
|
173
|
+
return {
|
|
174
|
+
...this.defaultPortOption(),
|
|
175
|
+
angle: 45,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
createToPort(left, top) {
|
|
179
|
+
if (this.descriptor.inEnabled) {
|
|
180
|
+
this.toPort = new Port_1.default({
|
|
181
|
+
id: 'defaultInPort',
|
|
182
|
+
type: 'toPort',
|
|
183
|
+
...this.toPortOption(),
|
|
184
|
+
left,
|
|
185
|
+
top,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return this.toPort;
|
|
189
|
+
},
|
|
190
|
+
createFromPort(left, top) {
|
|
191
|
+
if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.BROADCAST) {
|
|
192
|
+
this.fromPort = this.broadcastPort({ ...this.fromPortOption(), left, top });
|
|
193
|
+
}
|
|
194
|
+
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.STATIC) {
|
|
195
|
+
this.fromPort = this.staticPort({ ...this.fromPortOption(), left, top });
|
|
196
|
+
}
|
|
197
|
+
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.DYNAMIC) {
|
|
198
|
+
this.fromPort = this.dynamicPort({ ...this.fromPortOption(), left, top });
|
|
199
|
+
}
|
|
200
|
+
else if (this.descriptor.outPortType === exports.OUT_PORT_TYPE.NONE) {
|
|
201
|
+
this.fromPort = [];
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this.fromPort = this.singlePort({ ...this.fromPortOption(), left, top });
|
|
205
|
+
}
|
|
206
|
+
return this.fromPort;
|
|
207
|
+
},
|
|
208
|
+
singlePort(portOption) {
|
|
209
|
+
const fromPort = new Port_1.default({
|
|
210
|
+
id: 'defaultFromPort',
|
|
211
|
+
type: 'fromPort',
|
|
212
|
+
...portOption,
|
|
213
|
+
});
|
|
214
|
+
return [fromPort];
|
|
215
|
+
},
|
|
216
|
+
staticPort(portOption) {
|
|
217
|
+
return this.descriptor.outPorts.map((outPort, i) => {
|
|
218
|
+
return new Port_1.default({
|
|
219
|
+
id: outPort,
|
|
220
|
+
type: 'fromPort',
|
|
221
|
+
...portOption,
|
|
222
|
+
left: i === 0 ? portOption.left - 20 : portOption.left + 20,
|
|
223
|
+
top: portOption.top,
|
|
224
|
+
leftDiff: i === 0 ? -20 : 20,
|
|
225
|
+
fill: i === 0 ? 'rgba(0, 255, 0, 0.3)' : 'rgba(255, 0, 0, 0.3)',
|
|
226
|
+
originFill: i === 0 ? 'rgba(0, 255, 0, 0.3)' : 'rgba(255, 0, 0, 0.3)',
|
|
227
|
+
hoverFill: i === 0 ? 'rgba(0, 255, 0, 1)' : 'rgba(255, 0, 0, 1)',
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
dynamicPort(_portOption) {
|
|
232
|
+
return [];
|
|
233
|
+
},
|
|
234
|
+
broadcastPort(portOption) {
|
|
235
|
+
return this.singlePort(portOption);
|
|
236
|
+
},
|
|
237
|
+
setErrors(errors) {
|
|
238
|
+
this.set({
|
|
239
|
+
errors,
|
|
240
|
+
});
|
|
241
|
+
if (errors) {
|
|
242
|
+
this.errorFlag.set({
|
|
243
|
+
visible: true,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
this.errorFlag.set({
|
|
248
|
+
visible: false,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
},
|
|
252
|
+
duplicate() {
|
|
253
|
+
const options = this.toObject();
|
|
254
|
+
options.id = uuidv4_1.uuid();
|
|
255
|
+
options.name = `${options.name}_clone`;
|
|
256
|
+
return new Node(options);
|
|
257
|
+
},
|
|
258
|
+
_render(ctx) {
|
|
259
|
+
this.callSuper('_render', ctx);
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
Node.fromObject = (options, callback) => {
|
|
263
|
+
return callback(new Node(options));
|
|
264
|
+
};
|
|
265
|
+
// @ts-ignore
|
|
266
|
+
window.fabric.FromPort = Port_1.default;
|
|
267
|
+
// @ts-ignore
|
|
268
|
+
window.fabric.ToPort = Port_1.default;
|
|
269
|
+
// @ts-ignore
|
|
270
|
+
window.fabric.Node = Node;
|
|
271
|
+
exports.default = Node;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const OrthogonalLink: any;
|
|
2
|
-
export default OrthogonalLink;
|
|
1
|
+
declare const OrthogonalLink: any;
|
|
2
|
+
export default OrthogonalLink;
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fabric_1 = require("fabric");
|
|
7
|
-
const Link_1 = __importDefault(require("./Link"));
|
|
8
|
-
const OrthogonalLink = fabric_1.fabric.util.createClass(Link_1.default, {
|
|
9
|
-
type: 'OrthogonalLink',
|
|
10
|
-
superType: 'link',
|
|
11
|
-
initialize(fromNode, fromPort, toNode, toPort, options) {
|
|
12
|
-
options = options || {};
|
|
13
|
-
this.callSuper('initialize', fromNode, fromPort, toNode, toPort, options);
|
|
14
|
-
},
|
|
15
|
-
_render(ctx) {
|
|
16
|
-
// Drawing orthogonal link
|
|
17
|
-
const { x1, y1, x2, y2 } = this;
|
|
18
|
-
ctx.lineWidth = this.strokeWidth;
|
|
19
|
-
ctx.strokeStyle = this.stroke;
|
|
20
|
-
const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
|
|
21
|
-
const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
|
|
22
|
-
ctx.lineJoin = 'round';
|
|
23
|
-
ctx.beginPath();
|
|
24
|
-
ctx.moveTo(fp.x, fp.y);
|
|
25
|
-
ctx.lineTo(fp.x, sp.y / 2);
|
|
26
|
-
ctx.lineTo(sp.x, sp.y / 2);
|
|
27
|
-
ctx.lineTo(sp.x, sp.y);
|
|
28
|
-
ctx.stroke();
|
|
29
|
-
ctx.save();
|
|
30
|
-
const xDiff = this.x2 - this.x1;
|
|
31
|
-
const yDiff = this.y2 - this.y1;
|
|
32
|
-
const angle = Math.atan2(yDiff, xDiff);
|
|
33
|
-
ctx.translate((this.x2 - this.x1) / 2, (this.y2 - this.y1) / 2);
|
|
34
|
-
ctx.rotate(angle >= 0 ? 1.57 : -1.57);
|
|
35
|
-
ctx.beginPath();
|
|
36
|
-
if (this.arrow) {
|
|
37
|
-
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
38
|
-
ctx.moveTo(5, 0);
|
|
39
|
-
ctx.lineTo(-5, 5);
|
|
40
|
-
ctx.lineTo(-5, -5);
|
|
41
|
-
}
|
|
42
|
-
ctx.closePath();
|
|
43
|
-
ctx.fillStyle = this.stroke;
|
|
44
|
-
ctx.fill();
|
|
45
|
-
ctx.restore();
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
OrthogonalLink.fromObject = (options, callback) => {
|
|
49
|
-
const { fromNode, fromPort, toNode, toPort } = options;
|
|
50
|
-
return callback(new OrthogonalLink(fromNode, fromPort, toNode, toPort, options));
|
|
51
|
-
};
|
|
52
|
-
// @ts-ignore
|
|
53
|
-
window.fabric.OrthogonalLink = OrthogonalLink;
|
|
54
|
-
exports.default = OrthogonalLink;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fabric_1 = require("fabric");
|
|
7
|
+
const Link_1 = __importDefault(require("./Link"));
|
|
8
|
+
const OrthogonalLink = fabric_1.fabric.util.createClass(Link_1.default, {
|
|
9
|
+
type: 'OrthogonalLink',
|
|
10
|
+
superType: 'link',
|
|
11
|
+
initialize(fromNode, fromPort, toNode, toPort, options) {
|
|
12
|
+
options = options || {};
|
|
13
|
+
this.callSuper('initialize', fromNode, fromPort, toNode, toPort, options);
|
|
14
|
+
},
|
|
15
|
+
_render(ctx) {
|
|
16
|
+
// Drawing orthogonal link
|
|
17
|
+
const { x1, y1, x2, y2 } = this;
|
|
18
|
+
ctx.lineWidth = this.strokeWidth;
|
|
19
|
+
ctx.strokeStyle = this.stroke;
|
|
20
|
+
const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
|
|
21
|
+
const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
|
|
22
|
+
ctx.lineJoin = 'round';
|
|
23
|
+
ctx.beginPath();
|
|
24
|
+
ctx.moveTo(fp.x, fp.y);
|
|
25
|
+
ctx.lineTo(fp.x, sp.y / 2);
|
|
26
|
+
ctx.lineTo(sp.x, sp.y / 2);
|
|
27
|
+
ctx.lineTo(sp.x, sp.y);
|
|
28
|
+
ctx.stroke();
|
|
29
|
+
ctx.save();
|
|
30
|
+
const xDiff = this.x2 - this.x1;
|
|
31
|
+
const yDiff = this.y2 - this.y1;
|
|
32
|
+
const angle = Math.atan2(yDiff, xDiff);
|
|
33
|
+
ctx.translate((this.x2 - this.x1) / 2, (this.y2 - this.y1) / 2);
|
|
34
|
+
ctx.rotate(angle >= 0 ? 1.57 : -1.57);
|
|
35
|
+
ctx.beginPath();
|
|
36
|
+
if (this.arrow) {
|
|
37
|
+
// Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
|
|
38
|
+
ctx.moveTo(5, 0);
|
|
39
|
+
ctx.lineTo(-5, 5);
|
|
40
|
+
ctx.lineTo(-5, -5);
|
|
41
|
+
}
|
|
42
|
+
ctx.closePath();
|
|
43
|
+
ctx.fillStyle = this.stroke;
|
|
44
|
+
ctx.fill();
|
|
45
|
+
ctx.restore();
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
OrthogonalLink.fromObject = (options, callback) => {
|
|
49
|
+
const { fromNode, fromPort, toNode, toPort } = options;
|
|
50
|
+
return callback(new OrthogonalLink(fromNode, fromPort, toNode, toPort, options));
|
|
51
|
+
};
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
window.fabric.OrthogonalLink = OrthogonalLink;
|
|
54
|
+
exports.default = OrthogonalLink;
|