@webiny/lexical-editor 6.3.0 → 6.4.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/commands/image.js +2 -1
  2. package/commands/image.js.map +1 -1
  3. package/commands/index.js +0 -2
  4. package/commands/list.js +4 -3
  5. package/commands/list.js.map +1 -1
  6. package/commands/quote.js +2 -1
  7. package/commands/quote.js.map +1 -1
  8. package/commands/toolbar.js +2 -1
  9. package/commands/toolbar.js.map +1 -1
  10. package/commands/typography.js +2 -1
  11. package/commands/typography.js.map +1 -1
  12. package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
  13. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
  14. package/components/Editor/RichTextEditor.js +82 -121
  15. package/components/Editor/RichTextEditor.js.map +1 -1
  16. package/components/Editor/normalizeInputValue.js +11 -13
  17. package/components/Editor/normalizeInputValue.js.map +1 -1
  18. package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
  19. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  20. package/components/LexicalEditorConfig/components/Node.js +21 -26
  21. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  22. package/components/LexicalEditorConfig/components/Plugin.js +21 -26
  23. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  24. package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
  25. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  26. package/components/LexicalHtmlRenderer.js +35 -40
  27. package/components/LexicalHtmlRenderer.js.map +1 -1
  28. package/components/Toolbar/StaticToolbar.js +11 -16
  29. package/components/Toolbar/StaticToolbar.js.map +1 -1
  30. package/components/ToolbarActions/BoldAction.js +16 -19
  31. package/components/ToolbarActions/BoldAction.js.map +1 -1
  32. package/components/ToolbarActions/BulletListAction.js +24 -32
  33. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  34. package/components/ToolbarActions/CodeHighlightAction.js +16 -19
  35. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  36. package/components/ToolbarActions/FontColorAction.js +32 -38
  37. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  38. package/components/ToolbarActions/ImageAction.js +28 -30
  39. package/components/ToolbarActions/ImageAction.js.map +1 -1
  40. package/components/ToolbarActions/ItalicAction.js +16 -19
  41. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  42. package/components/ToolbarActions/LinkAction.js +25 -30
  43. package/components/ToolbarActions/LinkAction.js.map +1 -1
  44. package/components/ToolbarActions/NumberedListAction.js +28 -37
  45. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  46. package/components/ToolbarActions/QuoteAction.js +22 -27
  47. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  48. package/components/ToolbarActions/TextAlignmentAction.js +38 -50
  49. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  50. package/components/ToolbarActions/TypographyAction.js +69 -99
  51. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  52. package/components/ToolbarActions/UnderlineAction.js +16 -19
  53. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  54. package/context/FontColorActionContext.js +3 -2
  55. package/context/FontColorActionContext.js.map +1 -1
  56. package/context/RichTextEditorContext.js +26 -29
  57. package/context/RichTextEditorContext.js.map +1 -1
  58. package/context/SharedHistoryContext.js +11 -15
  59. package/context/SharedHistoryContext.js.map +1 -1
  60. package/context/TextAlignmentActionContextProps.js +3 -2
  61. package/context/TextAlignmentActionContextProps.js.map +1 -1
  62. package/context/TypographyActionContext.js +3 -2
  63. package/context/TypographyActionContext.js.map +1 -1
  64. package/exports/admin/lexical.js +2 -20
  65. package/hooks/index.js +0 -2
  66. package/hooks/useCurrentElement.js +18 -21
  67. package/hooks/useCurrentElement.js.map +1 -1
  68. package/hooks/useCurrentSelection.js +39 -48
  69. package/hooks/useCurrentSelection.js.map +1 -1
  70. package/hooks/useFontColorPicker.js +5 -6
  71. package/hooks/useFontColorPicker.js.map +1 -1
  72. package/hooks/useIsMounted.js +7 -8
  73. package/hooks/useIsMounted.js.map +1 -1
  74. package/hooks/useRichTextEditor.js +5 -6
  75. package/hooks/useRichTextEditor.js.map +1 -1
  76. package/hooks/useTextAlignmentAction.js +5 -6
  77. package/hooks/useTextAlignmentAction.js.map +1 -1
  78. package/hooks/useTypographyAction.js +5 -6
  79. package/hooks/useTypographyAction.js.map +1 -1
  80. package/images/icons/chat-square-quote.js +19 -0
  81. package/images/icons/chat-square-quote.js.map +1 -0
  82. package/images/icons/chevron-down.js +18 -0
  83. package/images/icons/chevron-down.js.map +1 -0
  84. package/images/icons/code.js +17 -0
  85. package/images/icons/code.js.map +1 -0
  86. package/images/icons/font-color.js +17 -0
  87. package/images/icons/font-color.js.map +1 -0
  88. package/images/icons/indent.js +18 -0
  89. package/images/icons/indent.js.map +1 -0
  90. package/images/icons/insert-image.js +20 -0
  91. package/images/icons/insert-image.js.map +1 -0
  92. package/images/icons/justify.js +19 -0
  93. package/images/icons/justify.js.map +1 -0
  94. package/images/icons/link.js +19 -0
  95. package/images/icons/link.js.map +1 -0
  96. package/images/icons/list-ol.js +20 -0
  97. package/images/icons/list-ol.js.map +1 -0
  98. package/images/icons/list-ul.js +18 -0
  99. package/images/icons/list-ul.js.map +1 -0
  100. package/images/icons/outdent.js +18 -0
  101. package/images/icons/outdent.js.map +1 -0
  102. package/images/icons/pencil-fill.js +17 -0
  103. package/images/icons/pencil-fill.js.map +1 -0
  104. package/images/icons/text-center.js +18 -0
  105. package/images/icons/text-center.js.map +1 -0
  106. package/images/icons/text-left.js +18 -0
  107. package/images/icons/text-left.js.map +1 -0
  108. package/images/icons/text-paragraph.js +18 -0
  109. package/images/icons/text-paragraph.js.map +1 -0
  110. package/images/icons/text-right.js +18 -0
  111. package/images/icons/text-right.js.map +1 -0
  112. package/images/icons/type-bold.js +17 -0
  113. package/images/icons/type-bold.js.map +1 -0
  114. package/images/icons/type-h1.js +17 -0
  115. package/images/icons/type-h1.js.map +1 -0
  116. package/images/icons/type-h2.js +17 -0
  117. package/images/icons/type-h2.js.map +1 -0
  118. package/images/icons/type-h3.js +17 -0
  119. package/images/icons/type-h3.js.map +1 -0
  120. package/images/icons/type-h4.js +17 -0
  121. package/images/icons/type-h4.js.map +1 -0
  122. package/images/icons/type-h5.js +17 -0
  123. package/images/icons/type-h5.js.map +1 -0
  124. package/images/icons/type-h6.js +17 -0
  125. package/images/icons/type-h6.js.map +1 -0
  126. package/images/icons/type-italic.js +17 -0
  127. package/images/icons/type-italic.js.map +1 -0
  128. package/images/icons/type-strikethrough.js +17 -0
  129. package/images/icons/type-strikethrough.js.map +1 -0
  130. package/images/icons/type-underline.js +17 -0
  131. package/images/icons/type-underline.js.map +1 -0
  132. package/images/icons/unlink_icon.js +27 -0
  133. package/images/icons/unlink_icon.js.map +1 -0
  134. package/index.js +5 -18
  135. package/package.json +7 -7
  136. package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
  137. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  138. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
  139. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  140. package/plugins/CodeHighlightPlugin/index.js +0 -2
  141. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
  142. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
  143. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
  144. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
  145. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
  146. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  147. package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
  148. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
  149. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  150. package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
  151. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
  152. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  153. package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
  154. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  155. package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
  156. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
  157. package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
  158. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
  159. package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
  160. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  161. package/plugins/LinkPlugin/LinkPlugin.js +46 -52
  162. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  163. package/plugins/ListPLugin/ListPlugin.js +44 -52
  164. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  165. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
  166. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  167. package/plugins/StateHandlingPlugin.js +55 -64
  168. package/plugins/StateHandlingPlugin.js.map +1 -1
  169. package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
  170. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  171. package/static/svg/chat-square-quote.123cfa24.svg +1 -0
  172. package/static/svg/chevron-down.d9636921.svg +1 -0
  173. package/static/svg/code.912b1f4d.svg +1 -0
  174. package/static/svg/font-color.4f0c0de5.svg +1 -0
  175. package/static/svg/indent.4d78e483.svg +3 -0
  176. package/static/svg/insert-image.354465f1.svg +4 -0
  177. package/static/svg/justify.dab42aec.svg +3 -0
  178. package/static/svg/link.b774de25.svg +1 -0
  179. package/static/svg/list-ol.d64946f3.svg +1 -0
  180. package/static/svg/list-ul.1d54da3f.svg +1 -0
  181. package/static/svg/outdent.5c13ff16.svg +3 -0
  182. package/static/svg/pencil-fill.94cb216b.svg +1 -0
  183. package/static/svg/text-center.a411e780.svg +1 -0
  184. package/static/svg/text-left.54f41f4e.svg +1 -0
  185. package/static/svg/text-paragraph.61674422.svg +1 -0
  186. package/static/svg/text-right.9288b7a2.svg +1 -0
  187. package/static/svg/type-bold.7e3e270b.svg +1 -0
  188. package/static/svg/type-h1.f292ffe1.svg +1 -0
  189. package/static/svg/type-h2.a9d1aa48.svg +1 -0
  190. package/static/svg/type-h3.4a29ff88.svg +1 -0
  191. package/static/svg/type-h4.7f48750c.svg +1 -0
  192. package/static/svg/type-h5.14b4ac56.svg +1 -0
  193. package/static/svg/type-h6.4e9dfe2d.svg +1 -0
  194. package/static/svg/type-italic.d8e45748.svg +1 -0
  195. package/static/svg/type-strikethrough.2694a816.svg +1 -0
  196. package/static/svg/type-underline.104a0ed5.svg +1 -0
  197. package/static/svg/unlink_icon.074ceed3.svg +1 -0
  198. package/types.js +0 -8
  199. package/ui/ContentEditable.js +6 -14
  200. package/ui/ContentEditable.js.map +1 -1
  201. package/ui/Divider.js +6 -5
  202. package/ui/Divider.js.map +1 -1
  203. package/ui/DropDown.js +146 -176
  204. package/ui/DropDown.js.map +1 -1
  205. package/ui/ImageResizer.js +173 -204
  206. package/ui/ImageResizer.js.map +1 -1
  207. package/ui/LinkPreview.js +61 -84
  208. package/ui/LinkPreview.js.map +1 -1
  209. package/ui/Placeholder.js +9 -20
  210. package/ui/Placeholder.js.map +1 -1
  211. package/ui/TextInput.js +17 -30
  212. package/ui/TextInput.js.map +1 -1
  213. package/ui/ToolbarActionDialog.js +64 -73
  214. package/ui/ToolbarActionDialog.js.map +1 -1
  215. package/utils/canUseDOM.js +2 -1
  216. package/utils/canUseDOM.js.map +1 -1
  217. package/utils/files.js +9 -8
  218. package/utils/files.js.map +1 -1
  219. package/utils/getDOMRangeRect.js +10 -20
  220. package/utils/getDOMRangeRect.js.map +1 -1
  221. package/utils/getSelectedNode.js +9 -20
  222. package/utils/getSelectedNode.js.map +1 -1
  223. package/utils/getTransparentImage.js +2 -3
  224. package/utils/getTransparentImage.js.map +1 -1
  225. package/utils/insertImage.js +9 -11
  226. package/utils/insertImage.js.map +1 -1
  227. package/utils/isAnchorLink.js +2 -3
  228. package/utils/isAnchorLink.js.map +1 -1
  229. package/utils/isChildOfFloatingToolbar.js +6 -9
  230. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  231. package/utils/isHTMLElement.js +3 -9
  232. package/utils/isHTMLElement.js.map +1 -1
  233. package/utils/isValidJSON.js +9 -10
  234. package/utils/isValidJSON.js.map +1 -1
  235. package/utils/isValidLexicalData.js +17 -20
  236. package/utils/isValidLexicalData.js.map +1 -1
  237. package/utils/point.js +32 -45
  238. package/utils/point.js.map +1 -1
  239. package/utils/rect.js +92 -125
  240. package/utils/rect.js.map +1 -1
  241. package/utils/sanitizeUrl.js +8 -21
  242. package/utils/sanitizeUrl.js.map +1 -1
  243. package/utils/setFloatingElemPosition.js +23 -27
  244. package/utils/setFloatingElemPosition.js.map +1 -1
  245. package/commands/index.js.map +0 -1
  246. package/exports/admin/lexical.js.map +0 -1
  247. package/hooks/index.js.map +0 -1
  248. package/index.js.map +0 -1
  249. package/plugins/CodeHighlightPlugin/index.js.map +0 -1
  250. package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
  251. package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
  252. package/types.js.map +0 -1
