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
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const constants_1 = require("../constants");
|
|
4
|
-
/**
|
|
5
|
-
* Shortcut Handler Class
|
|
6
|
-
*
|
|
7
|
-
* @author salgum1114
|
|
8
|
-
* @class ShortcutHandler
|
|
9
|
-
*/
|
|
10
|
-
class ShortcutHandler {
|
|
11
|
-
constructor(handler) {
|
|
12
|
-
/**
|
|
13
|
-
* Whether keydown Escape
|
|
14
|
-
*
|
|
15
|
-
* @param {KeyboardEvent} e
|
|
16
|
-
* @returns
|
|
17
|
-
*/
|
|
18
|
-
this.isEscape = (e) => {
|
|
19
|
-
return e.code === constants_1.code.ESCAPE && this.keyEvent.esc;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Whether keydown Q
|
|
23
|
-
*
|
|
24
|
-
* @param {KeyboardEvent} e
|
|
25
|
-
* @returns
|
|
26
|
-
*/
|
|
27
|
-
this.isQ = (e) => {
|
|
28
|
-
return e.code === constants_1.code.KEY_Q;
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Whether keydown W
|
|
32
|
-
*
|
|
33
|
-
* @param {KeyboardEvent} e
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
this.isW = (e) => {
|
|
37
|
-
return e.code === constants_1.code.KEY_W;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Whether keydown Delete or Backpsace
|
|
41
|
-
*
|
|
42
|
-
* @param {KeyboardEvent} e
|
|
43
|
-
* @returns
|
|
44
|
-
*/
|
|
45
|
-
this.isDelete = (e) => {
|
|
46
|
-
return (e.code === constants_1.code.BACKSPACE || e.code === constants_1.code.DELETE) && this.keyEvent.del;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Whether keydown Arrow
|
|
50
|
-
*
|
|
51
|
-
* @param {KeyboardEvent} e
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
this.isArrow = (e) => {
|
|
55
|
-
return e.code.includes('Arrow') && this.keyEvent.move;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Whether keydown Ctrl + A
|
|
59
|
-
*
|
|
60
|
-
* @param {KeyboardEvent} e
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
63
|
-
this.isCtrlA = (e) => {
|
|
64
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_A && this.keyEvent.all;
|
|
65
|
-
};
|
|
66
|
-
/**
|
|
67
|
-
* Whether keydown Ctrl + C
|
|
68
|
-
*
|
|
69
|
-
* @param {KeyboardEvent} e
|
|
70
|
-
* @returns
|
|
71
|
-
*/
|
|
72
|
-
this.isCtrlC = (e) => {
|
|
73
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_C && this.keyEvent.copy;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Whether keydown Ctrl + V
|
|
77
|
-
*
|
|
78
|
-
* @param {KeyboardEvent} e
|
|
79
|
-
* @returns
|
|
80
|
-
*/
|
|
81
|
-
this.isCtrlV = (e) => {
|
|
82
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_V && this.keyEvent.paste;
|
|
83
|
-
};
|
|
84
|
-
/**
|
|
85
|
-
* Whether keydown Ctrl + Z
|
|
86
|
-
*
|
|
87
|
-
* @param {KeyboardEvent} e
|
|
88
|
-
* @returns
|
|
89
|
-
*/
|
|
90
|
-
this.isCtrlZ = (e) => {
|
|
91
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_Z && this.keyEvent.transaction;
|
|
92
|
-
};
|
|
93
|
-
/**
|
|
94
|
-
* Whether keydown Ctrl + Y
|
|
95
|
-
*
|
|
96
|
-
* @param {KeyboardEvent} e
|
|
97
|
-
* @returns
|
|
98
|
-
*/
|
|
99
|
-
this.isCtrlY = (e) => {
|
|
100
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_Y && this.keyEvent.transaction;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Whether keydown Plus Or Equal
|
|
104
|
-
*
|
|
105
|
-
* @param {KeyboardEvent} e
|
|
106
|
-
* @returns
|
|
107
|
-
*/
|
|
108
|
-
this.isPlus = (e) => {
|
|
109
|
-
return e.code === constants_1.code.EQUAL && this.keyEvent.zoom;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Whether keydown Minus
|
|
113
|
-
*
|
|
114
|
-
* @param {KeyboardEvent} e
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
this.isMinus = (e) => {
|
|
118
|
-
return e.code === constants_1.code.MINUS && this.keyEvent.zoom;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Whether keydown O
|
|
122
|
-
*
|
|
123
|
-
* @param {KeyboardEvent} e
|
|
124
|
-
* @returns
|
|
125
|
-
*/
|
|
126
|
-
this.isO = (e) => {
|
|
127
|
-
return e.code === constants_1.code.KEY_O && this.keyEvent.zoom;
|
|
128
|
-
};
|
|
129
|
-
/**
|
|
130
|
-
* Whether keydown P
|
|
131
|
-
*
|
|
132
|
-
* @param {KeyboardEvent} e
|
|
133
|
-
* @returns
|
|
134
|
-
*/
|
|
135
|
-
this.isP = (e) => {
|
|
136
|
-
return e.code === constants_1.code.KEY_P && this.keyEvent.zoom;
|
|
137
|
-
};
|
|
138
|
-
/**
|
|
139
|
-
* Whether keydown Ctrl + X
|
|
140
|
-
*
|
|
141
|
-
* @param {KeyboardEvent} e
|
|
142
|
-
* @returns
|
|
143
|
-
*/
|
|
144
|
-
this.isCtrlX = (e) => {
|
|
145
|
-
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_X && this.keyEvent.cut;
|
|
146
|
-
};
|
|
147
|
-
this.handler = handler;
|
|
148
|
-
this.keyEvent = handler.keyEvent;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.default = ShortcutHandler;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
/**
|
|
5
|
+
* Shortcut Handler Class
|
|
6
|
+
*
|
|
7
|
+
* @author salgum1114
|
|
8
|
+
* @class ShortcutHandler
|
|
9
|
+
*/
|
|
10
|
+
class ShortcutHandler {
|
|
11
|
+
constructor(handler) {
|
|
12
|
+
/**
|
|
13
|
+
* Whether keydown Escape
|
|
14
|
+
*
|
|
15
|
+
* @param {KeyboardEvent} e
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
this.isEscape = (e) => {
|
|
19
|
+
return e.code === constants_1.code.ESCAPE && this.keyEvent.esc;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Whether keydown Q
|
|
23
|
+
*
|
|
24
|
+
* @param {KeyboardEvent} e
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
this.isQ = (e) => {
|
|
28
|
+
return e.code === constants_1.code.KEY_Q;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Whether keydown W
|
|
32
|
+
*
|
|
33
|
+
* @param {KeyboardEvent} e
|
|
34
|
+
* @returns
|
|
35
|
+
*/
|
|
36
|
+
this.isW = (e) => {
|
|
37
|
+
return e.code === constants_1.code.KEY_W;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Whether keydown Delete or Backpsace
|
|
41
|
+
*
|
|
42
|
+
* @param {KeyboardEvent} e
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
this.isDelete = (e) => {
|
|
46
|
+
return (e.code === constants_1.code.BACKSPACE || e.code === constants_1.code.DELETE) && this.keyEvent.del;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Whether keydown Arrow
|
|
50
|
+
*
|
|
51
|
+
* @param {KeyboardEvent} e
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
this.isArrow = (e) => {
|
|
55
|
+
return e.code.includes('Arrow') && this.keyEvent.move;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Whether keydown Ctrl + A
|
|
59
|
+
*
|
|
60
|
+
* @param {KeyboardEvent} e
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
this.isCtrlA = (e) => {
|
|
64
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_A && this.keyEvent.all;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Whether keydown Ctrl + C
|
|
68
|
+
*
|
|
69
|
+
* @param {KeyboardEvent} e
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
this.isCtrlC = (e) => {
|
|
73
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_C && this.keyEvent.copy;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Whether keydown Ctrl + V
|
|
77
|
+
*
|
|
78
|
+
* @param {KeyboardEvent} e
|
|
79
|
+
* @returns
|
|
80
|
+
*/
|
|
81
|
+
this.isCtrlV = (e) => {
|
|
82
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_V && this.keyEvent.paste;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Whether keydown Ctrl + Z
|
|
86
|
+
*
|
|
87
|
+
* @param {KeyboardEvent} e
|
|
88
|
+
* @returns
|
|
89
|
+
*/
|
|
90
|
+
this.isCtrlZ = (e) => {
|
|
91
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_Z && this.keyEvent.transaction;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Whether keydown Ctrl + Y
|
|
95
|
+
*
|
|
96
|
+
* @param {KeyboardEvent} e
|
|
97
|
+
* @returns
|
|
98
|
+
*/
|
|
99
|
+
this.isCtrlY = (e) => {
|
|
100
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_Y && this.keyEvent.transaction;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Whether keydown Plus Or Equal
|
|
104
|
+
*
|
|
105
|
+
* @param {KeyboardEvent} e
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
this.isPlus = (e) => {
|
|
109
|
+
return e.code === constants_1.code.EQUAL && this.keyEvent.zoom;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Whether keydown Minus
|
|
113
|
+
*
|
|
114
|
+
* @param {KeyboardEvent} e
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
this.isMinus = (e) => {
|
|
118
|
+
return e.code === constants_1.code.MINUS && this.keyEvent.zoom;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Whether keydown O
|
|
122
|
+
*
|
|
123
|
+
* @param {KeyboardEvent} e
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
this.isO = (e) => {
|
|
127
|
+
return e.code === constants_1.code.KEY_O && this.keyEvent.zoom;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Whether keydown P
|
|
131
|
+
*
|
|
132
|
+
* @param {KeyboardEvent} e
|
|
133
|
+
* @returns
|
|
134
|
+
*/
|
|
135
|
+
this.isP = (e) => {
|
|
136
|
+
return e.code === constants_1.code.KEY_P && this.keyEvent.zoom;
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Whether keydown Ctrl + X
|
|
140
|
+
*
|
|
141
|
+
* @param {KeyboardEvent} e
|
|
142
|
+
* @returns
|
|
143
|
+
*/
|
|
144
|
+
this.isCtrlX = (e) => {
|
|
145
|
+
return (e.ctrlKey || e.metaKey) && e.code === constants_1.code.KEY_X && this.keyEvent.cut;
|
|
146
|
+
};
|
|
147
|
+
this.handler = handler;
|
|
148
|
+
this.keyEvent = handler.keyEvent;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
exports.default = ShortcutHandler;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
|
-
import { FabricObject } from '../utils';
|
|
3
|
-
import Handler from './Handler';
|
|
4
|
-
declare class TooltipHandler {
|
|
5
|
-
handler: Handler;
|
|
6
|
-
tooltipEl: HTMLDivElement;
|
|
7
|
-
target?: fabric.Object;
|
|
8
|
-
constructor(handler: Handler);
|
|
9
|
-
/**
|
|
10
|
-
* Initialize tooltip
|
|
11
|
-
*
|
|
12
|
-
* @author salgum1114
|
|
13
|
-
*/
|
|
14
|
-
initialize(): void;
|
|
15
|
-
/**
|
|
16
|
-
* Destroy tooltip
|
|
17
|
-
*
|
|
18
|
-
* @author salgum1114
|
|
19
|
-
*/
|
|
20
|
-
destroy(): void;
|
|
21
|
-
/**
|
|
22
|
-
* Show tooltip
|
|
23
|
-
*
|
|
24
|
-
* @param {FabricObject} [target]
|
|
25
|
-
*/
|
|
26
|
-
show: import("lodash").DebouncedFunc<(target?: FabricObject) => Promise<void>>;
|
|
27
|
-
/**
|
|
28
|
-
* Hide tooltip
|
|
29
|
-
* @param {fabric.Object} [_target]
|
|
30
|
-
*/
|
|
31
|
-
hide: import("lodash").DebouncedFunc<(_target?: fabric.Object) => void>;
|
|
32
|
-
}
|
|
33
|
-
export default TooltipHandler;
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import { FabricObject } from '../utils';
|
|
3
|
+
import Handler from './Handler';
|
|
4
|
+
declare class TooltipHandler {
|
|
5
|
+
handler: Handler;
|
|
6
|
+
tooltipEl: HTMLDivElement;
|
|
7
|
+
target?: fabric.Object;
|
|
8
|
+
constructor(handler: Handler);
|
|
9
|
+
/**
|
|
10
|
+
* Initialize tooltip
|
|
11
|
+
*
|
|
12
|
+
* @author salgum1114
|
|
13
|
+
*/
|
|
14
|
+
initialize(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Destroy tooltip
|
|
17
|
+
*
|
|
18
|
+
* @author salgum1114
|
|
19
|
+
*/
|
|
20
|
+
destroy(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Show tooltip
|
|
23
|
+
*
|
|
24
|
+
* @param {FabricObject} [target]
|
|
25
|
+
*/
|
|
26
|
+
show: import("lodash").DebouncedFunc<(target?: FabricObject) => Promise<void>>;
|
|
27
|
+
/**
|
|
28
|
+
* Hide tooltip
|
|
29
|
+
* @param {fabric.Object} [_target]
|
|
30
|
+
*/
|
|
31
|
+
hide: import("lodash").DebouncedFunc<(_target?: fabric.Object) => void>;
|
|
32
|
+
}
|
|
33
|
+
export default TooltipHandler;
|
|
@@ -1,91 +1,91 @@
|
|
|
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 debounce_1 = __importDefault(require("lodash/debounce"));
|
|
7
|
-
const react_dom_1 = __importDefault(require("react-dom"));
|
|
8
|
-
class TooltipHandler {
|
|
9
|
-
constructor(handler) {
|
|
10
|
-
/**
|
|
11
|
-
* Show tooltip
|
|
12
|
-
*
|
|
13
|
-
* @param {FabricObject} [target]
|
|
14
|
-
*/
|
|
15
|
-
this.show = debounce_1.default(async (target) => {
|
|
16
|
-
if (target.tooltip && target.tooltip.enabled) {
|
|
17
|
-
while (this.tooltipEl.hasChildNodes()) {
|
|
18
|
-
this.tooltipEl.removeChild(this.tooltipEl.firstChild);
|
|
19
|
-
}
|
|
20
|
-
const tooltip = document.createElement('div');
|
|
21
|
-
tooltip.className = 'rde-tooltip-right';
|
|
22
|
-
let element = target.name;
|
|
23
|
-
const { onTooltip } = this.handler;
|
|
24
|
-
if (onTooltip) {
|
|
25
|
-
element = await onTooltip(tooltip, target);
|
|
26
|
-
if (!element) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
tooltip.innerHTML = element;
|
|
31
|
-
this.tooltipEl.appendChild(tooltip);
|
|
32
|
-
react_dom_1.default.render(element, tooltip);
|
|
33
|
-
this.tooltipEl.classList.remove('tooltip-hidden');
|
|
34
|
-
const zoom = this.handler.canvas.getZoom();
|
|
35
|
-
const { clientHeight } = this.tooltipEl;
|
|
36
|
-
const { width, height, scaleX, scaleY } = target;
|
|
37
|
-
const { left, top } = target.getBoundingRect();
|
|
38
|
-
const { _offset: offset } = this.handler.canvas.calcOffset();
|
|
39
|
-
const objWidthDiff = width * scaleX * zoom;
|
|
40
|
-
const objHeightDiff = (height * scaleY * zoom) / 2 - clientHeight / 2;
|
|
41
|
-
const calcLeft = offset.left + left + objWidthDiff;
|
|
42
|
-
const calcTop = offset.top + top + objHeightDiff;
|
|
43
|
-
if (document.body.clientWidth <= calcLeft + this.tooltipEl.offsetWidth) {
|
|
44
|
-
this.tooltipEl.style.left = `${left + offset.left - this.tooltipEl.offsetWidth}px`;
|
|
45
|
-
tooltip.className = 'rde-tooltip-left';
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.tooltipEl.style.left = `${calcLeft}px`;
|
|
49
|
-
}
|
|
50
|
-
this.tooltipEl.style.top = `${calcTop}px`;
|
|
51
|
-
this.handler.target = target;
|
|
52
|
-
}
|
|
53
|
-
}, 100);
|
|
54
|
-
/**
|
|
55
|
-
* Hide tooltip
|
|
56
|
-
* @param {fabric.Object} [_target]
|
|
57
|
-
*/
|
|
58
|
-
this.hide = debounce_1.default((_target) => {
|
|
59
|
-
this.handler.target = null;
|
|
60
|
-
if (this.tooltipEl) {
|
|
61
|
-
this.tooltipEl.classList.add('tooltip-hidden');
|
|
62
|
-
}
|
|
63
|
-
}, 100);
|
|
64
|
-
this.handler = handler;
|
|
65
|
-
if (!handler.editable) {
|
|
66
|
-
this.initialize();
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Initialize tooltip
|
|
71
|
-
*
|
|
72
|
-
* @author salgum1114
|
|
73
|
-
*/
|
|
74
|
-
initialize() {
|
|
75
|
-
this.tooltipEl = document.createElement('div');
|
|
76
|
-
this.tooltipEl.id = `${this.handler.id}_tooltip`;
|
|
77
|
-
this.tooltipEl.className = 'rde-tooltip tooltip-hidden';
|
|
78
|
-
document.body.appendChild(this.tooltipEl);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Destroy tooltip
|
|
82
|
-
*
|
|
83
|
-
* @author salgum1114
|
|
84
|
-
*/
|
|
85
|
-
destroy() {
|
|
86
|
-
if (this.tooltipEl) {
|
|
87
|
-
document.body.removeChild(this.tooltipEl);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.default = TooltipHandler;
|
|
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 debounce_1 = __importDefault(require("lodash/debounce"));
|
|
7
|
+
const react_dom_1 = __importDefault(require("react-dom"));
|
|
8
|
+
class TooltipHandler {
|
|
9
|
+
constructor(handler) {
|
|
10
|
+
/**
|
|
11
|
+
* Show tooltip
|
|
12
|
+
*
|
|
13
|
+
* @param {FabricObject} [target]
|
|
14
|
+
*/
|
|
15
|
+
this.show = debounce_1.default(async (target) => {
|
|
16
|
+
if (target.tooltip && target.tooltip.enabled) {
|
|
17
|
+
while (this.tooltipEl.hasChildNodes()) {
|
|
18
|
+
this.tooltipEl.removeChild(this.tooltipEl.firstChild);
|
|
19
|
+
}
|
|
20
|
+
const tooltip = document.createElement('div');
|
|
21
|
+
tooltip.className = 'rde-tooltip-right';
|
|
22
|
+
let element = target.name;
|
|
23
|
+
const { onTooltip } = this.handler;
|
|
24
|
+
if (onTooltip) {
|
|
25
|
+
element = await onTooltip(tooltip, target);
|
|
26
|
+
if (!element) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
tooltip.innerHTML = element;
|
|
31
|
+
this.tooltipEl.appendChild(tooltip);
|
|
32
|
+
react_dom_1.default.render(element, tooltip);
|
|
33
|
+
this.tooltipEl.classList.remove('tooltip-hidden');
|
|
34
|
+
const zoom = this.handler.canvas.getZoom();
|
|
35
|
+
const { clientHeight } = this.tooltipEl;
|
|
36
|
+
const { width, height, scaleX, scaleY } = target;
|
|
37
|
+
const { left, top } = target.getBoundingRect();
|
|
38
|
+
const { _offset: offset } = this.handler.canvas.calcOffset();
|
|
39
|
+
const objWidthDiff = width * scaleX * zoom;
|
|
40
|
+
const objHeightDiff = (height * scaleY * zoom) / 2 - clientHeight / 2;
|
|
41
|
+
const calcLeft = offset.left + left + objWidthDiff;
|
|
42
|
+
const calcTop = offset.top + top + objHeightDiff;
|
|
43
|
+
if (document.body.clientWidth <= calcLeft + this.tooltipEl.offsetWidth) {
|
|
44
|
+
this.tooltipEl.style.left = `${left + offset.left - this.tooltipEl.offsetWidth}px`;
|
|
45
|
+
tooltip.className = 'rde-tooltip-left';
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.tooltipEl.style.left = `${calcLeft}px`;
|
|
49
|
+
}
|
|
50
|
+
this.tooltipEl.style.top = `${calcTop}px`;
|
|
51
|
+
this.handler.target = target;
|
|
52
|
+
}
|
|
53
|
+
}, 100);
|
|
54
|
+
/**
|
|
55
|
+
* Hide tooltip
|
|
56
|
+
* @param {fabric.Object} [_target]
|
|
57
|
+
*/
|
|
58
|
+
this.hide = debounce_1.default((_target) => {
|
|
59
|
+
this.handler.target = null;
|
|
60
|
+
if (this.tooltipEl) {
|
|
61
|
+
this.tooltipEl.classList.add('tooltip-hidden');
|
|
62
|
+
}
|
|
63
|
+
}, 100);
|
|
64
|
+
this.handler = handler;
|
|
65
|
+
if (!handler.editable) {
|
|
66
|
+
this.initialize();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Initialize tooltip
|
|
71
|
+
*
|
|
72
|
+
* @author salgum1114
|
|
73
|
+
*/
|
|
74
|
+
initialize() {
|
|
75
|
+
this.tooltipEl = document.createElement('div');
|
|
76
|
+
this.tooltipEl.id = `${this.handler.id}_tooltip`;
|
|
77
|
+
this.tooltipEl.className = 'rde-tooltip tooltip-hidden';
|
|
78
|
+
document.body.appendChild(this.tooltipEl);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Destroy tooltip
|
|
82
|
+
*
|
|
83
|
+
* @author salgum1114
|
|
84
|
+
*/
|
|
85
|
+
destroy() {
|
|
86
|
+
if (this.tooltipEl) {
|
|
87
|
+
document.body.removeChild(this.tooltipEl);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.default = TooltipHandler;
|
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
|
-
import Handler from './Handler';
|
|
3
|
-
import { FabricObject } from '../utils';
|
|
4
|
-
export declare type TransactionType = 'add' | 'remove' | 'moved' | 'scaled' | 'rotated' | 'skewed' | 'group' | 'ungroup' | 'paste' | 'bringForward' | 'bringToFront' | 'sendBackwards' | 'sendToBack' | 'redo' | 'undo';
|
|
5
|
-
export interface TransactionTransform {
|
|
6
|
-
scaleX?: number;
|
|
7
|
-
scaleY?: number;
|
|
8
|
-
skewX?: number;
|
|
9
|
-
skewY?: number;
|
|
10
|
-
angle?: number;
|
|
11
|
-
left?: number;
|
|
12
|
-
top?: number;
|
|
13
|
-
flipX?: number;
|
|
14
|
-
flipY?: number;
|
|
15
|
-
originX?: string;
|
|
16
|
-
originY?: string;
|
|
17
|
-
}
|
|
18
|
-
export interface TransactionEvent {
|
|
19
|
-
json: string;
|
|
20
|
-
type: TransactionType;
|
|
21
|
-
}
|
|
22
|
-
declare class TransactionHandler {
|
|
23
|
-
handler: Handler;
|
|
24
|
-
redos: TransactionEvent[];
|
|
25
|
-
undos: TransactionEvent[];
|
|
26
|
-
active: boolean;
|
|
27
|
-
state: FabricObject[];
|
|
28
|
-
constructor(handler: Handler);
|
|
29
|
-
/**
|
|
30
|
-
* Initialize transaction handler
|
|
31
|
-
*
|
|
32
|
-
*/
|
|
33
|
-
initialize: () => void;
|
|
34
|
-
/**
|
|
35
|
-
* Save transaction
|
|
36
|
-
*
|
|
37
|
-
* @param {TransactionType} type
|
|
38
|
-
* @param {*} [canvasJSON]
|
|
39
|
-
* @param {boolean} [isWorkarea=true]
|
|
40
|
-
*/
|
|
41
|
-
save: (type: TransactionType, canvasJSON?: any, _isWorkarea?: boolean) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Undo transaction
|
|
44
|
-
*
|
|
45
|
-
*/
|
|
46
|
-
undo: import("lodash").DebouncedFunc<() => void>;
|
|
47
|
-
/**
|
|
48
|
-
* Redo transaction
|
|
49
|
-
*
|
|
50
|
-
*/
|
|
51
|
-
redo: import("lodash").DebouncedFunc<() => void>;
|
|
52
|
-
/**
|
|
53
|
-
* Replay transaction
|
|
54
|
-
*
|
|
55
|
-
* @param {TransactionEvent} transaction
|
|
56
|
-
*/
|
|
57
|
-
replay: (transaction: TransactionEvent) => void;
|
|
58
|
-
}
|
|
59
|
-
export default TransactionHandler;
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import Handler from './Handler';
|
|
3
|
+
import { FabricObject } from '../utils';
|
|
4
|
+
export declare type TransactionType = 'add' | 'remove' | 'moved' | 'scaled' | 'rotated' | 'skewed' | 'group' | 'ungroup' | 'paste' | 'bringForward' | 'bringToFront' | 'sendBackwards' | 'sendToBack' | 'redo' | 'undo';
|
|
5
|
+
export interface TransactionTransform {
|
|
6
|
+
scaleX?: number;
|
|
7
|
+
scaleY?: number;
|
|
8
|
+
skewX?: number;
|
|
9
|
+
skewY?: number;
|
|
10
|
+
angle?: number;
|
|
11
|
+
left?: number;
|
|
12
|
+
top?: number;
|
|
13
|
+
flipX?: number;
|
|
14
|
+
flipY?: number;
|
|
15
|
+
originX?: string;
|
|
16
|
+
originY?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TransactionEvent {
|
|
19
|
+
json: string;
|
|
20
|
+
type: TransactionType;
|
|
21
|
+
}
|
|
22
|
+
declare class TransactionHandler {
|
|
23
|
+
handler: Handler;
|
|
24
|
+
redos: TransactionEvent[];
|
|
25
|
+
undos: TransactionEvent[];
|
|
26
|
+
active: boolean;
|
|
27
|
+
state: FabricObject[];
|
|
28
|
+
constructor(handler: Handler);
|
|
29
|
+
/**
|
|
30
|
+
* Initialize transaction handler
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
initialize: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Save transaction
|
|
36
|
+
*
|
|
37
|
+
* @param {TransactionType} type
|
|
38
|
+
* @param {*} [canvasJSON]
|
|
39
|
+
* @param {boolean} [isWorkarea=true]
|
|
40
|
+
*/
|
|
41
|
+
save: (type: TransactionType, canvasJSON?: any, _isWorkarea?: boolean) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Undo transaction
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
undo: import("lodash").DebouncedFunc<() => void>;
|
|
47
|
+
/**
|
|
48
|
+
* Redo transaction
|
|
49
|
+
*
|
|
50
|
+
*/
|
|
51
|
+
redo: import("lodash").DebouncedFunc<() => void>;
|
|
52
|
+
/**
|
|
53
|
+
* Replay transaction
|
|
54
|
+
*
|
|
55
|
+
* @param {TransactionEvent} transaction
|
|
56
|
+
*/
|
|
57
|
+
replay: (transaction: TransactionEvent) => void;
|
|
58
|
+
}
|
|
59
|
+
export default TransactionHandler;
|