@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.
Files changed (37) hide show
  1. package/Changelog.md +107 -0
  2. package/README.md +0 -7
  3. package/dist/components/App.js +114 -79
  4. package/dist/components/Canvas.js +7 -7
  5. package/dist/components/common/Button.js +4 -4
  6. package/dist/components/common/Loading.js +3 -3
  7. package/dist/components/common/Modal.js +8 -4
  8. package/dist/components/common/Panel.js +5 -2
  9. package/dist/components/common/Snackbar.js +2 -2
  10. package/dist/components/settings/ColorField.js +11 -5
  11. package/dist/components/settings/FontFamilyField.js +6 -3
  12. package/dist/components/settings/LayoutButton.js +1 -1
  13. package/dist/components/settings/Layouts.js +18 -9
  14. package/dist/components/settings/LineArrowField.js +7 -4
  15. package/dist/components/settings/LineTypeField.js +7 -4
  16. package/dist/components/settings/PointsNumberField.js +4 -1
  17. package/dist/components/settings/RangeField.js +6 -3
  18. package/dist/components/settings/SelectField.js +11 -4
  19. package/dist/components/settings/SettingsBar.js +246 -131
  20. package/dist/components/settings/ToggleField.js +56 -0
  21. package/dist/components/toolbox/EditTextBox.js +23 -16
  22. package/dist/components/toolbox/MenuGroup.js +11 -11
  23. package/dist/components/toolbox/PictureUrlInput.js +1 -1
  24. package/dist/components/toolbox/Toolbar.js +13 -7
  25. package/dist/components/toolbox/ToolbarGroup.js +13 -11
  26. package/dist/constants/icons.js +18 -8
  27. package/dist/constants/tools.js +10 -2
  28. package/dist/hooks/useDoubleClick.js +46 -0
  29. package/dist/hooks/useDrawableCanvas.js +29 -45
  30. package/dist/styles.css +55 -51
  31. package/dist/utils/data.js +27 -5
  32. package/dist/utils/draw.js +3 -3
  33. package/dist/utils/file.js +15 -14
  34. package/dist/utils/intersect.js +1 -0
  35. package/dist/utils/selection.js +1 -1
  36. package/dist/utils/transform.js +23 -10
  37. package/package.json +1 -1
@@ -39,11 +39,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
39
39
 
40
40
  var StyledPanel = /*#__PURE__*/(0, _react2.styled)(_Panel["default"])({
41
41
  name: "StyledPanel",
42
- "class": "s1qu0ers"
42
+ "class": "s1uphjfh"
43
43
  });
44
44
  var StyledRelative = /*#__PURE__*/(0, _react2.styled)("div")({
45
45
  name: "StyledRelative",
46
- "class": "s1y35t9y"
46
+ "class": "s1e5a6k5"
47
47
  });
48
48
 
