ct-rich-text-editor 1.2.4 → 1.2.5

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 (35) hide show
  1. package/dist/assets/style.css +5319 -1
  2. package/dist/{babel-1c4a328b.js → babel-d155920e.js} +2303 -2279
  3. package/dist/{babel-1c4a328b.js.map → babel-d155920e.js.map} +1 -1
  4. package/dist/estree-b1fff53b.js +4706 -0
  5. package/dist/{estree-2cbea43c.js.map → estree-b1fff53b.js.map} +1 -1
  6. package/dist/html-f95ee5dc.js +2885 -0
  7. package/dist/{html-c18fb60e.js.map → html-f95ee5dc.js.map} +1 -1
  8. package/dist/index-7c4c0170.js +655 -0
  9. package/dist/index-7c4c0170.js.map +1 -0
  10. package/dist/index-c98eb13a.js +27325 -0
  11. package/dist/index-c98eb13a.js.map +1 -0
  12. package/dist/index.js +48 -15
  13. package/dist/index.js.map +1 -1
  14. package/dist/markdown-1d9e6c3f.js +3759 -0
  15. package/dist/markdown-1d9e6c3f.js.map +1 -0
  16. package/dist/postcss-c2592f3f.js +5399 -0
  17. package/dist/postcss-c2592f3f.js.map +1 -0
  18. package/dist/standalone-bcc7f37a.js +2649 -0
  19. package/dist/standalone-bcc7f37a.js.map +1 -0
  20. package/dist/typescript-48c10f50.js +13601 -0
  21. package/dist/{typescript-39d06710.js.map → typescript-48c10f50.js.map} +1 -1
  22. package/package.json +2 -2
  23. package/dist/estree-2cbea43c.js +0 -4668
  24. package/dist/html-c18fb60e.js +0 -2842
  25. package/dist/index-0e027fdf.js +0 -806
  26. package/dist/index-0e027fdf.js.map +0 -1
  27. package/dist/index-bd25a91b.js +0 -35926
  28. package/dist/index-bd25a91b.js.map +0 -1
  29. package/dist/markdown-39c3822b.js +0 -3548
  30. package/dist/markdown-39c3822b.js.map +0 -1
  31. package/dist/postcss-bbcc713e.js +0 -5152
  32. package/dist/postcss-bbcc713e.js.map +0 -1
  33. package/dist/standalone-36ad3877.js +0 -2601
  34. package/dist/standalone-36ad3877.js.map +0 -1
  35. package/dist/typescript-39d06710.js +0 -13534