@@ -1,211 +1,180 @@
1
- /**
2
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- *
7
- */
8
-
9
- import * as React from "react";
10
- import { useRef } from "react";
1
+ import * as __rspack_external_react from "react";
11
2
  function clamp(value, min, max) {
12
- return Math.min(Math.max(value, min), max);
3
+ return Math.min(Math.max(value, min), max);
13
4
  }
14
5
  const Direction = {
15
- east: 1 << 0,
16
- north: 1 << 3,
17
- south: 1 << 1,
18
- west: 1 << 2
6
+ east: 1,
7
+ north: 8,
8
+ south: 2,
9
+ west: 4
19
10
  };
20
- export function ImageResizer({
21
- onResizeStart,
22
- onResizeEnd,
23
- buttonRef,
24
- imageRef,
25
- maxWidth,
26
- editor,
27
- showCaption,
28
- setShowCaption,
29
- captionsEnabled
30
- }) {
31
- const controlWrapperRef = useRef(null);
32
- const userSelect = useRef({
33
- priority: "",
34
- value: "default"
35
- });
36
- const positioningRef = useRef({
37
- currentHeight: 0,
38
- currentWidth: 0,
39
- direction: 0,
40
- isResizing: false,
41
- ratio: 0,
42
- startHeight: 0,
43
- startWidth: 0,
44
- startX: 0,
45
- startY: 0
46
- });
47
- const editorRootElement = editor.getRootElement();
48
- // Find max width, accounting for editor padding.
49
- const maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
50
- const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
51
- const minWidth = 100;
52
- const minHeight = 100;
53
- const setStartCursor = direction => {
54
- const ew = direction === Direction.east || direction === Direction.west;
55
- const ns = direction === Direction.north || direction === Direction.south;
56
- const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
57
- const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
58
- if (editorRootElement !== null) {
59
- editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
60
- }
61
- if (document.body !== null) {
62
- document.body.style.setProperty("cursor", `${cursorDir}-resize`, "important");
63
- userSelect.current.value = document.body.style.getPropertyValue("-webkit-user-select");
64
- userSelect.current.priority = document.body.style.getPropertyPriority("-webkit-user-select");
65
- document.body.style.setProperty("-webkit-user-select", `none`, "important");
66
- }
67
- };
68
- const setEndCursor = () => {
69
- if (editorRootElement !== null) {
70
- editorRootElement.style.setProperty("cursor", "text");
71
- }
72
- if (document.body !== null) {
73
- document.body.style.setProperty("cursor", "default");
74
- document.body.style.setProperty("-webkit-user-select", userSelect.current.value, userSelect.current.priority);
75
- }
76
- };
77
- const handlePointerDown = (event, direction) => {
78
- if (!editor.isEditable()) {
79
- return;
80
- }
81
- const image = imageRef.current;
82
- const controlWrapper = controlWrapperRef.current;
83
- if (image !== null && controlWrapper !== null) {
84
- const {
85
- width,
86
- height
87
- } = image.getBoundingClientRect();
88
- const positioning = positioningRef.current;
89
- positioning.startWidth = width;
90
- positioning.startHeight = height;
91
- positioning.ratio = width / height;
92
- positioning.currentWidth = width;
93
- positioning.currentHeight = height;
94
- positioning.startX = event.clientX;
95
- positioning.startY = event.clientY;
96
- positioning.isResizing = true;
97
- positioning.direction = direction;
98
- setStartCursor(direction);
99
- onResizeStart();
100
- controlWrapper.classList.add("image-control-wrapper--resizing");
101
- image.style.height = `${height}px`;
102
- image.style.width = `${width}px`;
103
- document.addEventListener("pointermove", handlePointerMove);
104
- document.addEventListener("pointerup", handlePointerUp);
105
- }
106
- };
107
- const handlePointerMove = event => {
108
- const image = imageRef.current;
109
- const positioning = positioningRef.current;
110
- const isHorizontal = positioning.direction & (Direction.east | Direction.west);
111
- const isVertical = positioning.direction & (Direction.south | Direction.north);
112
- if (image !== null && positioning.isResizing) {
113
- // Corner cursor
114
- if (isHorizontal && isVertical) {
115
- let diff = Math.floor(positioning.startX - event.clientX);
116
- diff = positioning.direction & Direction.east ? -diff : diff;
117
- const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
118
- const height = width / positioning.ratio;
119
- image.style.width = `${width}px`;
120
- image.style.height = `${height}px`;
121
- positioning.currentHeight = height;
122
- positioning.currentWidth = width;
123
- } else if (isVertical) {
124
- let diff = Math.floor(positioning.startY - event.clientY);
125
- diff = positioning.direction & Direction.south ? -diff : diff;
126
- const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
127
- image.style.height = `${height}px`;
128
- positioning.currentHeight = height;
129
- } else {
130
- let diff = Math.floor(positioning.startX - event.clientX);
131
- diff = positioning.direction & Direction.east ? -diff : diff;
132
- const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
133
- image.style.width = `${width}px`;
134
- positioning.currentWidth = width;
135
- }
136
- }
137
- };
138
- const handlePointerUp = () => {
139
- const image = imageRef.current;
140
- const positioning = positioningRef.current;
141
- const controlWrapper = controlWrapperRef.current;
142
- if (image !== null && controlWrapper !== null && positioning.isResizing) {
143
- const width = positioning.currentWidth;
144
- const height = positioning.currentHeight;
145
- positioning.startWidth = 0;
146
- positioning.startHeight = 0;
147
- positioning.ratio = 0;
148
- positioning.startX = 0;
149
- positioning.startY = 0;
150
- positioning.currentWidth = 0;
151
- positioning.currentHeight = 0;
152
- positioning.isResizing = false;
153
- controlWrapper.classList.remove("image-control-wrapper--resizing");
154
- setEndCursor();
155
- onResizeEnd(width, height);
156
- document.removeEventListener("pointermove", handlePointerMove);
157
- document.removeEventListener("pointerup", handlePointerUp);
158
- }
159
- };
160
- return /*#__PURE__*/React.createElement("div", {
161
- ref: controlWrapperRef
162
- }, !showCaption && captionsEnabled && /*#__PURE__*/React.createElement("button", {
163
- className: "image-caption-button",
164
- ref: buttonRef,
165
- onClick: () => {
166
- setShowCaption(!showCaption);
167
- }
168
- }, "Add Caption"), /*#__PURE__*/React.createElement("div", {
169
- className: "image-resizer image-resizer-n",
170
- onPointerDown: event => {
171
- handlePointerDown(event, Direction.north);
172
- }
173
- }), /*#__PURE__*/React.createElement("div", {
174
- className: "image-resizer image-resizer-ne",
175
- onPointerDown: event => {
176
- handlePointerDown(event, Direction.north | Direction.east);
177
- }
178
- }), /*#__PURE__*/React.createElement("div", {
179
- className: "image-resizer image-resizer-e",
180
- onPointerDown: event => {
181
- handlePointerDown(event, Direction.east);
182
- }
183
- }), /*#__PURE__*/React.createElement("div", {
184
- className: "image-resizer image-resizer-se",
185
- onPointerDown: event => {
186
- handlePointerDown(event, Direction.south | Direction.east);
187
- }
188
- }), /*#__PURE__*/React.createElement("div", {
189
- className: "image-resizer image-resizer-s",
190
- onPointerDown: event => {
191
- handlePointerDown(event, Direction.south);
192
- }
193
- }), /*#__PURE__*/React.createElement("div", {
194
- className: "image-resizer image-resizer-sw",
195
- onPointerDown: event => {
196
- handlePointerDown(event, Direction.south | Direction.west);
197
- }
198
- }), /*#__PURE__*/React.createElement("div", {
199
- className: "image-resizer image-resizer-w",
200
- onPointerDown: event => {
201
- handlePointerDown(event, Direction.west);
202
- }
203
- }), /*#__PURE__*/React.createElement("div", {
204
- className: "image-resizer image-resizer-nw",
205
- onPointerDown: event => {
206
- handlePointerDown(event, Direction.north | Direction.west);
207
- }
208
- }));
11
+ function ImageResizer({ onResizeStart, onResizeEnd, buttonRef, imageRef, maxWidth, editor, showCaption, setShowCaption, captionsEnabled }) {
12
+ const controlWrapperRef = (0, __rspack_external_react.useRef)(null);
13
+ const userSelect = (0, __rspack_external_react.useRef)({
14
+ priority: "",
15
+ value: "default"
16
+ });
17
+ const positioningRef = (0, __rspack_external_react.useRef)({
18
+ currentHeight: 0,
19
+ currentWidth: 0,
20
+ direction: 0,
21
+ isResizing: false,
22
+ ratio: 0,
23
+ startHeight: 0,
24
+ startWidth: 0,
25
+ startX: 0,
26
+ startY: 0
27
+ });
28
+ const editorRootElement = editor.getRootElement();
29
+ const maxWidthContainer = maxWidth ? maxWidth : null !== editorRootElement ? editorRootElement.getBoundingClientRect().width - 20 : 100;
30
+ const maxHeightContainer = null !== editorRootElement ? editorRootElement.getBoundingClientRect().height - 20 : 100;
31
+ const minWidth = 100;
32
+ const minHeight = 100;
33
+ const setStartCursor = (direction)=>{
34
+ const ew = direction === Direction.east || direction === Direction.west;
35
+ const ns = direction === Direction.north || direction === Direction.south;
36
+ const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
37
+ const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
38
+ if (null !== editorRootElement) editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
39
+ if (null !== document.body) {
40
+ document.body.style.setProperty("cursor", `${cursorDir}-resize`, "important");
41
+ userSelect.current.value = document.body.style.getPropertyValue("-webkit-user-select");
42
+ userSelect.current.priority = document.body.style.getPropertyPriority("-webkit-user-select");
43
+ document.body.style.setProperty("-webkit-user-select", "none", "important");
44
+ }
45
+ };
46
+ const setEndCursor = ()=>{
47
+ if (null !== editorRootElement) editorRootElement.style.setProperty("cursor", "text");
48
+ if (null !== document.body) {
49
+ document.body.style.setProperty("cursor", "default");
50
+ document.body.style.setProperty("-webkit-user-select", userSelect.current.value, userSelect.current.priority);
51
+ }
52
+ };
53
+ const handlePointerDown = (event, direction)=>{
54
+ if (!editor.isEditable()) return;
55
+ const image = imageRef.current;
56
+ const controlWrapper = controlWrapperRef.current;
57
+ if (null !== image && null !== controlWrapper) {
58
+ const { width, height } = image.getBoundingClientRect();
59
+ const positioning = positioningRef.current;
60
+ positioning.startWidth = width;
61
+ positioning.startHeight = height;
62
+ positioning.ratio = width / height;
63
+ positioning.currentWidth = width;
64
+ positioning.currentHeight = height;
65
+ positioning.startX = event.clientX;
66
+ positioning.startY = event.clientY;
67
+ positioning.isResizing = true;
68
+ positioning.direction = direction;
69
+ setStartCursor(direction);
70
+ onResizeStart();
71
+ controlWrapper.classList.add("image-control-wrapper--resizing");
72
+ image.style.height = `${height}px`;
73
+ image.style.width = `${width}px`;
74
+ document.addEventListener("pointermove", handlePointerMove);
75
+ document.addEventListener("pointerup", handlePointerUp);
76
+ }
77
+ };
78
+ const handlePointerMove = (event)=>{
79
+ const image = imageRef.current;
80
+ const positioning = positioningRef.current;
81
+ const isHorizontal = positioning.direction & (Direction.east | Direction.west);
82
+ const isVertical = positioning.direction & (Direction.south | Direction.north);
83
+ if (null !== image && positioning.isResizing) if (isHorizontal && isVertical) {
84
+ let diff = Math.floor(positioning.startX - event.clientX);
85
+ diff = positioning.direction & Direction.east ? -diff : diff;
86
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
87
+ const height = width / positioning.ratio;
88
+ image.style.width = `${width}px`;
89
+ image.style.height = `${height}px`;
90
+ positioning.currentHeight = height;
91
+ positioning.currentWidth = width;
92
+ } else if (isVertical) {
93
+ let diff = Math.floor(positioning.startY - event.clientY);
94
+ diff = positioning.direction & Direction.south ? -diff : diff;
95
+ const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
96
+ image.style.height = `${height}px`;
97
+ positioning.currentHeight = height;
98
+ } else {
99
+ let diff = Math.floor(positioning.startX - event.clientX);
100
+ diff = positioning.direction & Direction.east ? -diff : diff;
101
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
102
+ image.style.width = `${width}px`;
103
+ positioning.currentWidth = width;
104
+ }
105
+ };
106
+ const handlePointerUp = ()=>{
107
+ const image = imageRef.current;
108
+ const positioning = positioningRef.current;
109
+ const controlWrapper = controlWrapperRef.current;
110
+ if (null !== image && null !== controlWrapper && positioning.isResizing) {
111
+ const width = positioning.currentWidth;
112
+ const height = positioning.currentHeight;
113
+ positioning.startWidth = 0;
114
+ positioning.startHeight = 0;
115
+ positioning.ratio = 0;
116
+ positioning.startX = 0;
117
+ positioning.startY = 0;
118
+ positioning.currentWidth = 0;
119
+ positioning.currentHeight = 0;
120
+ positioning.isResizing = false;
121
+ controlWrapper.classList.remove("image-control-wrapper--resizing");
122
+ setEndCursor();
123
+ onResizeEnd(width, height);
124
+ document.removeEventListener("pointermove", handlePointerMove);
125
+ document.removeEventListener("pointerup", handlePointerUp);
126
+ }
127
+ };
128
+ return /*#__PURE__*/ __rspack_external_react.createElement("div", {
129
+ ref: controlWrapperRef
130
+ }, !showCaption && captionsEnabled && /*#__PURE__*/ __rspack_external_react.createElement("button", {
131
+ className: "image-caption-button",
132
+ ref: buttonRef,
133
+ onClick: ()=>{
134
+ setShowCaption(!showCaption);
135
+ }
136
+ }, "Add Caption"), /*#__PURE__*/ __rspack_external_react.createElement("div", {
137
+ className: "image-resizer image-resizer-n",
138
+ onPointerDown: (event)=>{
139
+ handlePointerDown(event, Direction.north);
140
+ }
141
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
142
+ className: "image-resizer image-resizer-ne",
143
+ onPointerDown: (event)=>{
144
+ handlePointerDown(event, Direction.north | Direction.east);
145
+ }
146
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
147
+ className: "image-resizer image-resizer-e",
148
+ onPointerDown: (event)=>{
149
+ handlePointerDown(event, Direction.east);
150
+ }
151
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
152
+ className: "image-resizer image-resizer-se",
153
+ onPointerDown: (event)=>{
154
+ handlePointerDown(event, Direction.south | Direction.east);
155
+ }
156
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
157
+ className: "image-resizer image-resizer-s",
158
+ onPointerDown: (event)=>{
159
+ handlePointerDown(event, Direction.south);
160
+ }
161
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
162
+ className: "image-resizer image-resizer-sw",
163
+ onPointerDown: (event)=>{
164
+ handlePointerDown(event, Direction.south | Direction.west);
165
+ }
166
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
167
+ className: "image-resizer image-resizer-w",
168
+ onPointerDown: (event)=>{
169
+ handlePointerDown(event, Direction.west);
170
+ }
171
+ }), /*#__PURE__*/ __rspack_external_react.createElement("div", {
172
+ className: "image-resizer image-resizer-nw",
173
+ onPointerDown: (event)=>{
174
+ handlePointerDown(event, Direction.north | Direction.west);
175
+ }
176
+ }));
209
177
  }
178
+ export { ImageResizer };
210
179
 
211
180
  //# sourceMappingURL=ImageResizer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","clamp","value","min","max","Math","Direction","east","north","south","west","ImageResizer","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","userSelect","priority","positioningRef","currentHeight","currentWidth","direction","isResizing","ratio","startHeight","startWidth","startX","startY","editorRootElement","getRootElement","maxWidthContainer","getBoundingClientRect","width","maxHeightContainer","height","minWidth","minHeight","setStartCursor","ew","ns","nwse","cursorDir","style","setProperty","document","body","current","getPropertyValue","getPropertyPriority","setEndCursor","handlePointerDown","event","isEditable","image","controlWrapper","positioning","clientX","clientY","classList","add","addEventListener","handlePointerMove","handlePointerUp","isHorizontal","isVertical","diff","floor","remove","removeEventListener","createElement","ref","className","onClick","onPointerDown"],"sources":["ImageResizer.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\nimport * as React from \"react\";\nimport { useRef } from \"react\";\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nconst Direction = {\n east: 1 << 0,\n north: 1 << 3,\n south: 1 << 1,\n west: 1 << 2\n};\n\nexport function ImageResizer({\n onResizeStart,\n onResizeEnd,\n buttonRef,\n imageRef,\n maxWidth,\n editor,\n showCaption,\n setShowCaption,\n captionsEnabled\n}: {\n editor: LexicalEditor;\n buttonRef: { current: null | HTMLButtonElement };\n imageRef: { current: null | HTMLElement };\n maxWidth?: number;\n onResizeEnd: (width: \"inherit\" | number, height: \"inherit\" | number) => void;\n onResizeStart: () => void;\n setShowCaption: (show: boolean) => void;\n showCaption: boolean;\n captionsEnabled: boolean;\n}): React.JSX.Element {\n const controlWrapperRef = useRef<HTMLDivElement>(null);\n const userSelect = useRef({\n priority: \"\",\n value: \"default\"\n });\n const positioningRef = useRef<{\n currentHeight: \"inherit\" | number;\n currentWidth: \"inherit\" | number;\n direction: number;\n isResizing: boolean;\n ratio: number;\n startHeight: number;\n startWidth: number;\n startX: number;\n startY: number;\n }>({\n currentHeight: 0,\n currentWidth: 0,\n direction: 0,\n isResizing: false,\n ratio: 0,\n startHeight: 0,\n startWidth: 0,\n startX: 0,\n startY: 0\n });\n const editorRootElement = editor.getRootElement();\n // Find max width, accounting for editor padding.\n const maxWidthContainer = maxWidth\n ? maxWidth\n : editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n const setStartCursor = (direction: number) => {\n const ew = direction === Direction.east || direction === Direction.west;\n const ns = direction === Direction.north || direction === Direction.south;\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n const cursorDir = ew ? \"ew\" : ns ? \"ns\" : nwse ? \"nwse\" : \"nesw\";\n\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n userSelect.current.value = document.body.style.getPropertyValue(\"-webkit-user-select\");\n userSelect.current.priority =\n document.body.style.getPropertyPriority(\"-webkit-user-select\");\n document.body.style.setProperty(\"-webkit-user-select\", `none`, \"important\");\n }\n };\n\n const setEndCursor = () => {\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", \"text\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", \"default\");\n document.body.style.setProperty(\n \"-webkit-user-select\",\n userSelect.current.value,\n userSelect.current.priority\n );\n }\n };\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>, direction: number) => {\n if (!editor.isEditable()) {\n return;\n }\n\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n if (image !== null && controlWrapper !== null) {\n const { width, height } = image.getBoundingClientRect();\n const positioning = positioningRef.current;\n positioning.startWidth = width;\n positioning.startHeight = height;\n positioning.ratio = width / height;\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n positioning.startX = event.clientX;\n positioning.startY = event.clientY;\n positioning.isResizing = true;\n positioning.direction = direction;\n\n setStartCursor(direction);\n onResizeStart();\n\n controlWrapper.classList.add(\"image-control-wrapper--resizing\");\n image.style.height = `${height}px`;\n image.style.width = `${width}px`;\n\n document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n }\n };\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n const isHorizontal = positioning.direction & (Direction.east | Direction.west);\n const isVertical = positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Corner cursor\n if (isHorizontal && isVertical) {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n const height = width / positioning.ratio;\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n let diff = Math.floor(positioning.startY - event.clientY);\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);\n\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n } else {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n image.style.width = `${width}px`;\n positioning.currentWidth = width;\n }\n }\n };\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n positioning.startWidth = 0;\n positioning.startHeight = 0;\n positioning.ratio = 0;\n positioning.startX = 0;\n positioning.startY = 0;\n positioning.currentWidth = 0;\n positioning.currentHeight = 0;\n positioning.isResizing = false;\n\n controlWrapper.classList.remove(\"image-control-wrapper--resizing\");\n\n setEndCursor();\n onResizeEnd(width, height);\n\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n }\n };\n return (\n <div ref={controlWrapperRef}>\n {!showCaption && captionsEnabled && (\n <button\n className=\"image-caption-button\"\n ref={buttonRef}\n onClick={() => {\n setShowCaption(!showCaption);\n }}\n >\n Add Caption\n </button>\n )}\n <div\n className=\"image-resizer image-resizer-n\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north);\n }}\n />\n <div\n className=\"image-resizer image-resizer-ne\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-e\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-se\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-s\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south);\n }}\n />\n <div\n className=\"image-resizer image-resizer-sw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-w\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-nw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.west);\n }}\n />\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,QAAQ,OAAO;AAE9B,SAASC,KAAKA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAE;EACpD,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACF,KAAK,EAAEC,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC9C;AAEA,MAAME,SAAS,GAAG;EACdC,IAAI,EAAE,CAAC,IAAI,CAAC;EACZC,KAAK,EAAE,CAAC,IAAI,CAAC;EACbC,KAAK,EAAE,CAAC,IAAI,CAAC;EACbC,IAAI,EAAE,CAAC,IAAI;AACf,CAAC;AAED,OAAO,SAASC,YA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+ {"version":3,"file":"ui/ImageResizer.js","sources":["../../src/ui/ImageResizer.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\nimport * as React from \"react\";\nimport { useRef } from \"react\";\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nconst Direction = {\n east: 1 << 0,\n north: 1 << 3,\n south: 1 << 1,\n west: 1 << 2\n};\n\nexport function ImageResizer({\n onResizeStart,\n onResizeEnd,\n buttonRef,\n imageRef,\n maxWidth,\n editor,\n showCaption,\n setShowCaption,\n captionsEnabled\n}: {\n editor: LexicalEditor;\n buttonRef: { current: null | HTMLButtonElement };\n imageRef: { current: null | HTMLElement };\n maxWidth?: number;\n onResizeEnd: (width: \"inherit\" | number, height: \"inherit\" | number) => void;\n onResizeStart: () => void;\n setShowCaption: (show: boolean) => void;\n showCaption: boolean;\n captionsEnabled: boolean;\n}): React.JSX.Element {\n const controlWrapperRef = useRef<HTMLDivElement>(null);\n const userSelect = useRef({\n priority: \"\",\n value: \"default\"\n });\n const positioningRef = useRef<{\n currentHeight: \"inherit\" | number;\n currentWidth: \"inherit\" | number;\n direction: number;\n isResizing: boolean;\n ratio: number;\n startHeight: number;\n startWidth: number;\n startX: number;\n startY: number;\n }>({\n currentHeight: 0,\n currentWidth: 0,\n direction: 0,\n isResizing: false,\n ratio: 0,\n startHeight: 0,\n startWidth: 0,\n startX: 0,\n startY: 0\n });\n const editorRootElement = editor.getRootElement();\n // Find max width, accounting for editor padding.\n const maxWidthContainer = maxWidth\n ? maxWidth\n : editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n const setStartCursor = (direction: number) => {\n const ew = direction === Direction.east || direction === Direction.west;\n const ns = direction === Direction.north || direction === Direction.south;\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n const cursorDir = ew ? \"ew\" : ns ? \"ns\" : nwse ? \"nwse\" : \"nesw\";\n\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n userSelect.current.value = document.body.style.getPropertyValue(\"-webkit-user-select\");\n userSelect.current.priority =\n document.body.style.getPropertyPriority(\"-webkit-user-select\");\n document.body.style.setProperty(\"-webkit-user-select\", `none`, \"important\");\n }\n };\n\n const setEndCursor = () => {\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", \"text\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", \"default\");\n document.body.style.setProperty(\n \"-webkit-user-select\",\n userSelect.current.value,\n userSelect.current.priority\n );\n }\n };\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>, direction: number) => {\n if (!editor.isEditable()) {\n return;\n }\n\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n if (image !== null && controlWrapper !== null) {\n const { width, height } = image.getBoundingClientRect();\n const positioning = positioningRef.current;\n positioning.startWidth = width;\n positioning.startHeight = height;\n positioning.ratio = width / height;\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n positioning.startX = event.clientX;\n positioning.startY = event.clientY;\n positioning.isResizing = true;\n positioning.direction = direction;\n\n setStartCursor(direction);\n onResizeStart();\n\n controlWrapper.classList.add(\"image-control-wrapper--resizing\");\n image.style.height = `${height}px`;\n image.style.width = `${width}px`;\n\n document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n }\n };\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n const isHorizontal = positioning.direction & (Direction.east | Direction.west);\n const isVertical = positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Corner cursor\n if (isHorizontal && isVertical) {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n const height = width / positioning.ratio;\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n let diff = Math.floor(positioning.startY - event.clientY);\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);\n\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n } else {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n image.style.width = `${width}px`;\n positioning.currentWidth = width;\n }\n }\n };\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n positioning.startWidth = 0;\n positioning.startHeight = 0;\n positioning.ratio = 0;\n positioning.startX = 0;\n positioning.startY = 0;\n positioning.currentWidth = 0;\n positioning.currentHeight = 0;\n positioning.isResizing = false;\n\n controlWrapper.classList.remove(\"image-control-wrapper--resizing\");\n\n setEndCursor();\n onResizeEnd(width, height);\n\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n }\n };\n return (\n <div ref={controlWrapperRef}>\n {!showCaption && captionsEnabled && (\n <button\n className=\"image-caption-button\"\n ref={buttonRef}\n onClick={() => {\n setShowCaption(!showCaption);\n }}\n >\n Add Caption\n </button>\n )}\n <div\n className=\"image-resizer image-resizer-n\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north);\n }}\n />\n <div\n className=\"image-resizer image-resizer-ne\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-e\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-se\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-s\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south);\n }}\n />\n <div\n className=\"image-resizer image-resizer-sw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-w\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-nw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.west);\n }}\n />\n </div>\n );\n}\n"],"names":["clamp","value","min","max","Math","Direction","ImageResizer","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","useRef","userSelect","positioningRef","editorRootElement","maxWidthContainer","maxHeightContainer","minWidth","minHeight","setStartCursor","direction","ew","ns","nwse","cursorDir","document","setEndCursor","handlePointerDown","event","image","controlWrapper","width","height","positioning","handlePointerMove","handlePointerUp","isHorizontal","isVertical","diff"],"mappings":";AAaA,SAASA,MAAMC,KAAa,EAAEC,GAAW,EAAEC,GAAW;IAClD,OAAOC,KAAK,GAAG,CAACA,KAAK,GAAG,CAACH,OAAOC,MAAMC;AAC1C;AAEA,MAAME,YAAY;IACd,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;AACV;AAEO,SAASC,aAAa,EACzBC,aAAa,EACbC,WAAW,EACXC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,MAAM,EACNC,WAAW,EACXC,cAAc,EACdC,eAAe,EAWlB;IACG,MAAMC,oBAAoBC,AAAAA,IAA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