@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.
- package/commands/image.js +2 -1
- package/commands/image.js.map +1 -1
- package/commands/index.js +0 -2
- package/commands/list.js +4 -3
- package/commands/list.js.map +1 -1
- package/commands/quote.js +2 -1
- package/commands/quote.js.map +1 -1
- package/commands/toolbar.js +2 -1
- package/commands/toolbar.js.map +1 -1
- package/commands/typography.js +2 -1
- package/commands/typography.js.map +1 -1
- package/components/Editor/EnsureHeadingTagPlugin.js +8 -15
- package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -1
- package/components/Editor/RichTextEditor.js +82 -121
- package/components/Editor/RichTextEditor.js.map +1 -1
- package/components/Editor/normalizeInputValue.js +11 -13
- package/components/Editor/normalizeInputValue.js.map +1 -1
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +24 -15
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
- package/components/LexicalEditorConfig/components/Node.js +21 -26
- package/components/LexicalEditorConfig/components/Node.js.map +1 -1
- package/components/LexicalEditorConfig/components/Plugin.js +21 -26
- package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
- package/components/LexicalEditorConfig/components/ToolbarElement.js +21 -26
- package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
- package/components/LexicalHtmlRenderer.js +35 -40
- package/components/LexicalHtmlRenderer.js.map +1 -1
- package/components/Toolbar/StaticToolbar.js +11 -16
- package/components/Toolbar/StaticToolbar.js.map +1 -1
- package/components/ToolbarActions/BoldAction.js +16 -19
- package/components/ToolbarActions/BoldAction.js.map +1 -1
- package/components/ToolbarActions/BulletListAction.js +24 -32
- package/components/ToolbarActions/BulletListAction.js.map +1 -1
- package/components/ToolbarActions/CodeHighlightAction.js +16 -19
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
- package/components/ToolbarActions/FontColorAction.js +32 -38
- package/components/ToolbarActions/FontColorAction.js.map +1 -1
- package/components/ToolbarActions/ImageAction.js +28 -30
- package/components/ToolbarActions/ImageAction.js.map +1 -1
- package/components/ToolbarActions/ItalicAction.js +16 -19
- package/components/ToolbarActions/ItalicAction.js.map +1 -1
- package/components/ToolbarActions/LinkAction.js +25 -30
- package/components/ToolbarActions/LinkAction.js.map +1 -1
- package/components/ToolbarActions/NumberedListAction.js +28 -37
- package/components/ToolbarActions/NumberedListAction.js.map +1 -1
- package/components/ToolbarActions/QuoteAction.js +22 -27
- package/components/ToolbarActions/QuoteAction.js.map +1 -1
- package/components/ToolbarActions/TextAlignmentAction.js +38 -50
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
- package/components/ToolbarActions/TypographyAction.js +69 -99
- package/components/ToolbarActions/TypographyAction.js.map +1 -1
- package/components/ToolbarActions/UnderlineAction.js +16 -19
- package/components/ToolbarActions/UnderlineAction.js.map +1 -1
- package/context/FontColorActionContext.js +3 -2
- package/context/FontColorActionContext.js.map +1 -1
- package/context/RichTextEditorContext.js +26 -29
- package/context/RichTextEditorContext.js.map +1 -1
- package/context/SharedHistoryContext.js +11 -15
- package/context/SharedHistoryContext.js.map +1 -1
- package/context/TextAlignmentActionContextProps.js +3 -2
- package/context/TextAlignmentActionContextProps.js.map +1 -1
- package/context/TypographyActionContext.js +3 -2
- package/context/TypographyActionContext.js.map +1 -1
- package/exports/admin/lexical.js +2 -20
- package/hooks/index.js +0 -2
- package/hooks/useCurrentElement.js +18 -21
- package/hooks/useCurrentElement.js.map +1 -1
- package/hooks/useCurrentSelection.js +39 -48
- package/hooks/useCurrentSelection.js.map +1 -1
- package/hooks/useFontColorPicker.js +5 -6
- package/hooks/useFontColorPicker.js.map +1 -1
- package/hooks/useIsMounted.js +7 -8
- package/hooks/useIsMounted.js.map +1 -1
- package/hooks/useRichTextEditor.js +5 -6
- package/hooks/useRichTextEditor.js.map +1 -1
- package/hooks/useTextAlignmentAction.js +5 -6
- package/hooks/useTextAlignmentAction.js.map +1 -1
- package/hooks/useTypographyAction.js +5 -6
- package/hooks/useTypographyAction.js.map +1 -1
- package/images/icons/chat-square-quote.js +19 -0
- package/images/icons/chat-square-quote.js.map +1 -0
- package/images/icons/chevron-down.js +18 -0
- package/images/icons/chevron-down.js.map +1 -0
- package/images/icons/code.js +17 -0
- package/images/icons/code.js.map +1 -0
- package/images/icons/font-color.js +17 -0
- package/images/icons/font-color.js.map +1 -0
- package/images/icons/indent.js +18 -0
- package/images/icons/indent.js.map +1 -0
- package/images/icons/insert-image.js +20 -0
- package/images/icons/insert-image.js.map +1 -0
- package/images/icons/justify.js +19 -0
- package/images/icons/justify.js.map +1 -0
- package/images/icons/link.js +19 -0
- package/images/icons/link.js.map +1 -0
- package/images/icons/list-ol.js +20 -0
- package/images/icons/list-ol.js.map +1 -0
- package/images/icons/list-ul.js +18 -0
- package/images/icons/list-ul.js.map +1 -0
- package/images/icons/outdent.js +18 -0
- package/images/icons/outdent.js.map +1 -0
- package/images/icons/pencil-fill.js +17 -0
- package/images/icons/pencil-fill.js.map +1 -0
- package/images/icons/text-center.js +18 -0
- package/images/icons/text-center.js.map +1 -0
- package/images/icons/text-left.js +18 -0
- package/images/icons/text-left.js.map +1 -0
- package/images/icons/text-paragraph.js +18 -0
- package/images/icons/text-paragraph.js.map +1 -0
- package/images/icons/text-right.js +18 -0
- package/images/icons/text-right.js.map +1 -0
- package/images/icons/type-bold.js +17 -0
- package/images/icons/type-bold.js.map +1 -0
- package/images/icons/type-h1.js +17 -0
- package/images/icons/type-h1.js.map +1 -0
- package/images/icons/type-h2.js +17 -0
- package/images/icons/type-h2.js.map +1 -0
- package/images/icons/type-h3.js +17 -0
- package/images/icons/type-h3.js.map +1 -0
- package/images/icons/type-h4.js +17 -0
- package/images/icons/type-h4.js.map +1 -0
- package/images/icons/type-h5.js +17 -0
- package/images/icons/type-h5.js.map +1 -0
- package/images/icons/type-h6.js +17 -0
- package/images/icons/type-h6.js.map +1 -0
- package/images/icons/type-italic.js +17 -0
- package/images/icons/type-italic.js.map +1 -0
- package/images/icons/type-strikethrough.js +17 -0
- package/images/icons/type-strikethrough.js.map +1 -0
- package/images/icons/type-underline.js +17 -0
- package/images/icons/type-underline.js.map +1 -0
- package/images/icons/unlink_icon.js +27 -0
- package/images/icons/unlink_icon.js.map +1 -0
- package/index.js +5 -18
- package/package.json +7 -7
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +11 -14
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +7 -8
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
- package/plugins/CodeHighlightPlugin/index.js +0 -2
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +16 -24
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +37 -51
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +6 -5
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/index.js +0 -2
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +6 -9
- package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
- package/plugins/FloatingLinkEditorPlugin/types.js +0 -3
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +101 -108
- package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
- package/plugins/FontColorPlugin/FontColorPlugin.js +14 -19
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToNode.js +5 -4
- package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -1
- package/plugins/FontColorPlugin/applyColorToSelection.js +42 -60
- package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -1
- package/plugins/ImagesPlugin/ImagesPlugin.js +79 -121
- package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
- package/plugins/LinkPlugin/LinkPlugin.js +46 -52
- package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
- package/plugins/ListPLugin/ListPlugin.js +44 -52
- package/plugins/ListPLugin/ListPlugin.js.map +1 -1
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -19
- package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
- package/plugins/StateHandlingPlugin.js +55 -64
- package/plugins/StateHandlingPlugin.js.map +1 -1
- package/plugins/TypographyPlugin/TypographyPlugin.js +13 -20
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
- package/static/svg/chat-square-quote.123cfa24.svg +1 -0
- package/static/svg/chevron-down.d9636921.svg +1 -0
- package/static/svg/code.912b1f4d.svg +1 -0
- package/static/svg/font-color.4f0c0de5.svg +1 -0
- package/static/svg/indent.4d78e483.svg +3 -0
- package/static/svg/insert-image.354465f1.svg +4 -0
- package/static/svg/justify.dab42aec.svg +3 -0
- package/static/svg/link.b774de25.svg +1 -0
- package/static/svg/list-ol.d64946f3.svg +1 -0
- package/static/svg/list-ul.1d54da3f.svg +1 -0
- package/static/svg/outdent.5c13ff16.svg +3 -0
- package/static/svg/pencil-fill.94cb216b.svg +1 -0
- package/static/svg/text-center.a411e780.svg +1 -0
- package/static/svg/text-left.54f41f4e.svg +1 -0
- package/static/svg/text-paragraph.61674422.svg +1 -0
- package/static/svg/text-right.9288b7a2.svg +1 -0
- package/static/svg/type-bold.7e3e270b.svg +1 -0
- package/static/svg/type-h1.f292ffe1.svg +1 -0
- package/static/svg/type-h2.a9d1aa48.svg +1 -0
- package/static/svg/type-h3.4a29ff88.svg +1 -0
- package/static/svg/type-h4.7f48750c.svg +1 -0
- package/static/svg/type-h5.14b4ac56.svg +1 -0
- package/static/svg/type-h6.4e9dfe2d.svg +1 -0
- package/static/svg/type-italic.d8e45748.svg +1 -0
- package/static/svg/type-strikethrough.2694a816.svg +1 -0
- package/static/svg/type-underline.104a0ed5.svg +1 -0
- package/static/svg/unlink_icon.074ceed3.svg +1 -0
- package/types.js +0 -8
- package/ui/ContentEditable.js +6 -14
- package/ui/ContentEditable.js.map +1 -1
- package/ui/Divider.js +6 -5
- package/ui/Divider.js.map +1 -1
- package/ui/DropDown.js +146 -176
- package/ui/DropDown.js.map +1 -1
- package/ui/ImageResizer.js +173 -204
- package/ui/ImageResizer.js.map +1 -1
- package/ui/LinkPreview.js +61 -84
- package/ui/LinkPreview.js.map +1 -1
- package/ui/Placeholder.js +9 -20
- package/ui/Placeholder.js.map +1 -1
- package/ui/TextInput.js +17 -30
- package/ui/TextInput.js.map +1 -1
- package/ui/ToolbarActionDialog.js +64 -73
- package/ui/ToolbarActionDialog.js.map +1 -1
- package/utils/canUseDOM.js +2 -1
- package/utils/canUseDOM.js.map +1 -1
- package/utils/files.js +9 -8
- package/utils/files.js.map +1 -1
- package/utils/getDOMRangeRect.js +10 -20
- package/utils/getDOMRangeRect.js.map +1 -1
- package/utils/getSelectedNode.js +9 -20
- package/utils/getSelectedNode.js.map +1 -1
- package/utils/getTransparentImage.js +2 -3
- package/utils/getTransparentImage.js.map +1 -1
- package/utils/insertImage.js +9 -11
- package/utils/insertImage.js.map +1 -1
- package/utils/isAnchorLink.js +2 -3
- package/utils/isAnchorLink.js.map +1 -1
- package/utils/isChildOfFloatingToolbar.js +6 -9
- package/utils/isChildOfFloatingToolbar.js.map +1 -1
- package/utils/isHTMLElement.js +3 -9
- package/utils/isHTMLElement.js.map +1 -1
- package/utils/isValidJSON.js +9 -10
- package/utils/isValidJSON.js.map +1 -1
- package/utils/isValidLexicalData.js +17 -20
- package/utils/isValidLexicalData.js.map +1 -1
- package/utils/point.js +32 -45
- package/utils/point.js.map +1 -1
- package/utils/rect.js +92 -125
- package/utils/rect.js.map +1 -1
- package/utils/sanitizeUrl.js +8 -21
- package/utils/sanitizeUrl.js.map +1 -1
- package/utils/setFloatingElemPosition.js +23 -27
- package/utils/setFloatingElemPosition.js.map +1 -1
- package/commands/index.js.map +0 -1
- package/exports/admin/lexical.js.map +0 -1
- package/hooks/index.js.map +0 -1
- package/index.js.map +0 -1
- package/plugins/CodeHighlightPlugin/index.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/index.js.map +0 -1
- package/plugins/FloatingLinkEditorPlugin/types.js.map +0 -1
- package/types.js.map +0 -1
package/ui/ImageResizer.js
CHANGED
|
@@ -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
|
-
|
|
3
|
+
return Math.min(Math.max(value, min), max);
|
|
13
4
|
}
|
|
14
5
|
const Direction = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
east: 1,
|
|
7
|
+
north: 8,
|
|
8
|
+
south: 2,
|
|
9
|
+
west: 4
|
|
19
10
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
image.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
package/ui/ImageResizer.js.map
CHANGED
|
@@ -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,YAAYA,CAAC;EACzBC,aAAa;EACbC,WAAW;EACXC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,WAAW;EACXC,cAAc;EACdC;AAWJ,CAAC,EAAqB;EAClB,MAAMC,iBAAiB,GAAGrB,MAAM,CAAiB,IAAI,CAAC;EACtD,MAAMsB,UAAU,GAAGtB,MAAM,CAAC;IACtBuB,QAAQ,EAAE,EAAE;IACZrB,KAAK,EAAE;EACX,CAAC,CAAC;EACF,MAAMsB,cAAc,GAAGxB,MAAM,CAU1B;IACCyB,aAAa,EAAE,CAAC;IAChBC,YAAY,EAAE,CAAC;IACfC,SAAS,EAAE,CAAC;IACZC,UAAU,EAAE,KAAK;IACjBC,KAAK,EAAE,CAAC;IACRC,WAAW,EAAE,CAAC;IACdC,UAAU,EAAE,CA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S,EAAC,+BAA+B;IACzCE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,CAAC;IAC7C;EAAE,CACL,CAAC,eACFV,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,GAAGH,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,+BAA+B;IACzCE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACI,IAAI,CAAC;IAC5C;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACE,KAAK,GAAGF,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CACA,CAAC;AAEd","ignoreList":[]}
|
|
1
|
+
{"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,IAAAA,wBAAAA,MAAAA,AAAAA,EAAuB;IACjD,MAAMC,aAAaD,AAAAA,IAAAA,wBAAAA,MAAAA,AAAAA,EAAO;QACtB,UAAU;QACV,OAAO;IACX;IACA,MAAME,iBAAiBF,AAAAA,IAAAA,wBAAAA,MAAAA,AAAAA,EAUpB;QACC,eAAe;QACf,cAAc;QACd,WAAW;QACX,YAAY;QACZ,OAAO;QACP,aAAa;QACb,YAAY;QACZ,QAAQ;QACR,QAAQ;IACZ;IACA,MAAMG,oBAAoBR,OAAO,cAAc;IAE/C,MAAMS,oBAAoBV,WACpBA,WACAS,AAAsB,SAAtBA,oBACEA,kBAAkB,qBAAqB,GAAG,KAAK,GAAG,KAClD;IACR,MAAME,qBACFF,AAAsB,SAAtBA,oBAA6BA,kBAAkB,qBAAqB,GAAG,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