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,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class AlignmentHandler {
4
- constructor(handler) {
5
- /**
6
- * Align left at selection
7
- */
8
- this.left = () => {
9
- const activeObject = this.handler.canvas.getActiveObject();
10
- if (activeObject && activeObject.type === 'activeSelection') {
11
- const activeSelection = activeObject;
12
- const activeObjectLeft = -(activeObject.width / 2);
13
- activeSelection.forEachObject(obj => {
14
- obj.set({
15
- left: activeObjectLeft,
16
- });
17
- obj.setCoords();
18
- this.handler.canvas.renderAll();
19
- });
20
- }
21
- };
22
- /**
23
- * Align center at selection
24
- */
25
- this.center = () => {
26
- const activeObject = this.handler.canvas.getActiveObject();
27
- if (activeObject && activeObject.type === 'activeSelection') {
28
- const activeSelection = activeObject;
29
- activeSelection.forEachObject(obj => {
30
- obj.set({
31
- left: 0 - ((obj.width * obj.scaleX) / 2),
32
- });
33
- obj.setCoords();
34
- this.handler.canvas.renderAll();
35
- });
36
- }
37
- };
38
- /**
39
- * Align right at selection
40
- */
41
- this.right = () => {
42
- const activeObject = this.handler.canvas.getActiveObject();
43
- if (activeObject && activeObject.type === 'activeSelection') {
44
- const activeSelection = activeObject;
45
- const activeObjectLeft = (activeObject.width / 2);
46
- activeSelection.forEachObject(obj => {
47
- obj.set({
48
- left: activeObjectLeft - (obj.width * obj.scaleX),
49
- });
50
- obj.setCoords();
51
- this.handler.canvas.renderAll();
52
- });
53
- }
54
- };
55
- this.handler = handler;
56
- }
57
- }
58
- exports.default = AlignmentHandler;
@@ -1,50 +0,0 @@
1
- import anime from 'animejs';
2
- import { Handler } from '.';
3
- import { FabricObject } from '../utils';
4
- declare class AnimationHandler {
5
- handler: Handler;
6
- constructor(handler: Handler);
7
- /**
8
- * Play the animation
9
- * @param {string} id
10
- * @param {boolean} [hasControls]
11
- * @returns
12
- */
13
- play: (id: string, hasControls?: boolean) => void;
14
- /**
15
- * Pause the animation
16
- * @param {string} id
17
- * @returns
18
- */
19
- pause: (id: string) => void;
20
- /**
21
- * Stop the animation
22
- * @param {string} id
23
- * @param {boolean} [hasControls=true]
24
- * @returns
25
- */
26
- stop: (id: string, hasControls?: boolean) => void;
27
- /**
28
- * Restart the animation
29
- * @param {string} id
30
- * @returns
31
- */
32
- restart: (id: string) => void;
33
- /**
34
- * Reset animation
35
- *
36
- * @param {FabricObject} obj
37
- * @param {boolean} [hasControls=true]
38
- * @returns
39
- */
40
- resetAnimation: (obj: FabricObject, hasControls?: boolean) => void;
41
- /**
42
- * Get animation option
43
- *
44
- * @param {FabricObject} obj
45
- * @param {boolean} [hasControls]
46
- * @returns
47
- */
48
- getAnime: (obj: FabricObject, hasControls?: boolean) => anime.AnimeInstance;
49
- }
50
- export default AnimationHandler;
@@ -1,320 +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 animejs_1 = __importDefault(require("animejs"));
7
- class AnimationHandler {
8
- constructor(handler) {
9
- /**
10
- * Play the animation
11
- * @param {string} id
12
- * @param {boolean} [hasControls]
13
- * @returns
14
- */
15
- this.play = (id, hasControls) => {
16
- const findObject = this.handler.findById(id);
17
- if (!findObject) {
18
- return;
19
- }
20
- if (findObject.anime) {
21
- findObject.anime.restart();
22
- return;
23
- }
24
- if (findObject.animation.type === 'none') {
25
- return;
26
- }
27
- const instance = this.getAnime(findObject, hasControls);
28
- if (instance) {
29
- findObject.set('anime', instance);
30
- findObject.set({
31
- hasControls: false,
32
- lockMovementX: true,
33
- lockMovementY: true,
34
- hoverCursor: 'pointer',
35
- });
36
- this.handler.canvas.requestRenderAll();
37
- instance.play();
38
- }
39
- };
40
- /**
41
- * Pause the animation
42
- * @param {string} id
43
- * @returns
44
- */
45
- this.pause = (id) => {
46
- const findObject = this.handler.findById(id);
47
- if (!findObject) {
48
- return;
49
- }
50
- findObject.anime.pause();
51
- };
52
- /**
53
- * Stop the animation
54
- * @param {string} id
55
- * @param {boolean} [hasControls=true]
56
- * @returns
57
- */
58
- this.stop = (id, hasControls = true) => {
59
- const findObject = this.handler.findById(id);
60
- if (!findObject) {
61
- return;
62
- }
63
- this.resetAnimation(findObject, hasControls);
64
- };
65
- /**
66
- * Restart the animation
67
- * @param {string} id
68
- * @returns
69
- */
70
- this.restart = (id) => {
71
- const findObject = this.handler.findById(id);
72
- if (!findObject) {
73
- return;
74
- }
75
- if (!findObject.anime) {
76
- return;
77
- }
78
- this.stop(id);
79
- this.play(id);
80
- };
81
- /**
82
- * Reset animation
83
- *
84
- * @param {FabricObject} obj
85
- * @param {boolean} [hasControls=true]
86
- * @returns
87
- */
88
- this.resetAnimation = (obj, hasControls = true) => {
89
- if (!obj.anime) {
90
- return;
91
- }
92
- let option;
93
- if (this.handler.editable) {
94
- option = {
95
- anime: null,
96
- hasControls,
97
- lockMovementX: !hasControls,
98
- lockMovementY: !hasControls,
99
- hoverCursor: hasControls ? 'move' : 'pointer',
100
- };
101
- }
102
- else {
103
- option = {
104
- anime: null,
105
- hasControls: false,
106
- lockMovementX: true,
107
- lockMovementY: true,
108
- hoverCursor: 'pointer',
109
- };
110
- }
111
- animejs_1.default.remove(obj);
112
- const { type } = obj.animation;
113
- if (type === 'fade') {
114
- Object.assign(option, {
115
- opacity: obj.originOpacity,
116
- originOpacity: null,
117
- });
118
- }
119
- else if (type === 'bounce') {
120
- if (obj.animation.bounce === 'vertical') {
121
- Object.assign(option, {
122
- top: obj.originTop,
123
- originTop: null,
124
- });
125
- }
126
- else {
127
- Object.assign(option, {
128
- left: obj.originLeft,
129
- originLeft: null,
130
- });
131
- }
132
- }
133
- else if (type === 'shake') {
134
- if (obj.animation.shake === 'vertical') {
135
- Object.assign(option, {
136
- top: obj.originTop,
137
- originTop: null,
138
- });
139
- }
140
- else {
141
- Object.assign(option, {
142
- left: obj.originLeft,
143
- originLeft: null,
144
- });
145
- }
146
- }
147
- else if (type === 'scaling') {
148
- Object.assign(option, {
149
- scaleX: obj.originScaleX,
150
- scaleY: obj.originScaleY,
151
- originScaleX: null,
152
- originScaleY: null,
153
- });
154
- }
155
- else if (type === 'rotation') {
156
- Object.assign(option, {
157
- angle: obj.originAngle,
158
- rotation: obj.originAngle,
159
- left: obj.originLeft,
160
- top: obj.originTop,
161
- originLeft: null,
162
- originTop: null,
163
- originAngle: null,
164
- });
165
- }
166
- else if (type === 'flash') {
167
- Object.assign(option, {
168
- fill: obj.originFill,
169
- stroke: obj.originStroke,
170
- originFill: null,
171
- origniStroke: null,
172
- });
173
- }
174
- else {
175
- console.warn('Not supported type.');
176
- }
177
- obj.set(option);
178
- this.handler.canvas.renderAll();
179
- };
180
- /**
181
- * Get animation option
182
- *
183
- * @param {FabricObject} obj
184
- * @param {boolean} [hasControls]
185
- * @returns
186
- */
187
- this.getAnime = (obj, hasControls) => {
188
- const { delay = 0, duration = 100, autoplay = true, loop = true, type, ...other } = obj.animation;
189
- const option = {
190
- targets: obj,
191
- delay,
192
- loop,
193
- autoplay,
194
- duration,
195
- direction: 'alternate',
196
- begin: () => {
197
- obj.set({
198
- hasControls: false,
199
- lockMovementX: true,
200
- lockMovementY: true,
201
- hoverCursor: 'pointer',
202
- });
203
- this.handler.canvas.requestRenderAll();
204
- },
205
- update: (e) => {
206
- if (type === 'flash') {
207
- // I don't know why it works. Magic code...
208
- const fill = e.animations[0].currentValue;
209
- const stroke = e.animations[1].currentValue;
210
- obj.set('fill', '');
211
- obj.set('fill', fill);
212
- obj.set('stroke', stroke);
213
- }
214
- else if (type === 'rotation') {
215
- const angle = e.animations[0].currentValue;
216
- obj.rotate(angle);
217
- this.handler.canvas.requestRenderAll();
218
- return;
219
- }
220
- obj.setCoords();
221
- this.handler.canvas.requestRenderAll();
222
- },
223
- complete: () => {
224
- this.resetAnimation(obj, hasControls);
225
- },
226
- };
227
- if (type === 'fade') {
228
- const { opacity = 0 } = other;
229
- obj.set('originOpacity', obj.opacity);
230
- Object.assign(option, {
231
- opacity,
232
- easing: 'easeInQuad',
233
- });
234
- }
235
- else if (type === 'bounce') {
236
- const { offset = 1 } = other;
237
- if (other.bounce === 'vertical') {
238
- obj.set('originTop', obj.top);
239
- Object.assign(option, {
240
- top: obj.top + offset,
241
- easing: 'easeInQuad',
242
- });
243
- }
244
- else {
245
- obj.set('originLeft', obj.left);
246
- Object.assign(option, {
247
- left: obj.left + offset,
248
- easing: 'easeInQuad',
249
- });
250
- }
251
- }
252
- else if (type === 'shake') {
253
- const { offset = 1 } = other;
254
- if (other.shake === 'vertical') {
255
- obj.set('originTop', obj.top);
256
- Object.assign(option, {
257
- top: obj.top + offset,
258
- delay: 0,
259
- elasticity: 1000,
260
- duration: 500,
261
- });
262
- }
263
- else {
264
- obj.set('originLeft', obj.left);
265
- Object.assign(option, {
266
- left: obj.left + offset,
267
- delay: 0,
268
- elasticity: 1000,
269
- duration: 500,
270
- });
271
- }
272
- }
273
- else if (type === 'scaling') {
274
- const { scale = 2 } = other;
275
- obj.set('originScaleX', obj.scaleX);
276
- obj.set('originScaleY', obj.scaleY);
277
- obj.set({
278
- originScaleX: obj.scaleX,
279
- originScaleY: obj.scaleY,
280
- });
281
- const scaleX = obj.scaleX * scale;
282
- const scaleY = obj.scaleY * scale;
283
- Object.assign(option, {
284
- scaleX,
285
- scaleY,
286
- easing: 'easeInQuad',
287
- });
288
- }
289
- else if (type === 'rotation') {
290
- const { angle = 360 } = other;
291
- obj.set('rotation', obj.angle);
292
- obj.set('originAngle', obj.angle);
293
- obj.set('originLeft', obj.left);
294
- obj.set('originTop', obj.top);
295
- Object.assign(option, {
296
- rotation: angle,
297
- easing: 'linear',
298
- direction: 'normal',
299
- });
300
- }
301
- else if (type === 'flash') {
302
- const { fill = obj.fill, stroke = obj.stroke } = other;
303
- obj.set('originFill', obj.fill);
304
- obj.set('originStroke', obj.stroke);
305
- Object.assign(option, {
306
- fill,
307
- stroke,
308
- easing: 'easeInQuad',
309
- });
310
- }
311
- else {
312
- console.warn('Not supported type.');
313
- return null;
314
- }
315
- return animejs_1.default(option);
316
- };
317
- this.handler = handler;
318
- }
319
- }
320
- exports.default = AnimationHandler;
@@ -1,8 +0,0 @@
1
- import * as echarts from 'echarts';
2
- import Handler from './Handler';
3
- declare class ChartHandler {
4
- handler?: Handler;
5
- instance?: echarts.ECharts;
6
- constructor(handler: Handler);
7
- }
8
- export default ChartHandler;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class ChartHandler {
4
- constructor(handler) {
5
- this.handler = handler;
6
- }
7
- }
8
- exports.default = ChartHandler;
@@ -1,28 +0,0 @@
1
- /// <reference types="lodash" />
2
- import { Handler } from '.';
3
- declare class ContextmenuHandler {
4
- handler: Handler;
5
- contextmenuEl: HTMLDivElement;
6
- constructor(handler: Handler);
7
- /**
8
- * Initialize contextmenu
9
- *
10
- */
11
- initialize(): void;
12
- /**
13
- * Destroy contextmenu
14
- *
15
- */
16
- destory(): void;
17
- /**
18
- * Show context menu
19
- *
20
- */
21
- show: ((e: any, target: any) => Promise<void>) & import("lodash").Cancelable;
22
- /**
23
- * Hide context menu
24
- *
25
- */
26
- hide: (() => void) & import("lodash").Cancelable;
27
- }
28
- export default ContextmenuHandler;
@@ -1,65 +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 react_dom_1 = __importDefault(require("react-dom"));
7
- const debounce_1 = __importDefault(require("lodash/debounce"));
8
- class ContextmenuHandler {
9
- constructor(handler) {
10
- /**
11
- * Show context menu
12
- *
13
- */
14
- this.show = debounce_1.default(async (e, target) => {
15
- const { onContext } = this.handler;
16
- while (this.contextmenuEl.hasChildNodes()) {
17
- this.contextmenuEl.removeChild(this.contextmenuEl.firstChild);
18
- }
19
- const contextmenu = document.createElement('div');
20
- contextmenu.className = 'rde-contextmenu-right';
21
- const element = await onContext(this.contextmenuEl, e, target);
22
- if (!element) {
23
- return;
24
- }
25
- contextmenu.innerHTML = element;
26
- this.contextmenuEl.appendChild(contextmenu);
27
- react_dom_1.default.render(element, contextmenu);
28
- this.contextmenuEl.classList.remove('contextmenu-hidden');
29
- const { clientX: left, clientY: top } = e;
30
- this.contextmenuEl.style.left = `${left}px`;
31
- this.contextmenuEl.style.top = `${top}px`;
32
- }, 100);
33
- /**
34
- * Hide context menu
35
- *
36
- */
37
- this.hide = debounce_1.default(() => {
38
- if (this.contextmenuEl) {
39
- this.contextmenuEl.classList.add('contextmenu-hidden');
40
- }
41
- }, 100);
42
- this.handler = handler;
43
- this.initialize();
44
- }
45
- /**
46
- * Initialize contextmenu
47
- *
48
- */
49
- initialize() {
50
- this.contextmenuEl = document.createElement('div');
51
- this.contextmenuEl.id = `${this.handler.id}_contextmenu`;
52
- this.contextmenuEl.className = 'rde-contextmenu contextmenu-hidden';
53
- document.body.appendChild(this.contextmenuEl);
54
- }
55
- /**
56
- * Destroy contextmenu
57
- *
58
- */
59
- destory() {
60
- if (this.contextmenuEl) {
61
- document.body.removeChild(this.contextmenuEl);
62
- }
63
- }
64
- }
65
- exports.default = ContextmenuHandler;
@@ -1,43 +0,0 @@
1
- import { fabric } from 'fabric';
2
- import { Handler } from '.';
3
- import { FabricImage } from '../utils';
4
- declare class CropHandler {
5
- handler: Handler;
6
- cropRect: fabric.Rect;
7
- cropObject: FabricImage;
8
- constructor(handler: Handler);
9
- /**
10
- * Validate crop type
11
- *
12
- * @returns
13
- */
14
- validType: () => boolean;
15
- /**
16
- * Start crop image
17
- *
18
- */
19
- start: () => void;
20
- /**
21
- * Finish crop image
22
- *
23
- */
24
- finish: () => void;
25
- /**
26
- * Cancel crop
27
- *
28
- */
29
- cancel: () => void;
30
- /**
31
- * Resize crop
32
- *
33
- * @param {FabricEvent} opt
34
- */
35
- resize: (opt: fabric.IEvent) => void;
36
- /**
37
- * Resize crop
38
- *
39
- * @param {FabricEvent} opt
40
- */
41
- moving: (opt: fabric.IEvent) => void;
42
- }
43
- export default CropHandler;