@baasix/lexical 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +281 -0
- package/dist/DateTimeComponent-4MX2IKXK.css +45 -0
- package/dist/DateTimeComponent-4MX2IKXK.css.map +1 -0
- package/dist/DateTimeComponent-7V5RW3AE.js +2928 -0
- package/dist/DateTimeComponent-7V5RW3AE.js.map +1 -0
- package/dist/EquationComponent-3IW3ONJD.js +159 -0
- package/dist/EquationComponent-3IW3ONJD.js.map +1 -0
- package/dist/EquationComponent-C2C6477P.css +28 -0
- package/dist/EquationComponent-C2C6477P.css.map +1 -0
- package/dist/ExcalidrawComponent-GZYLHNOY.js +267 -0
- package/dist/ExcalidrawComponent-GZYLHNOY.js.map +1 -0
- package/dist/ExcalidrawComponent-U6BD7DUB.css +152 -0
- package/dist/ExcalidrawComponent-U6BD7DUB.css.map +1 -0
- package/dist/ImageComponent-IYUGOT6O.css +73 -0
- package/dist/ImageComponent-IYUGOT6O.css.map +1 -0
- package/dist/ImageComponent-TTUYUG3M.js +429 -0
- package/dist/ImageComponent-TTUYUG3M.js.map +1 -0
- package/dist/PollComponent-CWI5UJF5.css +187 -0
- package/dist/PollComponent-CWI5UJF5.css.map +1 -0
- package/dist/PollComponent-KLJZSW5O.js +199 -0
- package/dist/PollComponent-KLJZSW5O.js.map +1 -0
- package/dist/StickyComponent-MZSTQF47.css +774 -0
- package/dist/StickyComponent-MZSTQF47.css.map +1 -0
- package/dist/StickyComponent-ZED6LNTX.js +233 -0
- package/dist/StickyComponent-ZED6LNTX.js.map +1 -0
- package/dist/chunk-35UCX4ZT.js +168 -0
- package/dist/chunk-35UCX4ZT.js.map +1 -0
- package/dist/chunk-44LUNGL3.js +16608 -0
- package/dist/chunk-44LUNGL3.js.map +1 -0
- package/dist/chunk-BHROZTZU.js +42 -0
- package/dist/chunk-BHROZTZU.js.map +1 -0
- package/dist/chunk-FJ6COZ4H.js +275 -0
- package/dist/chunk-FJ6COZ4H.js.map +1 -0
- package/dist/chunk-GSFNU3JE.js +211 -0
- package/dist/chunk-GSFNU3JE.js.map +1 -0
- package/dist/chunk-I43VQAHW.js +918 -0
- package/dist/chunk-I43VQAHW.js.map +1 -0
- package/dist/chunk-N22RKA5D.js +402 -0
- package/dist/chunk-N22RKA5D.js.map +1 -0
- package/dist/chunk-OIMMC5C3.js +134 -0
- package/dist/chunk-OIMMC5C3.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/chunk-PZ5AY32C.js.map +1 -0
- package/dist/chunk-TVF6V3BJ.js +41 -0
- package/dist/chunk-TVF6V3BJ.js.map +1 -0
- package/dist/chunk-XTKVR2JI.js +225 -0
- package/dist/chunk-XTKVR2JI.js.map +1 -0
- package/dist/emoji-list-MUV74SND.js +8 -0
- package/dist/emoji-list-MUV74SND.js.map +1 -0
- package/dist/index.css +4234 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +16050 -0
- package/dist/index.js.map +1 -0
- package/dist/landscape-RJWVK6ET.jpg +0 -0
- package/dist/yellow-flower-R72KOP74.jpg +0 -0
- package/package.json +76 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* src/nodes/ImageNode.css */
|
|
2
|
+
.ImageNode__contentEditable {
|
|
3
|
+
min-height: 20px;
|
|
4
|
+
border: 0px;
|
|
5
|
+
resize: none;
|
|
6
|
+
cursor: text;
|
|
7
|
+
caret-color: rgb(5, 5, 5);
|
|
8
|
+
display: block;
|
|
9
|
+
position: relative;
|
|
10
|
+
outline: 0px;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
user-select: text;
|
|
13
|
+
font-size: 12px;
|
|
14
|
+
width: 100%;
|
|
15
|
+
white-space: pre-wrap;
|
|
16
|
+
word-break: break-word;
|
|
17
|
+
overflow-wrap: break-word;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
}
|
|
20
|
+
.ImageNode__placeholder {
|
|
21
|
+
font-size: 12px;
|
|
22
|
+
color: #888;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
position: absolute;
|
|
25
|
+
text-overflow: ellipsis;
|
|
26
|
+
top: 10px;
|
|
27
|
+
left: 10px;
|
|
28
|
+
user-select: none;
|
|
29
|
+
white-space: nowrap;
|
|
30
|
+
display: inline-block;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
}
|
|
33
|
+
.image-control-wrapper--resizing {
|
|
34
|
+
touch-action: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* src/ui/ContentEditable.css */
|
|
38
|
+
.ContentEditable__root {
|
|
39
|
+
border: 0;
|
|
40
|
+
font-size: 15px;
|
|
41
|
+
display: block;
|
|
42
|
+
position: relative;
|
|
43
|
+
outline: 0;
|
|
44
|
+
padding: 8px 46px 40px;
|
|
45
|
+
min-height: 150px;
|
|
46
|
+
}
|
|
47
|
+
@media (max-width: 1025px) {
|
|
48
|
+
.ContentEditable__root {
|
|
49
|
+
padding-left: 8px;
|
|
50
|
+
padding-right: 8px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
.ContentEditable__placeholder {
|
|
54
|
+
font-size: 15px;
|
|
55
|
+
color: #999;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
position: absolute;
|
|
58
|
+
text-overflow: ellipsis;
|
|
59
|
+
top: 8px;
|
|
60
|
+
left: 46px;
|
|
61
|
+
right: 28px;
|
|
62
|
+
user-select: none;
|
|
63
|
+
white-space: nowrap;
|
|
64
|
+
display: inline-block;
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
}
|
|
67
|
+
@media (max-width: 1025px) {
|
|
68
|
+
.ContentEditable__placeholder {
|
|
69
|
+
left: 8px;
|
|
70
|
+
right: 8px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/*# sourceMappingURL=ImageComponent-IYUGOT6O.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nodes/ImageNode.css","../src/ui/ContentEditable.css"],"sourcesContent":["/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n *\r\n */\r\n\r\n.ImageNode__contentEditable {\r\n min-height: 20px;\r\n border: 0px;\r\n resize: none;\r\n cursor: text;\r\n caret-color: rgb(5, 5, 5);\r\n display: block;\r\n position: relative;\r\n outline: 0px;\r\n padding: 10px;\r\n user-select: text;\r\n font-size: 12px;\r\n width: 100%;\r\n white-space: pre-wrap;\r\n word-break: break-word;\r\n overflow-wrap: break-word;\r\n box-sizing: border-box;\r\n}\r\n\r\n.ImageNode__placeholder {\r\n font-size: 12px;\r\n color: #888;\r\n overflow: hidden;\r\n position: absolute;\r\n text-overflow: ellipsis;\r\n top: 10px;\r\n left: 10px;\r\n user-select: none;\r\n white-space: nowrap;\r\n display: inline-block;\r\n pointer-events: none;\r\n}\r\n\r\n.image-control-wrapper--resizing {\r\n touch-action: none;\r\n}\r\n","/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n *\r\n */\r\n.ContentEditable__root {\r\n border: 0;\r\n font-size: 15px;\r\n display: block;\r\n position: relative;\r\n outline: 0;\r\n padding: 8px 46px 40px;\r\n min-height: 150px;\r\n}\r\n@media (max-width: 1025px) {\r\n .ContentEditable__root {\r\n padding-left: 8px;\r\n padding-right: 8px;\r\n }\r\n}\r\n\r\n.ContentEditable__placeholder {\r\n font-size: 15px;\r\n color: #999;\r\n overflow: hidden;\r\n position: absolute;\r\n text-overflow: ellipsis;\r\n top: 8px;\r\n left: 46px;\r\n right: 28px;\r\n user-select: none;\r\n white-space: nowrap;\r\n display: inline-block;\r\n pointer-events: none;\r\n}\r\n@media (max-width: 1025px) {\r\n .ContentEditable__placeholder {\r\n left: 8px;\r\n right: 8px;\r\n }\r\n}\r\n"],"mappings":";AASA,CAAC;AACC,cAAY;AACZ,UAAQ;AACR,UAAQ;AACR,UAAQ;AACR,eAAa,IAAI,CAAC,EAAE,CAAC,EAAE;AACvB,WAAS;AACT,YAAU;AACV,WAAS;AACT,WAAS;AACT,eAAa;AACb,aAAW;AACX,SAAO;AACP,eAAa;AACb,cAAY;AACZ,iBAAe;AACf,cAAY;AACd;AAEA,CAAC;AACC,aAAW;AACX,SAAO;AACP,YAAU;AACV,YAAU;AACV,iBAAe;AACf,OAAK;AACL,QAAM;AACN,eAAa;AACb,eAAa;AACb,WAAS;AACT,kBAAgB;AAClB;AAEA,CAAC;AACC,gBAAc;AAChB;;;ACpCA,CAAC;AACC,UAAQ;AACR,aAAW;AACX,WAAS;AACT,YAAU;AACV,WAAS;AACT,WAAS,IAAI,KAAK;AAClB,cAAY;AACd;AACA,QAAO,WAAY;AACjB,GAVD;AAWG,kBAAc;AACd,mBAAe;AACjB;AACF;AAEA,CAAC;AACC,aAAW;AACX,SAAO;AACP,YAAU;AACV,YAAU;AACV,iBAAe;AACf,OAAK;AACL,QAAM;AACN,SAAO;AACP,eAAa;AACb,eAAa;AACb,WAAS;AACT,kBAAgB;AAClB;AACA,QAAO,WAAY;AACjB,GAfD;AAgBG,UAAM;AACN,WAAO;AACT;AACF;","names":[]}
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$isCaptionEditorEmpty,
|
|
3
|
+
$isImageNode,
|
|
4
|
+
EmojisPlugin,
|
|
5
|
+
KeywordsPlugin,
|
|
6
|
+
LinkPlugin,
|
|
7
|
+
NewMentionsPlugin,
|
|
8
|
+
TreeViewPlugin,
|
|
9
|
+
useSettings
|
|
10
|
+
} from "./chunk-I43VQAHW.js";
|
|
11
|
+
import {
|
|
12
|
+
ImageResizer
|
|
13
|
+
} from "./chunk-FJ6COZ4H.js";
|
|
14
|
+
import {
|
|
15
|
+
LexicalContentEditable,
|
|
16
|
+
useSharedHistoryContext
|
|
17
|
+
} from "./chunk-BHROZTZU.js";
|
|
18
|
+
import "./chunk-PZ5AY32C.js";
|
|
19
|
+
|
|
20
|
+
// src/nodes/ImageComponent.tsx
|
|
21
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
22
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
23
|
+
import { HashtagPlugin } from "@lexical/react/LexicalHashtagPlugin";
|
|
24
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
25
|
+
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
26
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
27
|
+
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
28
|
+
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
29
|
+
import { mergeRegister } from "@lexical/utils";
|
|
30
|
+
import {
|
|
31
|
+
$getNodeByKey,
|
|
32
|
+
$getRoot,
|
|
33
|
+
$getSelection,
|
|
34
|
+
$isNodeSelection,
|
|
35
|
+
$isRangeSelection,
|
|
36
|
+
$setSelection,
|
|
37
|
+
BLUR_COMMAND,
|
|
38
|
+
CLICK_COMMAND,
|
|
39
|
+
COMMAND_PRIORITY_EDITOR,
|
|
40
|
+
COMMAND_PRIORITY_LOW,
|
|
41
|
+
createCommand,
|
|
42
|
+
DRAGSTART_COMMAND,
|
|
43
|
+
KEY_ENTER_COMMAND,
|
|
44
|
+
KEY_ESCAPE_COMMAND,
|
|
45
|
+
SELECTION_CHANGE_COMMAND
|
|
46
|
+
} from "lexical";
|
|
47
|
+
import {
|
|
48
|
+
Suspense,
|
|
49
|
+
useCallback,
|
|
50
|
+
useEffect,
|
|
51
|
+
useMemo,
|
|
52
|
+
useRef,
|
|
53
|
+
useState
|
|
54
|
+
} from "react";
|
|
55
|
+
|
|
56
|
+
// src/images/image-broken.svg
|
|
57
|
+
var image_broken_default = 'data:image/svg+xml,<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->%0D%0A<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">%0D%0A <path d="M22 3H2v18h20v-2h-2v-2h2v-2h-2v-2h2v-2h-2V9h2V7h-2V5h2V3zm-2 4v2h-2v2h2v2h-2v2h2v2h-2v2H4V5h14v2h2zm-6 2h-2v2h-2v2H8v2H6v2h2v-2h2v-2h2v-2h2v2h2v-2h-2V9zM6 7h2v2H6V7z" fill="%23000000"/>%0D%0A</svg>';
|
|
58
|
+
|
|
59
|
+
// src/nodes/ImageComponent.tsx
|
|
60
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
61
|
+
var brokenImage = typeof image_broken_default === "string" ? image_broken_default : image_broken_default.src;
|
|
62
|
+
var imageCache = /* @__PURE__ */ new Map();
|
|
63
|
+
var RIGHT_CLICK_IMAGE_COMMAND = createCommand("RIGHT_CLICK_IMAGE_COMMAND");
|
|
64
|
+
function DisableCaptionOnBlur({
|
|
65
|
+
setShowCaption
|
|
66
|
+
}) {
|
|
67
|
+
const [editor] = useLexicalComposerContext();
|
|
68
|
+
useEffect(
|
|
69
|
+
() => editor.registerCommand(
|
|
70
|
+
BLUR_COMMAND,
|
|
71
|
+
() => {
|
|
72
|
+
if ($isCaptionEditorEmpty()) {
|
|
73
|
+
setShowCaption(false);
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
},
|
|
77
|
+
COMMAND_PRIORITY_EDITOR
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
function useSuspenseImage(src) {
|
|
83
|
+
let cached = imageCache.get(src);
|
|
84
|
+
if (cached && "error" in cached && typeof cached.error === "boolean") {
|
|
85
|
+
return cached;
|
|
86
|
+
} else if (!cached) {
|
|
87
|
+
cached = new Promise((resolve) => {
|
|
88
|
+
const img = new Image();
|
|
89
|
+
img.src = src;
|
|
90
|
+
img.onload = () => resolve({
|
|
91
|
+
error: false,
|
|
92
|
+
height: img.naturalHeight,
|
|
93
|
+
width: img.naturalWidth
|
|
94
|
+
});
|
|
95
|
+
img.onerror = () => resolve({ error: true });
|
|
96
|
+
}).then((rval) => {
|
|
97
|
+
imageCache.set(src, rval);
|
|
98
|
+
return rval;
|
|
99
|
+
});
|
|
100
|
+
imageCache.set(src, cached);
|
|
101
|
+
throw cached;
|
|
102
|
+
}
|
|
103
|
+
throw cached;
|
|
104
|
+
}
|
|
105
|
+
function isSVG(src) {
|
|
106
|
+
return src.toLowerCase().endsWith(".svg");
|
|
107
|
+
}
|
|
108
|
+
function LazyImage({
|
|
109
|
+
altText,
|
|
110
|
+
className,
|
|
111
|
+
imageRef,
|
|
112
|
+
src,
|
|
113
|
+
width,
|
|
114
|
+
height,
|
|
115
|
+
maxWidth,
|
|
116
|
+
onError
|
|
117
|
+
}) {
|
|
118
|
+
const isSVGImage = isSVG(src);
|
|
119
|
+
const status = useSuspenseImage(src);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (status.error) {
|
|
122
|
+
onError();
|
|
123
|
+
}
|
|
124
|
+
}, [status.error, onError]);
|
|
125
|
+
if (status.error) {
|
|
126
|
+
return /* @__PURE__ */ jsx(BrokenImage, {});
|
|
127
|
+
}
|
|
128
|
+
const calculateDimensions = () => {
|
|
129
|
+
if (!isSVGImage) {
|
|
130
|
+
return {
|
|
131
|
+
height,
|
|
132
|
+
maxWidth,
|
|
133
|
+
width
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const naturalWidth = status.width;
|
|
137
|
+
const naturalHeight = status.height;
|
|
138
|
+
let finalWidth = naturalWidth;
|
|
139
|
+
let finalHeight = naturalHeight;
|
|
140
|
+
if (finalWidth > maxWidth) {
|
|
141
|
+
const scale = maxWidth / finalWidth;
|
|
142
|
+
finalWidth = maxWidth;
|
|
143
|
+
finalHeight = Math.round(finalHeight * scale);
|
|
144
|
+
}
|
|
145
|
+
const maxHeight = 500;
|
|
146
|
+
if (finalHeight > maxHeight) {
|
|
147
|
+
const scale = maxHeight / finalHeight;
|
|
148
|
+
finalHeight = maxHeight;
|
|
149
|
+
finalWidth = Math.round(finalWidth * scale);
|
|
150
|
+
}
|
|
151
|
+
return {
|
|
152
|
+
height: finalHeight,
|
|
153
|
+
maxWidth,
|
|
154
|
+
width: finalWidth
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
const imageStyle = calculateDimensions();
|
|
158
|
+
return /* @__PURE__ */ jsx(
|
|
159
|
+
"img",
|
|
160
|
+
{
|
|
161
|
+
className: className || void 0,
|
|
162
|
+
src,
|
|
163
|
+
alt: altText,
|
|
164
|
+
ref: imageRef,
|
|
165
|
+
style: imageStyle,
|
|
166
|
+
onError,
|
|
167
|
+
draggable: "false"
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
function BrokenImage() {
|
|
172
|
+
return /* @__PURE__ */ jsx(
|
|
173
|
+
"img",
|
|
174
|
+
{
|
|
175
|
+
src: brokenImage,
|
|
176
|
+
style: {
|
|
177
|
+
height: 200,
|
|
178
|
+
opacity: 0.2,
|
|
179
|
+
width: 200
|
|
180
|
+
},
|
|
181
|
+
draggable: "false",
|
|
182
|
+
alt: "Broken image"
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function noop() {
|
|
187
|
+
}
|
|
188
|
+
function ImageComponent({
|
|
189
|
+
src,
|
|
190
|
+
altText,
|
|
191
|
+
nodeKey,
|
|
192
|
+
width,
|
|
193
|
+
height,
|
|
194
|
+
maxWidth,
|
|
195
|
+
resizable,
|
|
196
|
+
showCaption,
|
|
197
|
+
caption,
|
|
198
|
+
captionsEnabled
|
|
199
|
+
}) {
|
|
200
|
+
const imageRef = useRef(null);
|
|
201
|
+
const buttonRef = useRef(null);
|
|
202
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
203
|
+
const [isResizing, setIsResizing] = useState(false);
|
|
204
|
+
const [editor] = useLexicalComposerContext();
|
|
205
|
+
const activeEditorRef = useRef(null);
|
|
206
|
+
const [isLoadError, setIsLoadError] = useState(false);
|
|
207
|
+
const isEditable = useLexicalEditable();
|
|
208
|
+
const isInNodeSelection = useMemo(
|
|
209
|
+
() => isSelected && editor.getEditorState().read(() => {
|
|
210
|
+
const selection = $getSelection();
|
|
211
|
+
return $isNodeSelection(selection) && selection.has(nodeKey);
|
|
212
|
+
}),
|
|
213
|
+
[editor, isSelected, nodeKey]
|
|
214
|
+
);
|
|
215
|
+
const $onEnter = useCallback(
|
|
216
|
+
(event) => {
|
|
217
|
+
const latestSelection = $getSelection();
|
|
218
|
+
const buttonElem = buttonRef.current;
|
|
219
|
+
if ($isNodeSelection(latestSelection) && latestSelection.has(nodeKey) && latestSelection.getNodes().length === 1) {
|
|
220
|
+
if (showCaption) {
|
|
221
|
+
$setSelection(null);
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
caption.focus();
|
|
224
|
+
return true;
|
|
225
|
+
} else if (buttonElem !== null && buttonElem !== document.activeElement) {
|
|
226
|
+
event.preventDefault();
|
|
227
|
+
buttonElem.focus();
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return false;
|
|
232
|
+
},
|
|
233
|
+
[caption, nodeKey, showCaption]
|
|
234
|
+
);
|
|
235
|
+
const $onEscape = useCallback(
|
|
236
|
+
(event) => {
|
|
237
|
+
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
238
|
+
$setSelection(null);
|
|
239
|
+
editor.update(() => {
|
|
240
|
+
setSelected(true);
|
|
241
|
+
const parentRootElement = editor.getRootElement();
|
|
242
|
+
if (parentRootElement !== null) {
|
|
243
|
+
parentRootElement.focus();
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
},
|
|
250
|
+
[caption, editor, setSelected]
|
|
251
|
+
);
|
|
252
|
+
const onClick = useCallback(
|
|
253
|
+
(payload) => {
|
|
254
|
+
const event = payload;
|
|
255
|
+
if (isResizing) {
|
|
256
|
+
return true;
|
|
257
|
+
}
|
|
258
|
+
if (event.target === imageRef.current) {
|
|
259
|
+
if (event.shiftKey) {
|
|
260
|
+
setSelected(!isSelected);
|
|
261
|
+
} else {
|
|
262
|
+
clearSelection();
|
|
263
|
+
setSelected(true);
|
|
264
|
+
}
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
},
|
|
269
|
+
[isResizing, isSelected, setSelected, clearSelection]
|
|
270
|
+
);
|
|
271
|
+
const onRightClick = useCallback(
|
|
272
|
+
(event) => {
|
|
273
|
+
editor.getEditorState().read(() => {
|
|
274
|
+
const latestSelection = $getSelection();
|
|
275
|
+
const domElement = event.target;
|
|
276
|
+
if (domElement.tagName === "IMG" && $isRangeSelection(latestSelection) && latestSelection.getNodes().length === 1) {
|
|
277
|
+
editor.dispatchCommand(RIGHT_CLICK_IMAGE_COMMAND, event);
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
},
|
|
281
|
+
[editor]
|
|
282
|
+
);
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
return mergeRegister(
|
|
285
|
+
editor.registerCommand(
|
|
286
|
+
SELECTION_CHANGE_COMMAND,
|
|
287
|
+
(_, activeEditor) => {
|
|
288
|
+
activeEditorRef.current = activeEditor;
|
|
289
|
+
return false;
|
|
290
|
+
},
|
|
291
|
+
COMMAND_PRIORITY_LOW
|
|
292
|
+
),
|
|
293
|
+
editor.registerCommand(
|
|
294
|
+
DRAGSTART_COMMAND,
|
|
295
|
+
(event) => {
|
|
296
|
+
if (event.target === imageRef.current) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
return false;
|
|
301
|
+
},
|
|
302
|
+
COMMAND_PRIORITY_LOW
|
|
303
|
+
)
|
|
304
|
+
);
|
|
305
|
+
}, [editor]);
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
let rootCleanup = noop;
|
|
308
|
+
return mergeRegister(
|
|
309
|
+
editor.registerCommand(
|
|
310
|
+
CLICK_COMMAND,
|
|
311
|
+
onClick,
|
|
312
|
+
COMMAND_PRIORITY_LOW
|
|
313
|
+
),
|
|
314
|
+
editor.registerCommand(
|
|
315
|
+
RIGHT_CLICK_IMAGE_COMMAND,
|
|
316
|
+
onClick,
|
|
317
|
+
COMMAND_PRIORITY_LOW
|
|
318
|
+
),
|
|
319
|
+
editor.registerCommand(KEY_ENTER_COMMAND, $onEnter, COMMAND_PRIORITY_LOW),
|
|
320
|
+
editor.registerCommand(
|
|
321
|
+
KEY_ESCAPE_COMMAND,
|
|
322
|
+
$onEscape,
|
|
323
|
+
COMMAND_PRIORITY_LOW
|
|
324
|
+
),
|
|
325
|
+
editor.registerRootListener((rootElement) => {
|
|
326
|
+
rootCleanup();
|
|
327
|
+
rootCleanup = noop;
|
|
328
|
+
if (rootElement) {
|
|
329
|
+
rootElement.addEventListener("contextmenu", onRightClick);
|
|
330
|
+
rootCleanup = () => rootElement.removeEventListener("contextmenu", onRightClick);
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
() => rootCleanup()
|
|
334
|
+
);
|
|
335
|
+
}, [editor, $onEnter, $onEscape, onClick, onRightClick]);
|
|
336
|
+
const setShowCaption = (show) => {
|
|
337
|
+
editor.update(() => {
|
|
338
|
+
const node = $getNodeByKey(nodeKey);
|
|
339
|
+
if ($isImageNode(node)) {
|
|
340
|
+
node.setShowCaption(show);
|
|
341
|
+
if (show) {
|
|
342
|
+
node.__caption.update(() => {
|
|
343
|
+
if (!$getSelection()) {
|
|
344
|
+
$getRoot().selectEnd();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
const onResizeEnd = (nextWidth, nextHeight) => {
|
|
352
|
+
setTimeout(() => {
|
|
353
|
+
setIsResizing(false);
|
|
354
|
+
}, 200);
|
|
355
|
+
editor.update(() => {
|
|
356
|
+
const node = $getNodeByKey(nodeKey);
|
|
357
|
+
if ($isImageNode(node)) {
|
|
358
|
+
node.setWidthAndHeight(nextWidth, nextHeight);
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
const onResizeStart = () => {
|
|
363
|
+
setIsResizing(true);
|
|
364
|
+
};
|
|
365
|
+
const { historyState } = useSharedHistoryContext();
|
|
366
|
+
const {
|
|
367
|
+
settings: { showTreeView: showNestedEditorTreeView }
|
|
368
|
+
} = useSettings();
|
|
369
|
+
const draggable = isInNodeSelection && !isResizing;
|
|
370
|
+
const isFocused = (isSelected || isResizing) && isEditable;
|
|
371
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
372
|
+
/* @__PURE__ */ jsx("div", { draggable, children: isLoadError ? /* @__PURE__ */ jsx(BrokenImage, {}) : /* @__PURE__ */ jsx(
|
|
373
|
+
LazyImage,
|
|
374
|
+
{
|
|
375
|
+
className: isFocused ? `focused ${isInNodeSelection ? "draggable" : ""}` : null,
|
|
376
|
+
src,
|
|
377
|
+
altText,
|
|
378
|
+
imageRef,
|
|
379
|
+
width,
|
|
380
|
+
height,
|
|
381
|
+
maxWidth,
|
|
382
|
+
onError: () => setIsLoadError(true)
|
|
383
|
+
}
|
|
384
|
+
) }),
|
|
385
|
+
showCaption && /* @__PURE__ */ jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ jsxs(LexicalNestedComposer, { initialEditor: caption, children: [
|
|
386
|
+
/* @__PURE__ */ jsx(DisableCaptionOnBlur, { setShowCaption }),
|
|
387
|
+
/* @__PURE__ */ jsx(NewMentionsPlugin, {}),
|
|
388
|
+
/* @__PURE__ */ jsx(LinkPlugin, {}),
|
|
389
|
+
/* @__PURE__ */ jsx(EmojisPlugin, {}),
|
|
390
|
+
/* @__PURE__ */ jsx(HashtagPlugin, {}),
|
|
391
|
+
/* @__PURE__ */ jsx(KeywordsPlugin, {}),
|
|
392
|
+
/* @__PURE__ */ jsx(HistoryPlugin, { externalHistoryState: historyState }),
|
|
393
|
+
/* @__PURE__ */ jsx(
|
|
394
|
+
RichTextPlugin,
|
|
395
|
+
{
|
|
396
|
+
contentEditable: /* @__PURE__ */ jsx(
|
|
397
|
+
LexicalContentEditable,
|
|
398
|
+
{
|
|
399
|
+
placeholder: "Enter a caption...",
|
|
400
|
+
placeholderClassName: "ImageNode__placeholder",
|
|
401
|
+
className: "ImageNode__contentEditable"
|
|
402
|
+
}
|
|
403
|
+
),
|
|
404
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
405
|
+
}
|
|
406
|
+
),
|
|
407
|
+
showNestedEditorTreeView === true ? /* @__PURE__ */ jsx(TreeViewPlugin, {}) : null
|
|
408
|
+
] }) }),
|
|
409
|
+
resizable && isInNodeSelection && isFocused && /* @__PURE__ */ jsx(
|
|
410
|
+
ImageResizer,
|
|
411
|
+
{
|
|
412
|
+
showCaption,
|
|
413
|
+
setShowCaption,
|
|
414
|
+
editor,
|
|
415
|
+
buttonRef,
|
|
416
|
+
imageRef,
|
|
417
|
+
maxWidth,
|
|
418
|
+
onResizeStart,
|
|
419
|
+
onResizeEnd,
|
|
420
|
+
captionsEnabled: !isLoadError && captionsEnabled
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
] }) });
|
|
424
|
+
}
|
|
425
|
+
export {
|
|
426
|
+
RIGHT_CLICK_IMAGE_COMMAND,
|
|
427
|
+
ImageComponent as default
|
|
428
|
+
};
|
|
429
|
+
//# sourceMappingURL=ImageComponent-TTUYUG3M.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/nodes/ImageComponent.tsx"],"sourcesContent":["/**\r\n * Copyright (c) Meta Platforms, Inc. and affiliates.\r\n *\r\n * This source code is licensed under the MIT license found in the\r\n * LICENSE file in the root directory of this source tree.\r\n *\r\n */\r\n\r\nimport type {LexicalCommand, LexicalEditor, NodeKey} from 'lexical';\r\nimport type {JSX} from 'react';\r\n\r\nimport './ImageNode.css';\r\n\r\nimport {useLexicalComposerContext} from '@lexical/react/LexicalComposerContext';\r\nimport {LexicalErrorBoundary} from '@lexical/react/LexicalErrorBoundary';\r\nimport {HashtagPlugin} from '@lexical/react/LexicalHashtagPlugin';\r\nimport {HistoryPlugin} from '@lexical/react/LexicalHistoryPlugin';\r\nimport {LexicalNestedComposer} from '@lexical/react/LexicalNestedComposer';\r\nimport {RichTextPlugin} from '@lexical/react/LexicalRichTextPlugin';\r\nimport {useLexicalEditable} from '@lexical/react/useLexicalEditable';\r\nimport {useLexicalNodeSelection} from '@lexical/react/useLexicalNodeSelection';\r\nimport {mergeRegister} from '@lexical/utils';\r\nimport {\r\n $getNodeByKey,\r\n $getRoot,\r\n $getSelection,\r\n $isNodeSelection,\r\n $isRangeSelection,\r\n $setSelection,\r\n BLUR_COMMAND,\r\n CLICK_COMMAND,\r\n COMMAND_PRIORITY_EDITOR,\r\n COMMAND_PRIORITY_LOW,\r\n createCommand,\r\n DRAGSTART_COMMAND,\r\n KEY_ENTER_COMMAND,\r\n KEY_ESCAPE_COMMAND,\r\n SELECTION_CHANGE_COMMAND,\r\n} from 'lexical';\r\nimport * as React from 'react';\r\nimport {\r\n Suspense,\r\n useCallback,\r\n useEffect,\r\n useMemo,\r\n useRef,\r\n useState,\r\n} from 'react';\r\n\r\nimport {useSettings} from '../context/SettingsContext';\r\nimport {useSharedHistoryContext} from '../context/SharedHistoryContext';\r\nimport brokenImageImport from '../images/image-broken.svg';\r\nimport EmojisPlugin from '../plugins/EmojisPlugin';\r\nimport KeywordsPlugin from '../plugins/KeywordsPlugin';\r\nimport LinkPlugin from '../plugins/LinkPlugin';\r\nimport MentionsPlugin from '../plugins/MentionsPlugin';\r\nimport TreeViewPlugin from '../plugins/TreeViewPlugin';\r\nimport ContentEditable from '../ui/ContentEditable';\r\nimport ImageResizer from '../ui/ImageResizer';\r\nimport {$isCaptionEditorEmpty, $isImageNode} from './ImageNode';\r\n\r\nconst brokenImage = (typeof brokenImageImport === 'string' ? brokenImageImport : (brokenImageImport as {src: string}).src) as string;\r\n\r\ntype ImageStatus =\r\n | {error: true}\r\n | {error: false; width: number; height: number};\r\n\r\nconst imageCache = new Map<string, Promise<ImageStatus> | ImageStatus>();\r\n\r\nexport const RIGHT_CLICK_IMAGE_COMMAND: LexicalCommand<MouseEvent> =\r\n createCommand('RIGHT_CLICK_IMAGE_COMMAND');\r\n\r\nfunction DisableCaptionOnBlur({\r\n setShowCaption,\r\n}: {\r\n setShowCaption: (show: boolean) => void;\r\n}) {\r\n const [editor] = useLexicalComposerContext();\r\n useEffect(() =>\r\n editor.registerCommand(\r\n BLUR_COMMAND,\r\n () => {\r\n if ($isCaptionEditorEmpty()) {\r\n setShowCaption(false);\r\n }\r\n return false;\r\n },\r\n COMMAND_PRIORITY_EDITOR,\r\n ),\r\n );\r\n return null;\r\n}\r\n\r\nfunction useSuspenseImage(src: string): ImageStatus {\r\n let cached = imageCache.get(src);\r\n if (cached && 'error' in cached && typeof cached.error === 'boolean') {\r\n return cached;\r\n } else if (!cached) {\r\n cached = new Promise<ImageStatus>((resolve) => {\r\n const img = new Image();\r\n img.src = src;\r\n img.onload = () =>\r\n resolve({\r\n error: false,\r\n height: img.naturalHeight,\r\n width: img.naturalWidth,\r\n });\r\n img.onerror = () => resolve({error: true});\r\n }).then((rval) => {\r\n imageCache.set(src, rval);\r\n return rval;\r\n });\r\n imageCache.set(src, cached);\r\n throw cached;\r\n }\r\n throw cached;\r\n}\r\n\r\nfunction isSVG(src: string): boolean {\r\n return src.toLowerCase().endsWith('.svg');\r\n}\r\n\r\nfunction LazyImage({\r\n altText,\r\n className,\r\n imageRef,\r\n src,\r\n width,\r\n height,\r\n maxWidth,\r\n onError,\r\n}: {\r\n altText: string;\r\n className: string | null;\r\n height: 'inherit' | number;\r\n imageRef: {current: null | HTMLImageElement};\r\n maxWidth: number;\r\n src: string;\r\n width: 'inherit' | number;\r\n onError: () => void;\r\n}): JSX.Element {\r\n const isSVGImage = isSVG(src);\r\n const status = useSuspenseImage(src);\r\n\r\n useEffect(() => {\r\n if (status.error) {\r\n onError();\r\n }\r\n }, [status.error, onError]);\r\n\r\n if (status.error) {\r\n return <BrokenImage />;\r\n }\r\n\r\n // Calculate final dimensions with proper scaling\r\n const calculateDimensions = () => {\r\n if (!isSVGImage) {\r\n return {\r\n height,\r\n maxWidth,\r\n width,\r\n };\r\n }\r\n\r\n // Use natural dimensions if available, otherwise fallback to defaults\r\n const naturalWidth = status.width;\r\n const naturalHeight = status.height;\r\n\r\n let finalWidth = naturalWidth;\r\n let finalHeight = naturalHeight;\r\n\r\n // Scale down if width exceeds maxWidth while maintaining aspect ratio\r\n if (finalWidth > maxWidth) {\r\n const scale = maxWidth / finalWidth;\r\n finalWidth = maxWidth;\r\n finalHeight = Math.round(finalHeight * scale);\r\n }\r\n\r\n // Scale down if height exceeds maxHeight while maintaining aspect ratio\r\n const maxHeight = 500;\r\n if (finalHeight > maxHeight) {\r\n const scale = maxHeight / finalHeight;\r\n finalHeight = maxHeight;\r\n finalWidth = Math.round(finalWidth * scale);\r\n }\r\n\r\n return {\r\n height: finalHeight,\r\n maxWidth,\r\n width: finalWidth,\r\n };\r\n };\r\n\r\n const imageStyle = calculateDimensions();\r\n\r\n return (\r\n <img\r\n className={className || undefined}\r\n src={src}\r\n alt={altText}\r\n ref={imageRef}\r\n style={imageStyle}\r\n onError={onError}\r\n draggable=\"false\"\r\n />\r\n );\r\n}\r\n\r\nfunction BrokenImage(): JSX.Element {\r\n return (\r\n <img\r\n src={brokenImage}\r\n style={{\r\n height: 200,\r\n opacity: 0.2,\r\n width: 200,\r\n }}\r\n draggable=\"false\"\r\n alt=\"Broken image\"\r\n />\r\n );\r\n}\r\n\r\nfunction noop() {}\r\n\r\nexport default function ImageComponent({\r\n src,\r\n altText,\r\n nodeKey,\r\n width,\r\n height,\r\n maxWidth,\r\n resizable,\r\n showCaption,\r\n caption,\r\n captionsEnabled,\r\n}: {\r\n altText: string;\r\n caption: LexicalEditor;\r\n height: 'inherit' | number;\r\n maxWidth: number;\r\n nodeKey: NodeKey;\r\n resizable: boolean;\r\n showCaption: boolean;\r\n src: string;\r\n width: 'inherit' | number;\r\n captionsEnabled: boolean;\r\n}): JSX.Element {\r\n const imageRef = useRef<null | HTMLImageElement>(null);\r\n const buttonRef = useRef<HTMLButtonElement | null>(null);\r\n const [isSelected, setSelected, clearSelection] =\r\n useLexicalNodeSelection(nodeKey);\r\n const [isResizing, setIsResizing] = useState<boolean>(false);\r\n const [editor] = useLexicalComposerContext();\r\n const activeEditorRef = useRef<LexicalEditor | null>(null);\r\n const [isLoadError, setIsLoadError] = useState<boolean>(false);\r\n const isEditable = useLexicalEditable();\r\n const isInNodeSelection = useMemo(\r\n () =>\r\n isSelected &&\r\n editor.getEditorState().read(() => {\r\n const selection = $getSelection();\r\n return $isNodeSelection(selection) && selection.has(nodeKey);\r\n }),\r\n [editor, isSelected, nodeKey],\r\n );\r\n\r\n const $onEnter = useCallback(\r\n (event: KeyboardEvent) => {\r\n const latestSelection = $getSelection();\r\n const buttonElem = buttonRef.current;\r\n if (\r\n $isNodeSelection(latestSelection) &&\r\n latestSelection.has(nodeKey) &&\r\n latestSelection.getNodes().length === 1\r\n ) {\r\n if (showCaption) {\r\n // Move focus into nested editor\r\n $setSelection(null);\r\n event.preventDefault();\r\n caption.focus();\r\n return true;\r\n } else if (\r\n buttonElem !== null &&\r\n buttonElem !== document.activeElement\r\n ) {\r\n event.preventDefault();\r\n buttonElem.focus();\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n [caption, nodeKey, showCaption],\r\n );\r\n\r\n const $onEscape = useCallback(\r\n (event: KeyboardEvent) => {\r\n if (\r\n activeEditorRef.current === caption ||\r\n buttonRef.current === event.target\r\n ) {\r\n $setSelection(null);\r\n editor.update(() => {\r\n setSelected(true);\r\n const parentRootElement = editor.getRootElement();\r\n if (parentRootElement !== null) {\r\n parentRootElement.focus();\r\n }\r\n });\r\n return true;\r\n }\r\n return false;\r\n },\r\n [caption, editor, setSelected],\r\n );\r\n\r\n const onClick = useCallback(\r\n (payload: MouseEvent) => {\r\n const event = payload;\r\n\r\n if (isResizing) {\r\n return true;\r\n }\r\n if (event.target === imageRef.current) {\r\n if (event.shiftKey) {\r\n setSelected(!isSelected);\r\n } else {\r\n clearSelection();\r\n setSelected(true);\r\n }\r\n return true;\r\n }\r\n\r\n return false;\r\n },\r\n [isResizing, isSelected, setSelected, clearSelection],\r\n );\r\n\r\n const onRightClick = useCallback(\r\n (event: MouseEvent): void => {\r\n editor.getEditorState().read(() => {\r\n const latestSelection = $getSelection();\r\n const domElement = event.target as HTMLElement;\r\n if (\r\n domElement.tagName === 'IMG' &&\r\n $isRangeSelection(latestSelection) &&\r\n latestSelection.getNodes().length === 1\r\n ) {\r\n editor.dispatchCommand(RIGHT_CLICK_IMAGE_COMMAND, event);\r\n }\r\n });\r\n },\r\n [editor],\r\n );\r\n\r\n useEffect(() => {\r\n return mergeRegister(\r\n editor.registerCommand(\r\n SELECTION_CHANGE_COMMAND,\r\n (_, activeEditor) => {\r\n activeEditorRef.current = activeEditor;\r\n return false;\r\n },\r\n COMMAND_PRIORITY_LOW,\r\n ),\r\n editor.registerCommand(\r\n DRAGSTART_COMMAND,\r\n (event) => {\r\n if (event.target === imageRef.current) {\r\n // TODO This is just a temporary workaround for FF to behave like other browsers.\r\n // Ideally, this handles drag & drop too (and all browsers).\r\n event.preventDefault();\r\n return true;\r\n }\r\n return false;\r\n },\r\n COMMAND_PRIORITY_LOW,\r\n ),\r\n );\r\n }, [editor]);\r\n useEffect(() => {\r\n let rootCleanup = noop;\r\n return mergeRegister(\r\n editor.registerCommand<MouseEvent>(\r\n CLICK_COMMAND,\r\n onClick,\r\n COMMAND_PRIORITY_LOW,\r\n ),\r\n editor.registerCommand<MouseEvent>(\r\n RIGHT_CLICK_IMAGE_COMMAND,\r\n onClick,\r\n COMMAND_PRIORITY_LOW,\r\n ),\r\n editor.registerCommand(KEY_ENTER_COMMAND, $onEnter, COMMAND_PRIORITY_LOW),\r\n editor.registerCommand(\r\n KEY_ESCAPE_COMMAND,\r\n $onEscape,\r\n COMMAND_PRIORITY_LOW,\r\n ),\r\n editor.registerRootListener((rootElement) => {\r\n rootCleanup();\r\n rootCleanup = noop;\r\n if (rootElement) {\r\n rootElement.addEventListener('contextmenu', onRightClick);\r\n rootCleanup = () =>\r\n rootElement.removeEventListener('contextmenu', onRightClick);\r\n }\r\n }),\r\n () => rootCleanup(),\r\n );\r\n }, [editor, $onEnter, $onEscape, onClick, onRightClick]);\r\n\r\n const setShowCaption = (show: boolean) => {\r\n editor.update(() => {\r\n const node = $getNodeByKey(nodeKey);\r\n if ($isImageNode(node)) {\r\n node.setShowCaption(show);\r\n if (show) {\r\n node.__caption.update(() => {\r\n if (!$getSelection()) {\r\n $getRoot().selectEnd();\r\n }\r\n });\r\n }\r\n }\r\n });\r\n };\r\n\r\n const onResizeEnd = (\r\n nextWidth: 'inherit' | number,\r\n nextHeight: 'inherit' | number,\r\n ) => {\r\n // Delay hiding the resize bars for click case\r\n setTimeout(() => {\r\n setIsResizing(false);\r\n }, 200);\r\n\r\n editor.update(() => {\r\n const node = $getNodeByKey(nodeKey);\r\n if ($isImageNode(node)) {\r\n node.setWidthAndHeight(nextWidth, nextHeight);\r\n }\r\n });\r\n };\r\n\r\n const onResizeStart = () => {\r\n setIsResizing(true);\r\n };\r\n\r\n const {historyState} = useSharedHistoryContext();\r\n const {\r\n settings: {showTreeView: showNestedEditorTreeView},\r\n } = useSettings();\r\n\r\n const draggable = isInNodeSelection && !isResizing;\r\n const isFocused = (isSelected || isResizing) && isEditable;\r\n return (\r\n <Suspense fallback={null}>\r\n <>\r\n <div draggable={draggable}>\r\n {isLoadError ? (\r\n <BrokenImage />\r\n ) : (\r\n <LazyImage\r\n className={\r\n isFocused\r\n ? `focused ${isInNodeSelection ? 'draggable' : ''}`\r\n : null\r\n }\r\n src={src}\r\n altText={altText}\r\n imageRef={imageRef}\r\n width={width}\r\n height={height}\r\n maxWidth={maxWidth}\r\n onError={() => setIsLoadError(true)}\r\n />\r\n )}\r\n </div>\r\n\r\n {showCaption && (\r\n <div className=\"image-caption-container\">\r\n <LexicalNestedComposer initialEditor={caption}>\r\n <DisableCaptionOnBlur setShowCaption={setShowCaption} />\r\n <MentionsPlugin />\r\n <LinkPlugin />\r\n <EmojisPlugin />\r\n <HashtagPlugin />\r\n <KeywordsPlugin />\r\n <HistoryPlugin externalHistoryState={historyState} />\r\n <RichTextPlugin\r\n contentEditable={\r\n <ContentEditable\r\n placeholder=\"Enter a caption...\"\r\n placeholderClassName=\"ImageNode__placeholder\"\r\n className=\"ImageNode__contentEditable\"\r\n />\r\n }\r\n ErrorBoundary={LexicalErrorBoundary}\r\n />\r\n {showNestedEditorTreeView === true ? <TreeViewPlugin /> : null}\r\n </LexicalNestedComposer>\r\n </div>\r\n )}\r\n {resizable && isInNodeSelection && isFocused && (\r\n <ImageResizer\r\n showCaption={showCaption}\r\n setShowCaption={setShowCaption}\r\n editor={editor}\r\n buttonRef={buttonRef}\r\n imageRef={imageRef}\r\n maxWidth={maxWidth}\r\n onResizeStart={onResizeStart}\r\n onResizeEnd={onResizeEnd}\r\n captionsEnabled={!isLoadError && captionsEnabled}\r\n />\r\n )}\r\n </>\r\n </Suspense>\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAaA,SAAQ,iCAAgC;AACxC,SAAQ,4BAA2B;AACnC,SAAQ,qBAAoB;AAC5B,SAAQ,qBAAoB;AAC5B,SAAQ,6BAA4B;AACpC,SAAQ,sBAAqB;AAC7B,SAAQ,0BAAyB;AACjC,SAAQ,+BAA8B;AACtC,SAAQ,qBAAoB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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