@yorab/react-paint 0.4.0 → 0.5.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/README.md +1 -0
- package/dist/components/App.js +61 -72
- package/dist/components/Canvas.js +31 -18
- 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 +11 -15
- package/dist/components/settings/FontFamilyField.js +7 -5
- package/dist/components/settings/LayoutButton.js +1 -1
- package/dist/components/settings/Layouts.js +9 -9
- package/dist/components/settings/LineArrowField.js +8 -6
- package/dist/components/settings/LineTypeField.js +7 -5
- package/dist/components/settings/PointsNumberField.js +19 -29
- package/dist/components/settings/RangeField.js +2 -1
- package/dist/components/settings/SelectField.js +2 -1
- package/dist/components/settings/SettingsBar.js +107 -80
- package/dist/components/toolbox/EditTextBox.js +6 -6
- package/dist/components/toolbox/LoadFileTool.js +5 -3
- package/dist/components/toolbox/MenuGroup.js +55 -29
- package/dist/components/toolbox/PictureUrlInput.js +1 -1
- package/dist/components/toolbox/Tool.js +4 -4
- package/dist/components/toolbox/Toolbar.js +82 -59
- package/dist/components/toolbox/ToolbarGroup.js +21 -25
- package/dist/constants/style.js +3 -1
- package/dist/constants/tools.js +420 -0
- package/dist/hooks/useComponent.js +6 -2
- package/dist/hooks/useDrawableCanvas.js +28 -19
- package/dist/styles.css +51 -54
- package/dist/types/Shapes.js +2 -16
- package/dist/types/tools.js +22 -0
- package/dist/utils/data.js +81 -25
- package/dist/utils/style.js +4 -2
- package/dist/utils/toolbar.js +66 -11
- package/dist/utils/transform.js +3 -3
- package/package.json +1 -1
- package/Changelog.md +0 -62
package/README.md
CHANGED
package/dist/components/App.js
CHANGED
|
@@ -19,10 +19,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
19
19
|
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
21
|
|
|
22
|
-
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
23
|
-
|
|
24
|
-
var _Shapes = require("../types/Shapes");
|
|
25
|
-
|
|
26
22
|
var _Canvas = _interopRequireDefault(require("./Canvas"));
|
|
27
23
|
|
|
28
24
|
var _Layouts = _interopRequireDefault(require("./settings/Layouts"));
|
|
@@ -59,6 +55,10 @@ var _useResizeObserver = _interopRequireDefault(require("../hooks/useResizeObser
|
|
|
59
55
|
|
|
60
56
|
var _shapes = require("../constants/shapes");
|
|
61
57
|
|
|
58
|
+
var _toolbar = require("../utils/toolbar");
|
|
59
|
+
|
|
60
|
+
var _tools = require("../constants/tools");
|
|
61
|
+
|
|
62
62
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
63
63
|
|
|
64
64
|
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; }
|
|
@@ -69,49 +69,49 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
69
69
|
|
|
70
70
|
var StyledApp = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
71
71
|
name: "StyledApp",
|
|
72
|
-
"class": "
|
|
72
|
+
"class": "sdhgr8u",
|
|
73
73
|
vars: {
|
|
74
|
-
"
|
|
74
|
+
"sdhgr8u-0": [function (props) {
|
|
75
75
|
return props.toolbarBackgroundColor;
|
|
76
76
|
}],
|
|
77
|
-
"
|
|
77
|
+
"sdhgr8u-1": [function (props) {
|
|
78
78
|
return props.dividerColor;
|
|
79
79
|
}],
|
|
80
|
-
"
|
|
80
|
+
"sdhgr8u-2": [function (props) {
|
|
81
81
|
return props.fontRadius;
|
|
82
82
|
}, "px"],
|
|
83
|
-
"
|
|
83
|
+
"sdhgr8u-3": [function (props) {
|
|
84
84
|
return props.fontDisabledColor;
|
|
85
85
|
}],
|
|
86
|
-
"
|
|
86
|
+
"sdhgr8u-4": [function (props) {
|
|
87
87
|
return props.fontDisabledBackgroundColor;
|
|
88
88
|
}],
|
|
89
|
-
"
|
|
89
|
+
"sdhgr8u-5": [function (props) {
|
|
90
90
|
return props.fontColor;
|
|
91
91
|
}],
|
|
92
|
-
"
|
|
92
|
+
"sdhgr8u-6": [function (props) {
|
|
93
93
|
return props.fontBackgroundColor;
|
|
94
94
|
}],
|
|
95
|
-
"
|
|
95
|
+
"sdhgr8u-7": [function (props) {
|
|
96
96
|
return props.fontSelectedColor;
|
|
97
97
|
}],
|
|
98
|
-
"
|
|
98
|
+
"sdhgr8u-8": [function (props) {
|
|
99
99
|
return props.fontSelectedBackgroundColor;
|
|
100
100
|
}],
|
|
101
|
-
"
|
|
101
|
+
"sdhgr8u-9": [function (props) {
|
|
102
102
|
return props.fontHoverColor;
|
|
103
103
|
}],
|
|
104
|
-
"
|
|
104
|
+
"sdhgr8u-10": [function (props) {
|
|
105
105
|
return props.fontHoverBackgroundColor;
|
|
106
106
|
}],
|
|
107
|
-
"
|
|
107
|
+
"sdhgr8u-11": [function (props) {
|
|
108
108
|
return props.canvasBackgroundColor;
|
|
109
109
|
}],
|
|
110
|
-
"
|
|
110
|
+
"sdhgr8u-12": [function (_ref) {
|
|
111
111
|
var canvasWidth = _ref.canvasWidth;
|
|
112
112
|
return "min(100%, ".concat(canvasWidth, "px)");
|
|
113
113
|
}],
|
|
114
|
-
"
|
|
114
|
+
"sdhgr8u-13": [function (_ref2) {
|
|
115
115
|
var canvasWidth = _ref2.canvasWidth;
|
|
116
116
|
return canvasWidth;
|
|
117
117
|
}, "px"]
|
|
@@ -119,19 +119,18 @@ var StyledApp = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
119
119
|
});
|
|
120
120
|
var StyledRow = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
121
121
|
name: "StyledRow",
|
|
122
|
-
"class": "
|
|
122
|
+
"class": "sm24hcl",
|
|
123
123
|
vars: {
|
|
124
|
-
"
|
|
124
|
+
"sm24hcl-1": [function (_ref3) {
|
|
125
125
|
var width = _ref3.width;
|
|
126
126
|
return width;
|
|
127
127
|
}, "px"],
|
|
128
|
-
"
|
|
128
|
+
"sm24hcl-2": [function (_ref4) {
|
|
129
129
|
var aspectRatio = _ref4.aspectRatio;
|
|
130
130
|
return aspectRatio;
|
|
131
131
|
}]
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
|
-
var DEFAULT_TOOLS = [_Shapes.ShapeEnum.brush, _Shapes.ShapeEnum.line, _Shapes.ShapeEnum.polygon, _Shapes.ShapeEnum.curve, _Shapes.ShapeEnum.rect, _Shapes.ShapeEnum.square, _Shapes.ShapeEnum.circle, _Shapes.ShapeEnum.ellipse, _Shapes.ShapeEnum.text, _Shapes.ShapeEnum.picture];
|
|
135
134
|
var DEFAULT_OPTIONS = {
|
|
136
135
|
layersManipulation: true,
|
|
137
136
|
gridVisible: false,
|
|
@@ -139,7 +138,9 @@ var DEFAULT_OPTIONS = {
|
|
|
139
138
|
canShrink: true,
|
|
140
139
|
withExport: true,
|
|
141
140
|
withLoadAndSave: true,
|
|
142
|
-
|
|
141
|
+
withUploadPicture: true,
|
|
142
|
+
withUrlPicture: false,
|
|
143
|
+
availableTools: _tools.DEFAULT_SHAPE_TOOLS,
|
|
143
144
|
uiStyle: {
|
|
144
145
|
toolbarBackgroundColor: 'white',
|
|
145
146
|
dividerColor: '#36418129',
|
|
@@ -183,6 +184,8 @@ var App = function App(_ref5) {
|
|
|
183
184
|
canShrink = _DEFAULT_OPTIONS$opti.canShrink,
|
|
184
185
|
withExport = _DEFAULT_OPTIONS$opti.withExport,
|
|
185
186
|
withLoadAndSave = _DEFAULT_OPTIONS$opti.withLoadAndSave,
|
|
187
|
+
withUploadPicture = _DEFAULT_OPTIONS$opti.withUploadPicture,
|
|
188
|
+
withUrlPicture = _DEFAULT_OPTIONS$opti.withUrlPicture,
|
|
186
189
|
availableToolsFromProps = _DEFAULT_OPTIONS$opti.availableTools;
|
|
187
190
|
|
|
188
191
|
var _DEFAULT_OPTIONS$uiSt = _objectSpread(_objectSpread({}, DEFAULT_OPTIONS.uiStyle), (_options$uiStyle = options === null || options === void 0 ? void 0 : options.uiStyle) !== null && _options$uiStyle !== void 0 ? _options$uiStyle : {}),
|
|
@@ -216,7 +219,7 @@ var App = function App(_ref5) {
|
|
|
216
219
|
canvasSize = _useState2[0],
|
|
217
220
|
setCanvasSize = _useState2[1];
|
|
218
221
|
|
|
219
|
-
var availableTools =
|
|
222
|
+
var availableTools = (0, _toolbar.sanitizeTools)(availableToolsFromProps, withUploadPicture || withUrlPicture);
|
|
220
223
|
|
|
221
224
|
var _useComponent = (0, _useComponent2["default"])({
|
|
222
225
|
disabled: disabled,
|
|
@@ -224,58 +227,42 @@ var App = function App(_ref5) {
|
|
|
224
227
|
}),
|
|
225
228
|
isInsideComponent = _useComponent.isInsideComponent;
|
|
226
229
|
|
|
227
|
-
var _useState3 = (0, _react.useState)(
|
|
228
|
-
style: {
|
|
229
|
-
fillColor: 'transparent',
|
|
230
|
-
strokeColor: 'black',
|
|
231
|
-
globalAlpha: 100,
|
|
232
|
-
lineWidth: 1,
|
|
233
|
-
lineDash: 0,
|
|
234
|
-
lineArrow: 0,
|
|
235
|
-
pointsCount: 3,
|
|
236
|
-
fontFamily: _style.STYLE_FONT_DEFAULT
|
|
237
|
-
}
|
|
238
|
-
}),
|
|
230
|
+
var _useState3 = (0, _react.useState)(false),
|
|
239
231
|
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
240
|
-
|
|
241
|
-
|
|
232
|
+
isLoading = _useState4[0],
|
|
233
|
+
setIsLoading = _useState4[1];
|
|
242
234
|
|
|
243
235
|
var _useState5 = (0, _react.useState)(false),
|
|
244
236
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
245
|
-
|
|
246
|
-
|
|
237
|
+
isLayoutPanelShown = _useState6[0],
|
|
238
|
+
setIsLayoutPanelShown = _useState6[1];
|
|
247
239
|
|
|
248
|
-
var _useState7 = (0, _react.useState)(
|
|
240
|
+
var _useState7 = (0, _react.useState)([0, 0]),
|
|
249
241
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
250
|
-
|
|
251
|
-
|
|
242
|
+
canvasOffset = _useState8[0],
|
|
243
|
+
setCanvasOffset = _useState8[1];
|
|
252
244
|
|
|
253
|
-
var _useState9 = (0, _react.useState)(
|
|
245
|
+
var _useState9 = (0, _react.useState)(undefined),
|
|
254
246
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
255
|
-
|
|
256
|
-
|
|
247
|
+
canvasOffsetStartPosition = _useState10[0],
|
|
248
|
+
setCanvasOffsetStartPosition = _useState10[1];
|
|
257
249
|
|
|
258
|
-
var _useState11 = (0, _react.useState)(
|
|
250
|
+
var _useState11 = (0, _react.useState)(_tools.SELECTION_TOOL),
|
|
259
251
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
260
|
-
|
|
261
|
-
|
|
252
|
+
activeTool = _useState12[0],
|
|
253
|
+
setActiveTool = _useState12[1];
|
|
262
254
|
|
|
263
|
-
var _useState13 = (0, _react.useState)(
|
|
264
|
-
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
265
|
-
activeTool = _useState14[0],
|
|
266
|
-
setActiveTool = _useState14[1];
|
|
267
|
-
|
|
268
|
-
var _useState15 = (0, _react.useState)({
|
|
255
|
+
var _useState13 = (0, _react.useState)({
|
|
269
256
|
mode: _Mode.SelectionModeLib["default"]
|
|
270
257
|
}),
|
|
271
|
-
|
|
272
|
-
selectionMode =
|
|
273
|
-
setSelectionMode =
|
|
258
|
+
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
259
|
+
selectionMode = _useState14[0],
|
|
260
|
+
setSelectionMode = _useState14[1];
|
|
274
261
|
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
withGrid =
|
|
278
|
-
setWithGrid =
|
|
262
|
+
var _useState15 = (0, _react.useState)(gridVisible),
|
|
263
|
+
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
264
|
+
withGrid = _useState16[0],
|
|
265
|
+
setWithGrid = _useState16[1];
|
|
279
266
|
|
|
280
267
|
var _useShapes = (0, _useShapes2["default"])(onDataChanged),
|
|
281
268
|
shapesRef = _useShapes.shapesRef,
|
|
@@ -305,22 +292,22 @@ var App = function App(_ref5) {
|
|
|
305
292
|
setActiveTool(tool);
|
|
306
293
|
}, [setSelectedShape]);
|
|
307
294
|
var undoAction = (0, _react.useCallback)(function () {
|
|
308
|
-
selectTool(
|
|
295
|
+
selectTool(_tools.SELECTION_TOOL);
|
|
309
296
|
backwardShape();
|
|
310
297
|
}, [selectTool, backwardShape]);
|
|
311
298
|
var redoAction = (0, _react.useCallback)(function () {
|
|
312
|
-
selectTool(
|
|
299
|
+
selectTool(_tools.SELECTION_TOOL);
|
|
313
300
|
forwardShape();
|
|
314
301
|
}, [selectTool, forwardShape]);
|
|
315
302
|
var clearCanvas = (0, _react.useCallback)(function () {
|
|
316
303
|
var shapesToInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
317
304
|
var clearHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
318
305
|
clearShapes(shapesToInit, clearHistory);
|
|
319
|
-
selectTool(
|
|
306
|
+
selectTool(_tools.SELECTION_TOOL);
|
|
320
307
|
setCanvasOffset([0, 0]);
|
|
321
308
|
}, [selectTool, clearShapes]);
|
|
322
309
|
var selectShape = (0, _react.useCallback)(function (shape) {
|
|
323
|
-
setActiveTool(
|
|
310
|
+
setActiveTool(_tools.SELECTION_TOOL);
|
|
324
311
|
setSelectedShape(shape);
|
|
325
312
|
}, [setSelectedShape]);
|
|
326
313
|
var pasteShape = (0, _react.useCallback)(function (shape) {
|
|
@@ -568,6 +555,7 @@ var App = function App(_ref5) {
|
|
|
568
555
|
fontHoverBackgroundColor: fontHoverBackgroundColor,
|
|
569
556
|
canvasBackgroundColor: canvasBackgroundColor
|
|
570
557
|
}, isEditMode && /*#__PURE__*/_react["default"].createElement(_Toolbar["default"], {
|
|
558
|
+
width: canvasSize.width,
|
|
571
559
|
disabled: disabled,
|
|
572
560
|
activeTool: activeTool,
|
|
573
561
|
clearCanvas: clearCanvas,
|
|
@@ -583,7 +571,9 @@ var App = function App(_ref5) {
|
|
|
583
571
|
redoAction: redoAction,
|
|
584
572
|
availableTools: availableTools,
|
|
585
573
|
withExport: withExport,
|
|
586
|
-
withLoadAndSave: withLoadAndSave
|
|
574
|
+
withLoadAndSave: withLoadAndSave,
|
|
575
|
+
withUploadPicture: withUploadPicture,
|
|
576
|
+
withUrlPicture: withUrlPicture
|
|
587
577
|
}), /*#__PURE__*/_react["default"].createElement(StyledRow, {
|
|
588
578
|
"data-grow": canGrow,
|
|
589
579
|
width: canvasSize.width,
|
|
@@ -604,7 +594,6 @@ var App = function App(_ref5) {
|
|
|
604
594
|
setSelectedShape: setSelectedShape,
|
|
605
595
|
canvasOffset: canvasOffset,
|
|
606
596
|
setCanvasOffset: setCanvasOffset,
|
|
607
|
-
defaultConf: defaultConf,
|
|
608
597
|
saveShapes: saveShapes,
|
|
609
598
|
ref: canvasRef,
|
|
610
599
|
canvasSize: canvasSize,
|
|
@@ -612,7 +601,8 @@ var App = function App(_ref5) {
|
|
|
612
601
|
setSelectionMode: setSelectionMode,
|
|
613
602
|
selectionColor: canvasSelectionColor,
|
|
614
603
|
selectionWidth: canvasSelectionWidth,
|
|
615
|
-
selectionPadding: canvasSelectionPadding
|
|
604
|
+
selectionPadding: canvasSelectionPadding,
|
|
605
|
+
isEditMode: isEditMode
|
|
616
606
|
}), isEditMode && layersManipulation && /*#__PURE__*/_react["default"].createElement(_Layouts["default"], {
|
|
617
607
|
withGrid: withGrid,
|
|
618
608
|
setWithGrid: setWithGrid,
|
|
@@ -628,11 +618,10 @@ var App = function App(_ref5) {
|
|
|
628
618
|
})), isEditMode && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_SettingsBar["default"], {
|
|
629
619
|
disabled: disabled,
|
|
630
620
|
activeTool: activeTool,
|
|
621
|
+
availableTools: availableTools,
|
|
631
622
|
selectedShape: selectedShape,
|
|
632
623
|
removeShape: removeShape,
|
|
633
624
|
updateShape: updateShape,
|
|
634
|
-
defaultConf: defaultConf,
|
|
635
|
-
setDefaultConf: setDefaultConf,
|
|
636
625
|
canvas: canvasRef.current,
|
|
637
626
|
layersManipulation: layersManipulation,
|
|
638
627
|
toggleLayoutPanel: function toggleLayoutPanel() {
|
|
@@ -31,6 +31,8 @@ var _useDrawableCanvas2 = _interopRequireDefault(require("../hooks/useDrawableCa
|
|
|
31
31
|
|
|
32
32
|
var _icons = require("../constants/icons");
|
|
33
33
|
|
|
34
|
+
var _tools = require("../types/tools");
|
|
35
|
+
|
|
34
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
37
|
|
|
36
38
|
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; }
|
|
@@ -39,20 +41,25 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
39
41
|
|
|
40
42
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
43
|
|
|
42
|
-
var
|
|
44
|
+
var renderDrawCanvas = function renderDrawCanvas(drawCtx, selectionMode, canvasSize, canvasOffset, shapes, selectionPadding, selectedShape) {
|
|
43
45
|
var width = canvasSize.width,
|
|
44
46
|
height = canvasSize.height,
|
|
45
47
|
scaleRatio = canvasSize.scaleRatio;
|
|
46
48
|
drawCtx.clearRect(0, 0, width, height);
|
|
47
|
-
selectionCtx.clearRect(0, 0, width, height);
|
|
48
49
|
|
|
49
50
|
for (var i = shapes.length - 1; i >= 0; i--) {
|
|
50
51
|
if (selectionMode.mode !== _Mode.SelectionModeLib.textedition || shapes[i] !== selectedShape) {
|
|
51
52
|
(0, _draw.drawShape)(drawCtx, shapes[i], scaleRatio, canvasOffset, selectionPadding);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
55
|
+
};
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
var renderSelectionCanvas = function renderSelectionCanvas(selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape) {
|
|
58
|
+
var width = canvasSize.width,
|
|
59
|
+
height = canvasSize.height,
|
|
60
|
+
scaleRatio = canvasSize.scaleRatio;
|
|
61
|
+
selectionCtx.clearRect(0, 0, width, height);
|
|
62
|
+
selectedShape && activeTool.type !== _Shapes.ShapeEnum.brush && (0, _draw.drawSelection)({
|
|
56
63
|
ctx: selectionCtx,
|
|
57
64
|
shape: selectedShape,
|
|
58
65
|
scaleRatio: scaleRatio,
|
|
@@ -66,21 +73,21 @@ var drawCanvas = function drawCanvas(drawCtx, selectionCtx, selectionMode, canva
|
|
|
66
73
|
|
|
67
74
|
var StyledCanvasBox = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
68
75
|
name: "StyledCanvasBox",
|
|
69
|
-
"class": "
|
|
76
|
+
"class": "s14cny8z"
|
|
70
77
|
});
|
|
71
78
|
var StyledCanvasContainer = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
72
79
|
name: "StyledCanvasContainer",
|
|
73
|
-
"class": "
|
|
80
|
+
"class": "s16bxms6"
|
|
74
81
|
});
|
|
75
82
|
var StyledDrawCanvas = /*#__PURE__*/(0, _react2.styled)("canvas")({
|
|
76
83
|
name: "StyledDrawCanvas",
|
|
77
|
-
"class": "
|
|
84
|
+
"class": "spzzsat"
|
|
78
85
|
});
|
|
79
86
|
var StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)("canvas")({
|
|
80
87
|
name: "StyledSelectionCanvas",
|
|
81
|
-
"class": "
|
|
88
|
+
"class": "s1egrskk",
|
|
82
89
|
vars: {
|
|
83
|
-
"
|
|
90
|
+
"s1egrskk-0": [function (_ref) {
|
|
84
91
|
var cursor = _ref.cursor;
|
|
85
92
|
return cursor;
|
|
86
93
|
}]
|
|
@@ -105,13 +112,13 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
105
112
|
setCanvasOffsetStartPosition = _ref2.setCanvasOffsetStartPosition,
|
|
106
113
|
canvasOffset = _ref2.canvasOffset,
|
|
107
114
|
setCanvasOffset = _ref2.setCanvasOffset,
|
|
108
|
-
defaultConf = _ref2.defaultConf,
|
|
109
115
|
isInsideComponent = _ref2.isInsideComponent,
|
|
110
116
|
selectionMode = _ref2.selectionMode,
|
|
111
117
|
setSelectionMode = _ref2.setSelectionMode,
|
|
112
118
|
selectionWidth = _ref2.selectionWidth,
|
|
113
119
|
selectionColor = _ref2.selectionColor,
|
|
114
|
-
selectionPadding = _ref2.selectionPadding
|
|
120
|
+
selectionPadding = _ref2.selectionPadding,
|
|
121
|
+
isEditMode = _ref2.isEditMode;
|
|
115
122
|
var drawCanvasRef = (0, _react.useRef)(null);
|
|
116
123
|
var selectionCanvasRef = (0, _react.useRef)(null); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
117
124
|
|
|
@@ -126,7 +133,6 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
126
133
|
drawCanvasRef: drawCanvasRef,
|
|
127
134
|
setActiveTool: setActiveTool,
|
|
128
135
|
shapes: shapes,
|
|
129
|
-
defaultConf: defaultConf,
|
|
130
136
|
selectionMode: selectionMode,
|
|
131
137
|
activeTool: activeTool,
|
|
132
138
|
isInsideComponent: isInsideComponent,
|
|
@@ -163,14 +169,21 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
163
169
|
updateSingleShape(resizedShape);
|
|
164
170
|
}, [updateSingleShape, selectedShape]);
|
|
165
171
|
(0, _react.useEffect)(function () {
|
|
166
|
-
var _drawCanvasRef$curren2
|
|
172
|
+
var _drawCanvasRef$curren2;
|
|
167
173
|
|
|
168
174
|
var drawCtx = (_drawCanvasRef$curren2 = drawCanvasRef.current) === null || _drawCanvasRef$curren2 === void 0 ? void 0 : _drawCanvasRef$curren2.getContext('2d');
|
|
175
|
+
drawCtx && window.requestAnimationFrame(function () {
|
|
176
|
+
return renderDrawCanvas(drawCtx, selectionMode, canvasSize, canvasOffset, shapes, selectionPadding, selectedShape);
|
|
177
|
+
});
|
|
178
|
+
}, [shapes, selectionMode, selectedShape, canvasOffset, canvasSize, selectionPadding]);
|
|
179
|
+
(0, _react.useEffect)(function () {
|
|
180
|
+
var _selectionCanvasRef$c;
|
|
181
|
+
|
|
169
182
|
var selectionCtx = (_selectionCanvasRef$c = selectionCanvasRef.current) === null || _selectionCanvasRef$c === void 0 ? void 0 : _selectionCanvasRef$c.getContext('2d');
|
|
170
|
-
|
|
171
|
-
return
|
|
183
|
+
selectionCtx && window.requestAnimationFrame(function () {
|
|
184
|
+
return renderSelectionCanvas(selectionCtx, selectionMode, canvasSize, activeTool, canvasOffset, selectionPadding, selectionWidth, selectionColor, selectedShape);
|
|
172
185
|
});
|
|
173
|
-
}, [
|
|
186
|
+
}, [selectionMode, selectedShape, activeTool, canvasOffset, canvasSize, selectionPadding, selectionWidth, selectionColor]);
|
|
174
187
|
return /*#__PURE__*/_react["default"].createElement(StyledCanvasBox, null, /*#__PURE__*/_react["default"].createElement(StyledCanvasContainer, {
|
|
175
188
|
"data-grid": withGrid,
|
|
176
189
|
"data-grow": canGrow
|
|
@@ -179,13 +192,13 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
179
192
|
"data-grow": canGrow,
|
|
180
193
|
width: canvasSize.width,
|
|
181
194
|
height: canvasSize.height
|
|
182
|
-
}), /*#__PURE__*/_react["default"].createElement(StyledSelectionCanvas, {
|
|
195
|
+
}), isEditMode && /*#__PURE__*/_react["default"].createElement(StyledSelectionCanvas, {
|
|
183
196
|
ref: selectionCanvasRef,
|
|
184
197
|
width: canvasSize.width,
|
|
185
198
|
height: canvasSize.height,
|
|
186
199
|
"data-grow": canGrow,
|
|
187
|
-
cursor: activeTool !==
|
|
188
|
-
}), selectionMode.mode === _Mode.SelectionModeLib.textedition && (selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) === _Shapes.ShapeEnum.text && /*#__PURE__*/_react["default"].createElement(_EditTextBox["default"], {
|
|
200
|
+
cursor: activeTool.type !== _tools.ActionsEnum.selection && activeTool.type !== _tools.ActionsEnum.move || hoverMode.mode === _Mode.SelectionModeLib.resize ? 'crosshair' : activeTool.type === _tools.ActionsEnum.move || hoverMode.mode === _Mode.SelectionModeLib.translate ? 'move' : hoverMode.mode === _Mode.SelectionModeLib.rotate ? 'grab' : 'default'
|
|
201
|
+
}), isEditMode && selectionMode.mode === _Mode.SelectionModeLib.textedition && (selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) === _Shapes.ShapeEnum.text && /*#__PURE__*/_react["default"].createElement(_EditTextBox["default"], {
|
|
189
202
|
scaleRatio: canvasSize.scaleRatio,
|
|
190
203
|
disabled: disabled,
|
|
191
204
|
shape: selectedShape,
|
|
@@ -19,19 +19,19 @@ var _excluded = ["hidden", "disabled", "selected", "icon", "children", "classNam
|
|
|
19
19
|
_excluded2 = ["hidden", "disabled", "selected", "icon", "children", "type"];
|
|
20
20
|
var StyledButton = /*#__PURE__*/(0, _react2.styled)("button")({
|
|
21
21
|
name: "StyledButton",
|
|
22
|
-
"class": "
|
|
22
|
+
"class": "sc6yefj"
|
|
23
23
|
});
|
|
24
24
|
var StyledButtonContent = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
25
25
|
name: "StyledButtonContent",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "s2aizej"
|
|
27
27
|
});
|
|
28
28
|
var StyledIcon = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
29
29
|
name: "StyledIcon",
|
|
30
|
-
"class": "
|
|
30
|
+
"class": "s13rkw3s"
|
|
31
31
|
});
|
|
32
32
|
var StyledChildren = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
33
33
|
name: "StyledChildren",
|
|
34
|
-
"class": "
|
|
34
|
+
"class": "s1qkcrgj"
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
var Button = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
@@ -24,15 +24,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
24
24
|
var TRANSITION_DURATION = 300;
|
|
25
25
|
var StyledLoading = /*#__PURE__*/(0, _react.styled)("div")({
|
|
26
26
|
name: "StyledLoading",
|
|
27
|
-
"class": "
|
|
27
|
+
"class": "s15r7ba"
|
|
28
28
|
});
|
|
29
29
|
var StyledLoader = /*#__PURE__*/(0, _react.styled)("div")({
|
|
30
30
|
name: "StyledLoader",
|
|
31
|
-
"class": "
|
|
31
|
+
"class": "s19n4ela"
|
|
32
32
|
});
|
|
33
33
|
var StyledShape = /*#__PURE__*/(0, _react.styled)("div")({
|
|
34
34
|
name: "StyledShape",
|
|
35
|
-
"class": "
|
|
35
|
+
"class": "ssemdwq"
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
var Loading = function Loading(_ref) {
|
|
@@ -15,15 +15,15 @@ var _style = require("../../constants/style");
|
|
|
15
15
|
|
|
16
16
|
var StyledModal = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
17
17
|
name: "StyledModal",
|
|
18
|
-
"class": "
|
|
18
|
+
"class": "s1hezj2d"
|
|
19
19
|
});
|
|
20
20
|
var StyledPanel = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
21
21
|
name: "StyledPanel",
|
|
22
|
-
"class": "
|
|
22
|
+
"class": "spuj31h"
|
|
23
23
|
});
|
|
24
24
|
var StyledMask = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
25
25
|
name: "StyledMask",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "s1ulcd40"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
var Modal = function Modal(_ref) {
|
|
@@ -19,11 +19,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
19
19
|
|
|
20
20
|
var StyledPanel = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
21
21
|
name: "StyledPanel",
|
|
22
|
-
"class": "
|
|
22
|
+
"class": "s2dsyaf"
|
|
23
23
|
});
|
|
24
24
|
var StyledTitle = /*#__PURE__*/(0, _react2.styled)("h3")({
|
|
25
25
|
name: "StyledTitle",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "s1f032bv"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
var Panel = function Panel(_ref) {
|
|
@@ -27,11 +27,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
27
27
|
|
|
28
28
|
var StyledSnackbar = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
29
29
|
name: "StyledSnackbar",
|
|
30
|
-
"class": "
|
|
30
|
+
"class": "s1xg1lj6"
|
|
31
31
|
});
|
|
32
32
|
var StyledSnackbarContainer = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
33
33
|
name: "StyledSnackbarContainer",
|
|
34
|
-
"class": "
|
|
34
|
+
"class": "sg1lk71"
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
var Snackbar = function Snackbar(_ref) {
|
|
@@ -21,8 +21,6 @@ var _Button = _interopRequireDefault(require("../common/Button"));
|
|
|
21
21
|
|
|
22
22
|
var _Panel = _interopRequireDefault(require("../common/Panel"));
|
|
23
23
|
|
|
24
|
-
var _style = require("../../constants/style");
|
|
25
|
-
|
|
26
24
|
var _icons = require("../../constants/icons");
|
|
27
25
|
|
|
28
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -31,9 +29,9 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
31
29
|
|
|
32
30
|
var StyledColor = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
33
31
|
name: "StyledColor",
|
|
34
|
-
"class": "
|
|
32
|
+
"class": "s1dqu4j7",
|
|
35
33
|
vars: {
|
|
36
|
-
"
|
|
34
|
+
"s1dqu4j7-0": [function (_ref) {
|
|
37
35
|
var color = _ref.color;
|
|
38
36
|
return color;
|
|
39
37
|
}]
|
|
@@ -41,18 +39,14 @@ var StyledColor = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
41
39
|
});
|
|
42
40
|
var StyledCustomColor = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
43
41
|
name: "StyledCustomColor",
|
|
44
|
-
"class": "
|
|
42
|
+
"class": "s1j0ldko",
|
|
45
43
|
vars: {
|
|
46
|
-
"
|
|
44
|
+
"s1j0ldko-0": [function (_ref2) {
|
|
47
45
|
var color = _ref2.color;
|
|
48
46
|
return color;
|
|
49
47
|
}]
|
|
50
48
|
}
|
|
51
49
|
});
|
|
52
|
-
var StyledColorButton = /*#__PURE__*/(0, _react2.styled)(_Button["default"])({
|
|
53
|
-
name: "StyledColorButton",
|
|
54
|
-
"class": "sttf061"
|
|
55
|
-
});
|
|
56
50
|
|
|
57
51
|
var ColorField = function ColorField(_ref3) {
|
|
58
52
|
var selectedSettings = _ref3.selectedSettings,
|
|
@@ -61,6 +55,7 @@ var ColorField = function ColorField(_ref3) {
|
|
|
61
55
|
title = _ref3$title === void 0 ? 'Choisissez une couleur' : _ref3$title,
|
|
62
56
|
_ref3$disabled = _ref3.disabled,
|
|
63
57
|
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
58
|
+
values = _ref3.values,
|
|
64
59
|
field = _ref3.field,
|
|
65
60
|
_ref3$value = _ref3.value,
|
|
66
61
|
value = _ref3$value === void 0 ? '' : _ref3$value,
|
|
@@ -87,6 +82,7 @@ var ColorField = function ColorField(_ref3) {
|
|
|
87
82
|
};
|
|
88
83
|
|
|
89
84
|
var isPanelVisible = selectedSettings === customKey;
|
|
85
|
+
if (_fp["default"].isEmpty(values)) return null;
|
|
90
86
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
91
87
|
selected: isPanelVisible,
|
|
92
88
|
title: title,
|
|
@@ -97,8 +93,8 @@ var ColorField = function ColorField(_ref3) {
|
|
|
97
93
|
})), isPanelVisible && /*#__PURE__*/_react["default"].createElement(_Panel["default"], {
|
|
98
94
|
title: title,
|
|
99
95
|
alignment: "left"
|
|
100
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null,
|
|
101
|
-
return /*#__PURE__*/_react["default"].createElement(
|
|
96
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, values.map(function (color, index) {
|
|
97
|
+
return /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
102
98
|
title: color,
|
|
103
99
|
key: index,
|
|
104
100
|
selected: color === value,
|
|
@@ -109,14 +105,14 @@ var ColorField = function ColorField(_ref3) {
|
|
|
109
105
|
}, /*#__PURE__*/_react["default"].createElement(StyledColor, {
|
|
110
106
|
color: color === 'transparent' ? "url('data:image/svg+xml,".concat(_icons.encodedTransparentIcon, "')") : color
|
|
111
107
|
}));
|
|
112
|
-
}), /*#__PURE__*/_react["default"].createElement(
|
|
108
|
+
}), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
113
109
|
type: "color",
|
|
114
110
|
title: "Custom color",
|
|
115
|
-
selected: !_fp["default"].includes(value,
|
|
111
|
+
selected: !_fp["default"].includes(value, values),
|
|
116
112
|
value: value,
|
|
117
113
|
onChange: handleChange
|
|
118
114
|
}, /*#__PURE__*/_react["default"].createElement(StyledCustomColor, {
|
|
119
|
-
color: _fp["default"].includes(value,
|
|
115
|
+
color: _fp["default"].includes(value, values) ? 'var(--font-color)' : value
|
|
120
116
|
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
121
117
|
dangerouslySetInnerHTML: {
|
|
122
118
|
__html: _icons.paletteIcon
|
|
@@ -11,15 +11,15 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
11
11
|
|
|
12
12
|
var _SelectField = _interopRequireDefault(require("./SelectField"));
|
|
13
13
|
|
|
14
|
-
var _style = require("../../constants/style");
|
|
15
|
-
|
|
16
14
|
var _react2 = require("@linaria/react");
|
|
17
15
|
|
|
16
|
+
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
17
|
+
|
|
18
18
|
var StyledOption = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
19
19
|
name: "StyledOption",
|
|
20
|
-
"class": "
|
|
20
|
+
"class": "s16o63ah",
|
|
21
21
|
vars: {
|
|
22
|
-
"
|
|
22
|
+
"s16o63ah-0": [function (_ref) {
|
|
23
23
|
var family = _ref.family;
|
|
24
24
|
return family;
|
|
25
25
|
}]
|
|
@@ -38,8 +38,10 @@ var FontFamilyField = function FontFamilyField(_ref3) {
|
|
|
38
38
|
setSelectedSettings = _ref3.setSelectedSettings,
|
|
39
39
|
_ref3$disabled = _ref3.disabled,
|
|
40
40
|
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
41
|
+
values = _ref3.values,
|
|
41
42
|
defaultValue = _ref3.defaultValue,
|
|
42
43
|
valueChanged = _ref3.valueChanged;
|
|
44
|
+
if (_fp["default"].isEmpty(values)) return null;
|
|
43
45
|
return /*#__PURE__*/_react["default"].createElement(_SelectField["default"], {
|
|
44
46
|
selectedSettings: selectedSettings,
|
|
45
47
|
setSelectedSettings: setSelectedSettings,
|
|
@@ -47,7 +49,7 @@ var FontFamilyField = function FontFamilyField(_ref3) {
|
|
|
47
49
|
title: "Font",
|
|
48
50
|
disabled: disabled,
|
|
49
51
|
field: "style.fontFamily",
|
|
50
|
-
values:
|
|
52
|
+
values: values,
|
|
51
53
|
defaultValue: defaultValue,
|
|
52
54
|
valueChanged: valueChanged
|
|
53
55
|
});
|