react-design-editor 0.0.33 → 0.0.37

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 (95) hide show
  1. package/README.md +37 -33
  2. package/dist/react-design-editor.js +20849 -11309
  3. package/dist/react-design-editor.min.js +1 -1
  4. package/dist/react-design-editor.min.js.LICENSE.txt +3 -10
  5. package/package.json +35 -31
  6. package/lib/Canvas.d.ts +0 -32
  7. package/lib/Canvas.js +0 -162
  8. package/lib/CanvasObject.d.ts +0 -10
  9. package/lib/CanvasObject.js +0 -96
  10. package/lib/constants/defaults.d.ts +0 -37
  11. package/lib/constants/defaults.js +0 -68
  12. package/lib/constants/index.d.ts +0 -2
  13. package/lib/constants/index.js +0 -24
  14. package/lib/handlers/AlignmentHandler.d.ts +0 -18
  15. package/lib/handlers/AlignmentHandler.js +0 -58
  16. package/lib/handlers/AnimationHandler.d.ts +0 -50
  17. package/lib/handlers/AnimationHandler.js +0 -320
  18. package/lib/handlers/ChartHandler.d.ts +0 -8
  19. package/lib/handlers/ChartHandler.js +0 -8
  20. package/lib/handlers/ContextmenuHandler.d.ts +0 -28
  21. package/lib/handlers/ContextmenuHandler.js +0 -65
  22. package/lib/handlers/CropHandler.d.ts +0 -43
  23. package/lib/handlers/CropHandler.js +0 -261
  24. package/lib/handlers/DrawingHandler.d.ts +0 -28
  25. package/lib/handlers/DrawingHandler.js +0 -318
  26. package/lib/handlers/ElementHandler.d.ts +0 -80
  27. package/lib/handlers/ElementHandler.js +0 -154
  28. package/lib/handlers/EventHandler.d.ts +0 -170
  29. package/lib/handlers/EventHandler.js +0 -877
  30. package/lib/handlers/GridHandler.d.ts +0 -19
  31. package/lib/handlers/GridHandler.js +0 -77
  32. package/lib/handlers/GuidelineHandler.d.ts +0 -61
  33. package/lib/handlers/GuidelineHandler.js +0 -314
  34. package/lib/handlers/Handler.d.ts +0 -603
  35. package/lib/handlers/Handler.js +0 -1612
  36. package/lib/handlers/ImageHandler.d.ts +0 -307
  37. package/lib/handlers/ImageHandler.js +0 -529
  38. package/lib/handlers/InteractionHandler.d.ts +0 -45
  39. package/lib/handlers/InteractionHandler.js +0 -159
  40. package/lib/handlers/LinkHandler.d.ts +0 -115
  41. package/lib/handlers/LinkHandler.js +0 -247
  42. package/lib/handlers/NodeHandler.d.ts +0 -50
  43. package/lib/handlers/NodeHandler.js +0 -274
  44. package/lib/handlers/PortHandler.d.ts +0 -22
  45. package/lib/handlers/PortHandler.js +0 -179
  46. package/lib/handlers/ShortcutHandler.d.ts +0 -119
  47. package/lib/handlers/ShortcutHandler.js +0 -150
  48. package/lib/handlers/TooltipHandler.d.ts +0 -33
  49. package/lib/handlers/TooltipHandler.js +0 -91
  50. package/lib/handlers/TransactionHandler.d.ts +0 -59
  51. package/lib/handlers/TransactionHandler.js +0 -139
  52. package/lib/handlers/WorkareaHandler.d.ts +0 -43
  53. package/lib/handlers/WorkareaHandler.js +0 -354
  54. package/lib/handlers/ZoomHandler.d.ts +0 -48
  55. package/lib/handlers/ZoomHandler.js +0 -143
  56. package/lib/handlers/index.d.ts +0 -21
  57. package/lib/handlers/index.js +0 -44
  58. package/lib/index.d.ts +0 -5
  59. package/lib/index.js +0 -19
  60. package/lib/objects/Arrow.d.ts +0 -2
  61. package/lib/objects/Arrow.js +0 -39
  62. package/lib/objects/Chart.d.ts +0 -10
  63. package/lib/objects/Chart.js +0 -123
  64. package/lib/objects/CirclePort.d.ts +0 -2
  65. package/lib/objects/CirclePort.js +0 -28
  66. package/lib/objects/Cube.d.ts +0 -5
  67. package/lib/objects/Cube.js +0 -71
  68. package/lib/objects/CurvedLink.d.ts +0 -2
  69. package/lib/objects/CurvedLink.js +0 -49
  70. package/lib/objects/Element.d.ts +0 -13
  71. package/lib/objects/Element.js +0 -83
  72. package/lib/objects/Gif.d.ts +0 -3
  73. package/lib/objects/Gif.js +0 -38
  74. package/lib/objects/Iframe.d.ts +0 -9
  75. package/lib/objects/Iframe.js +0 -69
  76. package/lib/objects/Line.d.ts +0 -2
  77. package/lib/objects/Line.js +0 -24
  78. package/lib/objects/Link.d.ts +0 -15
  79. package/lib/objects/Link.js +0 -104
  80. package/lib/objects/Node.d.ts +0 -59
  81. package/lib/objects/Node.js +0 -271
  82. package/lib/objects/OrthogonalLink.d.ts +0 -2
  83. package/lib/objects/OrthogonalLink.js +0 -52
  84. package/lib/objects/Port.d.ts +0 -12
  85. package/lib/objects/Port.js +0 -28
  86. package/lib/objects/Svg.d.ts +0 -8
  87. package/lib/objects/Svg.js +0 -59
  88. package/lib/objects/Video.d.ts +0 -14
  89. package/lib/objects/Video.js +0 -119
  90. package/lib/objects/index.d.ts +0 -15
  91. package/lib/objects/index.js +0 -32
  92. package/lib/utils/ObjectUtil.d.ts +0 -400
  93. package/lib/utils/ObjectUtil.js +0 -13
  94. package/lib/utils/index.d.ts +0 -1
  95. package/lib/utils/index.js +0 -13
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fabric_1 = require("fabric");
4
- const uuid_1 = require("uuid");
5
- const Node_1 = require("./Node");
6
- const Link = fabric_1.fabric.util.createClass(fabric_1.fabric.Line, {
7
- type: 'link',
8
- superType: 'link',
9
- initialize(fromNode, fromPort, toNode, toPort, options) {
10
- options = options || {};
11
- const coords = [fromPort.left, fromPort.top, toPort.left, toPort.top];
12
- this.callSuper('initialize', coords, options);
13
- this.set({
14
- strokeWidth: 4,
15
- id: options.id || uuid_1.v4(),
16
- originX: 'center',
17
- originY: 'center',
18
- lockScalingX: true,
19
- lockScalingY: true,
20
- lockRotation: true,
21
- hasRotatingPoint: false,
22
- hasControls: false,
23
- hasBorders: false,
24
- perPixelTargetFind: true,
25
- lockMovementX: true,
26
- lockMovementY: true,
27
- selectable: false,
28
- fromNode,
29
- fromPort,
30
- toNode,
31
- toPort,
32
- });
33
- },
34
- setPort(fromNode, fromPort, _toNode, toPort) {
35
- if (fromNode.type === 'BroadcastNode') {
36
- fromPort = fromNode.fromPort[0];
37
- }
38
- fromPort.links.push(this);
39
- toPort.links.push(this);
40
- this.setPortEnabled(fromNode, fromPort, false);
41
- },
42
- setPortEnabled(node, port, enabled) {
43
- if (node.descriptor.outPortType !== Node_1.OUT_PORT_TYPE.BROADCAST) {
44
- port.set({
45
- enabled,
46
- fill: enabled ? port.originFill : port.selectFill,
47
- });
48
- }
49
- else {
50
- if (node.toPort.id === port.id) {
51
- return;
52
- }
53
- port.links.forEach((link, index) => {
54
- link.set({
55
- fromPort: port,
56
- fromPortIndex: index,
57
- });
58
- });
59
- node.set({
60
- configuration: {
61
- outputCount: port.links.length,
62
- },
63
- });
64
- }
65
- },
66
- toObject() {
67
- return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
68
- id: this.get('id'),
69
- name: this.get('name'),
70
- superType: this.get('superType'),
71
- configuration: this.get('configuration'),
72
- fromNode: this.get('fromNode'),
73
- fromPort: this.get('fromPort'),
74
- toNode: this.get('toNode'),
75
- toPort: this.get('toPort'),
76
- });
77
- },
78
- _render(ctx) {
79
- this.callSuper('_render', ctx);
80
- ctx.save();
81
- const xDiff = this.x2 - this.x1;
82
- const yDiff = this.y2 - this.y1;
83
- const angle = Math.atan2(yDiff, xDiff);
84
- ctx.translate((this.x2 - this.x1) / 2, (this.y2 - this.y1) / 2);
85
- ctx.rotate(angle);
86
- ctx.beginPath();
87
- if (this.arrow) {
88
- // Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
89
- ctx.moveTo(5, 0);
90
- ctx.lineTo(-5, 5);
91
- ctx.lineTo(-5, -5);
92
- }
93
- ctx.closePath();
94
- ctx.fillStyle = this.stroke;
95
- ctx.fill();
96
- ctx.restore();
97
- },
98
- });
99
- Link.fromObject = (options, callback) => {
100
- const { fromNode, fromPort, toNode, toPort } = options;
101
- return callback(new Link(fromNode, fromPort, toNode, toPort, options));
102
- };
103
- window.fabric.Link = Link;
104
- exports.default = Link;
@@ -1,59 +0,0 @@
1
- import { fabric } from 'fabric';
2
- import { FabricObject } from '../utils';
3
- import { PortObject } from './Port';
4
- export declare const NODE_COLORS: {
5
- TRIGGER: {
6
- fill: string;
7
- border: string;
8
- };
9
- LOGIC: {
10
- fill: string;
11
- border: string;
12
- };
13
- DATA: {
14
- fill: string;
15
- border: string;
16
- };
17
- ACTION: {
18
- fill: string;
19
- border: string;
20
- };
21
- };
22
- export declare const OUT_PORT_TYPE: {
23
- SINGLE: string;
24
- STATIC: string;
25
- DYNAMIC: string;
26
- BROADCAST: string;
27
- NONE: string;
28
- };
29
- export declare const DESCRIPTIONS: {
30
- script: string;
31
- template: string;
32
- json: string;
33
- cron: string;
34
- };
35
- export declare const getEllipsis: (text: string, length: number) => string;
36
- export declare type NodeType = 'TRIGGER' | 'LOGIC' | 'DATA' | 'ACTION';
37
- export interface NodeObject extends FabricObject<fabric.Group> {
38
- errorFlag?: fabric.IText;
39
- label?: fabric.Text;
40
- toPort?: PortObject;
41
- errors?: any;
42
- fromPort?: PortObject[];
43
- descriptor?: Record<string, any>;
44
- nodeClazz?: string;
45
- configuration?: Record<string, any>;
46
- defaultPortOption?: () => Partial<PortObject>;
47
- toPortOption?: () => Partial<PortObject>;
48
- fromPortOption?: () => Partial<PortObject>;
49
- createToPort?: (left: number, top: number) => PortObject;
50
- createFromPort?: (left: number, top: number) => PortObject[];
51
- singlePort?: (portOption: Partial<PortObject>) => PortObject[];
52
- staticPort?: (portOption: Partial<PortObject>) => PortObject[];
53
- dynamicPort?: (portOption: Partial<PortObject>) => PortObject[];
54
- broadcastPort?: (portOption: Partial<PortObject>) => PortObject[];
55
- setErrors?: (errors: any) => void;
56
- duplicate?: () => NodeObject;
57
- }
58
- declare const Node: any;
59
- export default Node;
@@ -1,271 +0,0 @@
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 uuid_1 = require("uuid");
9
- const i18next_1 = __importDefault(require("i18next"));
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 || uuid_1.v4(),
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 = uuid_1.v4();
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 +0,0 @@
1
- declare const OrthogonalLink: any;
2
- export default OrthogonalLink;
@@ -1,52 +0,0 @@
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.strokeStyle = this.stroke;
19
- const fp = { x: (x1 - x2) / 2, y: (y1 - y2) / 2 };
20
- const sp = { x: (x2 - x1) / 2, y: (y2 - y1) / 2 };
21
- ctx.lineJoin = 'round';
22
- ctx.beginPath();
23
- ctx.moveTo(fp.x, fp.y);
24
- ctx.lineTo(fp.x, sp.y / 2);
25
- ctx.lineTo(sp.x, sp.y / 2);
26
- ctx.lineTo(sp.x, sp.y);
27
- ctx.stroke();
28
- ctx.save();
29
- const xDiff = this.x2 - this.x1;
30
- const yDiff = this.y2 - this.y1;
31
- const angle = Math.atan2(yDiff, xDiff);
32
- ctx.translate((this.x2 - this.x1) / 2, (this.y2 - this.y1) / 2);
33
- ctx.rotate(angle >= 0 ? 1.57 : -1.57);
34
- ctx.beginPath();
35
- if (this.arrow) {
36
- // Move 5px in front of line to start the arrow so it does not have the square line end showing in front (0,0)
37
- ctx.moveTo(5, 0);
38
- ctx.lineTo(-5, 5);
39
- ctx.lineTo(-5, -5);
40
- }
41
- ctx.closePath();
42
- ctx.fillStyle = this.stroke;
43
- ctx.fill();
44
- ctx.restore();
45
- },
46
- });
47
- OrthogonalLink.fromObject = (options, callback) => {
48
- const { fromNode, fromPort, toNode, toPort } = options;
49
- return callback(new OrthogonalLink(fromNode, fromPort, toNode, toPort, options));
50
- };
51
- window.fabric.OrthogonalLink = OrthogonalLink;
52
- exports.default = OrthogonalLink;
@@ -1,12 +0,0 @@
1
- import { fabric } from 'fabric';
2
- import { FabricObject } from '../utils';
3
- import { LinkObject } from './Link';
4
- export interface PortObject extends FabricObject<fabric.Rect> {
5
- links?: LinkObject[];
6
- nodeId?: string;
7
- enabled?: boolean;
8
- hoverFill?: string;
9
- selectFill?: string;
10
- }
11
- declare const Port: any;
12
- export default Port;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fabric_1 = require("fabric");
4
- const Port = fabric_1.fabric.util.createClass(fabric_1.fabric.Rect, {
5
- type: 'port',
6
- superType: 'port',
7
- initialize(options) {
8
- options = options || {};
9
- this.callSuper('initialize', options);
10
- },
11
- toObject() {
12
- return fabric_1.fabric.util.object.extend(this.callSuper('toObject'), {
13
- id: this.get('id'),
14
- superType: this.get('superType'),
15
- enabled: this.get('enabled'),
16
- nodeId: this.get('nodeId'),
17
- });
18
- },
19
- _render(ctx) {
20
- this.callSuper('_render', ctx);
21
- },
22
- });
23
- Port.fromObject = (options, callback) => {
24
- return callback(new Port(options));
25
- };
26
- // @ts-ignore
27
- window.fabric.Port = Port;
28
- exports.default = Port;
@@ -1,8 +0,0 @@
1
- import { FabricObject, FabricObjectOption, FabricGroup } from '../utils';
2
- export declare type SvgObject = FabricGroup | FabricObject;
3
- export interface SvgOption extends FabricObjectOption {
4
- svg?: string;
5
- loadType?: 'file' | 'svg';
6
- }
7
- declare const Svg: any;
8
- export default Svg;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const fabric_1 = require("fabric");
4
- const utils_1 = require("../utils");
5
- const Svg = fabric_1.fabric.util.createClass(fabric_1.fabric.Group, {
6
- type: 'svg',
7
- initialize(option = {}) {
8
- const { svg, loadType } = option;
9
- this.callSuper('initialize', [], option);
10
- this.loadSvg(svg, loadType);
11
- },
12
- addSvgElements(objects, options, path) {
13
- const createdObj = fabric_1.fabric.util.groupSVGElements(objects, options, path);
14
- this.set(options);
15
- if (createdObj.getObjects) {
16
- createdObj.getObjects().forEach(obj => this.add(obj));
17
- }
18
- else {
19
- createdObj.set({
20
- originX: 'center',
21
- originY: 'center',
22
- });
23
- this.add(createdObj);
24
- }
25
- this.setCoords();
26
- if (this.canvas) {
27
- this.canvas.requestRenderAll();
28
- }
29
- },
30
- loadSvg(svg, loadType) {
31
- return new Promise(resolve => {
32
- if (loadType === 'svg') {
33
- fabric_1.fabric.loadSVGFromString(svg, (objects, options) => {
34
- resolve(this.addSvgElements(objects, options, svg));
35
- });
36
- }
37
- else {
38
- fabric_1.fabric.loadSVGFromURL(svg, (objects, options) => {
39
- resolve(this.addSvgElements(objects, options, svg));
40
- });
41
- }
42
- });
43
- },
44
- toObject(propertiesToInclude) {
45
- return utils_1.toObject(this, propertiesToInclude, {
46
- svg: this.get('svg'),
47
- loadType: this.get('loadType'),
48
- });
49
- },
50
- _render(ctx) {
51
- this.callSuper('_render', ctx);
52
- },
53
- });
54
- Svg.fromObject = (option, callback) => {
55
- return callback(new Svg(option));
56
- };
57
- // @ts-ignore
58
- window.fabric.Svg = Svg;
59
- exports.default = Svg;
@@ -1,14 +0,0 @@
1
- import 'mediaelement';
2
- import 'mediaelement/build/mediaelementplayer.min.css';
3
- import { FabricElement } from '../utils';
4
- export interface VideoObject extends FabricElement {
5
- setSource: (source: string | File) => void;
6
- setFile: (file: File) => void;
7
- setSrc: (src: string) => void;
8
- file?: File;
9
- src?: string;
10
- videoElement?: HTMLVideoElement;
11
- player?: any;
12
- }
13
- declare const Video: any;
14
- export default Video;