@yorab/react-paint 0.6.6 → 0.7.1
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/README.md +3 -5
- package/dist/components/App.js +30 -57
- package/dist/components/Canvas.js +31 -40
- package/dist/components/common/Button.js +4 -4
- package/dist/components/common/Loading.js +8 -5
- package/dist/components/common/Modal.js +3 -3
- package/dist/components/common/Panel.js +7 -11
- package/dist/components/common/Snackbar.js +6 -6
- package/dist/components/settings/ColorField.js +3 -3
- package/dist/components/settings/FontFamilyField.js +1 -1
- package/dist/components/settings/Layouts.js +36 -26
- package/dist/components/settings/LineArrowField.js +3 -3
- package/dist/components/settings/LineTypeField.js +2 -2
- package/dist/components/settings/RangeField.js +1 -1
- package/dist/components/settings/SelectField.js +1 -1
- package/dist/components/settings/SettingsBar.js +9 -7
- package/dist/components/toolbox/EditTextBox.js +11 -9
- package/dist/components/toolbox/MenuGroup.js +9 -7
- package/dist/components/toolbox/Toolbar.js +7 -9
- package/dist/components/toolbox/ToolbarGroup.js +24 -11
- package/dist/constants/app.js +51 -0
- package/dist/constants/icons.js +2 -8
- package/dist/constants/loading.js +8 -0
- package/dist/constants/shapes.js +4 -2
- package/dist/constants/snackbar.js +6 -14
- package/dist/constants/style.js +12 -9
- package/dist/constants/tools.js +20 -24
- package/dist/hooks/useComponent.js +3 -1
- package/dist/hooks/useDrawableCanvas.js +35 -37
- package/dist/hooks/useKeyboard.js +60 -33
- package/dist/hooks/useShapes.js +2 -2
- package/dist/styles.css +16 -13
- package/dist/types/Mode.js +1 -13
- package/dist/types/Shapes.js +1 -17
- package/dist/types/snackbar.js +5 -0
- package/dist/types/tools.js +1 -18
- package/dist/utils/canvas.js +49 -0
- package/dist/utils/data.js +5 -248
- package/dist/utils/dom.js +12 -0
- package/dist/utils/file.js +12 -7
- package/dist/utils/intersect.js +29 -66
- package/dist/utils/migration.js +59 -0
- package/dist/utils/selection.js +9 -11
- package/dist/utils/shapes/brush.js +135 -0
- package/dist/utils/shapes/circle.js +93 -0
- package/dist/utils/shapes/curve.js +55 -0
- package/dist/utils/shapes/default.js +73 -0
- package/dist/utils/shapes/ellipse.js +101 -0
- package/dist/utils/shapes/grid.js +36 -0
- package/dist/utils/shapes/index.js +341 -0
- package/dist/utils/shapes/line.js +179 -0
- package/dist/utils/shapes/picture.js +88 -0
- package/dist/utils/shapes/polygon.js +69 -0
- package/dist/utils/shapes/rectangle.js +100 -0
- package/dist/utils/shapes/text.js +128 -0
- package/dist/utils/shapes/triangle.js +24 -0
- package/dist/utils/style.js +10 -12
- package/dist/utils/toolbar.js +9 -11
- package/dist/utils/transform.js +25 -261
- package/dist/utils/trigo.js +42 -0
- package/package.json +7 -8
- package/dist/types/keyboard.js +0 -28
- package/dist/utils/draw.js +0 -431
- package/dist/utils/shapeData.js +0 -155
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Paint
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## known issues :
|
|
4
4
|
|
|
5
5
|
- dnd layout on mobile not working (fix : use dnd lib, or add touch listener to fake dnd, or provide alt UI)
|
|
6
|
-
|
|
7
|
-
## other
|
|
8
|
-
|
|
9
6
|
- TextEdit cursor overflow MINOR (quick fix : edit on modale ?)
|
|
10
7
|
- circle resizing only goes one direction
|
|
11
8
|
- adding padding to selection result in wrong intersection calculs
|
|
12
9
|
- Clear with custom callback breaks history stack
|
|
13
10
|
- selection padding needs work
|
|
11
|
+
- with shrunk or grown container, anchors selection is miscalculated
|
package/dist/components/App.js
CHANGED
|
@@ -25,8 +25,6 @@ var _useKeyboard = _interopRequireDefault(require("../hooks/useKeyboard"));
|
|
|
25
25
|
|
|
26
26
|
var _file = require("../utils/file");
|
|
27
27
|
|
|
28
|
-
var _Mode = require("../types/Mode");
|
|
29
|
-
|
|
30
28
|
var _useComponent = _interopRequireDefault(require("../hooks/useComponent"));
|
|
31
29
|
|
|
32
30
|
var _useShapes = _interopRequireDefault(require("../hooks/useShapes"));
|
|
@@ -35,27 +33,25 @@ var _Snackbar = _interopRequireDefault(require("./common/Snackbar"));
|
|
|
35
33
|
|
|
36
34
|
var _useSnackbar = _interopRequireDefault(require("../hooks/useSnackbar"));
|
|
37
35
|
|
|
38
|
-
var _snackbar = require("../constants/snackbar");
|
|
39
|
-
|
|
40
36
|
var _Loading = _interopRequireDefault(require("./common/Loading"));
|
|
41
37
|
|
|
42
38
|
var _data = require("../utils/data");
|
|
43
39
|
|
|
44
40
|
var _useResizeObserver = _interopRequireDefault(require("../hooks/useResizeObserver"));
|
|
45
41
|
|
|
46
|
-
var _shapes = require("../constants/shapes");
|
|
47
|
-
|
|
48
42
|
var _toolbar = require("../utils/toolbar");
|
|
49
43
|
|
|
50
44
|
var _tools = require("../constants/tools");
|
|
51
45
|
|
|
52
46
|
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
53
47
|
|
|
48
|
+
var _app = require("../constants/app");
|
|
49
|
+
|
|
54
50
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
55
51
|
|
|
56
52
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
57
53
|
|
|
58
|
-
const StyledApp = /*#__PURE__*/(0, _react2.styled)(
|
|
54
|
+
const StyledApp = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
59
55
|
name: "StyledApp",
|
|
60
56
|
class: "s1v9piyg",
|
|
61
57
|
vars: {
|
|
@@ -85,17 +81,17 @@ const StyledApp = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
85
81
|
}, "px"]
|
|
86
82
|
}
|
|
87
83
|
});
|
|
88
|
-
const StyledRow = /*#__PURE__*/(0, _react2.styled)(
|
|
84
|
+
const StyledRow = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
89
85
|
name: "StyledRow",
|
|
90
86
|
class: "s6o5tmu",
|
|
91
87
|
vars: {
|
|
92
|
-
"s6o5tmu-
|
|
88
|
+
"s6o5tmu-0": [_ref3 => {
|
|
93
89
|
let {
|
|
94
90
|
width
|
|
95
91
|
} = _ref3;
|
|
96
92
|
return width;
|
|
97
93
|
}, "px"],
|
|
98
|
-
"s6o5tmu-
|
|
94
|
+
"s6o5tmu-1": [_ref4 => {
|
|
99
95
|
let {
|
|
100
96
|
aspectRatio
|
|
101
97
|
} = _ref4;
|
|
@@ -103,35 +99,6 @@ const StyledRow = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
103
99
|
}]
|
|
104
100
|
}
|
|
105
101
|
});
|
|
106
|
-
const DEFAULT_OPTIONS = {
|
|
107
|
-
layersManipulation: true,
|
|
108
|
-
gridVisible: false,
|
|
109
|
-
canGrow: false,
|
|
110
|
-
canShrink: true,
|
|
111
|
-
withExport: true,
|
|
112
|
-
withLoadAndSave: true,
|
|
113
|
-
withUploadPicture: true,
|
|
114
|
-
withUrlPicture: false,
|
|
115
|
-
availableTools: _tools.DEFAULT_SHAPE_TOOLS,
|
|
116
|
-
clearCallback: 'empty',
|
|
117
|
-
uiStyle: {
|
|
118
|
-
toolbarBackgroundColor: 'white',
|
|
119
|
-
dividerColor: '#36418129',
|
|
120
|
-
fontRadius: 8,
|
|
121
|
-
fontDisabledColor: '#3641812b',
|
|
122
|
-
fontDisabledBackgroundColor: 'transparent',
|
|
123
|
-
fontColor: '#364181',
|
|
124
|
-
fontBackgroundColor: 'transparent',
|
|
125
|
-
fontSelectedColor: 'white',
|
|
126
|
-
fontSelectedBackgroundColor: '#364181',
|
|
127
|
-
fontHoverColor: '#364181',
|
|
128
|
-
fontHoverBackgroundColor: '#afd8d8',
|
|
129
|
-
canvasBackgroundColor: 'white',
|
|
130
|
-
canvasSelectionColor: _shapes.SELECTION_DEFAULT_COLOR,
|
|
131
|
-
canvasSelectionWidth: _shapes.SELECTION_DEFAULT_WIDTH,
|
|
132
|
-
canvasSelectionPadding: _shapes.SELECTION_DEFAULT_PADDING
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
102
|
|
|
136
103
|
const App = _ref5 => {
|
|
137
104
|
var _options$uiStyle;
|
|
@@ -149,7 +116,7 @@ const App = _ref5 => {
|
|
|
149
116
|
} = _ref5;
|
|
150
117
|
const {
|
|
151
118
|
layersManipulation,
|
|
152
|
-
|
|
119
|
+
grid,
|
|
153
120
|
canGrow,
|
|
154
121
|
canShrink,
|
|
155
122
|
withExport,
|
|
@@ -158,7 +125,7 @@ const App = _ref5 => {
|
|
|
158
125
|
withUrlPicture,
|
|
159
126
|
clearCallback,
|
|
160
127
|
availableTools: availableToolsFromProps
|
|
161
|
-
} = { ...DEFAULT_OPTIONS,
|
|
128
|
+
} = { ..._app.DEFAULT_OPTIONS,
|
|
162
129
|
...options
|
|
163
130
|
};
|
|
164
131
|
const {
|
|
@@ -175,9 +142,9 @@ const App = _ref5 => {
|
|
|
175
142
|
fontHoverBackgroundColor,
|
|
176
143
|
canvasBackgroundColor,
|
|
177
144
|
canvasSelectionColor,
|
|
178
|
-
canvasSelectionWidth
|
|
179
|
-
|
|
180
|
-
} = { ...DEFAULT_OPTIONS.uiStyle,
|
|
145
|
+
canvasSelectionWidth // canvasSelectionPadding
|
|
146
|
+
|
|
147
|
+
} = { ..._app.DEFAULT_OPTIONS.uiStyle,
|
|
181
148
|
...((_options$uiStyle = options === null || options === void 0 ? void 0 : options.uiStyle) !== null && _options$uiStyle !== void 0 ? _options$uiStyle : {})
|
|
182
149
|
};
|
|
183
150
|
const isEditMode = mode !== 'viewer';
|
|
@@ -189,6 +156,8 @@ const App = _ref5 => {
|
|
|
189
156
|
height: canvasHeight,
|
|
190
157
|
scaleRatio: 1
|
|
191
158
|
});
|
|
159
|
+
const canvasSelectionPadding = 0; // selection padding should not be larger than 0 until shape resizing is refactored
|
|
160
|
+
|
|
192
161
|
const [availableTools, setAvailableTools] = (0, _react.useState)((0, _toolbar.sanitizeTools)(availableToolsFromProps, withUploadPicture || withUrlPicture));
|
|
193
162
|
(0, _react.useEffect)(() => {
|
|
194
163
|
setAvailableTools((0, _toolbar.sanitizeTools)(availableToolsFromProps, withUploadPicture || withUrlPicture));
|
|
@@ -205,9 +174,10 @@ const App = _ref5 => {
|
|
|
205
174
|
const [canvasOffsetStartPosition, setCanvasOffsetStartPosition] = (0, _react.useState)(undefined);
|
|
206
175
|
const [activeTool, setActiveTool] = (0, _react.useState)(_tools.SELECTION_TOOL);
|
|
207
176
|
const [selectionMode, setSelectionMode] = (0, _react.useState)({
|
|
208
|
-
mode:
|
|
177
|
+
mode: 'default'
|
|
209
178
|
});
|
|
210
|
-
const [
|
|
179
|
+
const [gridFormat, setGridFormat] = (0, _react.useState)(grid);
|
|
180
|
+
const [isShiftPressed, setShiftPressed] = (0, _react.useState)(false);
|
|
211
181
|
const {
|
|
212
182
|
shapesRef,
|
|
213
183
|
selectedShape,
|
|
@@ -297,7 +267,7 @@ const App = _ref5 => {
|
|
|
297
267
|
} catch (e) {
|
|
298
268
|
if (e instanceof Error) {
|
|
299
269
|
addSnackbar({
|
|
300
|
-
type:
|
|
270
|
+
type: 'error',
|
|
301
271
|
text: "L'export a échoué"
|
|
302
272
|
});
|
|
303
273
|
}
|
|
@@ -322,7 +292,7 @@ const App = _ref5 => {
|
|
|
322
292
|
} catch (e) {
|
|
323
293
|
if (e instanceof Error) {
|
|
324
294
|
addSnackbar({
|
|
325
|
-
type:
|
|
295
|
+
type: 'error',
|
|
326
296
|
text: "L'enregistrement a échoué"
|
|
327
297
|
});
|
|
328
298
|
}
|
|
@@ -339,13 +309,13 @@ const App = _ref5 => {
|
|
|
339
309
|
const json = await (0, _file.decodeJson)(file);
|
|
340
310
|
await loadImportedData(json);
|
|
341
311
|
addSnackbar({
|
|
342
|
-
type:
|
|
312
|
+
type: 'success',
|
|
343
313
|
text: 'Fichier chargé !'
|
|
344
314
|
});
|
|
345
315
|
} catch (e) {
|
|
346
316
|
if (e instanceof Error) {
|
|
347
317
|
addSnackbar({
|
|
348
|
-
type:
|
|
318
|
+
type: 'error',
|
|
349
319
|
text: 'Le chargement a échoué'
|
|
350
320
|
});
|
|
351
321
|
}
|
|
@@ -364,7 +334,7 @@ const App = _ref5 => {
|
|
|
364
334
|
} catch (e) {
|
|
365
335
|
if (e instanceof Error) {
|
|
366
336
|
addSnackbar({
|
|
367
|
-
type:
|
|
337
|
+
type: 'error',
|
|
368
338
|
text: 'Le chargement a échoué'
|
|
369
339
|
});
|
|
370
340
|
}
|
|
@@ -384,14 +354,16 @@ const App = _ref5 => {
|
|
|
384
354
|
}, [canvasWidth, canvasHeight]);
|
|
385
355
|
(0, _useKeyboard.default)({
|
|
386
356
|
isInsideComponent,
|
|
387
|
-
|
|
357
|
+
gridFormat,
|
|
358
|
+
isEditingText: selectionMode.mode === 'textedition',
|
|
388
359
|
selectedShape,
|
|
389
360
|
setSelectedShape,
|
|
390
361
|
removeShape,
|
|
391
362
|
pasteShape,
|
|
392
363
|
updateShape,
|
|
393
364
|
backwardShape,
|
|
394
|
-
forwardShape
|
|
365
|
+
forwardShape,
|
|
366
|
+
setShiftPressed
|
|
395
367
|
});
|
|
396
368
|
(0, _useResizeObserver.default)({
|
|
397
369
|
element: componentRef,
|
|
@@ -463,7 +435,7 @@ const App = _ref5 => {
|
|
|
463
435
|
aspectRatio: "calc(".concat(canvasSize.width, " / ").concat(canvasSize.height, ")")
|
|
464
436
|
}, /*#__PURE__*/_react.default.createElement(_Canvas.default, {
|
|
465
437
|
canGrow: canGrow,
|
|
466
|
-
|
|
438
|
+
gridFormat: gridFormat,
|
|
467
439
|
disabled: disabled,
|
|
468
440
|
isInsideComponent: isInsideComponent,
|
|
469
441
|
activeTool: activeTool,
|
|
@@ -485,10 +457,11 @@ const App = _ref5 => {
|
|
|
485
457
|
selectionColor: canvasSelectionColor,
|
|
486
458
|
selectionWidth: canvasSelectionWidth,
|
|
487
459
|
selectionPadding: canvasSelectionPadding,
|
|
488
|
-
isEditMode: isEditMode
|
|
460
|
+
isEditMode: isEditMode,
|
|
461
|
+
isShiftPressed: isShiftPressed
|
|
489
462
|
}), isEditMode && layersManipulation && /*#__PURE__*/_react.default.createElement(_Layouts.default, {
|
|
490
|
-
|
|
491
|
-
|
|
463
|
+
gridFormat: gridFormat,
|
|
464
|
+
setGridFormat: setGridFormat,
|
|
492
465
|
disabled: disabled,
|
|
493
466
|
shapes: shapesRef.current,
|
|
494
467
|
moveShapes: moveShapes,
|
|
@@ -11,39 +11,35 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _react2 = require("@linaria/react");
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _Shapes = require("../types/Shapes");
|
|
17
|
-
|
|
18
|
-
var _draw = require("../utils/draw");
|
|
19
|
-
|
|
20
|
-
var _Mode = require("../types/Mode");
|
|
21
|
-
|
|
22
|
-
var _transform = require("../utils/transform");
|
|
14
|
+
var _canvas = require("../utils/canvas");
|
|
23
15
|
|
|
24
16
|
var _EditTextBox = _interopRequireDefault(require("./toolbox/EditTextBox"));
|
|
25
17
|
|
|
26
18
|
var _useDrawableCanvas = _interopRequireDefault(require("../hooks/useDrawableCanvas"));
|
|
27
19
|
|
|
28
|
-
var
|
|
20
|
+
var _shapes = require("../utils/shapes");
|
|
29
21
|
|
|
30
|
-
var
|
|
22
|
+
var _text = require("../utils/shapes/text");
|
|
23
|
+
|
|
24
|
+
var _grid = require("../utils/shapes/grid");
|
|
31
25
|
|
|
32
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
27
|
|
|
34
28
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
29
|
|
|
36
|
-
const renderDrawCanvas = (drawCtx, selectionMode, canvasSize, canvasOffset, shapes, selectionPadding, selectedShape) => {
|
|
30
|
+
const renderDrawCanvas = (drawCtx, selectionMode, canvasSize, gridFormat, canvasOffset, shapes, selectionPadding, selectedShape) => {
|
|
37
31
|
const {
|
|
38
32
|
width,
|
|
39
33
|
height,
|
|
40
34
|
scaleRatio
|
|
41
35
|
} = canvasSize;
|
|
42
36
|
drawCtx.clearRect(0, 0, width, height);
|
|
37
|
+
(0, _canvas.initCanvasContext)(drawCtx);
|
|
38
|
+
gridFormat && (0, _grid.drawGrid)(drawCtx, width, height, scaleRatio, canvasOffset, gridFormat);
|
|
43
39
|
|
|
44
40
|
for (let i = shapes.length - 1; i >= 0; i--) {
|
|
45
|
-
if (selectionMode.mode !==
|
|
46
|
-
(0,
|
|
41
|
+
if (selectionMode.mode !== 'textedition' || shapes[i] !== selectedShape) {
|
|
42
|
+
(0, _shapes.drawShape)(drawCtx, shapes[i], scaleRatio, canvasOffset, selectionPadding);
|
|
47
43
|
}
|
|
48
44
|
}
|
|
49
45
|
};
|
|
@@ -55,7 +51,7 @@ const renderSelectionCanvas = (selectionCtx, selectionMode, canvasSize, activeTo
|
|
|
55
51
|
scaleRatio
|
|
56
52
|
} = canvasSize;
|
|
57
53
|
selectionCtx.clearRect(0, 0, width, height);
|
|
58
|
-
selectedShape && activeTool.type !==
|
|
54
|
+
selectedShape && activeTool.type !== 'brush' && (0, _shapes.drawShapeSelection)({
|
|
59
55
|
ctx: selectionCtx,
|
|
60
56
|
shape: selectedShape,
|
|
61
57
|
scaleRatio,
|
|
@@ -63,23 +59,23 @@ const renderSelectionCanvas = (selectionCtx, selectionMode, canvasSize, activeTo
|
|
|
63
59
|
selectionPadding,
|
|
64
60
|
selectionWidth,
|
|
65
61
|
selectionColor,
|
|
66
|
-
withAnchors: selectionMode.mode !==
|
|
62
|
+
withAnchors: selectionMode.mode !== 'textedition'
|
|
67
63
|
});
|
|
68
64
|
};
|
|
69
65
|
|
|
70
|
-
const StyledCanvasBox = /*#__PURE__*/(0, _react2.styled)(
|
|
66
|
+
const StyledCanvasBox = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
71
67
|
name: "StyledCanvasBox",
|
|
72
68
|
class: "s9czb9p"
|
|
73
69
|
});
|
|
74
|
-
const StyledCanvasContainer = /*#__PURE__*/(0, _react2.styled)(
|
|
70
|
+
const StyledCanvasContainer = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
75
71
|
name: "StyledCanvasContainer",
|
|
76
72
|
class: "s1538eht"
|
|
77
73
|
});
|
|
78
|
-
const StyledDrawCanvas = /*#__PURE__*/(0, _react2.styled)(
|
|
74
|
+
const StyledDrawCanvas = /*#__PURE__*/(0, _react2.styled)('canvas')({
|
|
79
75
|
name: "StyledDrawCanvas",
|
|
80
76
|
class: "s101qxdc"
|
|
81
77
|
});
|
|
82
|
-
const StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)(
|
|
78
|
+
const StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)('canvas')({
|
|
83
79
|
name: "StyledSelectionCanvas",
|
|
84
80
|
class: "sa4oq48",
|
|
85
81
|
vars: {
|
|
@@ -94,7 +90,7 @@ const StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)("canvas")({
|
|
|
94
90
|
|
|
95
91
|
const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
96
92
|
let {
|
|
97
|
-
|
|
93
|
+
gridFormat,
|
|
98
94
|
canGrow,
|
|
99
95
|
disabled = false,
|
|
100
96
|
canvasSize,
|
|
@@ -116,7 +112,8 @@ const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
116
112
|
selectionWidth,
|
|
117
113
|
selectionColor,
|
|
118
114
|
selectionPadding,
|
|
119
|
-
isEditMode
|
|
115
|
+
isEditMode,
|
|
116
|
+
isShiftPressed
|
|
120
117
|
} = _ref2;
|
|
121
118
|
const drawCanvasRef = (0, _react.useRef)(null);
|
|
122
119
|
const selectionCanvasRef = (0, _react.useRef)(null); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
@@ -141,33 +138,28 @@ const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
141
138
|
setSelectedShape,
|
|
142
139
|
setCanvasOffsetStartPosition,
|
|
143
140
|
updateSingleShape,
|
|
141
|
+
gridFormat,
|
|
144
142
|
canvasOffset,
|
|
145
143
|
saveShapes,
|
|
146
144
|
setSelectionMode,
|
|
147
|
-
selectionPadding
|
|
145
|
+
selectionPadding,
|
|
146
|
+
isShiftPressed
|
|
148
147
|
});
|
|
149
148
|
const updateSelectedShapeText = (0, _react.useCallback)(newText => {
|
|
150
|
-
var _drawCanvasRef$curren
|
|
149
|
+
var _drawCanvasRef$curren;
|
|
151
150
|
|
|
152
|
-
if ((selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) !==
|
|
151
|
+
if ((selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) !== 'text') return;
|
|
153
152
|
const ctx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
154
153
|
if (!ctx) return;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const newWidth = (0, _transform.calculateTextWidth)(ctx, newShape.value, newShape.fontSize, (_newShape$style$fontB = (_newShape$style = newShape.style) === null || _newShape$style === void 0 ? void 0 : _newShape$style.fontBold) !== null && _newShape$style$fontB !== void 0 ? _newShape$style$fontB : false, (_newShape$style$fontI = (_newShape$style2 = newShape.style) === null || _newShape$style2 === void 0 ? void 0 : _newShape$style2.fontItalic) !== null && _newShape$style$fontI !== void 0 ? _newShape$style$fontI : false, (_newShape$style3 = newShape.style) === null || _newShape$style3 === void 0 ? void 0 : _newShape$style3.fontFamily);
|
|
159
|
-
const resizedShape = { ...newShape,
|
|
160
|
-
width: newWidth,
|
|
161
|
-
height: newShape.fontSize * newShape.value.length
|
|
162
|
-
};
|
|
163
|
-
updateSingleShape(resizedShape);
|
|
164
|
-
}, [updateSingleShape, selectedShape]);
|
|
154
|
+
const newShape = (0, _text.resizeTextShapeWithNewContent)(ctx, selectedShape, newText, canvasOffset);
|
|
155
|
+
updateSingleShape(newShape);
|
|
156
|
+
}, [updateSingleShape, selectedShape, canvasOffset]);
|
|
165
157
|
(0, _react.useEffect)(() => {
|
|
166
158
|
var _drawCanvasRef$curren2;
|
|
167
159
|
|
|
168
160
|
const drawCtx = (_drawCanvasRef$curren2 = drawCanvasRef.current) === null || _drawCanvasRef$curren2 === void 0 ? void 0 : _drawCanvasRef$curren2.getContext('2d');
|
|
169
|
-
drawCtx && window.requestAnimationFrame(() => renderDrawCanvas(drawCtx, selectionMode, canvasSize, canvasOffset, shapes, selectionPadding, selectedShape));
|
|
170
|
-
}, [shapes, selectionMode, selectedShape, canvasOffset, canvasSize, selectionPadding]);
|
|
161
|
+
drawCtx && window.requestAnimationFrame(() => renderDrawCanvas(drawCtx, selectionMode, canvasSize, gridFormat, canvasOffset, shapes, selectionPadding, selectedShape));
|
|
162
|
+
}, [shapes, gridFormat, selectionMode, selectedShape, canvasOffset, canvasSize, selectionPadding]);
|
|
171
163
|
(0, _react.useEffect)(() => {
|
|
172
164
|
var _selectionCanvasRef$c;
|
|
173
165
|
|
|
@@ -175,7 +167,6 @@ const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
175
167
|
selectionCtx && window.requestAnimationFrame(() => renderSelectionCanvas(selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape));
|
|
176
168
|
}, [selectionMode, selectedShape, activeTool, canvasOffset, canvasSize, selectionPadding, selectionWidth, selectionColor]);
|
|
177
169
|
return /*#__PURE__*/_react.default.createElement(StyledCanvasBox, null, /*#__PURE__*/_react.default.createElement(StyledCanvasContainer, {
|
|
178
|
-
"data-grid": withGrid,
|
|
179
170
|
"data-grow": canGrow
|
|
180
171
|
}, /*#__PURE__*/_react.default.createElement(StyledDrawCanvas, {
|
|
181
172
|
ref: drawCanvasRef,
|
|
@@ -187,8 +178,8 @@ const Canvas = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
|
187
178
|
width: canvasSize.width,
|
|
188
179
|
height: canvasSize.height,
|
|
189
180
|
"data-grow": canGrow,
|
|
190
|
-
cursor: activeTool.type !==
|
|
191
|
-
}), isEditMode && selectionMode.mode ===
|
|
181
|
+
cursor: activeTool.type !== 'selection' && activeTool.type !== 'move' || hoverMode.mode === 'resize' ? 'crosshair' : activeTool.type === 'move' || hoverMode.mode === 'translate' ? 'move' : hoverMode.mode === 'rotate' ? 'grab' : 'default'
|
|
182
|
+
}), isEditMode && selectionMode.mode === 'textedition' && (selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) === 'text' && /*#__PURE__*/_react.default.createElement(_EditTextBox.default, {
|
|
192
183
|
scaleRatio: canvasSize.scaleRatio,
|
|
193
184
|
disabled: disabled,
|
|
194
185
|
shape: selectedShape,
|
|
@@ -13,19 +13,19 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _react2 = require("@linaria/react");
|
|
15
15
|
|
|
16
|
-
const StyledButton = /*#__PURE__*/(0, _react2.styled)(
|
|
16
|
+
const StyledButton = /*#__PURE__*/(0, _react2.styled)('button')({
|
|
17
17
|
name: "StyledButton",
|
|
18
18
|
class: "sq3bzv4"
|
|
19
19
|
});
|
|
20
|
-
const StyledButtonContent = /*#__PURE__*/(0, _react2.styled)(
|
|
20
|
+
const StyledButtonContent = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
21
21
|
name: "StyledButtonContent",
|
|
22
22
|
class: "sst453j"
|
|
23
23
|
});
|
|
24
|
-
const StyledIcon = /*#__PURE__*/(0, _react2.styled)(
|
|
24
|
+
const StyledIcon = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
25
25
|
name: "StyledIcon",
|
|
26
26
|
class: "s1q5lsc2"
|
|
27
27
|
});
|
|
28
|
-
const StyledChildren = /*#__PURE__*/(0, _react2.styled)(
|
|
28
|
+
const StyledChildren = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
29
29
|
name: "StyledChildren",
|
|
30
30
|
class: "s1dis2j8"
|
|
31
31
|
});
|
|
@@ -7,6 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _react = require("@linaria/react");
|
|
9
9
|
|
|
10
|
+
var _app = require("../../constants/app");
|
|
11
|
+
|
|
12
|
+
var _loading = require("../../constants/loading");
|
|
13
|
+
|
|
10
14
|
var _style = require("../../constants/style");
|
|
11
15
|
|
|
12
16
|
var _react2 = _interopRequireWildcard(require("react"));
|
|
@@ -15,16 +19,15 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
19
|
|
|
16
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
21
|
|
|
18
|
-
const
|
|
19
|
-
const StyledLoading = /*#__PURE__*/(0, _react.styled)("div")({
|
|
22
|
+
const StyledLoading = /*#__PURE__*/(0, _react.styled)('div')({
|
|
20
23
|
name: "StyledLoading",
|
|
21
24
|
class: "s9j48u3"
|
|
22
25
|
});
|
|
23
|
-
const StyledLoader = /*#__PURE__*/(0, _react.styled)(
|
|
26
|
+
const StyledLoader = /*#__PURE__*/(0, _react.styled)('div')({
|
|
24
27
|
name: "StyledLoader",
|
|
25
28
|
class: "s4auclc"
|
|
26
29
|
});
|
|
27
|
-
const StyledShape = /*#__PURE__*/(0, _react.styled)(
|
|
30
|
+
const StyledShape = /*#__PURE__*/(0, _react.styled)('div')({
|
|
28
31
|
name: "StyledShape",
|
|
29
32
|
class: "s1l3fbq"
|
|
30
33
|
});
|
|
@@ -39,7 +42,7 @@ const Loading = _ref => {
|
|
|
39
42
|
setLoadingState('visible');
|
|
40
43
|
} else {
|
|
41
44
|
setLoadingState('fadeOut');
|
|
42
|
-
const fadeOutTimeout = setTimeout(() => setLoadingState('hidden'),
|
|
45
|
+
const fadeOutTimeout = setTimeout(() => setLoadingState('hidden'), _loading.LOADING_TRANSITION_DURATION);
|
|
43
46
|
return () => {
|
|
44
47
|
clearTimeout(fadeOutTimeout);
|
|
45
48
|
};
|
|
@@ -13,15 +13,15 @@ var _react2 = require("@linaria/react");
|
|
|
13
13
|
|
|
14
14
|
var _style = require("../../constants/style");
|
|
15
15
|
|
|
16
|
-
const StyledModal = /*#__PURE__*/(0, _react2.styled)(
|
|
16
|
+
const StyledModal = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
17
17
|
name: "StyledModal",
|
|
18
18
|
class: "s1c8tp02"
|
|
19
19
|
});
|
|
20
|
-
const StyledPanel = /*#__PURE__*/(0, _react2.styled)(
|
|
20
|
+
const StyledPanel = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
21
21
|
name: "StyledPanel",
|
|
22
22
|
class: "svkxpz4"
|
|
23
23
|
});
|
|
24
|
-
const StyledMask = /*#__PURE__*/(0, _react2.styled)(
|
|
24
|
+
const StyledMask = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
25
25
|
name: "StyledMask",
|
|
26
26
|
class: "s1s9jyyg"
|
|
27
27
|
});
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = void 0;
|
|
7
9
|
|
|
8
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
11
|
|
|
10
12
|
var _react2 = require("@linaria/react");
|
|
11
13
|
|
|
12
14
|
var _style = require("../../constants/style");
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
|
-
const StyledPanel = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
16
|
+
const StyledPanel = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
19
17
|
name: "StyledPanel",
|
|
20
18
|
class: "s1xzg253"
|
|
21
19
|
});
|
|
22
|
-
const StyledTitle = /*#__PURE__*/(0, _react2.styled)(
|
|
20
|
+
const StyledTitle = /*#__PURE__*/(0, _react2.styled)('h3')({
|
|
23
21
|
name: "StyledTitle",
|
|
24
22
|
class: "s17qj3jh"
|
|
25
23
|
});
|
|
@@ -27,18 +25,16 @@ const StyledTitle = /*#__PURE__*/(0, _react2.styled)("h3")({
|
|
|
27
25
|
const Panel = _ref => {
|
|
28
26
|
let {
|
|
29
27
|
children,
|
|
30
|
-
vertical = false,
|
|
31
28
|
title = '',
|
|
32
29
|
className,
|
|
30
|
+
position = 'bottom',
|
|
33
31
|
fitContainer = false,
|
|
34
32
|
alignment = 'center'
|
|
35
33
|
} = _ref;
|
|
36
|
-
const componentRef = (0, _react.useRef)(null);
|
|
37
34
|
return /*#__PURE__*/_react.default.createElement(StyledPanel, {
|
|
38
|
-
ref: componentRef,
|
|
39
35
|
className: className,
|
|
40
36
|
"data-fitcontainer": fitContainer,
|
|
41
|
-
"data-
|
|
37
|
+
"data-position": position,
|
|
42
38
|
"data-alignment": alignment
|
|
43
39
|
}, title && /*#__PURE__*/_react.default.createElement(StyledTitle, null, title), children);
|
|
44
40
|
};
|
|
@@ -9,23 +9,23 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
12
|
-
var _snackbar = require("../../constants/snackbar");
|
|
13
|
-
|
|
14
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
13
|
|
|
16
14
|
var _react2 = require("@linaria/react");
|
|
17
15
|
|
|
18
16
|
var _style = require("../../constants/style");
|
|
19
17
|
|
|
18
|
+
var _snackbar = require("../../constants/snackbar");
|
|
19
|
+
|
|
20
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
21
|
|
|
22
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
23
|
|
|
24
|
-
const StyledSnackbar = /*#__PURE__*/(0, _react2.styled)(
|
|
24
|
+
const StyledSnackbar = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
25
25
|
name: "StyledSnackbar",
|
|
26
26
|
class: "s1xssqat"
|
|
27
27
|
});
|
|
28
|
-
const StyledSnackbarContainer = /*#__PURE__*/(0, _react2.styled)(
|
|
28
|
+
const StyledSnackbarContainer = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
29
29
|
name: "StyledSnackbarContainer",
|
|
30
30
|
class: "s1bgtt22"
|
|
31
31
|
});
|
|
@@ -40,10 +40,10 @@ const Snackbar = _ref => {
|
|
|
40
40
|
(0, _react.useEffect)(() => {
|
|
41
41
|
const timeoutShowId = setTimeout(() => {
|
|
42
42
|
setIsShown(true);
|
|
43
|
-
},
|
|
43
|
+
}, _snackbar.SNACKBAR_TOGGLE_ANIMATION_DURATION);
|
|
44
44
|
const timeoutHideId = setTimeout(() => {
|
|
45
45
|
setIsShown(false);
|
|
46
|
-
}, duration - _snackbar.
|
|
46
|
+
}, duration - _snackbar.SNACKBAR_DURATION - _snackbar.SNACKBAR_TOGGLE_ANIMATION_DURATION);
|
|
47
47
|
return () => {
|
|
48
48
|
clearTimeout(timeoutShowId);
|
|
49
49
|
clearTimeout(timeoutHideId);
|
|
@@ -23,7 +23,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
23
23
|
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
25
|
|
|
26
|
-
const StyledColor = /*#__PURE__*/(0, _react2.styled)(
|
|
26
|
+
const StyledColor = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
27
27
|
name: "StyledColor",
|
|
28
28
|
class: "snh2jyk",
|
|
29
29
|
vars: {
|
|
@@ -35,11 +35,11 @@ const StyledColor = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
35
35
|
}]
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
const StyleWrapper = /*#__PURE__*/(0, _react2.styled)(
|
|
38
|
+
const StyleWrapper = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
39
39
|
name: "StyleWrapper",
|
|
40
40
|
class: "sfm1cqx"
|
|
41
41
|
});
|
|
42
|
-
const StyledCustomColor = /*#__PURE__*/(0, _react2.styled)(
|
|
42
|
+
const StyledCustomColor = /*#__PURE__*/(0, _react2.styled)('div')({
|
|
43
43
|
name: "StyledCustomColor",
|
|
44
44
|
class: "sttf061",
|
|
45
45
|
vars: {
|
|
@@ -17,7 +17,7 @@ var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
|
17
17
|
|
|
18
18
|
var _icons = require("../../constants/icons");
|
|
19
19
|
|
|
20
|
-
const StyledOption = /*#__PURE__*/(0, _react2.styled)(
|
|
20
|
+
const StyledOption = /*#__PURE__*/(0, _react2.styled)('span')({
|
|
21
21
|
name: "StyledOption",
|
|
22
22
|
class: "smpmxx5",
|
|
23
23
|
vars: {
|