@@ -0,0 +1,655 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { CodeNode } from "@lexical/code";
3
+ import { LinkNode } from "@lexical/link";
4
+ import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
5
+ import { useCollaborationContext } from "@lexical/react/LexicalCollaborationContext";
6
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
7
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
8
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
9
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
10
+ import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
11
+ import { OnChangePlugin } from "@lexical/react/LexicalOnChangePlugin";
12
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
13
+ import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
14
+ import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
15
+ import { calculateZoomLevel, mergeRegister } from "@lexical/utils";
16
+ import { $getSelection, $isNodeSelection, $setSelection, $isRangeSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, RootNode, TextNode, LineBreakNode, ParagraphNode, createCommand, $getNodeByKey } from "lexical";
17
+ import { useRef, useState, useCallback, useEffect, Suspense } from "react";
18
+ import { $ as $isImageNode, L as LocalStoragePlugin, i as initialConfig } from "./index-c98eb13a.js";
19
+ import "axios";
20
+ import "@emotion/styled";
21
+ import "@lexical/html";
22
+ import "@lexical/react/LexicalCheckListPlugin";
23
+ import "@lexical/react/LexicalComposer";
24
+ import "@lexical/react/LexicalHorizontalRulePlugin";
25
+ import "@lexical/react/LexicalListPlugin";
26
+ import "@lexical/react/LexicalTablePlugin";
27
+ import "@mui/material/Stack";
28
+ import "react-dom";
29
+ import "@lexical/list";
30
+ import "@lexical/rich-text";
31
+ import "@lexical/selection";
32
+ import "@lexical/table";
33
+ import "@lexical/react/LexicalHorizontalRuleNode";
34
+ import "@mui/icons-material/Description";
35
+ import "@mui/icons-material/FolderZip";
36
+ import "@mui/icons-material/InsertChart";
37
+ import "@mui/icons-material/InsertDriveFile";
38
+ import "@mui/icons-material/PictureAsPdf";
39
+ import "@lexical/react/LexicalDecoratorBlockNode";
40
+ import "emoji-picker-react";
41
+ import "@mui/icons-material/Code";
42
+ import "@mui/icons-material/ContentCopy";
43
+ import "@mui/icons-material/CropOriginal";
44
+ import "@mui/icons-material/Delete";
45
+ import "@mui/icons-material/FormatAlignCenter";
46
+ import "@mui/icons-material/FormatAlignLeft";
47
+ import "@mui/icons-material/FormatAlignRight";
48
+ import "@mui/icons-material/Link";
49
+ import "@mui/icons-material/OpenInNew";
50
+ import "@lexical/react/LexicalLinkPlugin";
51
+ import "@lexical/react/LexicalTypeaheadMenuPlugin";
52
+ const imageCaptionStyles = "";
53
+ function clamp(value, min, max) {
54
+ return Math.min(Math.max(value, min), max);
55
+ }
56
+ const Direction = {
57
+ east: 1 << 0,
58
+ north: 1 << 3,
59
+ south: 1 << 1,
60
+ west: 1 << 2
61
+ };
62
+ function ImageResizer({
63
+ onResizeStart,
64
+ onResizeEnd,
65
+ buttonRef,
66
+ imageRef,
67
+ maxWidth,
68
+ editor,
69
+ showCaption,
70
+ setShowCaption,
71
+ captionsEnabled
72
+ }) {
73
+ const controlWrapperRef = useRef(null);
74
+ const userSelect = useRef({
75
+ priority: "",
76
+ value: "default"
77
+ });
78
+ const positioningRef = useRef({
79
+ currentHeight: 0,
80
+ currentWidth: 0,
81
+ direction: 0,
82
+ isResizing: false,
83
+ ratio: 0,
84
+ startHeight: 0,
85
+ startWidth: 0,
86
+ startX: 0,
87
+ startY: 0
88
+ });
89
+ const editorRootElement = editor.getRootElement();
90
+ const maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
91
+ const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
92
+ const minWidth = 100;
93
+ const minHeight = 100;
94
+ const setStartCursor = (direction) => {
95
+ const ew = direction === Direction.east || direction === Direction.west;
96
+ const ns = direction === Direction.north || direction === Direction.south;
97
+ const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
98
+ const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
99
+ if (editorRootElement !== null) {
100
+ editorRootElement.style.setProperty(
101
+ "cursor",
102
+ `${cursorDir}-resize`,
103
+ "important"
104
+ );
105
+ }
106
+ if (document.body !== null) {
107
+ document.body.style.setProperty(
108
+ "cursor",
109
+ `${cursorDir}-resize`,
110
+ "important"
111
+ );
112
+ userSelect.current.value = document.body.style.getPropertyValue(
113
+ "-webkit-user-select"
114
+ );
115
+ userSelect.current.priority = document.body.style.getPropertyPriority(
116
+ "-webkit-user-select"
117
+ );
118
+ document.body.style.setProperty(
119
+ "-webkit-user-select",
120
+ `none`,
121
+ "important"
122
+ );
123
+ }
124
+ };
125
+ const setEndCursor = () => {
126
+ if (editorRootElement !== null) {
127
+ editorRootElement.style.setProperty("cursor", "text");
128
+ }
129
+ if (document.body !== null) {
130
+ document.body.style.setProperty("cursor", "default");
131
+ document.body.style.setProperty(
132
+ "-webkit-user-select",
133
+ userSelect.current.value,
134
+ userSelect.current.priority
135
+ );
136
+ }
137
+ };
138
+ const handlePointerDown = (event, direction) => {
139
+ if (!editor.isEditable()) {
140
+ return;
141
+ }
142
+ const image = imageRef.current;
143
+ const controlWrapper = controlWrapperRef.current;
144
+ if (image !== null && controlWrapper !== null) {
145
+ event.preventDefault();
146
+ const { width, height } = image.getBoundingClientRect();
147
+ const zoom = calculateZoomLevel(image);
148
+ const positioning = positioningRef.current;
149
+ positioning.startWidth = width;
150
+ positioning.startHeight = height;
151
+ positioning.ratio = width / height;
152
+ positioning.currentWidth = width;
153
+ positioning.currentHeight = height;
154
+ positioning.startX = event.clientX / zoom;
155
+ positioning.startY = event.clientY / zoom;
156
+ positioning.isResizing = true;
157
+ positioning.direction = direction;
158
+ setStartCursor(direction);
159
+ onResizeStart();
160
+ controlWrapper.classList.add("image-control-wrapper--resizing");
161
+ image.style.height = `${height}px`;
162
+ image.style.width = `${width}px`;
163
+ document.addEventListener("pointermove", handlePointerMove);
164
+ document.addEventListener("pointerup", handlePointerUp);
165
+ }
166
+ };
167
+ const handlePointerMove = (event) => {
168
+ const image = imageRef.current;
169
+ const positioning = positioningRef.current;
170
+ const isHorizontal = positioning.direction & (Direction.east | Direction.west);
171
+ const isVertical = positioning.direction & (Direction.south | Direction.north);
172
+ if (image !== null && positioning.isResizing) {
173
+ const zoom = calculateZoomLevel(image);
174
+ if (isHorizontal && isVertical) {
175
+ let diff = Math.floor(positioning.startX - event.clientX / zoom);
176
+ diff = positioning.direction & Direction.east ? -diff : diff;
177
+ const width = clamp(
178
+ positioning.startWidth + diff,
179
+ minWidth,
180
+ maxWidthContainer
181
+ );
182
+ const height = width / positioning.ratio;
183
+ image.style.width = `${width}px`;
184
+ image.style.height = `${height}px`;
185
+ positioning.currentHeight = height;
186
+ positioning.currentWidth = width;
187
+ } else if (isVertical) {
188
+ let diff = Math.floor(positioning.startY - event.clientY / zoom);
189
+ diff = positioning.direction & Direction.south ? -diff : diff;
190
+ const height = clamp(
191
+ positioning.startHeight + diff,
192
+ minHeight,
193
+ maxHeightContainer
194
+ );
195
+ image.style.height = `${height}px`;
196
+ positioning.currentHeight = height;
197
+ } else {
198
+ let diff = Math.floor(positioning.startX - event.clientX / zoom);
199
+ diff = positioning.direction & Direction.east ? -diff : diff;
200
+ const width = clamp(
201
+ positioning.startWidth + diff,
202
+ minWidth,
203
+ maxWidthContainer
204
+ );
205
+ image.style.width = `${width}px`;
206
+ positioning.currentWidth = width;
207
+ }
208
+ }
209
+ };
210
+ const handlePointerUp = () => {
211
+ const image = imageRef.current;
212
+ const positioning = positioningRef.current;
213
+ const controlWrapper = controlWrapperRef.current;
214
+ if (image !== null && controlWrapper !== null && positioning.isResizing) {
215
+ const width = positioning.currentWidth;
216
+ const height = positioning.currentHeight;
217
+ positioning.startWidth = 0;
218
+ positioning.startHeight = 0;
219
+ positioning.ratio = 0;
220
+ positioning.startX = 0;
221
+ positioning.startY = 0;
222
+ positioning.currentWidth = 0;
223
+ positioning.currentHeight = 0;
224
+ positioning.isResizing = false;
225
+ controlWrapper.classList.remove("image-control-wrapper--resizing");
226
+ setEndCursor();
227
+ onResizeEnd(width, height);
228
+ document.removeEventListener("pointermove", handlePointerMove);
229
+ document.removeEventListener("pointerup", handlePointerUp);
230
+ }
231
+ };
232
+ return /* @__PURE__ */ jsxs("div", { ref: controlWrapperRef, children: [
233
+ !showCaption && captionsEnabled && /* @__PURE__ */ jsx(
234
+ "button",
235
+ {
236
+ className: "image-caption-button",
237
+ ref: buttonRef,
238
+ onClick: () => {
239
+ setShowCaption(!showCaption);
240
+ },
241
+ children: "Add Caption"
242
+ }
243
+ ),
244
+ /* @__PURE__ */ jsx(
245
+ "div",
246
+ {
247
+ className: "image-resizer image-resizer-n",
248
+ onPointerDown: (event) => {
249
+ handlePointerDown(event, Direction.north);
250
+ }
251
+ }
252
+ ),
253
+ /* @__PURE__ */ jsx(
254
+ "div",
255
+ {
256
+ className: "image-resizer image-resizer-ne",
257
+ onPointerDown: (event) => {
258
+ handlePointerDown(event, Direction.north | Direction.east);
259
+ }
260
+ }
261
+ ),
262
+ /* @__PURE__ */ jsx(
263
+ "div",
264
+ {
265
+ className: "image-resizer image-resizer-e",
266
+ onPointerDown: (event) => {
267
+ handlePointerDown(event, Direction.east);
268
+ }
269
+ }
270
+ ),
271
+ /* @__PURE__ */ jsx(
272
+ "div",
273
+ {
274
+ className: "image-resizer image-resizer-se",
275
+ onPointerDown: (event) => {
276
+ handlePointerDown(event, Direction.south | Direction.east);
277
+ }
278
+ }
279
+ ),
280
+ /* @__PURE__ */ jsx(
281
+ "div",
282
+ {
283
+ className: "image-resizer image-resizer-s",
284
+ onPointerDown: (event) => {
285
+ handlePointerDown(event, Direction.south);
286
+ }
287
+ }
288
+ ),
289
+ /* @__PURE__ */ jsx(
290
+ "div",
291
+ {
292
+ className: "image-resizer image-resizer-sw",
293
+ onPointerDown: (event) => {
294
+ handlePointerDown(event, Direction.south | Direction.west);
295
+ }
296
+ }
297
+ ),
298
+ /* @__PURE__ */ jsx(
299
+ "div",
300
+ {
301
+ className: "image-resizer image-resizer-w",
302
+ onPointerDown: (event) => {
303
+ handlePointerDown(event, Direction.west);
304
+ }
305
+ }
306
+ ),
307
+ /* @__PURE__ */ jsx(
308
+ "div",
309
+ {
310
+ className: "image-resizer image-resizer-nw",
311
+ onPointerDown: (event) => {
312
+ handlePointerDown(event, Direction.north | Direction.west);
313
+ }
314
+ }
315
+ )
316
+ ] });
317
+ }
318
+ const imageCache = /* @__PURE__ */ new Set();
319
+ const RIGHT_CLICK_IMAGE_COMMAND = createCommand("RIGHT_CLICK_IMAGE_COMMAND");
320
+ function useSuspenseImage(src) {
321
+ if (!imageCache.has(src)) {
322
+ throw new Promise((resolve) => {
323
+ const img = new Image();
324
+ img.src = src;
325
+ img.onload = () => {
326
+ imageCache.add(src);
327
+ resolve(null);
328
+ };
329
+ img.onerror = () => {
330
+ imageCache.add(src);
331
+ };
332
+ });
333
+ }
334
+ }
335
+ function LazyImage({
336
+ altText,
337
+ className,
338
+ imageRef,
339
+ src,
340
+ width,
341
+ height,
342
+ maxWidth,
343
+ onError
344
+ }) {
345
+ useSuspenseImage(src);
346
+ return /* @__PURE__ */ jsx(
347
+ "img",
348
+ {
349
+ className: className || void 0,
350
+ src,
351
+ alt: altText,
352
+ ref: imageRef,
353
+ style: {
354
+ height,
355
+ maxWidth,
356
+ width
357
+ },
358
+ onError,
359
+ draggable: "false"
360
+ }
361
+ );
362
+ }
363
+ function BrokenImage() {
364
+ return /* @__PURE__ */ jsx(
365
+ "img",
366
+ {
367
+ src: "",
368
+ style: {
369
+ height: 200,
370
+ opacity: 0.2,
371
+ width: 200
372
+ },
373
+ draggable: "false"
374
+ }
375
+ );
376
+ }
377
+ function ImageComponent({
378
+ src,
379
+ altText,
380
+ nodeKey,
381
+ width,
382
+ height,
383
+ maxWidth,
384
+ resizable,
385
+ showCaption,
386
+ caption,
387
+ captionsEnabled
388
+ }) {
389
+ const imageRef = useRef(null);
390
+ const buttonRef = useRef(null);
391
+ const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
392
+ const [isResizing, setIsResizing] = useState(false);
393
+ useCollaborationContext();
394
+ const [editor] = useLexicalComposerContext();
395
+ const [selection, setSelection] = useState(null);
396
+ const activeEditorRef = useRef(null);
397
+ const [isLoadError, setIsLoadError] = useState(false);
398
+ const isEditable = useLexicalEditable();
399
+ const $onDelete = useCallback(
400
+ (payload) => {
401
+ const deleteSelection = $getSelection();
402
+ if (isSelected && $isNodeSelection(deleteSelection)) {
403
+ const event = payload;
404
+ event.preventDefault();
405
+ editor.update(() => {
406
+ deleteSelection.getNodes().forEach((node) => {
407
+ if ($isImageNode(node)) {
408
+ node.remove();
409
+ }
410
+ });
411
+ });
412
+ }
413
+ return false;
414
+ },
415
+ [editor, isSelected]
416
+ );
417
+ const $onEnter = useCallback(
418
+ (event) => {
419
+ const latestSelection = $getSelection();
420
+ const buttonElem = buttonRef.current;
421
+ if (isSelected && $isNodeSelection(latestSelection) && latestSelection.getNodes().length === 1) {
422
+ if (showCaption) {
423
+ $setSelection(null);
424
+ event.preventDefault();
425
+ caption.focus();
426
+ return true;
427
+ } else if (buttonElem !== null && buttonElem !== document.activeElement) {
428
+ event.preventDefault();
429
+ buttonElem.focus();
430
+ return true;
431
+ }
432
+ }
433
+ return false;
434
+ },
435
+ [caption, isSelected, showCaption]
436
+ );
437
+ const $onEscape = useCallback(
438
+ (event) => {
439
+ if (activeEditorRef.current === caption || buttonRef.current === event.target) {
440
+ $setSelection(null);
441
+ editor.update(() => {
442
+ setSelected(true);
443
+ const parentRootElement = editor.getRootElement();
444
+ if (parentRootElement !== null) {
445
+ parentRootElement.focus();
446
+ }
447
+ });
448
+ return true;
449
+ }
450
+ return false;
451
+ },
452
+ [caption, editor, setSelected]
453
+ );
454
+ const onClick = useCallback(
455
+ (payload) => {
456
+ const event = payload;
457
+ if (isResizing) {
458
+ return true;
459
+ }
460
+ if (event.target === imageRef.current) {
461
+ if (event.shiftKey) {
462
+ setSelected(!isSelected);
463
+ } else {
464
+ clearSelection();
465
+ setSelected(true);
466
+ }
467
+ return true;
468
+ }
469
+ return false;
470
+ },
471
+ [isResizing, isSelected, setSelected, clearSelection]
472
+ );
473
+ const onRightClick = useCallback(
474
+ (event) => {
475
+ editor.getEditorState().read(() => {
476
+ const latestSelection = $getSelection();
477
+ const domElement = event.target;
478
+ if (domElement.tagName === "IMG" && $isRangeSelection(latestSelection) && latestSelection.getNodes().length === 1) {
479
+ editor.dispatchCommand(
480
+ RIGHT_CLICK_IMAGE_COMMAND,
481
+ event
482
+ );
483
+ }
484
+ });
485
+ },
486
+ [editor]
487
+ );
488
+ useEffect(() => {
489
+ let isMounted = true;
490
+ const rootElement = editor.getRootElement();
491
+ const unregister = mergeRegister(
492
+ editor.registerUpdateListener(({ editorState }) => {
493
+ if (isMounted) {
494
+ setSelection(editorState.read(() => $getSelection()));
495
+ }
496
+ }),
497
+ editor.registerCommand(
498
+ SELECTION_CHANGE_COMMAND,
499
+ (_, activeEditor) => {
500
+ activeEditorRef.current = activeEditor;
501
+ return false;
502
+ },
503
+ COMMAND_PRIORITY_LOW
504
+ ),
505
+ editor.registerCommand(
506
+ CLICK_COMMAND,
507
+ onClick,
508
+ COMMAND_PRIORITY_LOW
509
+ ),
510
+ editor.registerCommand(
511
+ RIGHT_CLICK_IMAGE_COMMAND,
512
+ onClick,
513
+ COMMAND_PRIORITY_LOW
514
+ ),
515
+ editor.registerCommand(
516
+ DRAGSTART_COMMAND,
517
+ (event) => {
518
+ if (event.target === imageRef.current) {
519
+ alert("s");
520
+ event.preventDefault();
521
+ return true;
522
+ }
523
+ return false;
524
+ },
525
+ COMMAND_PRIORITY_LOW
526
+ ),
527
+ editor.registerCommand(
528
+ KEY_DELETE_COMMAND,
529
+ $onDelete,
530
+ COMMAND_PRIORITY_LOW
531
+ ),
532
+ editor.registerCommand(
533
+ KEY_BACKSPACE_COMMAND,
534
+ $onDelete,
535
+ COMMAND_PRIORITY_LOW
536
+ ),
537
+ editor.registerCommand(KEY_ENTER_COMMAND, $onEnter, COMMAND_PRIORITY_LOW),
538
+ editor.registerCommand(
539
+ KEY_ESCAPE_COMMAND,
540
+ $onEscape,
541
+ COMMAND_PRIORITY_LOW
542
+ )
543
+ );
544
+ rootElement == null ? void 0 : rootElement.addEventListener("contextmenu", onRightClick);
545
+ return () => {
546
+ isMounted = false;
547
+ unregister();
548
+ rootElement == null ? void 0 : rootElement.removeEventListener("contextmenu", onRightClick);
549
+ };
550
+ }, [
551
+ clearSelection,
552
+ editor,
553
+ isResizing,
554
+ isSelected,
555
+ nodeKey,
556
+ $onDelete,
557
+ $onEnter,
558
+ $onEscape,
559
+ onClick,
560
+ onRightClick,
561
+ setSelected
562
+ ]);
563
+ const setShowCaption = () => {
564
+ editor.update(() => {
565
+ const node = $getNodeByKey(nodeKey);
566
+ if ($isImageNode(node)) {
567
+ node.setShowCaption(true);
568
+ }
569
+ });
570
+ };
571
+ const onResizeEnd = (nextWidth, nextHeight) => {
572
+ setTimeout(() => {
573
+ setIsResizing(false);
574
+ }, 200);
575
+ editor.update(() => {
576
+ const node = $getNodeByKey(nodeKey);
577
+ if ($isImageNode(node)) {
578
+ node.setWidthAndHeight(nextWidth, nextHeight);
579
+ }
580
+ });
581
+ };
582
+ const onResizeStart = () => {
583
+ setIsResizing(true);
584
+ };
585
+ const draggable = isSelected && $isNodeSelection(selection) && !isResizing;
586
+ const isFocused = (isSelected || isResizing) && isEditable;
587
+ return /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsxs(Fragment, { children: [
588
+ /* @__PURE__ */ jsx("div", { draggable, children: isLoadError ? /* @__PURE__ */ jsx(BrokenImage, {}) : /* @__PURE__ */ jsx(
589
+ LazyImage,
590
+ {
591
+ className: isFocused ? `focused ${$isNodeSelection(selection) ? "draggable" : ""}` : null,
592
+ src,
593
+ altText,
594
+ imageRef,
595
+ width,
596
+ height,
597
+ maxWidth,
598
+ onError: () => setIsLoadError(true)
599
+ }
600
+ ) }),
601
+ showCaption && /* @__PURE__ */ jsx("div", { className: "image-caption-container", children: /* @__PURE__ */ jsxs(
602
+ LexicalNestedComposer,
603
+ {
604
+ initialEditor: caption,
605
+ initialNodes: [
606
+ RootNode,
607
+ TextNode,
608
+ LineBreakNode,
609
+ ParagraphNode,
610
+ LinkNode,
611
+ CodeNode
612
+ ],
613
+ children: [
614
+ /* @__PURE__ */ jsx(AutoFocusPlugin, {}),
615
+ /* @__PURE__ */ jsx(
616
+ RichTextPlugin,
617
+ {
618
+ contentEditable: /* @__PURE__ */ jsx(
619
+ ContentEditable,
620
+ {
621
+ "aria-placeholder": "Enter a caption...",
622
+ placeholder: () => /* @__PURE__ */ jsx("span", { children: "Enter a caption..." }),
623
+ className: "ImageNode__contentEditable"
624
+ }
625
+ ),
626
+ ErrorBoundary: LexicalErrorBoundary
627
+ }
628
+ ),
629
+ /* @__PURE__ */ jsx(OnChangePlugin, { onChange: (e) => console.log("e") }),
630
+ /* @__PURE__ */ jsx(HistoryPlugin, {}),
631
+ /* @__PURE__ */ jsx(LocalStoragePlugin, { namespace: initialConfig.namespace })
632
+ ]
633
+ }
634
+ ) }),
635
+ resizable && $isNodeSelection(selection) && isFocused && /* @__PURE__ */ jsx(
636
+ ImageResizer,
637
+ {
638
+ showCaption,
639
+ setShowCaption,
640
+ editor,
641
+ buttonRef,
642
+ imageRef,
643
+ maxWidth,
644
+ onResizeStart,
645
+ onResizeEnd,
646
+ captionsEnabled: !isLoadError && captionsEnabled
647
+ }
648
+ )
649
+ ] }) });
650
+ }
651
+ export {
652
+ RIGHT_CLICK_IMAGE_COMMAND,
653
+ ImageComponent as default
654
+ };
655
+ //# sourceMappingURL=index-7c4c0170.js.map