@yorab/react-paint 0.5.0 → 0.6.0
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/Changelog.md +96 -0
- package/README.md +0 -7
- package/dist/components/App.js +69 -49
- package/dist/components/Canvas.js +7 -7
- package/dist/components/common/Button.js +4 -4
- package/dist/components/common/Loading.js +3 -3
- package/dist/components/common/Modal.js +3 -3
- package/dist/components/common/Panel.js +2 -2
- package/dist/components/common/Snackbar.js +2 -2
- package/dist/components/settings/ColorField.js +4 -4
- package/dist/components/settings/FontFamilyField.js +3 -3
- package/dist/components/settings/LayoutButton.js +1 -1
- package/dist/components/settings/Layouts.js +18 -9
- package/dist/components/settings/LineArrowField.js +4 -4
- package/dist/components/settings/LineTypeField.js +3 -3
- package/dist/components/settings/PointsNumberField.js +1 -1
- package/dist/components/settings/RangeField.js +1 -1
- package/dist/components/settings/SelectField.js +1 -1
- package/dist/components/settings/SettingsBar.js +105 -79
- package/dist/components/settings/ToggleField.js +56 -0
- package/dist/components/toolbox/EditTextBox.js +23 -16
- package/dist/components/toolbox/MenuGroup.js +10 -8
- package/dist/components/toolbox/PictureUrlInput.js +1 -1
- package/dist/components/toolbox/Toolbar.js +12 -4
- package/dist/components/toolbox/ToolbarGroup.js +13 -11
- package/dist/constants/icons.js +6 -2
- package/dist/constants/tools.js +8 -0
- package/dist/hooks/useDoubleClick.js +46 -0
- package/dist/hooks/useDrawableCanvas.js +29 -45
- package/dist/styles.css +52 -51
- package/dist/utils/data.js +27 -5
- package/dist/utils/draw.js +3 -3
- package/dist/utils/file.js +15 -14
- package/dist/utils/selection.js +1 -1
- package/dist/utils/transform.js +23 -10
- package/package.json +1 -1
|
@@ -29,11 +29,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
29
29
|
|
|
30
30
|
var StyledPanel = /*#__PURE__*/(0, _react2.styled)(_Panel["default"])({
|
|
31
31
|
name: "StyledPanel",
|
|
32
|
-
"class": "
|
|
32
|
+
"class": "s1bvz4xj"
|
|
33
33
|
});
|
|
34
34
|
var StyledRelative = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
35
35
|
name: "StyledRelative",
|
|
36
|
-
"class": "
|
|
36
|
+
"class": "siejlch"
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
var ToolbarGroup = function ToolbarGroup(_ref) {
|
|
@@ -44,13 +44,17 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
|
|
|
44
44
|
group = _ref.group,
|
|
45
45
|
_ref$disabled = _ref.disabled,
|
|
46
46
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
47
|
-
|
|
47
|
+
setActiveToolFromId = _ref.setActiveToolFromId;
|
|
48
48
|
|
|
49
49
|
var _useState = (0, _react.useState)(false),
|
|
50
50
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
51
51
|
isOpen = _useState2[0],
|
|
52
52
|
setIsOpen = _useState2[1];
|
|
53
53
|
|
|
54
|
+
var _useTransition = (0, _react.useTransition)(),
|
|
55
|
+
_useTransition2 = (0, _slicedToArray2["default"])(_useTransition, 2),
|
|
56
|
+
startTransition = _useTransition2[1];
|
|
57
|
+
|
|
54
58
|
var _useState3 = (0, _react.useState)(undefined),
|
|
55
59
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
56
60
|
localActiveTool = _useState4[0],
|
|
@@ -58,7 +62,7 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
|
|
|
58
62
|
|
|
59
63
|
var setActiveTool = function setActiveTool(tool) {
|
|
60
64
|
setLocalActiveTool(tool);
|
|
61
|
-
|
|
65
|
+
setActiveToolFromId(tool.id);
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
(0, _react.useEffect)(function () {
|
|
@@ -68,12 +72,8 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
|
|
|
68
72
|
setIsOpen(false);
|
|
69
73
|
};
|
|
70
74
|
|
|
71
|
-
|
|
72
|
-
//TODO find a better fix than settimeout for react18
|
|
73
|
-
document.addEventListener('click', closePanel);
|
|
74
|
-
}, 0);
|
|
75
|
+
document.addEventListener('click', closePanel);
|
|
75
76
|
return function () {
|
|
76
|
-
clearTimeout(timeoutId);
|
|
77
77
|
document.removeEventListener('click', closePanel);
|
|
78
78
|
};
|
|
79
79
|
}, [isOpen]);
|
|
@@ -106,8 +106,10 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
|
|
|
106
106
|
var groupIcon = (_ref2 = localActiveTool ? localActiveTool.icon : group.toolsType && group.toolsType[0] && group.toolsType[0].icon) !== null && _ref2 !== void 0 ? _ref2 : group.title;
|
|
107
107
|
|
|
108
108
|
var openPanel = function openPanel() {
|
|
109
|
-
if (localActiveTool)
|
|
110
|
-
|
|
109
|
+
if (localActiveTool) setActiveToolFromId(localActiveTool.id);else group.toolsType && group.toolsType[0] && setActiveTool(group.toolsType[0]);
|
|
110
|
+
startTransition(function () {
|
|
111
|
+
setIsOpen(true);
|
|
112
|
+
});
|
|
111
113
|
};
|
|
112
114
|
|
|
113
115
|
return /*#__PURE__*/_react["default"].createElement(StyledRelative, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
package/dist/constants/icons.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.visibilityOffIcon = exports.visibilityIcon = exports.unlockedIcon = exports.undoIcon = exports.trashIcon = exports.textIcon = exports.squareIcon = exports.shapesIcon = exports.selectIcon = exports.saveIcon = exports.redoIcon = exports.recIcon = exports.publicIcon = exports.polygonIcon = exports.pictureIcon = exports.penIcon = exports.paletteIcon = exports.paintIcon = exports.openFileIcon = exports.opacityIcon = exports.menuIcon = exports.lockedIcon = exports.layersIcon = exports.gridOnIcon = exports.gridOffIcon = exports.gestureIcon = exports.exportFileIcon = exports.encodedTransparentIcon = exports.ellipseIcon = exports.dragIcon = exports.dotsIcon = exports.curveIcon = exports.clearIcon = exports.circleIcon = exports.brushIcon = exports.arrowIcon = void 0;
|
|
6
|
+
exports.visibilityOffIcon = exports.visibilityIcon = exports.unlockedIcon = exports.undoIcon = exports.trashIcon = exports.textIcon = exports.squareIcon = exports.shapesIcon = exports.selectIcon = exports.saveIcon = exports.redoIcon = exports.recIcon = exports.publicIcon = exports.polygonIcon = exports.pictureIcon = exports.penIcon = exports.paletteIcon = exports.paintIcon = exports.openFileIcon = exports.opacityIcon = exports.menuIcon = exports.lockedIcon = exports.layersIcon = exports.italicIcon = exports.gridOnIcon = exports.gridOffIcon = exports.gestureIcon = exports.exportFileIcon = exports.encodedTransparentIcon = exports.ellipseIcon = exports.dragIcon = exports.dotsIcon = exports.curveIcon = exports.clearIcon = exports.circleIcon = exports.brushIcon = exports.boldIcon = exports.arrowIcon = void 0;
|
|
7
7
|
var brushIcon = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>';
|
|
8
8
|
exports.brushIcon = brushIcon;
|
|
9
9
|
var squareIcon = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>';
|
|
@@ -77,4 +77,8 @@ exports.ellipseIcon = ellipseIcon;
|
|
|
77
77
|
var selectIcon = '<svg><path d="M8.854 17.5Q8.5 17.5 8.188 17.354Q7.875 17.208 7.604 16.958L3.271 12.646L4.5 11.375Q4.812 11.042 5.24 10.906Q5.667 10.771 6.104 10.875L7.479 11.188V4.667Q7.479 3.771 8.115 3.135Q8.75 2.5 9.646 2.5Q10.542 2.5 11.177 3.135Q11.812 3.771 11.812 4.667V8.062H12.188Q12.333 8.062 12.458 8.094Q12.583 8.125 12.708 8.188L15.812 9.708Q16.292 9.938 16.542 10.406Q16.792 10.875 16.688 11.417L15.917 16.042Q15.812 16.688 15.323 17.094Q14.833 17.5 14.167 17.5ZM8.854 15.75H14.167L14.958 11.229Q14.958 11.229 14.958 11.229Q14.958 11.229 14.958 11.229L11.5 9.562H10.062V4.667Q10.062 4.479 9.948 4.365Q9.833 4.25 9.646 4.25Q9.458 4.25 9.344 4.365Q9.229 4.479 9.229 4.667V13.333L5.708 12.604ZM8.854 15.75H9.229Q9.229 15.75 9.344 15.75Q9.458 15.75 9.646 15.75Q9.833 15.75 9.948 15.75Q10.062 15.75 10.062 15.75H11.521H14.167Q14.167 15.75 14.167 15.75Q14.167 15.75 14.167 15.75Z"/></svg>';
|
|
78
78
|
exports.selectIcon = selectIcon;
|
|
79
79
|
var curveIcon = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>';
|
|
80
|
-
exports.curveIcon = curveIcon;
|
|
80
|
+
exports.curveIcon = curveIcon;
|
|
81
|
+
var boldIcon = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>';
|
|
82
|
+
exports.boldIcon = boldIcon;
|
|
83
|
+
var italicIcon = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>';
|
|
84
|
+
exports.italicIcon = italicIcon;
|
package/dist/constants/tools.js
CHANGED
|
@@ -145,6 +145,14 @@ var SETTINGS_DEFAULT_TEXT = {
|
|
|
145
145
|
fontFamily: {
|
|
146
146
|
values: _style.STYLE_FONTS,
|
|
147
147
|
"default": _style.STYLE_FONT_DEFAULT
|
|
148
|
+
},
|
|
149
|
+
fontBold: {
|
|
150
|
+
values: [false, true],
|
|
151
|
+
"default": false
|
|
152
|
+
},
|
|
153
|
+
fontItalic: {
|
|
154
|
+
values: [false, true],
|
|
155
|
+
"default": false
|
|
148
156
|
}
|
|
149
157
|
};
|
|
150
158
|
exports.SETTINGS_DEFAULT_TEXT = SETTINGS_DEFAULT_TEXT;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var DELTA_TIME_THRESHOLD_MS = 300;
|
|
11
|
+
|
|
12
|
+
var useDoubleClick = function useDoubleClick() {
|
|
13
|
+
var lastClickTimestampRef = (0, _react.useRef)(undefined);
|
|
14
|
+
var callbackRef = (0, _react.useRef)(undefined);
|
|
15
|
+
|
|
16
|
+
var onClick = function onClick(e) {
|
|
17
|
+
var currentTimestamp = new Date().getTime();
|
|
18
|
+
|
|
19
|
+
if (lastClickTimestampRef.current && currentTimestamp < lastClickTimestampRef.current + DELTA_TIME_THRESHOLD_MS) {
|
|
20
|
+
var _callbackRef$current;
|
|
21
|
+
|
|
22
|
+
(_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, e);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
lastClickTimestampRef.current = new Date().getTime();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var registerDoubleClickEvent = function registerDoubleClickEvent(element, callback) {
|
|
29
|
+
callbackRef.current = callback;
|
|
30
|
+
element.addEventListener('click', onClick);
|
|
31
|
+
element.addEventListener('touchend', onClick);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var unRegisterDoubleClickEvent = function unRegisterDoubleClickEvent(element) {
|
|
35
|
+
element.removeEventListener('click', onClick);
|
|
36
|
+
element.removeEventListener('touchend', onClick);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
registerDoubleClickEvent: registerDoubleClickEvent,
|
|
41
|
+
unRegisterDoubleClickEvent: unRegisterDoubleClickEvent
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
var _default = useDoubleClick;
|
|
46
|
+
exports["default"] = _default;
|
|
@@ -29,6 +29,8 @@ var _tools = require("../types/tools");
|
|
|
29
29
|
|
|
30
30
|
var _tools2 = require("../constants/tools");
|
|
31
31
|
|
|
32
|
+
var _useDoubleClick2 = _interopRequireDefault(require("./useDoubleClick"));
|
|
33
|
+
|
|
32
34
|
var handleMove = function handleMove(e, canvasRef, activeTool, canvasOffset, selectedShape, selectionMode, canvasOffsetStartPosition, width, height, scaleRatio, setHoverMode, updateSingleShape, setCanvasOffset, setSelectedShape, selectionPadding) {
|
|
33
35
|
if (activeTool.type === _tools.ActionsEnum.move && canvasOffsetStartPosition !== undefined) {
|
|
34
36
|
var _cursorPosition = (0, _intersect.getCursorPosition)(e, canvasRef.current, width, height, scaleRatio);
|
|
@@ -40,7 +42,7 @@ var handleMove = function handleMove(e, canvasRef, activeTool, canvasOffset, sel
|
|
|
40
42
|
if (selectedShape.locked) return;
|
|
41
43
|
var cursorPosition = (0, _intersect.getCursorPosition)(e, canvasRef.current, width, height, scaleRatio);
|
|
42
44
|
|
|
43
|
-
if (selectionMode.mode === _Mode.SelectionModeLib["default"]) {
|
|
45
|
+
if (selectionMode.mode === _Mode.SelectionModeLib["default"] || selectionMode.mode === _Mode.SelectionModeLib.textedition) {
|
|
44
46
|
var positionIntersection = (0, _intersect.checkPositionIntersection)(selectedShape, cursorPosition, canvasOffset, selectionPadding, scaleRatio, true) || {
|
|
45
47
|
mode: _Mode.SelectionModeLib["default"]
|
|
46
48
|
};
|
|
@@ -91,6 +93,10 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
|
|
|
91
93
|
hoverMode = _useState2[0],
|
|
92
94
|
setHoverMode = _useState2[1];
|
|
93
95
|
|
|
96
|
+
var _useDoubleClick = (0, _useDoubleClick2["default"])(),
|
|
97
|
+
registerDoubleClickEvent = _useDoubleClick.registerDoubleClickEvent,
|
|
98
|
+
unRegisterDoubleClickEvent = _useDoubleClick.unRegisterDoubleClickEvent;
|
|
99
|
+
|
|
94
100
|
(0, _react.useEffect)(function () {
|
|
95
101
|
var handleMouseMove = function handleMouseMove(e) {
|
|
96
102
|
return window.requestAnimationFrame(function () {
|
|
@@ -111,28 +117,9 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
|
|
|
111
117
|
};
|
|
112
118
|
}, [isInsideComponent, selectionCanvasRef, selectedShape, selectionMode, setHoverMode, canvasOffset, canvasOffsetStartPosition, width, height, scaleRatio, updateSingleShape, activeTool, setCanvasOffset, setSelectedShape, selectionPadding]);
|
|
113
119
|
(0, _react.useEffect)(function () {
|
|
114
|
-
var handleMouseUp = function handleMouseUp(
|
|
120
|
+
var handleMouseUp = function handleMouseUp() {
|
|
115
121
|
if (selectionMode.mode === _Mode.SelectionModeLib.textedition) return;
|
|
116
122
|
|
|
117
|
-
if (activeTool.type === _Shapes.ShapeEnum.text) {
|
|
118
|
-
var _drawCanvasRef$curren;
|
|
119
|
-
|
|
120
|
-
var cursorPosition = (0, _intersect.getCursorPosition)(e, selectionCanvasRef.current, width, height, scaleRatio);
|
|
121
|
-
var drawCtx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
122
|
-
if (!drawCtx) return;
|
|
123
|
-
|
|
124
|
-
var _newShape2 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
|
|
125
|
-
|
|
126
|
-
addShape(_newShape2);
|
|
127
|
-
setActiveTool(_tools2.SELECTION_TOOL);
|
|
128
|
-
setSelectedShape(_newShape2);
|
|
129
|
-
setSelectionMode({
|
|
130
|
-
mode: _Mode.SelectionModeLib.textedition,
|
|
131
|
-
defaultValue: _newShape2.value
|
|
132
|
-
});
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
123
|
if (selectionMode.mode !== _Mode.SelectionModeLib["default"]) {
|
|
137
124
|
setSelectionMode({
|
|
138
125
|
mode: _Mode.SelectionModeLib["default"]
|
|
@@ -152,7 +139,7 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
|
|
|
152
139
|
document.removeEventListener('touchend', handleMouseUp);
|
|
153
140
|
}
|
|
154
141
|
};
|
|
155
|
-
}, [isInsideComponent,
|
|
142
|
+
}, [isInsideComponent, selectionMode, saveShapes, setSelectionMode]);
|
|
156
143
|
(0, _react.useEffect)(function () {
|
|
157
144
|
var ref = selectionCanvasRef.current;
|
|
158
145
|
if (!ref) return;
|
|
@@ -174,39 +161,39 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
|
|
|
174
161
|
}
|
|
175
162
|
|
|
176
163
|
if (_fp["default"].includes(activeTool.type, _Shapes.ShapeEnum)) {
|
|
177
|
-
var _drawCanvasRef$
|
|
164
|
+
var _drawCanvasRef$curren;
|
|
178
165
|
|
|
179
|
-
var drawCtx = (_drawCanvasRef$
|
|
166
|
+
var drawCtx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
180
167
|
if (!drawCtx) return;
|
|
181
168
|
|
|
182
169
|
if (activeTool.type === _Shapes.ShapeEnum.brush) {
|
|
183
170
|
if (!!selectedShape) {
|
|
184
|
-
var
|
|
171
|
+
var _newShape2 = (0, _transform.createNewPointGroupToShape)(selectedShape, cursorPosition);
|
|
185
172
|
|
|
186
|
-
updateSingleShape(
|
|
187
|
-
setSelectedShape(
|
|
173
|
+
updateSingleShape(_newShape2);
|
|
174
|
+
setSelectedShape(_newShape2);
|
|
188
175
|
} else {
|
|
189
|
-
var
|
|
176
|
+
var _newShape3 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
|
|
190
177
|
|
|
191
|
-
if (!
|
|
192
|
-
addShape(
|
|
193
|
-
setSelectedShape(
|
|
178
|
+
if (!_newShape3) return;
|
|
179
|
+
addShape(_newShape3);
|
|
180
|
+
setSelectedShape(_newShape3);
|
|
194
181
|
}
|
|
195
182
|
|
|
196
183
|
setSelectionMode({
|
|
197
184
|
mode: _Mode.SelectionModeLib.brush
|
|
198
185
|
});
|
|
199
|
-
} else
|
|
200
|
-
var
|
|
186
|
+
} else {
|
|
187
|
+
var _newShape4 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
|
|
201
188
|
|
|
202
|
-
if (!
|
|
203
|
-
addShape(
|
|
189
|
+
if (!_newShape4) return;
|
|
190
|
+
addShape(_newShape4);
|
|
204
191
|
setActiveTool(_tools2.SELECTION_TOOL);
|
|
205
|
-
setSelectedShape(
|
|
192
|
+
setSelectedShape(_newShape4);
|
|
206
193
|
setSelectionMode({
|
|
207
194
|
mode: _Mode.SelectionModeLib.resize,
|
|
208
195
|
cursorStartPosition: cursorPosition,
|
|
209
|
-
originalShape:
|
|
196
|
+
originalShape: _newShape4,
|
|
210
197
|
anchor: activeTool.type === _Shapes.ShapeEnum.line || activeTool.type === _Shapes.ShapeEnum.polygon || activeTool.type === _Shapes.ShapeEnum.curve ? 0 : [1, 1]
|
|
211
198
|
});
|
|
212
199
|
}
|
|
@@ -244,15 +231,12 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
|
|
|
244
231
|
};
|
|
245
232
|
|
|
246
233
|
if (isInsideComponent) {
|
|
247
|
-
ref
|
|
234
|
+
registerDoubleClickEvent(ref, handleDoubleClick);
|
|
235
|
+
return function () {
|
|
236
|
+
unRegisterDoubleClickEvent(ref);
|
|
237
|
+
};
|
|
248
238
|
}
|
|
249
|
-
|
|
250
|
-
return function () {
|
|
251
|
-
if (isInsideComponent) {
|
|
252
|
-
ref.removeEventListener('dblclick', handleDoubleClick);
|
|
253
|
-
}
|
|
254
|
-
};
|
|
255
|
-
}, [isInsideComponent, selectionCanvasRef, activeTool, selectedShape, width, height, scaleRatio, canvasOffset, setSelectionMode, selectionPadding]);
|
|
239
|
+
}, [registerDoubleClickEvent, unRegisterDoubleClickEvent, isInsideComponent, selectionCanvasRef, activeTool, selectedShape, width, height, scaleRatio, canvasOffset, setSelectionMode, selectionPadding]);
|
|
256
240
|
return {
|
|
257
241
|
hoverMode: hoverMode
|
|
258
242
|
};
|
package/dist/styles.css
CHANGED
|
@@ -31,54 +31,55 @@
|
|
|
31
31
|
min-width: 0;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
.
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
.
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
.
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
-
.
|
|
55
|
-
.
|
|
56
|
-
.
|
|
57
|
-
.
|
|
58
|
-
.
|
|
59
|
-
.
|
|
60
|
-
.
|
|
61
|
-
.
|
|
62
|
-
.
|
|
63
|
-
.
|
|
64
|
-
.
|
|
65
|
-
.
|
|
66
|
-
.
|
|
67
|
-
.
|
|
68
|
-
.
|
|
69
|
-
.
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
.
|
|
73
|
-
.
|
|
74
|
-
.
|
|
75
|
-
.
|
|
76
|
-
.
|
|
77
|
-
.
|
|
78
|
-
.
|
|
79
|
-
.
|
|
80
|
-
.
|
|
81
|
-
.
|
|
82
|
-
.
|
|
83
|
-
.
|
|
84
|
-
.
|
|
34
|
+
.s1unz6yq{position:absolute;display:inline-block;outline:none;left:0px;top:0px;-webkit-transform-origin:left top;-ms-transform-origin:left top;transform-origin:left top;box-sizing:border-box;-webkit-transform:var(--s1unz6yq-0);-ms-transform:var(--s1unz6yq-0);transform:var(--s1unz6yq-0);color:var(--s1unz6yq-1);padding:var(--s1unz6yq-2);font-size:var(--s1unz6yq-3);line-height:var(--s1unz6yq-3);font-family:var(--s1unz6yq-5);opacity:var(--s1unz6yq-6);}.s1unz6yq[data-fontbold='true']{font-weight:bold;}.s1unz6yq[data-fontitalic='true']{font-style:italic;}
|
|
35
|
+
.s9czb9p{-webkit-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;}
|
|
36
|
+
.s1538eht{position:relative;background-color:var(--canvas-bg);background-repeat:repeat;background-size:16px;overflow:hidden;display:grid;}.s1538eht[data-grid='true']{background-image:url("data:image/svg+xml,%3Csvg%20id%3D%22svg%22%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20width%3D%22400%22%20height%3D%22400%22%20viewBox%3D%220%2C%200%2C%20400%2C400%22%3E%3Cg%20id%3D%22svgg%22%3E%3Cpath%20id%3D%22path0%22%20d%3D%22M204.800%2094.600%20C%20204.800%20188.933%2C204.802%20189.200%2C205.600%20189.200%20C%20206.248%20189.200%2C206.400%20189.467%2C206.400%20190.600%20C%20206.400%20191.733%2C206.552%20192.000%2C207.200%20192.000%20C%20207.733%20192.000%2C208.000%20192.267%2C208.000%20192.800%20C%20208.000%20193.244%2C208.267%20193.600%2C208.600%20193.600%20C%20208.933%20193.600%2C209.200%20193.956%2C209.200%20194.400%20C%20209.200%20195.067%2C209.467%20195.200%2C210.800%20195.200%20C%20212.133%20195.200%2C212.400%20195.333%2C212.400%20196.000%20C%20212.400%20196.798%2C212.667%20196.800%2C306.200%20196.800%20L%20400.000%20196.800%20400.000%2098.400%20L%20400.000%200.000%20302.400%200.000%20L%20204.800%200.000%20204.800%2094.600%20M0.000%20302.400%20L%200.000%20400.000%2098.400%20400.000%20L%20196.800%20400.000%20196.800%20306.200%20C%20196.800%20212.667%2C196.798%20212.400%2C196.000%20212.400%20C%20195.333%20212.400%2C195.200%20212.133%2C195.200%20210.800%20C%20195.200%20209.467%2C195.067%20209.200%2C194.400%20209.200%20C%20193.956%20209.200%2C193.600%20208.933%2C193.600%20208.600%20C%20193.600%20208.267%2C193.244%20208.000%2C192.800%20208.000%20C%20192.267%20208.000%2C192.000%20207.733%2C192.000%20207.200%20C%20192.000%20206.552%2C191.733%20206.400%2C190.600%20206.400%20C%20189.467%20206.400%2C189.200%20206.248%2C189.200%20205.600%20C%20189.200%20204.802%2C188.933%20204.800%2C94.600%20204.800%20L%200.000%20204.800%200.000%20302.400%20%22%20stroke%3D%22none%22%20fill%3D%22%23fcfcfc%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path1%22%20d%3D%22M0.000%20100.000%20L%200.000%20200.000%2096.800%20200.000%20C%20193.333%20200.000%2C193.600%20199.998%2C193.600%20199.200%20C%20193.600%20198.533%2C193.867%20198.400%2C195.200%20198.400%20C%20196.533%20198.400%2C196.800%20198.267%2C196.800%20197.600%20C%20196.800%20197.067%2C197.067%20196.800%2C197.600%20196.800%20C%20198.267%20196.800%2C198.400%20196.533%2C198.400%20195.200%20C%20198.400%20193.867%2C198.533%20193.600%2C199.200%20193.600%20C%20199.998%20193.600%2C200.000%20193.333%2C200.000%2096.800%20L%20200.000%200.000%20100.000%200.000%20L%200.000%200.000%200.000%20100.000%20M208.000%20202.400%20C%20208.000%20203.067%2C207.733%20203.200%2C206.400%20203.200%20C%20205.067%20203.200%2C204.800%20203.333%2C204.800%20204.000%20C%20204.800%20204.533%2C204.533%20204.800%2C204.000%20204.800%20C%20203.333%20204.800%2C203.200%20205.067%2C203.200%20206.400%20C%20203.200%20207.733%2C203.067%20208.000%2C202.400%20208.000%20C%20201.602%20208.000%2C201.600%20208.267%2C201.600%20304.000%20L%20201.600%20400.000%20300.800%20400.000%20L%20400.000%20400.000%20400.000%20300.800%20L%20400.000%20201.600%20304.000%20201.600%20C%20208.267%20201.600%2C208.000%20201.602%2C208.000%20202.400%20%22%20stroke%3D%22none%22%20fill%3D%22%23e4e4e4%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path2%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path3%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3Cpath%20id%3D%22path4%22%20d%3D%22%22%20stroke%3D%22none%22%20fill%3D%22%23f4100f0%22%20fill-rule%3D%22evenodd%22%3E%3C%2Fpath%3E%3C%2Fg%3E%3C%2Fsvg%3E");}.s1538eht[data-grow='true']{width:100%;height:100%;}
|
|
37
|
+
.s101qxdc{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;max-width:100%;touch-action:none;display:block;grid-area:1 / 1;}.s101qxdc[data-grow='true']{width:100%;}
|
|
38
|
+
.sa4oq48{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:relative;max-width:100%;touch-action:none;display:block;grid-area:1 / 1;cursor:var(--sa4oq48-0);}.sa4oq48[data-grow='true']{width:100%;}
|
|
39
|
+
.sq3bzv4{min-width:32px;height:32px;font-size:14px;display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;vertical-align:middle;box-sizing:border-box;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;background:none;border:none;cursor:pointer;border-radius:var(--font-radius);color:var(--font-color);margin:2px 4px;padding:0;}.sq3bzv4[data-selected='1']{color:var(--font-selected-color);background:var(--font-selected-bg);}.sq3bzv4[data-hidden='1']{visibility:hidden;}.sq3bzv4[data-disabled='1']{cursor:default;color:var(--font-disabled-color);background:var(--font-disabled-bg);}.sq3bzv4[data-selected='0'][data-disabled='0']{background:var(--font-bg);color:var(--font-color);}.sq3bzv4[data-selected='0'][data-disabled='0']:hover{color:var(--font-hover-color);background:var(--font-hover-bg);}.sq3bzv4[data-disabled='0']{cursor:pointer;}.sq3bzv4 svg{fill:currentColor;width:20px;height:20px;}.sq3bzv4 input{position:absolute;visibility:hidden;}
|
|
40
|
+
.sst453j{width:100%;box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;padding:2px 6px;}
|
|
41
|
+
.s1q5lsc2{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
42
|
+
.s1dis2j8{-webkit-flex:1;-ms-flex:1;flex:1;text-align:left;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.s1dis2j8 + .s1q5lsc2{margin-left:12px;}
|
|
43
|
+
.s1xzg253{position:absolute;z-index:3;background:var(--toolbar-bg);bottom:100%;box-shadow:0 3px 8px rgb(0 0 0 / 24%);padding:8px;border-radius:8px;white-space:nowrap;}.s1xzg253[data-alignment='left']{left:0;margin:4px;}.s1xzg253[data-alignment='center']{left:50%;-webkit-transform:translate3d(-50%,0px,0px);-ms-transform:translate3d(-50%,0px,0px);transform:translate3d(-50%,0px,0px);margin:4px 0px;}.s1xzg253[data-alignment='right']{right:0;margin:4px;}
|
|
44
|
+
.s17qj3jh{margin-bottom:8px;margin-top:4px;font-size:18px;}
|
|
45
|
+
.su3a8bs{display:inline-block;background:var(--toolbar-bg);box-sizing:border-box;overflow-y:auto;min-width:200px;}
|
|
46
|
+
.szboplp{margin:2px 0;}.szboplp:not(:hover){opacity:0.2;}
|
|
47
|
+
.sff5xt{border:3px solid transparent;padding:4px 0px;position:relative;background:var(--toolbar-bg);box-sizing:border-box;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;}.sff5xt[data-is-over='1']{border:3px dotted var(--font-hover-bg);}.sff5xt[data-is-dragging='1']{opacity:0.4;}.sff5xt[data-selected='1']{color:var(--font-selected-color);background:var(--font-selected-bg);}.sff5xt[data-selected='1'] .szboplp{color:white;}.sff5xt[data-selected='0'][data-disabled='0']{background:var(--font-bg);color:var(--font-color);}.sff5xt[data-selected='0'][data-disabled='0']:hover{color:var(--font-hover-color);background:var(--font-hover-bg);}.sff5xt[data-disabled='1']{cursor:default;color:var(--font-disabled-color);background:var(--font-disabled-bg);}.sff5xt[data-disabled='0']{cursor:move;}.sff5xt > span{height:20px;line-height:1;color:#8a8a8a;}.sff5xt > span > svg{fill:#8a8a8a;width:20px;height:20px;padding:0 4px;-webkit-transform:scale(0.75);-ms-transform:scale(0.75);transform:scale(0.75);}
|
|
48
|
+
.sj3bift{margin:2px 0;}.sj3bift[data-visible='false']{opacity:0.2;}
|
|
49
|
+
.s10ip0a4{margin:2px 0;}.s10ip0a4[data-locked='false']{opacity:0.2;}
|
|
50
|
+
.s1j9uq9o[data-grid='false'] svg{opacity:0.2;}
|
|
51
|
+
.s156ddbb{-webkit-flex:1;-ms-flex:1;flex:1;}
|
|
52
|
+
.s11gt4hl{bottom:0;left:unset;top:unset;max-height:100%;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
|
|
53
|
+
.s13cxqhq{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;overflow-y:auto;}
|
|
54
|
+
.s1idv8qv{opacity:0.6;text-align:center;padding:12px 0px;}
|
|
55
|
+
.s1bvz4xj{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;bottom:unset;top:100%;}.s1bvz4xj[data-vertical='1']{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
|
|
56
|
+
.siejlch{position:relative;display:inline-block;}
|
|
57
|
+
.s1uphjfh{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;bottom:unset;top:100%;}.s1uphjfh[data-vertical='1']{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}
|
|
58
|
+
.s1e5a6k5{position:relative;display:inline-block;}
|
|
59
|
+
.s1c8tp02{z-index:3;position:absolute;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;left:0;right:0;bottom:0;top:0;}
|
|
60
|
+
.svkxpz4{display:grid;background:var(--toolbar-bg);box-shadow:0 3px 8px rgb(0 0 0 / 24%);padding:12px;border-radius:8px;white-space:nowrap;position:relative;}
|
|
61
|
+
.s1s9jyyg{position:absolute;left:0;top:0;right:0;bottom:0;background:#00000073;}
|
|
62
|
+
.s95bkm9 form{grid-template-columns:3fr 1fr 1fr;}.s95bkm9 form input{color:var(--font-color);border:1px solid var(--font-color);background:var(--toolbar-bg);outline:none;}
|
|
63
|
+
.so6hnjf{-webkit-flex:1;-ms-flex:1;flex:1;position:relative;height:100%;text-align:center;height:36px;}
|
|
64
|
+
.s1c1dllr{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;max-height:36px;background:var(--toolbar-bg);border-bottom:1px solid var(--divider-color);box-sizing:border-box;}
|
|
65
|
+
.s1g032mh{grid-template-columns:1fr 1fr 1fr;}
|
|
66
|
+
.snh2jyk{width:24px;height:24px;box-sizing:border-box;border-radius:50%;border:1px solid gray;background:var(--snh2jyk-0);background-repeat:repeat;background-size:16px;}
|
|
67
|
+
.sfm1cqx{width:24px;height:24px;box-sizing:border-box;border-radius:50%;color:var(--sfm1cqx-0);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:baseline;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;line-height:36px;font-weight:bold;}
|
|
68
|
+
.layoutPanelOpened .sj7hhjx.sj7hhjx{color:var(--font-selected-color);background:var(--font-selected-bg);}.sj7hhjx[data-hidden='1']{display:none;}
|
|
69
|
+
.s9mugpt{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
70
|
+
.s1ktxhkr{padding:16px;}
|
|
71
|
+
.smpmxx5{font-family:var(--smpmxx5-0);}
|
|
72
|
+
.s1qssg4n{display:inline-block;width:6px;height:2px;background:transparent;vertical-align:middle;}
|
|
73
|
+
.se26iq6{display:inline-block;}.se26iq6[data-type='0'] .s1qssg4n{background:currentColor;}.se26iq6[data-type='1']{position:relative;left:3px;}.se26iq6[data-type='1'] .s1qssg4n:nth-child(3n-1){background:currentColor;width:12px;}.se26iq6[data-type='1'] .s1qssg4n:nth-child(n+11){display:none;}.se26iq6[data-type='2'] .s1qssg4n:nth-child(2n+1){background:currentColor;}
|
|
74
|
+
.s1xxj4yl{position:absolute;left:0;top:50%;-webkit-transform:translate3d(-25%,-50%,0px);-ms-transform:translate3d(-25%,-50%,0px);transform:translate3d(-25%,-50%,0px);display:inline-block;width:0;height:0;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:15px solid currentColor;}
|
|
75
|
+
.sbd6jc8{position:absolute;right:0;top:50%;-webkit-transform:translate3d(25%,-50%,0px);-ms-transform:translate3d(25%,-50%,0px);transform:translate3d(25%,-50%,0px);display:inline-block;width:0;height:0;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:15px solid currentColor;}
|
|
76
|
+
.scawaat{position:relative;display:inline-block;width:60px;height:2px;background:currentColor;vertical-align:middle;}.scawaat[data-type='0'] .s1xxj4yl,.scawaat[data-type='1'] .s1xxj4yl{display:none;}.scawaat[data-type='0'] .sbd6jc8,.scawaat[data-type='2'] .sbd6jc8{display:none;}
|
|
77
|
+
.s16z54di{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;background:var(--toolbar-bg);position:relative;height:36px;border-top:1px solid var(--divider-color);box-sizing:border-box;}
|
|
78
|
+
.sa7lzh9{-webkit-flex:1;-ms-flex:1;flex:1;}
|
|
79
|
+
.s1xssqat{display:inline-block;padding:12px 48px;margin:4px;max-width:calc(100% - 24px);overflow-wrap:break-word;box-sizing:border-box;-webkit-transition:all 500ms;transition:all 500ms;opacity:0;-webkit-transform:translate3d(0px,40px,0px);-ms-transform:translate3d(0px,40px,0px);transform:translate3d(0px,40px,0px);}.s1xssqat[data-type='0']{background:#646464;color:white;}.s1xssqat[data-type='1']{background:#c3a200;color:black;}.s1xssqat[data-type='2']{background:#911717;color:white;}.s1xssqat[data-type='3']{background:#088900;color:white;}.s1xssqat[data-is-shown='1']{opacity:1;-webkit-transform:translate3d(0px,0px,0px);-ms-transform:translate3d(0px,0px,0px);transform:translate3d(0px,0px,0px);}.s1xssqat[data-is-shown='0']{opacity:0;-webkit-transform:translate3d(0px,40px,0px);-ms-transform:translate3d(0px,40px,0px);transform:translate3d(0px,40px,0px);}
|
|
80
|
+
.s1bgtt22{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column-reverse;-ms-flex-direction:column-reverse;flex-direction:column-reverse;position:absolute;z-index:4;bottom:0;left:0;right:0;height:0px;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
|
|
81
|
+
.s9j48u3{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;position:absolute;z-index:2;top:0;bottom:0;left:0;right:0;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:#00000050;-webkit-transition:opacity 300ms linear;transition:opacity 300ms linear;opacity:0;}.s9j48u3[data-loading='visible']{opacity:1;}
|
|
82
|
+
.s4auclc{width:40px;height:40px;position:relative;-webkit-transform:rotate(10deg);-ms-transform:rotate(10deg);transform:rotate(10deg);-webkit-animation:react-paint-rotation-s4auclc 1s infinite;animation:react-paint-rotation-s4auclc 1s infinite;}@-webkit-keyframes react-paint-rotation-s4auclc{from{-webkit-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}@keyframes react-paint-rotation-s4auclc{from{-webkit-transform:rotate(0deg);-ms-transform:rotate(0deg);transform:rotate(0deg);}to{-webkit-transform:rotate(360deg);-ms-transform:rotate(360deg);transform:rotate(360deg);}}
|
|
83
|
+
.s1l3fbq{border-radius:50%;position:absolute;width:15px;height:15px;}.s1l3fbq:nth-child(1){left:0;background-color:#5c6bc0;}.s1l3fbq:nth-child(2){right:0;background-color:#8bc34a;}.s1l3fbq:nth-child(3){bottom:0;background-color:#ffb74d;}.s1l3fbq:nth-child(4){bottom:0;right:0;background-color:#f44336;}
|
|
84
|
+
.s1v9piyg{--toolbar-bg:var(--s1v9piyg-0);--divider-color:var(--s1v9piyg-1);--font-radius:var(--s1v9piyg-2);--font-disabled-color:var(--s1v9piyg-3);--font-disabled-bg:var(--s1v9piyg-4);--font-color:var(--s1v9piyg-5);--font-bg:var(--s1v9piyg-6);--font-selected-color:var(--s1v9piyg-7);--font-selected-bg:var(--s1v9piyg-8);--font-hover-color:var(--s1v9piyg-9);--font-hover-bg:var(--s1v9piyg-10);--canvas-bg:var(--s1v9piyg-11);display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;color:var(--font-color);position:relative;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}.s1v9piyg hr{width:100%;border:none;border-top:1px solid var(--divider-color);}.s1v9piyg[data-grow='false']{max-width:var(--s1v9piyg-12);}.s1v9piyg[data-shrink='false']{min-width:var(--s1v9piyg-13);}
|
|
85
|
+
.s6o5tmu{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;position:relative;max-width:100%;z-index:1;aspect-ratio:var(--s6o5tmu-2);}.s6o5tmu[data-grow='true']{width:100%;}.s6o5tmu[data-grow='false']{width:var(--s6o5tmu-1);}
|
package/dist/utils/data.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.roundValues = exports.createShape = exports.createPicture = exports.copyShape = exports.cleanShapesBeforeExport = exports.addDefaultAndTempShapeProps = void 0;
|
|
8
|
+
exports.roundValues = exports.createShape = exports.createPicture = exports.copyShape = exports.cleanShapesBeforeExport = exports.buildDataToExport = exports.addDefaultAndTempShapeProps = void 0;
|
|
9
9
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
|
|
@@ -43,7 +43,7 @@ var createPicture = function createPicture(fileOrUrl, maxPictureWidth, maxPictur
|
|
|
43
43
|
y: (maxPictureHeight - height) / 2,
|
|
44
44
|
width: width,
|
|
45
45
|
height: height,
|
|
46
|
-
src: img.src,
|
|
46
|
+
src: fileOrUrl instanceof File ? img.src : fileOrUrl,
|
|
47
47
|
img: img,
|
|
48
48
|
translation: [0, 0],
|
|
49
49
|
rotation: 0
|
|
@@ -51,10 +51,18 @@ var createPicture = function createPicture(fileOrUrl, maxPictureWidth, maxPictur
|
|
|
51
51
|
resolve(pictureShape);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
img.onerror = function () {
|
|
55
|
+
reject(new Error('Some images could not be loaded'));
|
|
56
|
+
};
|
|
57
|
+
|
|
54
58
|
if (fileOrUrl instanceof File) {
|
|
55
59
|
img.src = URL.createObjectURL(fileOrUrl);
|
|
56
60
|
} else {
|
|
57
|
-
|
|
61
|
+
(0, _file.fetchAndStringify)(fileOrUrl).then(function (picData) {
|
|
62
|
+
img.src = picData;
|
|
63
|
+
})["catch"](function () {
|
|
64
|
+
img.src = ''; // to trigger onerror
|
|
65
|
+
});
|
|
58
66
|
}
|
|
59
67
|
|
|
60
68
|
img.onerror = function () {
|
|
@@ -70,6 +78,8 @@ var createPicture = function createPicture(fileOrUrl, maxPictureWidth, maxPictur
|
|
|
70
78
|
exports.createPicture = createPicture;
|
|
71
79
|
|
|
72
80
|
var createShape = function createShape(ctx, shape, cursorPosition) {
|
|
81
|
+
var _shape$settings$fontB, _shape$settings, _shape$settings$fontI, _shape$settings2;
|
|
82
|
+
|
|
73
83
|
switch (shape.type) {
|
|
74
84
|
case _Shapes.ShapeEnum.brush:
|
|
75
85
|
shape.settings;
|
|
@@ -167,8 +177,8 @@ var createShape = function createShape(ctx, shape, cursorPosition) {
|
|
|
167
177
|
};
|
|
168
178
|
|
|
169
179
|
case _Shapes.ShapeEnum.text:
|
|
170
|
-
var defaultValue = [];
|
|
171
|
-
var fontSize = (0, _transform.calculateTextFontSize)(ctx, defaultValue, 50, shape.settings.fontFamily["default"]);
|
|
180
|
+
var defaultValue = ['Texte'];
|
|
181
|
+
var fontSize = (0, _transform.calculateTextFontSize)(ctx, defaultValue, 50, (_shape$settings$fontB = (_shape$settings = shape.settings) === null || _shape$settings === void 0 ? void 0 : _shape$settings.fontBold["default"]) !== null && _shape$settings$fontB !== void 0 ? _shape$settings$fontB : false, (_shape$settings$fontI = (_shape$settings2 = shape.settings) === null || _shape$settings2 === void 0 ? void 0 : _shape$settings2.fontItalic["default"]) !== null && _shape$settings$fontI !== void 0 ? _shape$settings$fontI : false, shape.settings.fontFamily["default"]);
|
|
172
182
|
return {
|
|
173
183
|
toolId: shape.id,
|
|
174
184
|
type: _Shapes.ShapeEnum.text,
|
|
@@ -277,6 +287,18 @@ var cleanShapesBeforeExport = function cleanShapesBeforeExport(shapes) {
|
|
|
277
287
|
|
|
278
288
|
exports.cleanShapesBeforeExport = cleanShapesBeforeExport;
|
|
279
289
|
|
|
290
|
+
var buildDataToExport = function buildDataToExport(shapes, width, height) {
|
|
291
|
+
return {
|
|
292
|
+
shapes: cleanShapesBeforeExport(shapes),
|
|
293
|
+
config: {
|
|
294
|
+
width: width,
|
|
295
|
+
height: height
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
exports.buildDataToExport = buildDataToExport;
|
|
301
|
+
|
|
280
302
|
var addDefaultAndTempShapeProps = function addDefaultAndTempShapeProps(shape) {
|
|
281
303
|
return _objectSpread(_objectSpread({}, shape), {}, {
|
|
282
304
|
id: _fp["default"].uniqueId("".concat(shape.type, "_"))
|
package/dist/utils/draw.js
CHANGED
|
@@ -225,12 +225,12 @@ var drawRect = function drawRect(ctx, rect) {
|
|
|
225
225
|
exports.drawRect = drawRect;
|
|
226
226
|
|
|
227
227
|
var drawText = function drawText(ctx, text) {
|
|
228
|
-
var _text$style, _text$style$fontFamil, _text$
|
|
228
|
+
var _text$style, _text$style2, _text$style3, _text$style$fontFamil, _text$style4;
|
|
229
229
|
|
|
230
230
|
updateDrawStyle(ctx, text.style);
|
|
231
231
|
if (ctx.globalAlpha === 0 || !((_text$style = text.style) !== null && _text$style !== void 0 && _text$style.strokeColor) || text.style.strokeColor === 'transparent') return;
|
|
232
|
-
ctx.font = "".concat(text.fontSize, "px ").concat((_text$style$fontFamil = (_text$
|
|
233
|
-
ctx.textBaseline = '
|
|
232
|
+
ctx.font = "".concat((_text$style2 = text.style) !== null && _text$style2 !== void 0 && _text$style2.fontItalic ? 'italic' : '', " ").concat((_text$style3 = text.style) !== null && _text$style3 !== void 0 && _text$style3.fontBold ? 'bold' : '', " ").concat(text.fontSize, "px ").concat((_text$style$fontFamil = (_text$style4 = text.style) === null || _text$style4 === void 0 ? void 0 : _text$style4.fontFamily) !== null && _text$style$fontFamil !== void 0 ? _text$style$fontFamil : _style.STYLE_FONT_DEFAULT);
|
|
233
|
+
ctx.textBaseline = 'top';
|
|
234
234
|
ctx.fillStyle = text.style.strokeColor;
|
|
235
235
|
|
|
236
236
|
for (var i = 0; i < text.value.length; i++) {
|