49
49
  var MenuGroup = function MenuGroup(_ref) {
@@ -81,6 +81,10 @@ var MenuGroup = function MenuGroup(_ref) {
81
81
  isOpen = _useState2[0],
82
82
  setIsOpen = _useState2[1];
83
83
 
84
+ var _useTransition = (0, _react.useTransition)(),
85
+ _useTransition2 = (0, _slicedToArray2["default"])(_useTransition, 2),
86
+ startTransition = _useTransition2[1];
87
+
84
88
  var loadFile = function loadFile(file) {
85
89
  setIsOpen(false);
86
90
  loadFileFromProps(file);
@@ -110,7 +114,9 @@ var MenuGroup = function MenuGroup(_ref) {
110
114
  }();
111
115
 
112
116
  var openPanel = function openPanel() {
113
- setIsOpen(true);
117
+ startTransition(function () {
118
+ setIsOpen(true);
119
+ });
114
120
  };
115
121
 
116
122
  var isActive = _fp["default"].includes(activeTool.type, group === null || group === void 0 ? void 0 : group.tools);
@@ -123,12 +129,8 @@ var MenuGroup = function MenuGroup(_ref) {
123
129
  setIsOpen(false);
124
130
  };
125
131
 
126
- var timeoutId = setTimeout(function () {
127
- //TODO find a better fix than settimeout for react18
128
- document.addEventListener('click', closePanel);
129
- }, 0);
132
+ document.addEventListener('click', closePanel);
130
133
  return function () {
131
- clearTimeout(timeoutId);
132
134
  document.removeEventListener('click', closePanel);
133
135
  };
134
136
  }, [isOpen]);
@@ -162,9 +164,7 @@ var MenuGroup = function MenuGroup(_ref) {
162
164
  disabled: disabled || !hasActionToClear,
163
165
  img: _tools.CLEAR_TOOL.icon,
164
166
  isActive: activeTool.id === _tools.CLEAR_TOOL.id,
165
- setActive: function setActive() {
166
- return clearCanvas();
167
- }
167
+ setActive: clearCanvas
168
168
  }), (withUploadPicture || withUrlPicture || withLoadAndSave) && /*#__PURE__*/_react["default"].createElement("hr", null)), withUploadPicture && /*#__PURE__*/_react["default"].createElement(_LoadFileTool["default"], {
169
169
  withText: true,
170
170
  type: _tools.UPLOAD_PICTURE_TOOL,
@@ -27,7 +27,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27
27
 
28
28
  var StyledInputModal = /*#__PURE__*/(0, _react2.styled)(_Modal["default"])({
29
29
  name: "StyledInputModal",
30
- "class": "s1rncfwv"
30
+ "class": "s95bkm9"
31
31
  });
32
32
 
33
33
  var PictureUrlModal = function PictureUrlModal(_ref) {
@@ -44,15 +44,15 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
44
44
  var TOOL_WIDTH = 40;
45
45
  var StyledShrinkableTools = /*#__PURE__*/(0, _react2.styled)("div")({
46
46
  name: "StyledShrinkableTools",
47
- "class": "s1gorp95"
47
+ "class": "so6hnjf"
48
48
  });
49
49
  var StyledToolbox = /*#__PURE__*/(0, _react2.styled)("div")({
50
50
  name: "StyledToolbox",
51
- "class": "s1ivsaf6"
51
+ "class": "s1c1dllr"
52
52
  });
53
53
  var StyledToolsModal = /*#__PURE__*/(0, _react2.styled)(_Modal["default"])({
54
54
  name: "StyledToolsModal",
55
- "class": "sv0y70r"
55
+ "class": "s1g032mh"
56
56
  });
57
57
  var TOOLBAR_STRUCTURE = [{
58
58
  title: 'brush',
@@ -135,6 +135,14 @@ var Toolbar = function Toolbar(_ref) {
135
135
  var setActiveTool = function setActiveTool(tool) {
136
136
  setActiveToolFromProps(tool);
137
137
  setIsMenuOpen(false);
138
+ };
139
+
140
+ var setActiveToolFromId = function setActiveToolFromId(toolId) {
141
+ var _availableTools$find;
142
+
143
+ setActiveTool((_availableTools$find = availableTools.find(function (tool) {
144
+ return tool.id === toolId;
145
+ })) !== null && _availableTools$find !== void 0 ? _availableTools$find : activeTool);
138
146
  }; //360 240
139
147
 
140
148
 
@@ -163,7 +171,7 @@ var Toolbar = function Toolbar(_ref) {
163
171
  key: i,
164
172
  activeTool: activeTool,
165
173
  group: group,
166
- setActiveTool: setActiveTool
174
+ setActiveToolFromId: setActiveToolFromId
167
175
  });
168
176
  })), !actionsInMenu && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Tool["default"], {
169
177
  type: _tools.UNDO_TOOL,
@@ -182,9 +190,7 @@ var Toolbar = function Toolbar(_ref) {
182
190
  disabled: disabled || !hasActionToClear,
183
191
  img: _tools.CLEAR_TOOL.icon,
184
192
  isActive: activeTool.id === _tools.CLEAR_TOOL.id,
185
- setActive: function setActive() {
186
- return clearCanvas();
187
- }
193
+ setActive: clearCanvas
188
194
  })), /*#__PURE__*/_react["default"].createElement(_MenuGroup["default"], {
189
195
  withActionsInMenu: actionsInMenu,
190
196
  disabled: disabled,
@@ -29,11 +29,11 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
29
29
 
30
30
  var StyledPanel = /*#__PURE__*/(0, _react2.styled)(_Panel["default"])({
31
31
  name: "StyledPanel",
32
- "class": "s3kynji"
32
+ "class": "s1bvz4xj"
33
33
  });
34
34
  var StyledRelative = /*#__PURE__*/(0, _react2.styled)("div")({
35
35
  name: "StyledRelative",
36
- "class": "s1614rl3"
36
+ "class": "siejlch"
37
37
  });
38
38
 
39
39
  var ToolbarGroup = function ToolbarGroup(_ref) {
@@ -44,13 +44,17 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
44
44
  group = _ref.group,
45
45
  _ref$disabled = _ref.disabled,
46
46
  disabled = _ref$disabled === void 0 ? false : _ref$disabled,
47
- setActiveToolFromProps = _ref.setActiveTool;
47
+ setActiveToolFromId = _ref.setActiveToolFromId;
48
48
 
49
49
  var _useState = (0, _react.useState)(false),
50
50
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
51
51
  isOpen = _useState2[0],
52
52
  setIsOpen = _useState2[1];
53
53
 
54
+ var _useTransition = (0, _react.useTransition)(),
55
+ _useTransition2 = (0, _slicedToArray2["default"])(_useTransition, 2),
56
+ startTransition = _useTransition2[1];
57
+
54
58
  var _useState3 = (0, _react.useState)(undefined),
55
59
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
56
60
  localActiveTool = _useState4[0],
@@ -58,7 +62,7 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
58
62
 
59
63
  var setActiveTool = function setActiveTool(tool) {
60
64
  setLocalActiveTool(tool);
61
- setActiveToolFromProps(tool);
65
+ setActiveToolFromId(tool.id);
62
66
  };
63
67
 
64
68
  (0, _react.useEffect)(function () {
@@ -68,12 +72,8 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
68
72
  setIsOpen(false);
69
73
  };
70
74
 
71
- var timeoutId = setTimeout(function () {
72
- //TODO find a better fix than settimeout for react18
73
- document.addEventListener('click', closePanel);
74
- }, 0);
75
+ document.addEventListener('click', closePanel);
75
76
  return function () {
76
- clearTimeout(timeoutId);
77
77
  document.removeEventListener('click', closePanel);
78
78
  };
79
79
  }, [isOpen]);
@@ -106,8 +106,10 @@ var ToolbarGroup = function ToolbarGroup(_ref) {
106
106
  var groupIcon = (_ref2 = localActiveTool ? localActiveTool.icon : group.toolsType && group.toolsType[0] && group.toolsType[0].icon) !== null && _ref2 !== void 0 ? _ref2 : group.title;
107
107
 
108
108
  var openPanel = function openPanel() {
109
- if (localActiveTool) setActiveToolFromProps(localActiveTool);else group.toolsType && group.toolsType[0] && setActiveTool(group.toolsType[0]);
110
- setIsOpen(true);
109
+ if (localActiveTool) setActiveToolFromId(localActiveTool.id);else group.toolsType && group.toolsType[0] && setActiveTool(group.toolsType[0]);
110
+ startTransition(function () {
111
+ setIsOpen(true);
112
+ });
111
113
  };
112
114
 
113
115
  return /*#__PURE__*/_react["default"].createElement(StyledRelative, null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.visibilityOffIcon = exports.visibilityIcon = exports.unlockedIcon = exports.undoIcon = exports.trashIcon = exports.textIcon = exports.squareIcon = exports.shapesIcon = exports.selectIcon = exports.saveIcon = exports.redoIcon = exports.recIcon = exports.publicIcon = exports.polygonIcon = exports.pictureIcon = exports.penIcon = exports.paletteIcon = exports.paintIcon = exports.openFileIcon = exports.opacityIcon = exports.menuIcon = exports.lockedIcon = exports.layersIcon = exports.gridOnIcon = exports.gridOffIcon = exports.gestureIcon = exports.exportFileIcon = exports.encodedTransparentIcon = exports.ellipseIcon = exports.dragIcon = exports.dotsIcon = exports.curveIcon = exports.clearIcon = exports.circleIcon = exports.brushIcon = exports.arrowIcon = void 0;
6
+ exports.visibilityOffIcon = exports.visibilityIcon = exports.unlockedIcon = exports.undoIcon = exports.trashIcon = exports.textIcon = exports.squareIcon = exports.shapesIcon = exports.settingsIcon = exports.saveIcon = exports.redoIcon = exports.recIcon = exports.publicIcon = exports.polygonIcon = exports.pictureIcon = exports.penIcon = exports.paletteIcon = exports.paintIcon = exports.openFileIcon = exports.opacityIcon = exports.menuIcon = exports.lockedIcon = exports.lineWidthIcon = exports.lineTypeIcon = exports.lineEndIcon = exports.layersIcon = exports.italicIcon = exports.gridOnIcon = exports.gridOffIcon = exports.fontIcon = exports.exportFileIcon = exports.encodedTransparentIcon = exports.ellipseIcon = exports.dotsIcon = exports.curveIcon = exports.cursorIcon = exports.clearIcon = exports.circleIcon = exports.brushIcon = exports.boldIcon = exports.arrowIcon = void 0;
7
7
  var brushIcon = '<svg><path d="M5.146 17.5Q4.146 17.5 3.208 17Q2.271 16.5 1.667 15.708Q2.208 15.75 2.802 15.344Q3.396 14.938 3.396 14.104Q3.396 13.042 4.135 12.292Q4.875 11.542 5.958 11.542Q7.021 11.542 7.76 12.292Q8.5 13.042 8.5 14.104Q8.5 15.5 7.51 16.5Q6.521 17.5 5.146 17.5ZM9.917 12.5 7.562 10.146 14.917 2.729Q15.146 2.5 15.469 2.5Q15.792 2.5 16.021 2.729L17.271 3.958Q17.5 4.188 17.5 4.531Q17.5 4.875 17.271 5.125Z"/></svg>';
8
8
  exports.brushIcon = brushIcon;
9
9
  var squareIcon = '<svg><path d="M2.5 17.5V2.5H17.5V17.5ZM4.25 15.75H15.75V4.25H4.25ZM4.25 15.75V4.25V15.75Z"/></svg>';
@@ -46,18 +46,16 @@ var textIcon = '<svg><path d="M8.708 16.667V5.917H4.167V3.333H15.833V5.917H11.29
46
46
  exports.textIcon = textIcon;
47
47
  var arrowIcon = '<svg><path d="M7.5 15.833V14.083H12.833L3.333 4.583L4.583 3.333L14.083 12.833V7.5H15.833V15.833Z"/></svg>';
48
48
  exports.arrowIcon = arrowIcon;
49
+ var cursorIcon = '<svg><path d="M8.0145 11.1707C8.38484 10.9914 8.82183 11.1558 8.99959 11.5295L10.7031 15.2591L12.0363 14.6238L10.3254 10.9017C10.1476 10.528 10.3106 10.0795 10.6809 9.90761L10.8883 9.84782L12.5918 9.51148L6.48133 4.33192V12.389L7.82934 11.2903L8.0145 11.1707ZM10.6587 16.9258C10.2883 17.1052 9.84395 16.9482 9.67359 16.5745L8.05894 13.0318L6.19988 14.5416C6.07396 14.6462 5.91842 14.706 5.74066 14.706C5.54423 14.706 5.35584 14.6272 5.21694 14.4871C5.07803 14.3469 5 14.1568 5 13.9586V2.74741C5 2.54919 5.07803 2.35908 5.21694 2.21891C5.35584 2.07874 5.54423 2 5.74066 2C5.91842 2 6.08878 2.06727 6.21469 2.1719L6.2221 2.16443L14.7323 9.36947C15.0508 9.63854 15.0879 10.1094 14.8286 10.4233C14.7175 10.5579 14.562 10.6475 14.4064 10.6774L12.0659 11.1408L13.6954 14.6761C13.888 15.0498 13.7102 15.4908 13.3399 15.6627L10.6587 16.9258Z"/></svg>';
50
+ exports.cursorIcon = cursorIcon;
49
51
  var menuIcon = '<svg><path d="M2.5 15V13.25H17.5V15ZM2.5 10.875V9.125H17.5V10.875ZM2.5 6.75V5H17.5V6.75Z"/></svg>';
50
52
  exports.menuIcon = menuIcon;
51
- var dragIcon = '<svg><path d="M7.542 16.667Q6.833 16.667 6.333 16.167Q5.833 15.667 5.833 14.958Q5.833 14.25 6.333 13.75Q6.833 13.25 7.542 13.25Q8.25 13.25 8.75 13.75Q9.25 14.25 9.25 14.958Q9.25 15.667 8.75 16.167Q8.25 16.667 7.542 16.667ZM7.542 11.708Q6.833 11.708 6.333 11.208Q5.833 10.708 5.833 10Q5.833 9.292 6.333 8.792Q6.833 8.292 7.542 8.292Q8.25 8.292 8.75 8.792Q9.25 9.292 9.25 10Q9.25 10.708 8.75 11.208Q8.25 11.708 7.542 11.708ZM7.542 6.75Q6.833 6.75 6.333 6.25Q5.833 5.75 5.833 5.042Q5.833 4.333 6.333 3.833Q6.833 3.333 7.542 3.333Q8.25 3.333 8.75 3.833Q9.25 4.333 9.25 5.042Q9.25 5.75 8.75 6.25Q8.25 6.75 7.542 6.75ZM12.458 6.75Q11.75 6.75 11.25 6.25Q10.75 5.75 10.75 5.042Q10.75 4.333 11.25 3.833Q11.75 3.333 12.458 3.333Q13.167 3.333 13.667 3.833Q14.167 4.333 14.167 5.042Q14.167 5.75 13.667 6.25Q13.167 6.75 12.458 6.75ZM12.458 11.708Q11.75 11.708 11.25 11.208Q10.75 10.708 10.75 10Q10.75 9.292 11.25 8.792Q11.75 8.292 12.458 8.292Q13.167 8.292 13.667 8.792Q14.167 9.292 14.167 10Q14.167 10.708 13.667 11.208Q13.167 11.708 12.458 11.708ZM12.458 16.667Q11.75 16.667 11.25 16.167Q10.75 15.667 10.75 14.958Q10.75 14.25 11.25 13.75Q11.75 13.25 12.458 13.25Q13.167 13.25 13.667 13.75Q14.167 14.25 14.167 14.958Q14.167 15.667 13.667 16.167Q13.167 16.667 12.458 16.667Z"/></svg>';
52
- exports.dragIcon = dragIcon;
53
53
  var visibilityIcon = '<svg><path d="M10 13.354Q11.583 13.354 12.688 12.25Q13.792 11.146 13.792 9.562Q13.792 7.979 12.688 6.875Q11.583 5.771 10 5.771Q8.417 5.771 7.312 6.875Q6.208 7.979 6.208 9.562Q6.208 11.146 7.312 12.25Q8.417 13.354 10 13.354ZM10 11.812Q9.062 11.812 8.406 11.156Q7.75 10.5 7.75 9.562Q7.75 8.625 8.406 7.969Q9.062 7.312 10 7.312Q10.938 7.312 11.594 7.969Q12.25 8.625 12.25 9.562Q12.25 10.5 11.594 11.156Q10.938 11.812 10 11.812ZM10 15.833Q6.938 15.833 4.448 14.125Q1.958 12.417 0.833 9.562Q1.958 6.708 4.458 5.021Q6.958 3.333 10 3.333Q13.042 3.333 15.542 5.021Q18.042 6.708 19.167 9.562Q18.042 12.417 15.552 14.125Q13.062 15.833 10 15.833ZM10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562Q10 9.562 10 9.562ZM10 14.083Q12.333 14.083 14.281 12.865Q16.229 11.646 17.25 9.562Q16.229 7.479 14.281 6.281Q12.333 5.083 10 5.083Q7.667 5.083 5.708 6.281Q3.75 7.479 2.729 9.562Q3.75 11.646 5.708 12.865Q7.667 14.083 10 14.083Z"/></svg>';
54
54
  exports.visibilityIcon = visibilityIcon;
55
55
  var visibilityOffIcon = '<svg><path d="M13.521 11.021 12.25 9.75Q12.333 8.75 11.604 7.979Q10.875 7.208 9.812 7.312L8.542 6.042Q8.896 5.896 9.26 5.833Q9.625 5.771 10 5.771Q11.583 5.771 12.688 6.875Q13.792 7.979 13.792 9.562Q13.792 9.979 13.719 10.354Q13.646 10.729 13.521 11.021ZM16.167 13.646 14.917 12.417Q15.667 11.833 16.25 11.146Q16.833 10.458 17.25 9.562Q16.229 7.479 14.292 6.281Q12.354 5.083 10 5.083Q9.396 5.083 8.885 5.156Q8.375 5.229 7.875 5.375L6.5 4Q7.354 3.646 8.208 3.49Q9.062 3.333 10 3.333Q13.146 3.333 15.615 5.052Q18.083 6.771 19.167 9.562Q18.688 10.792 17.917 11.823Q17.146 12.854 16.167 13.646ZM16.396 18.854 12.938 15.396Q12.208 15.625 11.479 15.729Q10.75 15.833 10 15.833Q6.833 15.833 4.375 14.094Q1.917 12.354 0.833 9.562Q1.25 8.479 1.917 7.552Q2.583 6.625 3.417 5.875L1.125 3.562L2.375 2.354L17.625 17.625ZM4.604 7.062Q4.021 7.604 3.542 8.219Q3.062 8.833 2.729 9.562Q3.75 11.646 5.688 12.865Q7.625 14.083 10 14.083Q10.354 14.083 10.74 14.052Q11.125 14.021 11.479 13.938L10.812 13.271Q10.625 13.312 10.417 13.333Q10.208 13.354 10 13.354Q8.417 13.354 7.312 12.25Q6.208 11.146 6.208 9.562Q6.208 9.354 6.24 9.167Q6.271 8.979 6.312 8.771ZM11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875Q11.375 8.875 11.375 8.875ZM8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Q8.042 10.5 8.042 10.5Z"/></svg>';
56
56
  exports.visibilityOffIcon = visibilityOffIcon;
57
57
  var paletteIcon = '<svg><path d="M9.958 18.333Q8.25 18.333 6.74 17.677Q5.229 17.021 4.104 15.885Q2.979 14.75 2.323 13.229Q1.667 11.708 1.667 10Q1.667 8.271 2.333 6.75Q3 5.229 4.156 4.104Q5.312 2.979 6.854 2.323Q8.396 1.667 10.125 1.667Q11.771 1.667 13.26 2.25Q14.75 2.833 15.875 3.854Q17 4.875 17.667 6.26Q18.333 7.646 18.333 9.25Q18.333 11.688 16.792 12.948Q15.25 14.208 13.188 14.208H11.75Q11.625 14.208 11.562 14.281Q11.5 14.354 11.5 14.458Q11.5 14.688 11.812 15.219Q12.125 15.75 12.125 16.458Q12.125 17.458 11.51 17.896Q10.896 18.333 9.958 18.333ZM5.458 10.875Q6 10.875 6.375 10.5Q6.75 10.125 6.75 9.583Q6.75 9.042 6.375 8.667Q6 8.292 5.458 8.292Q4.917 8.292 4.542 8.667Q4.167 9.042 4.167 9.583Q4.167 10.125 4.542 10.5Q4.917 10.875 5.458 10.875ZM7.917 7.583Q8.458 7.583 8.833 7.208Q9.208 6.833 9.208 6.292Q9.208 5.75 8.833 5.375Q8.458 5 7.917 5Q7.375 5 7 5.375Q6.625 5.75 6.625 6.292Q6.625 6.833 7 7.208Q7.375 7.583 7.917 7.583ZM12.021 7.583Q12.562 7.583 12.938 7.208Q13.312 6.833 13.312 6.292Q13.312 5.75 12.938 5.375Q12.562 5 12.021 5Q11.479 5 11.104 5.375Q10.729 5.75 10.729 6.292Q10.729 6.833 11.104 7.208Q11.479 7.583 12.021 7.583ZM14.479 10.875Q15.021 10.875 15.396 10.5Q15.771 10.125 15.771 9.583Q15.771 9.042 15.396 8.667Q15.021 8.292 14.479 8.292Q13.938 8.292 13.562 8.667Q13.188 9.042 13.188 9.583Q13.188 10.125 13.562 10.5Q13.938 10.875 14.479 10.875Z"/></svg>';
58
58
  exports.paletteIcon = paletteIcon;
59
- var gestureIcon = '<svg><path d="M11.542 17.542Q10.417 17.542 9.625 16.75Q8.833 15.958 8.833 14.833Q8.833 14.083 9.135 13.365Q9.438 12.646 10.01 12.031Q10.583 11.417 11.396 10.979Q12.208 10.542 13.229 10.354Q13.188 9.646 12.885 9.323Q12.583 9 12.104 9Q11.479 9 10.76 9.521Q10.042 10.042 9.104 11.229Q7.792 12.896 6.906 13.552Q6.021 14.208 5.125 14.208Q4.062 14.208 3.302 13.458Q2.542 12.708 2.542 11.521Q2.542 10.521 3 9.406Q3.458 8.292 4.583 6.646Q5.021 6.021 5.219 5.656Q5.417 5.292 5.417 5.062Q5.417 4.938 5.375 4.885Q5.333 4.833 5.25 4.833Q5.042 4.833 4.74 5.104Q4.438 5.375 4.062 5.875L2.5 4.333Q3.188 3.396 3.948 3Q4.708 2.604 5.312 2.604Q6.271 2.604 6.958 3.313Q7.646 4.021 7.646 5.021Q7.646 5.625 7.323 6.344Q7 7.062 6.229 8.188Q5.438 9.375 5.094 10.135Q4.75 10.896 4.75 11.417Q4.75 11.708 4.844 11.854Q4.938 12 5.104 12Q5.396 12 5.927 11.49Q6.458 10.979 7.562 9.604Q8.167 8.875 8.729 8.344Q9.292 7.812 9.844 7.469Q10.396 7.125 10.958 6.958Q11.521 6.792 12.104 6.792Q13.604 6.792 14.458 7.781Q15.312 8.771 15.458 10.25H17.5V12.458H15.458Q15.312 14.479 14.323 16.01Q13.333 17.542 11.542 17.542ZM11.625 15.312Q12.271 15.312 12.656 14.531Q13.042 13.75 13.208 12.625Q12.188 12.896 11.625 13.531Q11.062 14.167 11.062 14.708Q11.062 14.979 11.219 15.146Q11.375 15.312 11.625 15.312Z"/></svg>';
60
- exports.gestureIcon = gestureIcon;
61
59
  var penIcon = '<svg><path d="M2.5 17.5V13.771L13.479 2.792Q14 2.271 14.719 2.271Q15.438 2.271 15.958 2.792L17.208 4.042Q17.708 4.542 17.708 5.281Q17.708 6.021 17.208 6.521L6.229 17.5ZM14.729 6.5 15.958 5.271 14.729 4.042 13.5 5.271Z"/></svg>';
62
60
  exports.penIcon = penIcon;
63
61
  var paintIcon = '<svg><path d="M9.167 18.333Q8.438 18.333 7.927 17.823Q7.417 17.312 7.417 16.583V13.438H5.083Q4.354 13.438 3.844 12.927Q3.333 12.417 3.333 11.688V5.938Q3.333 4.5 4.333 3.5Q5.333 2.5 6.75 2.5H16.667V11.688Q16.667 12.417 16.156 12.927Q15.646 13.438 14.917 13.438H12.542V16.583Q12.542 17.312 12.031 17.823Q11.521 18.333 10.792 18.333ZM5.083 8.312H14.917V4.25H14.125V7.562H12.375V4.25H11.667V5.917H9.917V4.25H6.75Q6.062 4.25 5.573 4.75Q5.083 5.25 5.083 5.938Z"/></svg>';
@@ -74,7 +72,19 @@ var gridOffIcon = '<svg><path d="M18.333 15.854 16.583 14.104V13.354H15.833L14.0
74
72
  exports.gridOffIcon = gridOffIcon;
75
73
  var ellipseIcon = '<svg><path d="M10 15.833Q7.917 15.833 6.667 14.177Q5.417 12.521 5.417 10Q5.417 7.479 6.667 5.823Q7.917 4.167 10 4.167Q12.083 4.167 13.333 5.823Q14.583 7.479 14.583 10Q14.583 12.521 13.333 14.177Q12.083 15.833 10 15.833ZM10 14.042Q11.375 14.042 12.021 12.833Q12.667 11.625 12.667 10Q12.667 8.375 12.021 7.167Q11.375 5.958 10 5.958Q8.625 5.958 7.979 7.167Q7.333 8.375 7.333 10Q7.333 11.625 7.979 12.833Q8.625 14.042 10 14.042Z"/></svg>';
76
74
  exports.ellipseIcon = ellipseIcon;
77
- var selectIcon = '<svg><path d="M8.854 17.5Q8.5 17.5 8.188 17.354Q7.875 17.208 7.604 16.958L3.271 12.646L4.5 11.375Q4.812 11.042 5.24 10.906Q5.667 10.771 6.104 10.875L7.479 11.188V4.667Q7.479 3.771 8.115 3.135Q8.75 2.5 9.646 2.5Q10.542 2.5 11.177 3.135Q11.812 3.771 11.812 4.667V8.062H12.188Q12.333 8.062 12.458 8.094Q12.583 8.125 12.708 8.188L15.812 9.708Q16.292 9.938 16.542 10.406Q16.792 10.875 16.688 11.417L15.917 16.042Q15.812 16.688 15.323 17.094Q14.833 17.5 14.167 17.5ZM8.854 15.75H14.167L14.958 11.229Q14.958 11.229 14.958 11.229Q14.958 11.229 14.958 11.229L11.5 9.562H10.062V4.667Q10.062 4.479 9.948 4.365Q9.833 4.25 9.646 4.25Q9.458 4.25 9.344 4.365Q9.229 4.479 9.229 4.667V13.333L5.708 12.604ZM8.854 15.75H9.229Q9.229 15.75 9.344 15.75Q9.458 15.75 9.646 15.75Q9.833 15.75 9.948 15.75Q10.062 15.75 10.062 15.75H11.521H14.167Q14.167 15.75 14.167 15.75Q14.167 15.75 14.167 15.75Z"/></svg>';
78
- exports.selectIcon = selectIcon;
79
75
  var curveIcon = '<svg><path d="M7.521 17.5Q6.125 17.5 5.146 16.51Q4.167 15.521 4.167 14.125V7.417Q3.438 7.125 2.969 6.49Q2.5 5.854 2.5 5.042Q2.5 3.979 3.24 3.24Q3.979 2.5 5.042 2.5Q6.104 2.5 6.844 3.24Q7.583 3.979 7.583 5.042Q7.583 5.854 7.115 6.49Q6.646 7.125 5.917 7.417V14.125Q5.917 14.792 6.385 15.271Q6.854 15.75 7.521 15.75Q8.188 15.75 8.656 15.271Q9.125 14.792 9.125 14.125V5.875Q9.125 4.479 10.104 3.49Q11.083 2.5 12.479 2.5Q13.875 2.5 14.854 3.49Q15.833 4.479 15.833 5.875V12.583Q16.562 12.875 17.031 13.51Q17.5 14.146 17.5 14.958Q17.5 16.021 16.76 16.76Q16.021 17.5 14.958 17.5Q13.896 17.5 13.156 16.76Q12.417 16.021 12.417 14.958Q12.417 14.146 12.885 13.5Q13.354 12.854 14.083 12.583V5.875Q14.083 5.208 13.615 4.729Q13.146 4.25 12.479 4.25Q11.812 4.25 11.344 4.729Q10.875 5.208 10.875 5.875V14.125Q10.875 15.521 9.896 16.51Q8.917 17.5 7.521 17.5Z"/></svg>';
80
- exports.curveIcon = curveIcon;
76
+ exports.curveIcon = curveIcon;
77
+ var boldIcon = '<svg><path d="M5.833 15V3.333H10.375Q11.812 3.333 12.885 4.156Q13.958 4.979 13.958 6.375Q13.958 7.375 13.49 7.969Q13.021 8.562 12.396 8.875V9.042Q13.312 9.354 13.844 10.021Q14.375 10.688 14.375 11.75Q14.375 13.312 13.229 14.156Q12.083 15 10.5 15ZM8.125 8.042H10.188Q10.854 8.042 11.302 7.656Q11.75 7.271 11.75 6.708Q11.75 6.167 11.302 5.771Q10.854 5.375 10.188 5.375H8.125ZM8.125 12.917H10.354Q11.167 12.917 11.625 12.51Q12.083 12.104 12.083 11.458Q12.083 10.812 11.625 10.406Q11.167 10 10.354 10H8.125Z"/></svg>';
78
+ exports.boldIcon = boldIcon;
79
+ var italicIcon = '<svg><path d="M4.167 16.667V14.083H6.979L10.229 5.917H7.5V3.333H15.833V5.917H13.021L9.771 14.083H12.5V16.667Z"/></svg>';
80
+ exports.italicIcon = italicIcon;
81
+ var lineWidthIcon = '<svg><path d="M3.021 16V15H17V16ZM3.021 13.5V12H17V13.5ZM3 10.5V8.5H16.979V10.5ZM3.021 7V4H17V7Z"/></svg>';
82
+ exports.lineWidthIcon = lineWidthIcon;
83
+ var lineTypeIcon = '<svg><path d="M3 16V14.5H4.5V16ZM6.125 16V14.5H7.625V16ZM9.25 16V14.5H10.75V16ZM12.375 16V14.5H13.875V16ZM15.5 16V14.5H17V16ZM3 13V11.5H6.5V13ZM8.25 13V11.5H11.75V13ZM13.5 13V11.5H17V13ZM3 10V8.5H9.25V10ZM10.75 10V8.5H17V10ZM3 7V4H17V7Z"/></svg>';
84
+ exports.lineTypeIcon = lineTypeIcon;
85
+ var fontIcon = '<svg><path d="M5.312 14.979H7.125L8.042 12.479H11.979L12.896 14.979H14.708L10.917 5H9.083ZM8.542 10.958 9.958 6.958H10.042L11.458 10.958ZM3.417 18.333Q2.688 18.333 2.177 17.823Q1.667 17.312 1.667 16.583V3.417Q1.667 2.688 2.177 2.177Q2.688 1.667 3.417 1.667H16.583Q17.312 1.667 17.823 2.177Q18.333 2.688 18.333 3.417V16.583Q18.333 17.312 17.823 17.823Q17.312 18.333 16.583 18.333ZM3.417 16.583H16.583Q16.583 16.583 16.583 16.583Q16.583 16.583 16.583 16.583V3.417Q16.583 3.417 16.583 3.417Q16.583 3.417 16.583 3.417H3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583ZM3.417 3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417V16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583Q3.417 16.583 3.417 16.583V3.417Q3.417 3.417 3.417 3.417Q3.417 3.417 3.417 3.417Z"/></svg>';
86
+ exports.fontIcon = fontIcon;
87
+ var lineEndIcon = '<svg><path d="M6 17 2 13 6 9 7.062 10.062 4.875 12.25H17V13.75H4.875L7.062 15.938ZM14 11 12.938 9.938 15.125 7.75H3V6.25H15.125L12.938 4.062L14 3L18 7Z"/></svg>';
88
+ exports.lineEndIcon = lineEndIcon;
89
+ var settingsIcon = '<svg><path d="M2.5 15.833V14.083H7.667V15.833ZM2.5 5.917V4.167H10.771V5.917ZM9.208 17.5V12.438H10.958V14.083H17.5V15.833H10.958V17.5ZM5.917 12.542V10.875H2.5V9.125H5.917V7.479H7.667V12.542ZM9.208 10.875V9.125H17.5V10.875ZM12.333 7.562V2.5H14.083V4.167H17.5V5.917H14.083V7.562Z"/></svg>';
90
+ exports.settingsIcon = settingsIcon;
@@ -145,6 +145,14 @@ var SETTINGS_DEFAULT_TEXT = {
145
145
  fontFamily: {
146
146
  values: _style.STYLE_FONTS,
147
147
  "default": _style.STYLE_FONT_DEFAULT
148
+ },
149
+ fontBold: {
150
+ values: [false, true],
151
+ "default": false
152
+ },
153
+ fontItalic: {
154
+ values: [false, true],
155
+ "default": false
148
156
  }
149
157
  };
150
158
  exports.SETTINGS_DEFAULT_TEXT = SETTINGS_DEFAULT_TEXT;
@@ -351,7 +359,7 @@ exports.DEFAULT_SHAPE_TOOLS = DEFAULT_SHAPE_TOOLS;
351
359
  var SELECTION_TOOL = {
352
360
  id: "".concat(PREFIX_ID, "selection"),
353
361
  type: _tools.ActionsEnum.selection,
354
- icon: _icons.selectIcon,
362
+ icon: _icons.cursorIcon,
355
363
  lib: 'Sélection'
356
364
  };
357
365
  exports.SELECTION_TOOL = SELECTION_TOOL;
@@ -400,7 +408,7 @@ exports.SAVE_TOOL = SAVE_TOOL;
400
408
  var MOVE_TOOL = {
401
409
  id: "".concat(PREFIX_ID, "move"),
402
410
  type: _tools.ActionsEnum.move,
403
- icon: _icons.selectIcon,
411
+ icon: _icons.cursorIcon,
404
412
  lib: 'Move'
405
413
  };
406
414
  exports.MOVE_TOOL = MOVE_TOOL;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var DELTA_TIME_THRESHOLD_MS = 300;
11
+
12
+ var useDoubleClick = function useDoubleClick() {
13
+ var lastClickTimestampRef = (0, _react.useRef)(undefined);
14
+ var callbackRef = (0, _react.useRef)(undefined);
15
+
16
+ var onClick = function onClick(e) {
17
+ var currentTimestamp = new Date().getTime();
18
+
19
+ if (lastClickTimestampRef.current && currentTimestamp < lastClickTimestampRef.current + DELTA_TIME_THRESHOLD_MS) {
20
+ var _callbackRef$current;
21
+
22
+ (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 ? void 0 : _callbackRef$current.call(callbackRef, e);
23
+ }
24
+
25
+ lastClickTimestampRef.current = new Date().getTime();
26
+ };
27
+
28
+ var registerDoubleClickEvent = function registerDoubleClickEvent(element, callback) {
29
+ callbackRef.current = callback;
30
+ element.addEventListener('click', onClick);
31
+ element.addEventListener('touchend', onClick);
32
+ };
33
+
34
+ var unRegisterDoubleClickEvent = function unRegisterDoubleClickEvent(element) {
35
+ element.removeEventListener('click', onClick);
36
+ element.removeEventListener('touchend', onClick);
37
+ };
38
+
39
+ return {
40
+ registerDoubleClickEvent: registerDoubleClickEvent,
41
+ unRegisterDoubleClickEvent: unRegisterDoubleClickEvent
42
+ };
43
+ };
44
+
45
+ var _default = useDoubleClick;
46
+ exports["default"] = _default;
@@ -29,6 +29,8 @@ var _tools = require("../types/tools");
29
29
 
30
30
  var _tools2 = require("../constants/tools");
31
31
 
32
+ var _useDoubleClick2 = _interopRequireDefault(require("./useDoubleClick"));
33
+
32
34
  var handleMove = function handleMove(e, canvasRef, activeTool, canvasOffset, selectedShape, selectionMode, canvasOffsetStartPosition, width, height, scaleRatio, setHoverMode, updateSingleShape, setCanvasOffset, setSelectedShape, selectionPadding) {
33
35
  if (activeTool.type === _tools.ActionsEnum.move && canvasOffsetStartPosition !== undefined) {
34
36
  var _cursorPosition = (0, _intersect.getCursorPosition)(e, canvasRef.current, width, height, scaleRatio);
@@ -40,7 +42,7 @@ var handleMove = function handleMove(e, canvasRef, activeTool, canvasOffset, sel
40
42
  if (selectedShape.locked) return;
41
43
  var cursorPosition = (0, _intersect.getCursorPosition)(e, canvasRef.current, width, height, scaleRatio);
42
44
 
43
- if (selectionMode.mode === _Mode.SelectionModeLib["default"]) {
45
+ if (selectionMode.mode === _Mode.SelectionModeLib["default"] || selectionMode.mode === _Mode.SelectionModeLib.textedition) {
44
46
  var positionIntersection = (0, _intersect.checkPositionIntersection)(selectedShape, cursorPosition, canvasOffset, selectionPadding, scaleRatio, true) || {
45
47
  mode: _Mode.SelectionModeLib["default"]
46
48
  };
@@ -91,6 +93,10 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
91
93
  hoverMode = _useState2[0],
92
94
  setHoverMode = _useState2[1];
93
95
 
96
+ var _useDoubleClick = (0, _useDoubleClick2["default"])(),
97
+ registerDoubleClickEvent = _useDoubleClick.registerDoubleClickEvent,
98
+ unRegisterDoubleClickEvent = _useDoubleClick.unRegisterDoubleClickEvent;
99
+
94
100
  (0, _react.useEffect)(function () {
95
101
  var handleMouseMove = function handleMouseMove(e) {
96
102
  return window.requestAnimationFrame(function () {
@@ -111,28 +117,9 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
111
117
  };
112
118
  }, [isInsideComponent, selectionCanvasRef, selectedShape, selectionMode, setHoverMode, canvasOffset, canvasOffsetStartPosition, width, height, scaleRatio, updateSingleShape, activeTool, setCanvasOffset, setSelectedShape, selectionPadding]);
113
119
  (0, _react.useEffect)(function () {
114
- var handleMouseUp = function handleMouseUp(e) {
120
+ var handleMouseUp = function handleMouseUp() {
115
121
  if (selectionMode.mode === _Mode.SelectionModeLib.textedition) return;
116
122
 
117
- if (activeTool.type === _Shapes.ShapeEnum.text) {
118
- var _drawCanvasRef$curren;
119
-
120
- var cursorPosition = (0, _intersect.getCursorPosition)(e, selectionCanvasRef.current, width, height, scaleRatio);
121
- var drawCtx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
122
- if (!drawCtx) return;
123
-
124
- var _newShape2 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
125
-
126
- addShape(_newShape2);
127
- setActiveTool(_tools2.SELECTION_TOOL);
128
- setSelectedShape(_newShape2);
129
- setSelectionMode({
130
- mode: _Mode.SelectionModeLib.textedition,
131
- defaultValue: _newShape2.value
132
- });
133
- return;
134
- }
135
-
136
123
  if (selectionMode.mode !== _Mode.SelectionModeLib["default"]) {
137
124
  setSelectionMode({
138
125
  mode: _Mode.SelectionModeLib["default"]
@@ -152,7 +139,7 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
152
139
  document.removeEventListener('touchend', handleMouseUp);
153
140
  }
154
141
  };
155
- }, [isInsideComponent, selectionCanvasRef, drawCanvasRef, selectionMode, saveShapes, activeTool, addShape, width, height, scaleRatio, setActiveTool, setSelectedShape, setSelectionMode]);
142
+ }, [isInsideComponent, selectionMode, saveShapes, setSelectionMode]);
156
143
  (0, _react.useEffect)(function () {
157
144
  var ref = selectionCanvasRef.current;
158
145
  if (!ref) return;
@@ -174,39 +161,39 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
174
161
  }
175
162
 
176
163
  if (_fp["default"].includes(activeTool.type, _Shapes.ShapeEnum)) {
177
- var _drawCanvasRef$curren2;
164
+ var _drawCanvasRef$curren;
178
165
 
179
- var drawCtx = (_drawCanvasRef$curren2 = drawCanvasRef.current) === null || _drawCanvasRef$curren2 === void 0 ? void 0 : _drawCanvasRef$curren2.getContext('2d');
166
+ var drawCtx = (_drawCanvasRef$curren = drawCanvasRef.current) === null || _drawCanvasRef$curren === void 0 ? void 0 : _drawCanvasRef$curren.getContext('2d');
180
167
  if (!drawCtx) return;
181
168
 
182
169
  if (activeTool.type === _Shapes.ShapeEnum.brush) {
183
170
  if (!!selectedShape) {
184
- var _newShape3 = (0, _transform.createNewPointGroupToShape)(selectedShape, cursorPosition);
171
+ var _newShape2 = (0, _transform.createNewPointGroupToShape)(selectedShape, cursorPosition);
185
172
 
186
- updateSingleShape(_newShape3);
187
- setSelectedShape(_newShape3);
173
+ updateSingleShape(_newShape2);
174
+ setSelectedShape(_newShape2);
188
175
  } else {
189
- var _newShape4 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
176
+ var _newShape3 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
190
177
 
191
- if (!_newShape4) return;
192
- addShape(_newShape4);
193
- setSelectedShape(_newShape4);
178
+ if (!_newShape3) return;
179
+ addShape(_newShape3);
180
+ setSelectedShape(_newShape3);
194
181
  }
195
182
 
196
183
  setSelectionMode({
197
184
  mode: _Mode.SelectionModeLib.brush
198
185
  });
199
- } else if (activeTool.type !== _Shapes.ShapeEnum.text) {
200
- var _newShape5 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
186
+ } else {
187
+ var _newShape4 = (0, _data.createShape)(drawCtx, activeTool, cursorPosition);
201
188
 
202
- if (!_newShape5) return;
203
- addShape(_newShape5);
189
+ if (!_newShape4) return;
190
+ addShape(_newShape4);
204
191
  setActiveTool(_tools2.SELECTION_TOOL);
205
- setSelectedShape(_newShape5);
192
+ setSelectedShape(_newShape4);
206
193
  setSelectionMode({
207
194
  mode: _Mode.SelectionModeLib.resize,
208
195
  cursorStartPosition: cursorPosition,
209
- originalShape: _newShape5,
196
+ originalShape: _newShape4,
210
197
  anchor: activeTool.type === _Shapes.ShapeEnum.line || activeTool.type === _Shapes.ShapeEnum.polygon || activeTool.type === _Shapes.ShapeEnum.curve ? 0 : [1, 1]
211
198
  });
212
199
  }
@@ -244,15 +231,12 @@ var useDrawableCanvas = function useDrawableCanvas(_ref) {
244
231
  };
245
232
 
246
233
  if (isInsideComponent) {
247
- ref.addEventListener('dblclick', handleDoubleClick);
234
+ registerDoubleClickEvent(ref, handleDoubleClick);
235
+ return function () {
236
+ unRegisterDoubleClickEvent(ref);
237
+ };
248
238
  }
249
-
250
- return function () {
251
- if (isInsideComponent) {
252
- ref.removeEventListener('dblclick', handleDoubleClick);
253
- }
254
- };
255
- }, [isInsideComponent, selectionCanvasRef, activeTool, selectedShape, width, height, scaleRatio, canvasOffset, setSelectionMode, selectionPadding]);
239
+ }, [registerDoubleClickEvent, unRegisterDoubleClickEvent, isInsideComponent, selectionCanvasRef, activeTool, selectedShape, width, height, scaleRatio, canvasOffset, setSelectionMode, selectionPadding]);
256
240
  return {
257
241
  hoverMode: hoverMode
258
242
  };