@yorab/react-paint 0.5.0 → 0.6.2
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 +107 -0
- package/README.md +0 -7
- package/dist/components/App.js +114 -79
- 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 +8 -4
- package/dist/components/common/Panel.js +5 -2
- package/dist/components/common/Snackbar.js +2 -2
- package/dist/components/settings/ColorField.js +11 -5
- package/dist/components/settings/FontFamilyField.js +6 -3
- package/dist/components/settings/LayoutButton.js +1 -1
- package/dist/components/settings/Layouts.js +18 -9
- package/dist/components/settings/LineArrowField.js +7 -4
- package/dist/components/settings/LineTypeField.js +7 -4
- package/dist/components/settings/PointsNumberField.js +4 -1
- package/dist/components/settings/RangeField.js +6 -3
- package/dist/components/settings/SelectField.js +11 -4
- package/dist/components/settings/SettingsBar.js +246 -131
- package/dist/components/settings/ToggleField.js +56 -0
- package/dist/components/toolbox/EditTextBox.js +23 -16
- package/dist/components/toolbox/MenuGroup.js +11 -11
- package/dist/components/toolbox/PictureUrlInput.js +1 -1
- package/dist/components/toolbox/Toolbar.js +13 -7
- package/dist/components/toolbox/ToolbarGroup.js +13 -11
- package/dist/constants/icons.js +18 -8
- package/dist/constants/tools.js +10 -2
- package/dist/hooks/useDoubleClick.js +46 -0
- package/dist/hooks/useDrawableCanvas.js +29 -45
- package/dist/styles.css +55 -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/intersect.js +1 -0
- package/dist/utils/selection.js +1 -1
- package/dist/utils/transform.js +23 -10
- package/package.json +1 -1
package/Changelog.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# V0.6.2
|
|
2
|
+
|
|
3
|
+
- Lock : can't select shape by click on it (only via layers panel)
|
|
4
|
+
- Clear : reset state to shapes prop by default if not undefined
|
|
5
|
+
- update icons
|
|
6
|
+
- Add responsive to settings UI
|
|
7
|
+
|
|
8
|
+
# V0.6.1
|
|
9
|
+
|
|
10
|
+
- Fix shapes prop not refreshing component (introduced by 0.6.0)
|
|
11
|
+
|
|
12
|
+
# V0.6.0
|
|
13
|
+
|
|
14
|
+
- Fix text opacity range dancing in edit mode
|
|
15
|
+
- Fix opacity not visually shown in edit mode
|
|
16
|
+
- add delete button in layouts panel and update style
|
|
17
|
+
- update shape selection priority : use layers order, unless an anchor is
|
|
18
|
+
- stored data format updated
|
|
19
|
+
|
|
20
|
+
# V0.5.1
|
|
21
|
+
|
|
22
|
+
- add possibility to update default settings for a tool
|
|
23
|
+
- fix png export not working with url pic
|
|
24
|
+
- fix pictures missing id
|
|
25
|
+
- fix text tool
|
|
26
|
+
- double click for editing text is now working on mobile
|
|
27
|
+
- add bold and italic for text
|
|
28
|
+
|
|
29
|
+
# V0.5.0
|
|
30
|
+
|
|
31
|
+
- Add tool presets feature
|
|
32
|
+
|
|
33
|
+
# V.0.4.2
|
|
34
|
+
|
|
35
|
+
- fix toolgroup not displayed
|
|
36
|
+
- add passive prop to event listener
|
|
37
|
+
|
|
38
|
+
# V.0.4.1
|
|
39
|
+
|
|
40
|
+
- prevent mounting selection canvas when viewer mode
|
|
41
|
+
- prevent drawing selection when not needed
|
|
42
|
+
- Click on toolbar tool group always enable a tool
|
|
43
|
+
- fix input and select options not being impacted by
|
|
44
|
+
- new reponsive for toolbar
|
|
45
|
+
|
|
46
|
+
# V.0.4.0
|
|
47
|
+
|
|
48
|
+
- Add possibility to customize UI from props
|
|
49
|
+
|
|
50
|
+
# V.0.3.1
|
|
51
|
+
|
|
52
|
+
- Add prop to change canvas background color
|
|
53
|
+
- Move some props to options
|
|
54
|
+
- fix Picture shape not being saved and not triggering onDataChanged
|
|
55
|
+
- small picture are upscaled to fit container when imported
|
|
56
|
+
- Add prop to choose to display save/load/export
|
|
57
|
+
|
|
58
|
+
# V.0.3.0 :
|
|
59
|
+
|
|
60
|
+
- prevent picture from url submit to reload page
|
|
61
|
+
- add gridVisible prop and default to false
|
|
62
|
+
- rename withLayouts to layersManipulation and reduce possible values
|
|
63
|
+
- move every options inside options prop
|
|
64
|
+
- remove ajv and any kind of json validation
|
|
65
|
+
- limit snackbar use on success and always log errors
|
|
66
|
+
- fit size and center uploaded picture
|
|
67
|
+
- Add new viewer mode
|
|
68
|
+
- add borders on bars
|
|
69
|
+
- display shape id in layer panel
|
|
70
|
+
- Export : round values to 2 decimal points
|
|
71
|
+
- Export and import : remove temporary values (id) from stored file
|
|
72
|
+
- Clean unknown shape format from imported data
|
|
73
|
+
- Use ref for onDataChanged prop to avoid rerender if callback changes
|
|
74
|
+
- Calculate container size to resize canvas instead of CSS
|
|
75
|
+
- use requestAnimationFrame to improve perf
|
|
76
|
+
- fix TextEdit position and size not working with canvas resized
|
|
77
|
+
- fix anchors area becoming too small after rezsize
|
|
78
|
+
- add MIT license to project
|
|
79
|
+
- other minor fixes
|
|
80
|
+
- minor design improvements
|
|
81
|
+
|
|
82
|
+
# V.0.2.2 :
|
|
83
|
+
|
|
84
|
+
- Migrate to react 18
|
|
85
|
+
- fix Picture type
|
|
86
|
+
- change pen join and cap to round
|
|
87
|
+
- replace loading snackbar with proper loader
|
|
88
|
+
- support for canGrow and canShrink prop
|
|
89
|
+
- rename project
|
|
90
|
+
- release on npm
|
|
91
|
+
|
|
92
|
+
# V.0.2.1 :
|
|
93
|
+
|
|
94
|
+
- better ui for input modal
|
|
95
|
+
- lock functionnality
|
|
96
|
+
- toggle grid
|
|
97
|
+
- layouts panel UI
|
|
98
|
+
|
|
99
|
+
# V.0.2.0 :
|
|
100
|
+
|
|
101
|
+
- fix for scaling brush
|
|
102
|
+
- fix snackbar
|
|
103
|
+
- refonte UI toolbar
|
|
104
|
+
- update examples
|
|
105
|
+
- button with icons
|
|
106
|
+
- mini toolbar to fix
|
|
107
|
+
- provide tool for url only
|
package/README.md
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
# known issues :
|
|
2
2
|
|
|
3
|
-
## To resolve before beta release
|
|
4
|
-
|
|
5
|
-
- Text tool broken since 0.2.2
|
|
6
|
-
- double click not working with touch (fix: fake it counting delay between touch)
|
|
7
|
-
- selected style not saved when changing tool (since presets)
|
|
8
|
-
|
|
9
3
|
## mobile/touch
|
|
10
4
|
|
|
11
5
|
- dnd layout on mobile not working (fix : use dnd lib, or add touch listener to fake dnd, or provide alt UI)
|
|
@@ -15,5 +9,4 @@
|
|
|
15
9
|
- TextEdit cursor overflow MINOR (quick fix : edit on modale ?)
|
|
16
10
|
- TextEdit copy/paste containing html breaks display
|
|
17
11
|
- circle resizing only goes one direction
|
|
18
|
-
- New text component opacity range is dancing
|
|
19
12
|
- adding padding to selection result in wrong intersection calculs
|
package/dist/components/App.js
CHANGED
|
@@ -59,6 +59,8 @@ var _toolbar = require("../utils/toolbar");
|
|
|
59
59
|
|
|
60
60
|
var _tools = require("../constants/tools");
|
|
61
61
|
|
|
62
|
+
var _fp = _interopRequireDefault(require("lodash/fp"));
|
|
63
|
+
|
|
62
64
|
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
65
|
|
|
64
66
|
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 +71,49 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
69
71
|
|
|
70
72
|
var StyledApp = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
71
73
|
name: "StyledApp",
|
|
72
|
-
"class": "
|
|
74
|
+
"class": "s1v9piyg",
|
|
73
75
|
vars: {
|
|
74
|
-
"
|
|
76
|
+
"s1v9piyg-0": [function (props) {
|
|
75
77
|
return props.toolbarBackgroundColor;
|
|
76
78
|
}],
|
|
77
|
-
"
|
|
79
|
+
"s1v9piyg-1": [function (props) {
|
|
78
80
|
return props.dividerColor;
|
|
79
81
|
}],
|
|
80
|
-
"
|
|
82
|
+
"s1v9piyg-2": [function (props) {
|
|
81
83
|
return props.fontRadius;
|
|
82
84
|
}, "px"],
|
|
83
|
-
"
|
|
85
|
+
"s1v9piyg-3": [function (props) {
|
|
84
86
|
return props.fontDisabledColor;
|
|
85
87
|
}],
|
|
86
|
-
"
|
|
88
|
+
"s1v9piyg-4": [function (props) {
|
|
87
89
|
return props.fontDisabledBackgroundColor;
|
|
88
90
|
}],
|
|
89
|
-
"
|
|
91
|
+
"s1v9piyg-5": [function (props) {
|
|
90
92
|
return props.fontColor;
|
|
91
93
|
}],
|
|
92
|
-
"
|
|
94
|
+
"s1v9piyg-6": [function (props) {
|
|
93
95
|
return props.fontBackgroundColor;
|
|
94
96
|
}],
|
|
95
|
-
"
|
|
97
|
+
"s1v9piyg-7": [function (props) {
|
|
96
98
|
return props.fontSelectedColor;
|
|
97
99
|
}],
|
|
98
|
-
"
|
|
100
|
+
"s1v9piyg-8": [function (props) {
|
|
99
101
|
return props.fontSelectedBackgroundColor;
|
|
100
102
|
}],
|
|
101
|
-
"
|
|
103
|
+
"s1v9piyg-9": [function (props) {
|
|
102
104
|
return props.fontHoverColor;
|
|
103
105
|
}],
|
|
104
|
-
"
|
|
106
|
+
"s1v9piyg-10": [function (props) {
|
|
105
107
|
return props.fontHoverBackgroundColor;
|
|
106
108
|
}],
|
|
107
|
-
"
|
|
109
|
+
"s1v9piyg-11": [function (props) {
|
|
108
110
|
return props.canvasBackgroundColor;
|
|
109
111
|
}],
|
|
110
|
-
"
|
|
112
|
+
"s1v9piyg-12": [function (_ref) {
|
|
111
113
|
var canvasWidth = _ref.canvasWidth;
|
|
112
114
|
return "min(100%, ".concat(canvasWidth, "px)");
|
|
113
115
|
}],
|
|
114
|
-
"
|
|
116
|
+
"s1v9piyg-13": [function (_ref2) {
|
|
115
117
|
var canvasWidth = _ref2.canvasWidth;
|
|
116
118
|
return canvasWidth;
|
|
117
119
|
}, "px"]
|
|
@@ -119,13 +121,13 @@ var StyledApp = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
|
119
121
|
});
|
|
120
122
|
var StyledRow = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
121
123
|
name: "StyledRow",
|
|
122
|
-
"class": "
|
|
124
|
+
"class": "s6o5tmu",
|
|
123
125
|
vars: {
|
|
124
|
-
"
|
|
126
|
+
"s6o5tmu-1": [function (_ref3) {
|
|
125
127
|
var width = _ref3.width;
|
|
126
128
|
return width;
|
|
127
129
|
}, "px"],
|
|
128
|
-
"
|
|
130
|
+
"s6o5tmu-2": [function (_ref4) {
|
|
129
131
|
var aspectRatio = _ref4.aspectRatio;
|
|
130
132
|
return aspectRatio;
|
|
131
133
|
}]
|
|
@@ -219,7 +221,14 @@ var App = function App(_ref5) {
|
|
|
219
221
|
canvasSize = _useState2[0],
|
|
220
222
|
setCanvasSize = _useState2[1];
|
|
221
223
|
|
|
222
|
-
var
|
|
224
|
+
var _useState3 = (0, _react.useState)((0, _toolbar.sanitizeTools)(availableToolsFromProps, withUploadPicture || withUrlPicture)),
|
|
225
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
226
|
+
availableTools = _useState4[0],
|
|
227
|
+
setAvailableTools = _useState4[1];
|
|
228
|
+
|
|
229
|
+
(0, _react.useEffect)(function () {
|
|
230
|
+
setAvailableTools((0, _toolbar.sanitizeTools)(availableToolsFromProps, withUploadPicture || withUrlPicture));
|
|
231
|
+
}, [availableToolsFromProps, withUploadPicture, withUrlPicture]);
|
|
223
232
|
|
|
224
233
|
var _useComponent = (0, _useComponent2["default"])({
|
|
225
234
|
disabled: disabled,
|
|
@@ -227,42 +236,42 @@ var App = function App(_ref5) {
|
|
|
227
236
|
}),
|
|
228
237
|
isInsideComponent = _useComponent.isInsideComponent;
|
|
229
238
|
|
|
230
|
-
var _useState3 = (0, _react.useState)(false),
|
|
231
|
-
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
232
|
-
isLoading = _useState4[0],
|
|
233
|
-
setIsLoading = _useState4[1];
|
|
234
|
-
|
|
235
239
|
var _useState5 = (0, _react.useState)(false),
|
|
236
240
|
_useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
|
|
237
|
-
|
|
238
|
-
|
|
241
|
+
isLoading = _useState6[0],
|
|
242
|
+
setIsLoading = _useState6[1];
|
|
239
243
|
|
|
240
|
-
var _useState7 = (0, _react.useState)(
|
|
244
|
+
var _useState7 = (0, _react.useState)(false),
|
|
241
245
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
|
242
|
-
|
|
243
|
-
|
|
246
|
+
isLayoutPanelShown = _useState8[0],
|
|
247
|
+
setIsLayoutPanelShown = _useState8[1];
|
|
244
248
|
|
|
245
|
-
var _useState9 = (0, _react.useState)(
|
|
249
|
+
var _useState9 = (0, _react.useState)([0, 0]),
|
|
246
250
|
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
|
247
|
-
|
|
248
|
-
|
|
251
|
+
canvasOffset = _useState10[0],
|
|
252
|
+
setCanvasOffset = _useState10[1];
|
|
249
253
|
|
|
250
|
-
var _useState11 = (0, _react.useState)(
|
|
254
|
+
var _useState11 = (0, _react.useState)(undefined),
|
|
251
255
|
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
|
252
|
-
|
|
253
|
-
|
|
256
|
+
canvasOffsetStartPosition = _useState12[0],
|
|
257
|
+
setCanvasOffsetStartPosition = _useState12[1];
|
|
254
258
|
|
|
255
|
-
var _useState13 = (0, _react.useState)(
|
|
256
|
-
mode: _Mode.SelectionModeLib["default"]
|
|
257
|
-
}),
|
|
259
|
+
var _useState13 = (0, _react.useState)(_tools.SELECTION_TOOL),
|
|
258
260
|
_useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
|
|
259
|
-
|
|
260
|
-
|
|
261
|
+
activeTool = _useState14[0],
|
|
262
|
+
setActiveTool = _useState14[1];
|
|
261
263
|
|
|
262
|
-
var _useState15 = (0, _react.useState)(
|
|
264
|
+
var _useState15 = (0, _react.useState)({
|
|
265
|
+
mode: _Mode.SelectionModeLib["default"]
|
|
266
|
+
}),
|
|
263
267
|
_useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
selectionMode = _useState16[0],
|
|
269
|
+
setSelectionMode = _useState16[1];
|
|
270
|
+
|
|
271
|
+
var _useState17 = (0, _react.useState)(gridVisible),
|
|
272
|
+
_useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
|
|
273
|
+
withGrid = _useState18[0],
|
|
274
|
+
setWithGrid = _useState18[1];
|
|
266
275
|
|
|
267
276
|
var _useShapes = (0, _useShapes2["default"])(onDataChanged),
|
|
268
277
|
shapesRef = _useShapes.shapesRef,
|
|
@@ -291,6 +300,16 @@ var App = function App(_ref5) {
|
|
|
291
300
|
setSelectedShape(undefined);
|
|
292
301
|
setActiveTool(tool);
|
|
293
302
|
}, [setSelectedShape]);
|
|
303
|
+
var updateToolSettings = (0, _react.useCallback)(function (toolId, field, value) {
|
|
304
|
+
setAvailableTools(function (availableTools) {
|
|
305
|
+
return availableTools.map(function (tool) {
|
|
306
|
+
return tool.id === toolId ? _fp["default"].set(['settings', field, 'default'], value, tool) : tool;
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
setActiveTool(function (activeTool) {
|
|
310
|
+
return activeTool.id === toolId ? _fp["default"].set(['settings', field, 'default'], value, activeTool) : activeTool;
|
|
311
|
+
});
|
|
312
|
+
}, []);
|
|
294
313
|
var undoAction = (0, _react.useCallback)(function () {
|
|
295
314
|
selectTool(_tools.SELECTION_TOOL);
|
|
296
315
|
backwardShape();
|
|
@@ -299,13 +318,51 @@ var App = function App(_ref5) {
|
|
|
299
318
|
selectTool(_tools.SELECTION_TOOL);
|
|
300
319
|
forwardShape();
|
|
301
320
|
}, [selectTool, forwardShape]);
|
|
302
|
-
var
|
|
321
|
+
var resetCanvas = (0, _react.useCallback)(function () {
|
|
303
322
|
var shapesToInit = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
304
323
|
var clearHistory = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
305
324
|
clearShapes(shapesToInit, clearHistory);
|
|
306
325
|
selectTool(_tools.SELECTION_TOOL);
|
|
307
326
|
setCanvasOffset([0, 0]);
|
|
308
327
|
}, [selectTool, clearShapes]);
|
|
328
|
+
var loadImportedData = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
329
|
+
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(json) {
|
|
330
|
+
var clearHistory,
|
|
331
|
+
shapes,
|
|
332
|
+
_args = arguments;
|
|
333
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
334
|
+
while (1) {
|
|
335
|
+
switch (_context.prev = _context.next) {
|
|
336
|
+
case 0:
|
|
337
|
+
clearHistory = _args.length > 1 && _args[1] !== undefined ? _args[1] : true;
|
|
338
|
+
_context.next = 3;
|
|
339
|
+
return (0, _file.decodeImportedData)(json);
|
|
340
|
+
|
|
341
|
+
case 3:
|
|
342
|
+
shapes = _context.sent;
|
|
343
|
+
resetCanvas(shapes, clearHistory);
|
|
344
|
+
|
|
345
|
+
case 5:
|
|
346
|
+
case "end":
|
|
347
|
+
return _context.stop();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}, _callee);
|
|
351
|
+
}));
|
|
352
|
+
|
|
353
|
+
return function (_x) {
|
|
354
|
+
return _ref6.apply(this, arguments);
|
|
355
|
+
};
|
|
356
|
+
}(), [resetCanvas]);
|
|
357
|
+
var clearCanvas = (0, _react.useCallback)(function () {
|
|
358
|
+
if (shapesFromProps !== undefined) {
|
|
359
|
+
void loadImportedData({
|
|
360
|
+
shapes: shapesFromProps
|
|
361
|
+
}, false);
|
|
362
|
+
} else {
|
|
363
|
+
resetCanvas();
|
|
364
|
+
}
|
|
365
|
+
}, [resetCanvas, loadImportedData, shapesFromProps]);
|
|
309
366
|
var selectShape = (0, _react.useCallback)(function (shape) {
|
|
310
367
|
setActiveTool(_tools.SELECTION_TOOL);
|
|
311
368
|
setSelectedShape(shape);
|
|
@@ -343,7 +400,7 @@ var App = function App(_ref5) {
|
|
|
343
400
|
setIsLoading(true);
|
|
344
401
|
|
|
345
402
|
try {
|
|
346
|
-
var content = (0, _file.encodeShapesInString)(shapesRef.current);
|
|
403
|
+
var content = (0, _file.encodeShapesInString)(shapesRef.current, canvasWidth, canvasHeight);
|
|
347
404
|
|
|
348
405
|
if (!content) {
|
|
349
406
|
throw new Error("L'encodage a échoué");
|
|
@@ -363,33 +420,7 @@ var App = function App(_ref5) {
|
|
|
363
420
|
} finally {
|
|
364
421
|
setIsLoading(false);
|
|
365
422
|
}
|
|
366
|
-
}, [shapesRef, addSnackbar]);
|
|
367
|
-
var loadJson = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
368
|
-
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(json) {
|
|
369
|
-
var shapes;
|
|
370
|
-
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
371
|
-
while (1) {
|
|
372
|
-
switch (_context.prev = _context.next) {
|
|
373
|
-
case 0:
|
|
374
|
-
_context.next = 2;
|
|
375
|
-
return (0, _file.decodePicturesInShapes)(json);
|
|
376
|
-
|
|
377
|
-
case 2:
|
|
378
|
-
shapes = _context.sent;
|
|
379
|
-
clearCanvas(shapes, true);
|
|
380
|
-
|
|
381
|
-
case 4:
|
|
382
|
-
case "end":
|
|
383
|
-
return _context.stop();
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}, _callee);
|
|
387
|
-
}));
|
|
388
|
-
|
|
389
|
-
return function (_x) {
|
|
390
|
-
return _ref6.apply(this, arguments);
|
|
391
|
-
};
|
|
392
|
-
}(), [clearCanvas]);
|
|
423
|
+
}, [shapesRef, addSnackbar, canvasWidth, canvasHeight]);
|
|
393
424
|
var loadFile = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
394
425
|
var _ref7 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(file) {
|
|
395
426
|
var json;
|
|
@@ -405,7 +436,7 @@ var App = function App(_ref5) {
|
|
|
405
436
|
case 4:
|
|
406
437
|
json = _context2.sent;
|
|
407
438
|
_context2.next = 7;
|
|
408
|
-
return
|
|
439
|
+
return loadImportedData(json);
|
|
409
440
|
|
|
410
441
|
case 7:
|
|
411
442
|
addSnackbar({
|
|
@@ -444,7 +475,7 @@ var App = function App(_ref5) {
|
|
|
444
475
|
return function (_x2) {
|
|
445
476
|
return _ref7.apply(this, arguments);
|
|
446
477
|
};
|
|
447
|
-
}(), [
|
|
478
|
+
}(), [loadImportedData, addSnackbar]);
|
|
448
479
|
var addPicture = (0, _react.useCallback)( /*#__PURE__*/function () {
|
|
449
480
|
var _ref8 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(fileOrUrl) {
|
|
450
481
|
var pictureShape;
|
|
@@ -493,7 +524,7 @@ var App = function App(_ref5) {
|
|
|
493
524
|
return _ref8.apply(this, arguments);
|
|
494
525
|
};
|
|
495
526
|
}(), [addPictureShape, selectShape, addSnackbar, canvasWidth, canvasHeight]);
|
|
496
|
-
var onResized = (0, _react.useCallback)(function (measuredWidth
|
|
527
|
+
var onResized = (0, _react.useCallback)(function (measuredWidth) {
|
|
497
528
|
var scaleRatio = measuredWidth / canvasWidth;
|
|
498
529
|
setCanvasSize({
|
|
499
530
|
width: measuredWidth,
|
|
@@ -521,9 +552,11 @@ var App = function App(_ref5) {
|
|
|
521
552
|
}, [isInsideComponent, setSelectedShape]);
|
|
522
553
|
(0, _react.useEffect)(function () {
|
|
523
554
|
if (shapesFromProps !== undefined) {
|
|
524
|
-
void
|
|
555
|
+
void loadImportedData({
|
|
556
|
+
shapes: shapesFromProps
|
|
557
|
+
});
|
|
525
558
|
}
|
|
526
|
-
}, [
|
|
559
|
+
}, [loadImportedData, shapesFromProps]);
|
|
527
560
|
(0, _react.useEffect)(function () {
|
|
528
561
|
if (!apiRef) return;
|
|
529
562
|
apiRef.current = {
|
|
@@ -531,7 +564,7 @@ var App = function App(_ref5) {
|
|
|
531
564
|
return canvasRef.current ? (0, _file.getCanvasImage)(shapesRef.current, canvasOffset, canvasWidth, canvasHeight, canvasSelectionPadding) : undefined;
|
|
532
565
|
},
|
|
533
566
|
getCurrentData: function getCurrentData() {
|
|
534
|
-
return (0, _data.
|
|
567
|
+
return (0, _data.buildDataToExport)(shapesRef.current, canvasWidth, canvasHeight);
|
|
535
568
|
}
|
|
536
569
|
};
|
|
537
570
|
}, [apiRef, shapesRef, canvasOffset, canvasWidth, canvasHeight, canvasSelectionPadding]);
|
|
@@ -616,6 +649,7 @@ var App = function App(_ref5) {
|
|
|
616
649
|
toggleShapeLock: toggleShapeLock,
|
|
617
650
|
isLayoutPanelShown: isLayoutPanelShown
|
|
618
651
|
})), isEditMode && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_SettingsBar["default"], {
|
|
652
|
+
width: canvasSize.width,
|
|
619
653
|
disabled: disabled,
|
|
620
654
|
activeTool: activeTool,
|
|
621
655
|
availableTools: availableTools,
|
|
@@ -628,7 +662,8 @@ var App = function App(_ref5) {
|
|
|
628
662
|
setIsLayoutPanelShown(function (prev) {
|
|
629
663
|
return !prev;
|
|
630
664
|
});
|
|
631
|
-
}
|
|
665
|
+
},
|
|
666
|
+
updateToolSettings: updateToolSettings
|
|
632
667
|
}), /*#__PURE__*/_react["default"].createElement(_Loading["default"], {
|
|
633
668
|
isLoading: isLoading
|
|
634
669
|
}), /*#__PURE__*/_react["default"].createElement(_Snackbar["default"], {
|
|
@@ -73,21 +73,21 @@ var renderSelectionCanvas = function renderSelectionCanvas(selectionCtx, selecti
|
|
|
73
73
|
|
|
74
74
|
var StyledCanvasBox = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
75
75
|
name: "StyledCanvasBox",
|
|
76
|
-
"class": "
|
|
76
|
+
"class": "s9czb9p"
|
|
77
77
|
});
|
|
78
78
|
var StyledCanvasContainer = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
79
79
|
name: "StyledCanvasContainer",
|
|
80
|
-
"class": "
|
|
80
|
+
"class": "s1538eht"
|
|
81
81
|
});
|
|
82
82
|
var StyledDrawCanvas = /*#__PURE__*/(0, _react2.styled)("canvas")({
|
|
83
83
|
name: "StyledDrawCanvas",
|
|
84
|
-
"class": "
|
|
84
|
+
"class": "s101qxdc"
|
|
85
85
|
});
|
|
86
86
|
var StyledSelectionCanvas = /*#__PURE__*/(0, _react2.styled)("canvas")({
|
|
87
87
|
name: "StyledSelectionCanvas",
|
|
88
|
-
"class": "
|
|
88
|
+
"class": "sa4oq48",
|
|
89
89
|
vars: {
|
|
90
|
-
"
|
|
90
|
+
"sa4oq48-0": [function (_ref) {
|
|
91
91
|
var cursor = _ref.cursor;
|
|
92
92
|
return cursor;
|
|
93
93
|
}]
|
|
@@ -151,7 +151,7 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
151
151
|
hoverMode = _useDrawableCanvas.hoverMode;
|
|
152
152
|
|
|
153
153
|
var updateSelectedShapeText = (0, _react.useCallback)(function (newText) {
|
|
154
|
-
var _drawCanvasRef$curren, _newShape$style;
|
|
154
|
+
var _drawCanvasRef$curren, _newShape$style$fontB, _newShape$style, _newShape$style$fontI, _newShape$style2, _newShape$style3;
|
|
155
155
|
|
|
156
156
|
if ((selectedShape === null || selectedShape === void 0 ? void 0 : selectedShape.type) !== _Shapes.ShapeEnum.text) return;
|
|
157
157
|
var ctx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
|
|
@@ -159,7 +159,7 @@ var Canvas = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, ref) {
|
|
|
159
159
|
|
|
160
160
|
var newShape = _fp["default"].set('value', newText, selectedShape);
|
|
161
161
|
|
|
162
|
-
var newWidth = (0, _transform.calculateTextWidth)(ctx, newShape.value, newShape.fontSize, (_newShape$style = newShape.style) === null || _newShape$style === void 0 ? void 0 : _newShape$style.fontFamily);
|
|
162
|
+
var 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);
|
|
163
163
|
|
|
164
164
|
var resizedShape = _objectSpread(_objectSpread({}, newShape), {}, {
|
|
165
165
|
width: newWidth,
|
|
@@ -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": "sq3bzv4"
|
|
23
23
|
});
|
|
24
24
|
var StyledButtonContent = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
25
25
|
name: "StyledButtonContent",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "sst453j"
|
|
27
27
|
});
|
|
28
28
|
var StyledIcon = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
29
29
|
name: "StyledIcon",
|
|
30
|
-
"class": "
|
|
30
|
+
"class": "s1q5lsc2"
|
|
31
31
|
});
|
|
32
32
|
var StyledChildren = /*#__PURE__*/(0, _react2.styled)("span")({
|
|
33
33
|
name: "StyledChildren",
|
|
34
|
-
"class": "
|
|
34
|
+
"class": "s1dis2j8"
|
|
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": "s9j48u3"
|
|
28
28
|
});
|
|
29
29
|
var StyledLoader = /*#__PURE__*/(0, _react.styled)("div")({
|
|
30
30
|
name: "StyledLoader",
|
|
31
|
-
"class": "
|
|
31
|
+
"class": "s4auclc"
|
|
32
32
|
});
|
|
33
33
|
var StyledShape = /*#__PURE__*/(0, _react.styled)("div")({
|
|
34
34
|
name: "StyledShape",
|
|
35
|
-
"class": "
|
|
35
|
+
"class": "s1l3fbq"
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
var Loading = function Loading(_ref) {
|
|
@@ -15,22 +15,26 @@ var _style = require("../../constants/style");
|
|
|
15
15
|
|
|
16
16
|
var StyledModal = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
17
17
|
name: "StyledModal",
|
|
18
|
-
"class": "
|
|
18
|
+
"class": "s1c8tp02"
|
|
19
19
|
});
|
|
20
20
|
var StyledPanel = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
21
21
|
name: "StyledPanel",
|
|
22
|
-
"class": "
|
|
22
|
+
"class": "svkxpz4"
|
|
23
23
|
});
|
|
24
24
|
var StyledMask = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
25
25
|
name: "StyledMask",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "s1s9jyyg"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
var Modal = function Modal(_ref) {
|
|
30
30
|
var children = _ref.children,
|
|
31
31
|
onClose = _ref.onClose,
|
|
32
|
+
_ref$position = _ref.position,
|
|
33
|
+
position = _ref$position === void 0 ? 'center' : _ref$position,
|
|
32
34
|
className = _ref.className;
|
|
33
|
-
return /*#__PURE__*/_react["default"].createElement(StyledModal,
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement(StyledModal, {
|
|
36
|
+
"data-position": position
|
|
37
|
+
}, /*#__PURE__*/_react["default"].createElement(StyledMask, {
|
|
34
38
|
onClick: onClose
|
|
35
39
|
}), /*#__PURE__*/_react["default"].createElement(StyledPanel, {
|
|
36
40
|
className: className
|
|
@@ -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": "s1xzg253"
|
|
23
23
|
});
|
|
24
24
|
var StyledTitle = /*#__PURE__*/(0, _react2.styled)("h3")({
|
|
25
25
|
name: "StyledTitle",
|
|
26
|
-
"class": "
|
|
26
|
+
"class": "s17qj3jh"
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
var Panel = function Panel(_ref) {
|
|
@@ -33,12 +33,15 @@ var Panel = function Panel(_ref) {
|
|
|
33
33
|
_ref$title = _ref.title,
|
|
34
34
|
title = _ref$title === void 0 ? '' : _ref$title,
|
|
35
35
|
className = _ref.className,
|
|
36
|
+
_ref$fitContainer = _ref.fitContainer,
|
|
37
|
+
fitContainer = _ref$fitContainer === void 0 ? false : _ref$fitContainer,
|
|
36
38
|
_ref$alignment = _ref.alignment,
|
|
37
39
|
alignment = _ref$alignment === void 0 ? 'center' : _ref$alignment;
|
|
38
40
|
var componentRef = (0, _react.useRef)(null);
|
|
39
41
|
return /*#__PURE__*/_react["default"].createElement(StyledPanel, {
|
|
40
42
|
ref: componentRef,
|
|
41
43
|
className: className,
|
|
44
|
+
"data-fitcontainer": fitContainer,
|
|
42
45
|
"data-vertical": +vertical,
|
|
43
46
|
"data-alignment": alignment
|
|
44
47
|
}, title && /*#__PURE__*/_react["default"].createElement(StyledTitle, null, title), children);
|
|
@@ -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": "s1xssqat"
|
|
31
31
|
});
|
|
32
32
|
var StyledSnackbarContainer = /*#__PURE__*/(0, _react2.styled)("div")({
|
|
33
33
|
name: "StyledSnackbarContainer",
|
|
34
|
-
"class": "
|
|
34
|
+
"class": "s1bgtt22"
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
var Snackbar = function Snackbar(_ref) {
|