ct-rich-text-editor 1.3.26 → 1.3.28
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/dist/api/config/endpoints.d.ts +3 -0
- package/dist/api/linkPreview.d.ts +15 -0
- package/dist/assets/style.css +86 -4
- package/dist/components/ImageView/index.d.ts +2 -1
- package/dist/{html2pdf.bundle-41a72ab2.js → html2pdf.bundle-0e71462c.js} +2 -2
- package/dist/{html2pdf.bundle-41a72ab2.js.map → html2pdf.bundle-0e71462c.js.map} +1 -1
- package/dist/{html2pdf.bundle.min-1f376935.js → html2pdf.bundle.min-d2f5d9cb.js} +2 -2
- package/dist/{html2pdf.bundle.min-1f376935.js.map → html2pdf.bundle.min-d2f5d9cb.js.map} +1 -1
- package/dist/{index-9b519a99.js → index-03cae849.js} +2 -15
- package/dist/index-03cae849.js.map +1 -0
- package/dist/{index-a2107b7c.js → index-0533674e.js} +2101 -276
- package/dist/index-0533674e.js.map +1 -0
- package/dist/{index-01a6d110.js → index-c26337f6.js} +216 -12
- package/dist/index-c26337f6.js.map +1 -0
- package/dist/index.js +5 -5
- package/dist/nodes/ImageNode.d.ts +9 -3
- package/dist/plugins/LinkPreviewPlugin/index.d.ts +3 -1
- package/dist/plugins/MarkdownShortcutsPlugin/index.d.ts +20 -0
- package/dist/plugins/PasteOptionsPlugin/index.d.ts +17 -0
- package/dist/plugins/RichTextPastePlugin/index.d.ts +3 -12
- package/package.json +1 -1
- package/dist/index-01a6d110.js.map +0 -1
- package/dist/index-9b519a99.js.map +0 -1
- package/dist/index-a2107b7c.js.map +0 -1
|
@@ -13,9 +13,9 @@ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
|
13
13
|
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
14
14
|
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
15
15
|
import { calculateZoomLevel, mergeRegister } from "@lexical/utils";
|
|
16
|
-
import { RootNode, TextNode, LineBreakNode, ParagraphNode, $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, createCommand, $getNodeByKey } from "lexical";
|
|
17
|
-
import { useRef, useState,
|
|
18
|
-
import { b as Dialog, d as DialogContent, e as DialogHeader, f as DialogTitle, h as DialogDescription, i as DialogFooter, B as Button, L as LocalStoragePlugin, j as initialConfig, k as $isImageNode, S as Sparkles, E as ExternalLink, T as Trash2, t as toast,
|
|
16
|
+
import { RootNode, TextNode, LineBreakNode, ParagraphNode, $getSelection, $isNodeSelection, $isParagraphNode, $setSelection, $isRangeSelection, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_LOW, CLICK_COMMAND, DRAGSTART_COMMAND, KEY_DELETE_COMMAND, KEY_BACKSPACE_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, createCommand, $getNodeByKey } from "lexical";
|
|
17
|
+
import { useRef, useState, useEffect, useCallback, Suspense } from "react";
|
|
18
|
+
import { a as createLucideIcon, b as Dialog, d as DialogContent, e as DialogHeader, f as DialogTitle, h as DialogDescription, i as DialogFooter, B as Button, L as LocalStoragePlugin, j as initialConfig, k as $isImageNode, A as AlignLeft, l as AlignCenter, m as AlignRight, n as Type, S as Sparkles, E as ExternalLink, T as Trash2, t as toast, o as AiJsonResponse } from "./index-0533674e.js";
|
|
19
19
|
import "axios";
|
|
20
20
|
import "@emotion/styled";
|
|
21
21
|
import "@lexical/html";
|
|
@@ -41,6 +41,29 @@ import "emoji-picker-react";
|
|
|
41
41
|
import "@mui/icons-material";
|
|
42
42
|
import "@lexical/react/LexicalLinkPlugin";
|
|
43
43
|
import "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
44
|
+
/**
|
|
45
|
+
* @license lucide-react v0.344.0 - ISC
|
|
46
|
+
*
|
|
47
|
+
* This source code is licensed under the ISC license.
|
|
48
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
49
|
+
*/
|
|
50
|
+
const Link2 = createLucideIcon("Link2", [
|
|
51
|
+
["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
|
|
52
|
+
["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
|
|
53
|
+
["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
|
|
54
|
+
]);
|
|
55
|
+
/**
|
|
56
|
+
* @license lucide-react v0.344.0 - ISC
|
|
57
|
+
*
|
|
58
|
+
* This source code is licensed under the ISC license.
|
|
59
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
60
|
+
*/
|
|
61
|
+
const WrapText = createLucideIcon("WrapText", [
|
|
62
|
+
["line", { x1: "3", x2: "21", y1: "6", y2: "6", key: "4m8b97" }],
|
|
63
|
+
["path", { d: "M3 12h15a3 3 0 1 1 0 6h-4", key: "1cl7v7" }],
|
|
64
|
+
["polyline", { points: "16 16 14 18 16 20", key: "1jznyi" }],
|
|
65
|
+
["line", { x1: "3", x2: "10", y1: "18", y2: "18", key: "1h33wv" }]
|
|
66
|
+
]);
|
|
44
67
|
const imageCaptionStyles = "";
|
|
45
68
|
const ImageComparisonDialog = ({
|
|
46
69
|
open,
|
|
@@ -493,7 +516,8 @@ function ImageComponent({
|
|
|
493
516
|
caption,
|
|
494
517
|
captionsEnabled,
|
|
495
518
|
originalPrompt,
|
|
496
|
-
position = "none"
|
|
519
|
+
position = "none",
|
|
520
|
+
linkUrl
|
|
497
521
|
}) {
|
|
498
522
|
const imageRef = useRef(null);
|
|
499
523
|
const buttonRef = useRef(null);
|
|
@@ -511,6 +535,23 @@ function ImageComponent({
|
|
|
511
535
|
const [showComparisonDialog, setShowComparisonDialog] = useState(false);
|
|
512
536
|
const [newImageUrl, setNewImageUrl] = useState("");
|
|
513
537
|
const [newCombinedPrompt, setNewCombinedPrompt] = useState("");
|
|
538
|
+
const [showLinkPreview, setShowLinkPreview] = useState(false);
|
|
539
|
+
const linkPreviewTimeoutRef = useRef(null);
|
|
540
|
+
const [imageWidth, setImageWidth] = useState(0);
|
|
541
|
+
const shouldPositionBelow = imageWidth > 0 && imageWidth < 350;
|
|
542
|
+
useEffect(() => {
|
|
543
|
+
if (imageRef.current) {
|
|
544
|
+
const updateWidth = () => {
|
|
545
|
+
if (imageRef.current) {
|
|
546
|
+
setImageWidth(imageRef.current.offsetWidth);
|
|
547
|
+
}
|
|
548
|
+
};
|
|
549
|
+
updateWidth();
|
|
550
|
+
const resizeObserver = new ResizeObserver(updateWidth);
|
|
551
|
+
resizeObserver.observe(imageRef.current);
|
|
552
|
+
return () => resizeObserver.disconnect();
|
|
553
|
+
}
|
|
554
|
+
}, [width, height, isSelected]);
|
|
514
555
|
const $onDelete = useCallback(
|
|
515
556
|
(payload) => {
|
|
516
557
|
const deleteSelection = $getSelection();
|
|
@@ -520,7 +561,11 @@ function ImageComponent({
|
|
|
520
561
|
editor.update(() => {
|
|
521
562
|
deleteSelection.getNodes().forEach((node) => {
|
|
522
563
|
if ($isImageNode(node)) {
|
|
564
|
+
const parent = node.getParent();
|
|
523
565
|
node.remove();
|
|
566
|
+
if (parent && $isParagraphNode(parent) && parent.getChildrenSize() === 0) {
|
|
567
|
+
parent.setFormat("left");
|
|
568
|
+
}
|
|
524
569
|
}
|
|
525
570
|
});
|
|
526
571
|
});
|
|
@@ -568,14 +613,18 @@ function ImageComponent({
|
|
|
568
613
|
);
|
|
569
614
|
const onClick = useCallback(
|
|
570
615
|
(payload) => {
|
|
571
|
-
var _a, _b;
|
|
572
616
|
const event = payload;
|
|
573
617
|
if (isResizing) {
|
|
574
618
|
return true;
|
|
575
619
|
}
|
|
576
620
|
const target = event.target;
|
|
577
|
-
const isClickOnImage = target === imageRef.current
|
|
578
|
-
|
|
621
|
+
const isClickOnImage = target === imageRef.current;
|
|
622
|
+
let isClickWithinImageBounds = false;
|
|
623
|
+
if (!isClickOnImage && imageRef.current) {
|
|
624
|
+
const imageRect = imageRef.current.getBoundingClientRect();
|
|
625
|
+
isClickWithinImageBounds = event.clientX >= imageRect.left && event.clientX <= imageRect.right && event.clientY >= imageRect.top && event.clientY <= imageRect.bottom;
|
|
626
|
+
}
|
|
627
|
+
if (isClickOnImage || isClickWithinImageBounds) {
|
|
579
628
|
if (event.shiftKey) {
|
|
580
629
|
setSelected(!isSelected);
|
|
581
630
|
} else {
|
|
@@ -743,7 +792,21 @@ function ImageComponent({
|
|
|
743
792
|
editor.update(() => {
|
|
744
793
|
const node = $getNodeByKey(nodeKey);
|
|
745
794
|
if ($isImageNode(node)) {
|
|
795
|
+
const parent = node.getParent();
|
|
746
796
|
node.remove();
|
|
797
|
+
if (parent && $isParagraphNode(parent) && parent.getChildrenSize() === 0) {
|
|
798
|
+
parent.setFormat("left");
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
});
|
|
802
|
+
};
|
|
803
|
+
const handlePositionChange = (e, newPosition) => {
|
|
804
|
+
e.preventDefault();
|
|
805
|
+
e.stopPropagation();
|
|
806
|
+
editor.update(() => {
|
|
807
|
+
const node = $getNodeByKey(nodeKey);
|
|
808
|
+
if ($isImageNode(node)) {
|
|
809
|
+
node.setPosition(newPosition);
|
|
747
810
|
}
|
|
748
811
|
});
|
|
749
812
|
};
|
|
@@ -752,6 +815,34 @@ function ImageComponent({
|
|
|
752
815
|
e.stopPropagation();
|
|
753
816
|
setShowRefineInput(!showRefineInput);
|
|
754
817
|
};
|
|
818
|
+
const handleImageMouseEnter = useCallback(() => {
|
|
819
|
+
if (linkUrl && !isSelected) {
|
|
820
|
+
linkPreviewTimeoutRef.current = setTimeout(() => {
|
|
821
|
+
setShowLinkPreview(true);
|
|
822
|
+
}, 300);
|
|
823
|
+
}
|
|
824
|
+
}, [linkUrl, isSelected]);
|
|
825
|
+
const handleImageMouseLeave = useCallback(() => {
|
|
826
|
+
if (linkPreviewTimeoutRef.current) {
|
|
827
|
+
clearTimeout(linkPreviewTimeoutRef.current);
|
|
828
|
+
linkPreviewTimeoutRef.current = null;
|
|
829
|
+
}
|
|
830
|
+
setShowLinkPreview(false);
|
|
831
|
+
}, []);
|
|
832
|
+
const handleLinkClick = useCallback((e) => {
|
|
833
|
+
e.preventDefault();
|
|
834
|
+
e.stopPropagation();
|
|
835
|
+
if (linkUrl) {
|
|
836
|
+
window.open(linkUrl, "_blank", "noopener,noreferrer");
|
|
837
|
+
}
|
|
838
|
+
}, [linkUrl]);
|
|
839
|
+
useEffect(() => {
|
|
840
|
+
return () => {
|
|
841
|
+
if (linkPreviewTimeoutRef.current) {
|
|
842
|
+
clearTimeout(linkPreviewTimeoutRef.current);
|
|
843
|
+
}
|
|
844
|
+
};
|
|
845
|
+
}, []);
|
|
755
846
|
const handleRefineImage = async () => {
|
|
756
847
|
if (!refinementPrompt.trim() || isRefining)
|
|
757
848
|
return;
|
|
@@ -842,8 +933,15 @@ function ImageComponent({
|
|
|
842
933
|
if (position === "full") {
|
|
843
934
|
return {
|
|
844
935
|
position: "relative",
|
|
845
|
-
display: "block"
|
|
846
|
-
|
|
936
|
+
display: "inline-block"
|
|
937
|
+
// Use inline-block to respect text-align: center from parent
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
if (position === "inline-left" || position === "inline-center" || position === "inline-right") {
|
|
941
|
+
return {
|
|
942
|
+
position: "relative",
|
|
943
|
+
display: "inline-block"
|
|
944
|
+
// Use inline-block to respect text-align from parent
|
|
847
945
|
};
|
|
848
946
|
}
|
|
849
947
|
return {
|
|
@@ -859,6 +957,17 @@ function ImageComponent({
|
|
|
859
957
|
if (e.target.closest("button")) {
|
|
860
958
|
return;
|
|
861
959
|
}
|
|
960
|
+
const target = e.target;
|
|
961
|
+
const isClickOnImage = target === imageRef.current;
|
|
962
|
+
let isClickWithinImageBounds = false;
|
|
963
|
+
if (!isClickOnImage && imageRef.current) {
|
|
964
|
+
const imageRect = imageRef.current.getBoundingClientRect();
|
|
965
|
+
isClickWithinImageBounds = e.clientX >= imageRect.left && e.clientX <= imageRect.right && e.clientY >= imageRect.top && e.clientY <= imageRect.bottom;
|
|
966
|
+
}
|
|
967
|
+
if (!isClickOnImage && !isClickWithinImageBounds) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
e.stopPropagation();
|
|
862
971
|
if (e.shiftKey) {
|
|
863
972
|
setSelected(!isSelected);
|
|
864
973
|
} else {
|
|
@@ -875,11 +984,13 @@ function ImageComponent({
|
|
|
875
984
|
draggable,
|
|
876
985
|
style: getPositionStyles(),
|
|
877
986
|
onClick: handleDirectClick,
|
|
987
|
+
onMouseEnter: handleImageMouseEnter,
|
|
988
|
+
onMouseLeave: handleImageMouseLeave,
|
|
878
989
|
children: [
|
|
879
990
|
isLoadError ? /* @__PURE__ */ jsx(BrokenImage, {}) : /* @__PURE__ */ jsx(
|
|
880
991
|
LazyImage,
|
|
881
992
|
{
|
|
882
|
-
className: isFocused ? `focused ${$isNodeSelection(selection) ? "draggable" : ""}` : null,
|
|
993
|
+
className: isFocused ? `focused ${$isNodeSelection(selection) ? "draggable" : ""}` : linkUrl ? "cteditor-cursor-pointer" : null,
|
|
883
994
|
src,
|
|
884
995
|
altText,
|
|
885
996
|
imageRef,
|
|
@@ -889,12 +1000,105 @@ function ImageComponent({
|
|
|
889
1000
|
onError: () => setIsLoadError(true)
|
|
890
1001
|
}
|
|
891
1002
|
),
|
|
1003
|
+
showLinkPreview && linkUrl && !isSelected && /* @__PURE__ */ jsxs(
|
|
1004
|
+
"div",
|
|
1005
|
+
{
|
|
1006
|
+
className: "cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-lg cteditor-border cteditor-border-border cteditor-p-2 cteditor-flex cteditor-items-center cteditor-gap-2",
|
|
1007
|
+
style: { zIndex: 10 },
|
|
1008
|
+
children: [
|
|
1009
|
+
/* @__PURE__ */ jsx(Link2, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground cteditor-flex-shrink-0" }),
|
|
1010
|
+
/* @__PURE__ */ jsx("span", { className: "cteditor-text-sm cteditor-text-foreground cteditor-truncate cteditor-flex-1", children: linkUrl }),
|
|
1011
|
+
/* @__PURE__ */ jsx(
|
|
1012
|
+
"button",
|
|
1013
|
+
{
|
|
1014
|
+
onClick: handleLinkClick,
|
|
1015
|
+
className: "cteditor-px-2 cteditor-py-1 cteditor-text-xs cteditor-rounded cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors cteditor-flex-shrink-0",
|
|
1016
|
+
children: "Open"
|
|
1017
|
+
}
|
|
1018
|
+
)
|
|
1019
|
+
]
|
|
1020
|
+
}
|
|
1021
|
+
),
|
|
892
1022
|
isSelected && $isNodeSelection(selection) && !isLoadError && /* @__PURE__ */ jsxs(
|
|
893
1023
|
"div",
|
|
894
1024
|
{
|
|
895
|
-
className:
|
|
1025
|
+
className: `cteditor-absolute cteditor-flex cteditor-gap-1 cteditor-flex-wrap ${shouldPositionBelow ? "cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-bottom-0 cteditor-translate-y-full cteditor-mt-1" : "cteditor-top-2 cteditor-right-2"}`,
|
|
896
1026
|
style: { zIndex: 10 },
|
|
897
1027
|
children: [
|
|
1028
|
+
/* @__PURE__ */ jsxs("div", { className: "cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-background/80 cteditor-rounded-md cteditor-shadow-md cteditor-border cteditor-border-border cteditor-p-0.5", children: [
|
|
1029
|
+
/* @__PURE__ */ jsx(
|
|
1030
|
+
"button",
|
|
1031
|
+
{
|
|
1032
|
+
onClick: (e) => handlePositionChange(e, "left"),
|
|
1033
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "left" ? "cteditor-bg-accent" : ""}`,
|
|
1034
|
+
"aria-label": "Wrap text left",
|
|
1035
|
+
title: "Wrap text left",
|
|
1036
|
+
children: /* @__PURE__ */ jsx(WrapText, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground", style: { transform: "scaleX(-1)" } })
|
|
1037
|
+
}
|
|
1038
|
+
),
|
|
1039
|
+
/* @__PURE__ */ jsx(
|
|
1040
|
+
"button",
|
|
1041
|
+
{
|
|
1042
|
+
onClick: (e) => handlePositionChange(e, "right"),
|
|
1043
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "right" ? "cteditor-bg-accent" : ""}`,
|
|
1044
|
+
"aria-label": "Wrap text right",
|
|
1045
|
+
title: "Wrap text right",
|
|
1046
|
+
children: /* @__PURE__ */ jsx(WrapText, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1047
|
+
}
|
|
1048
|
+
),
|
|
1049
|
+
/* @__PURE__ */ jsx("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
|
|
1050
|
+
/* @__PURE__ */ jsx(
|
|
1051
|
+
"button",
|
|
1052
|
+
{
|
|
1053
|
+
onClick: (e) => handlePositionChange(e, "inline-left"),
|
|
1054
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "inline-left" ? "cteditor-bg-accent" : ""}`,
|
|
1055
|
+
"aria-label": "Align left",
|
|
1056
|
+
title: "Align left (no text wrap)",
|
|
1057
|
+
children: /* @__PURE__ */ jsx(AlignLeft, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1058
|
+
}
|
|
1059
|
+
),
|
|
1060
|
+
/* @__PURE__ */ jsx(
|
|
1061
|
+
"button",
|
|
1062
|
+
{
|
|
1063
|
+
onClick: (e) => handlePositionChange(e, "inline-center"),
|
|
1064
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "inline-center" || position === "full" ? "cteditor-bg-accent" : ""}`,
|
|
1065
|
+
"aria-label": "Align center",
|
|
1066
|
+
title: "Align center (no text wrap)",
|
|
1067
|
+
children: /* @__PURE__ */ jsx(AlignCenter, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1068
|
+
}
|
|
1069
|
+
),
|
|
1070
|
+
/* @__PURE__ */ jsx(
|
|
1071
|
+
"button",
|
|
1072
|
+
{
|
|
1073
|
+
onClick: (e) => handlePositionChange(e, "inline-right"),
|
|
1074
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "inline-right" ? "cteditor-bg-accent" : ""}`,
|
|
1075
|
+
"aria-label": "Align right",
|
|
1076
|
+
title: "Align right (no text wrap)",
|
|
1077
|
+
children: /* @__PURE__ */ jsx(AlignRight, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1078
|
+
}
|
|
1079
|
+
),
|
|
1080
|
+
/* @__PURE__ */ jsx("div", { className: "cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5" }),
|
|
1081
|
+
/* @__PURE__ */ jsx(
|
|
1082
|
+
"button",
|
|
1083
|
+
{
|
|
1084
|
+
onClick: (e) => handlePositionChange(e, "none"),
|
|
1085
|
+
className: `cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === "none" ? "cteditor-bg-accent" : ""}`,
|
|
1086
|
+
"aria-label": "Inline",
|
|
1087
|
+
title: "Inline with text",
|
|
1088
|
+
children: /* @__PURE__ */ jsx(Type, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1089
|
+
}
|
|
1090
|
+
)
|
|
1091
|
+
] }),
|
|
1092
|
+
linkUrl && /* @__PURE__ */ jsx(
|
|
1093
|
+
"button",
|
|
1094
|
+
{
|
|
1095
|
+
onClick: handleLinkClick,
|
|
1096
|
+
className: "cteditor-p-2 cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border",
|
|
1097
|
+
"aria-label": "Visit link",
|
|
1098
|
+
title: `Visit: ${linkUrl}`,
|
|
1099
|
+
children: /* @__PURE__ */ jsx(Link2, { className: "cteditor-w-4 cteditor-h-4 cteditor-text-foreground" })
|
|
1100
|
+
}
|
|
1101
|
+
),
|
|
898
1102
|
originalPrompt && /* @__PURE__ */ jsx(
|
|
899
1103
|
"button",
|
|
900
1104
|
{
|
|
@@ -1082,4 +1286,4 @@ export {
|
|
|
1082
1286
|
RIGHT_CLICK_IMAGE_COMMAND,
|
|
1083
1287
|
ImageComponent as default
|
|
1084
1288
|
};
|
|
1085
|
-
//# sourceMappingURL=index-
|
|
1289
|
+
//# sourceMappingURL=index-c26337f6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-c26337f6.js","sources":["../../../node_modules/lucide-react/dist/esm/icons/link-2.js","../../../node_modules/lucide-react/dist/esm/icons/wrap-text.js","../src/components/ImageComparisonDialog/index.tsx","../src/components/SignatureCaption/index.tsx","../src/components/ImageView/ImageResizer.tsx","../src/components/ImageView/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.344.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Link2 = createLucideIcon(\"Link2\", [\n [\"path\", { d: \"M9 17H7A5 5 0 0 1 7 7h2\", key: \"8i5ue5\" }],\n [\"path\", { d: \"M15 7h2a5 5 0 1 1 0 10h-2\", key: \"1b9ql8\" }],\n [\"line\", { x1: \"8\", x2: \"16\", y1: \"12\", y2: \"12\", key: \"1jonct\" }]\n]);\n\nexport { Link2 as default };\n//# sourceMappingURL=link-2.js.map\n","/**\n * @license lucide-react v0.344.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst WrapText = createLucideIcon(\"WrapText\", [\n [\"line\", { x1: \"3\", x2: \"21\", y1: \"6\", y2: \"6\", key: \"4m8b97\" }],\n [\"path\", { d: \"M3 12h15a3 3 0 1 1 0 6h-4\", key: \"1cl7v7\" }],\n [\"polyline\", { points: \"16 16 14 18 16 20\", key: \"1jznyi\" }],\n [\"line\", { x1: \"3\", x2: \"10\", y1: \"18\", y2: \"18\", key: \"1h33wv\" }]\n]);\n\nexport { WrapText as default };\n//# sourceMappingURL=wrap-text.js.map\n","import React from \"react\";\nimport { Button } from \"../ui/button\";\nimport {\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n} from \"../ui/dialog\";\n\ninterface ImageComparisonDialogProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n oldImageUrl: string;\n newImageUrl: string;\n onReplace: () => void;\n onCancel: () => void;\n}\n\nexport const ImageComparisonDialog: React.FC<ImageComparisonDialogProps> = ({\n open,\n onOpenChange,\n oldImageUrl,\n newImageUrl,\n onReplace,\n onCancel,\n}) => {\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"sm:max-w-[800px] max-h-[90vh] overflow-y-auto\">\n <DialogHeader>\n <DialogTitle className=\"flex items-center gap-2 text-xl\">\n <span className=\"text-2xl\">🔄</span>\n Compare Images\n </DialogTitle>\n <DialogDescription className=\"text-sm pt-1\">\n Choose whether to replace the original image with the refined version.\n </DialogDescription>\n </DialogHeader>\n\n <div className=\"space-y-4 py-4\">\n <div className=\"grid grid-cols-2 gap-4\">\n\n {/* New Image */}\n <div className=\"space-y-2\">\n <div className=\"flex items-center justify-between\">\n <span className=\"text-sm font-semibold text-gray-700 dark:text-gray-300\">\n Refined Image\n </span>\n <span className=\"text-xs px-2 py-1 rounded-full bg-blue-100 dark:bg-blue-950/30 text-blue-600 dark:text-blue-400\">\n New\n </span>\n </div>\n <div className=\"relative aspect-square rounded-lg overflow-hidden bg-gray-100 dark:bg-gray-800 border-2 border-blue-500 dark:border-blue-600\">\n <img\n src={newImageUrl}\n alt=\"Refined\"\n className=\"w-full h-full object-contain\"\n />\n </div>\n </div>\n </div>\n\n {/* Info */}\n <div className=\"p-3 rounded-lg bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800\">\n <p className=\"text-sm text-blue-800 dark:text-blue-200\">\n <span className=\"font-semibold\">Note:</span> Clicking \"Replace\" will update the image in your document.\n This action cannot be undone.\n </p>\n </div>\n </div>\n\n <DialogFooter className=\"gap-2\">\n <Button\n variant=\"outline\"\n onClick={onCancel}\n >\n Keep Original\n </Button>\n <Button\n onClick={onReplace}\n className=\"bg-blue-500 hover:bg-blue-600 text-white\"\n >\n <span className=\"mr-2\">✓</span>\n Replace Image\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n );\n};\n\n","/**\n * SignatureCaption Component\n * A premium styled caption component specifically for signatures\n */\n\nimport \"./signature-caption.css\";\n\nimport { CodeNode } from \"@lexical/code\";\nimport { LinkNode } from \"@lexical/link\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { LexicalNestedComposer } from \"@lexical/react/LexicalNestedComposer\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport type { LexicalEditor } from \"lexical\";\nimport { LineBreakNode, ParagraphNode, RootNode, TextNode } from \"lexical\";\nimport { initialConfig } from \"src/constants\";\nimport LocalStoragePlugin from \"src/plugins/LocalStoragePlugin\";\n\ninterface SignatureCaptionProps {\n caption: LexicalEditor;\n}\n\nexport default function SignatureCaption({\n caption,\n}: SignatureCaptionProps): JSX.Element {\n return (\n <div className=\"signature-caption-container\">\n <LexicalNestedComposer\n initialEditor={caption}\n initialNodes={[\n RootNode,\n TextNode,\n LineBreakNode,\n ParagraphNode,\n LinkNode,\n CodeNode,\n ]}\n >\n <RichTextPlugin\n contentEditable={\n <ContentEditable\n aria-placeholder=\"Enter signature name...\"\n placeholder={\n <div style={{\n position: 'absolute',\n top: '4px',\n left: '8px',\n right: '8px',\n textAlign: 'center',\n pointerEvents: 'none',\n color: 'hsla(var(--cteditorf47ac10b-foreground) / 0.4)',\n fontStyle: 'italic'\n }}>\n Enter signature name...\n </div>\n }\n className=\"signature-caption-editable\"\n />\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n\n <OnChangePlugin onChange={() => {\n // Placeholder for future change handling\n }} />\n <HistoryPlugin />\n <LocalStoragePlugin namespace={initialConfig.namespace} />\n </LexicalNestedComposer>\n </div>\n );\n}\n","/**\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 \"./image-caption-styles.css\";\n\nimport { calculateZoomLevel } from \"@lexical/utils\";\nimport type { LexicalEditor } from \"lexical\";\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 default 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}): 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\n // Allow enlarging up to the editor container width (ignore any fixed maxWidth cap)\n const maxWidthContainer =\n editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().height - 20\n : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n /**\n * Sets the cursor style to indicate the resizing direction.\n * This function updates the cursor for the editor and document body\n * based on the resizing direction.\n */\n const setStartCursor = (direction: number) => {\n // Determine if the resizing is happening horizontally (east or west)\n const ew = direction === Direction.east || direction === Direction.west;\n // Determine if the resizing is happening vertically (north or south)\n const ns = direction === Direction.north || direction === Direction.south;\n // Determine if the resizing is diagonal (north-west, south-east, etc.)\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n // Set the appropriate cursor style based on the detected direction\n const cursorDir = ew ? \"ew\" : ns ? \"ns\" : nwse ? \"nwse\" : \"nesw\";\n\n // Apply the cursor style to the editor root element if it exists\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\n \"cursor\",\n `${cursorDir}-resize`,\n \"important\"\n );\n }\n\n // Apply the cursor style to the document body\n if (document.body !== null) {\n document.body.style.setProperty(\n \"cursor\",\n `${cursorDir}-resize`,\n \"important\"\n );\n\n // Store the current user selection settings before modifying them\n userSelect.current.value = document.body.style.getPropertyValue(\n \"-webkit-user-select\"\n );\n userSelect.current.priority = document.body.style.getPropertyPriority(\n \"-webkit-user-select\"\n );\n\n // Disable text selection during resizing to prevent unwanted text selection\n document.body.style.setProperty(\n \"-webkit-user-select\",\n `none`,\n \"important\"\n );\n }\n };\n\n /**\n * Resets the cursor style when resizing ends.\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 /**\n * Handles pointer down event when resizing starts.\n */\n const handlePointerDown = (\n event: React.PointerEvent<HTMLDivElement>,\n direction: number\n ) => {\n if (!editor.isEditable()) {\n return;\n }\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n // Ensure both the image and control wrapper exist before proceeding\n if (image !== null && controlWrapper !== null) {\n event.preventDefault();\n\n // Get the image's current width and height from its bounding rectangle\n const { width, height } = image.getBoundingClientRect();\n // Calculate the zoom level to adjust calculations accordingly\n const zoom = calculateZoomLevel(image);\n // Retrieve the positioning reference object to store resize state\n const positioning = positioningRef.current;\n\n // Store the initial dimensions of the image\n positioning.startWidth = width;\n positioning.startHeight = height;\n // Store the aspect ratio to maintain proportions when resizing\n positioning.ratio = width / height;\n // Set the current width and height values for tracking changes\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n // Store the initial pointer position, adjusted for zoom level\n positioning.startX = event.clientX / zoom;\n positioning.startY = event.clientY / zoom;\n // Mark the resizing state as active\n positioning.isResizing = true;\n // Store the resize direction (north, south, east, west, or combinations)\n positioning.direction = direction;\n\n // Set the cursor style to indicate resizing in the correct direction\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 document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n }\n };\n\n /**\n * Handles pointer move event when resizing the image dynamically.\n */\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n // Check if the resize direction includes horizontal movement (east or west)\n const isHorizontal =\n positioning.direction & (Direction.east | Direction.west);\n // Check if the resize direction includes vertical movement (north or south)\n const isVertical =\n positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Get the zoom level of the image to ensure accurate calculations\n const zoom = calculateZoomLevel(image);\n\n if (isHorizontal && isVertical) {\n // Calculate the difference in X position relative to the starting point\n let diff = Math.floor(positioning.startX - event.clientX / zoom);\n // Reverse the difference if resizing from the east to ensure correct calculations\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n // Calculate the new width, ensuring it stays within allowed min and max limits\n const width = clamp(\n positioning.startWidth + diff,\n minWidth,\n maxWidthContainer\n );\n // Maintain the aspect ratio by adjusting height proportionally\n const height = width / positioning.ratio;\n // Apply the new width and height to the image\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n // Update stored dimensions for ongoing tracking\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n // Calculate the difference in Y position relative to the starting point\n let diff = Math.floor(positioning.startY - event.clientY / zoom);\n // Reverse the difference if resizing from the south to maintain correct direction\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n // Calculate the new height, ensuring it stays within allowed min and max limits\n const height = clamp(\n positioning.startHeight + diff,\n minHeight,\n maxHeightContainer\n );\n\n // Apply the new height to the image\n image.style.height = `${height}px`;\n // Update stored height for ongoing tracking\n positioning.currentHeight = height;\n } else {\n // Calculate the difference in X position relative to the starting point\n let diff = Math.floor(positioning.startX - event.clientX / zoom);\n // Reverse the difference if resizing from the east to maintain correct direction\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n // Calculate the new width, ensuring it stays within allowed min and max limits\n const width = clamp(\n positioning.startWidth + diff,\n minWidth,\n maxWidthContainer\n );\n\n // Apply the new width to the image\n image.style.width = `${width}px`;\n // Update stored width for ongoing tracking\n positioning.currentWidth = width;\n }\n }\n };\n\n /**\n * Handles the pointer up event when resizing ends.\n */\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n // Ensure the image, control wrapper exist, and resizing is active before proceeding\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n // Capture the final width and height of the resized image\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n\n // Reset positioning values after resizing is complete\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; // Mark resizing as finished\n\n // Remove the resizing class from the control wrapper\n controlWrapper.classList.remove(\"image-control-wrapper--resizing\");\n\n // Restore default cursor appearance\n setEndCursor();\n // Trigger the resize end callback with the final dimensions\n onResizeEnd(width, height);\n\n // Remove event listeners for pointer movement and release to stop tracking\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n }\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","/**\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 \"./image-caption-styles.css\";\n\nimport { CodeNode } from \"@lexical/code\";\nimport { LinkNode } from \"@lexical/link\";\nimport { AutoFocusPlugin } from \"@lexical/react/LexicalAutoFocusPlugin\";\nimport { useCollaborationContext } from \"@lexical/react/LexicalCollaborationContext\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary\";\nimport { HistoryPlugin } from \"@lexical/react/LexicalHistoryPlugin\";\nimport { LexicalNestedComposer } from \"@lexical/react/LexicalNestedComposer\";\nimport { OnChangePlugin } from \"@lexical/react/LexicalOnChangePlugin\";\n// import './ImageNode.css';\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { useLexicalEditable } from \"@lexical/react/useLexicalEditable\";\nimport { useLexicalNodeSelection } from \"@lexical/react/useLexicalNodeSelection\";\nimport { mergeRegister } from \"@lexical/utils\";\nimport type {\n BaseSelection,\n LexicalCommand,\n LexicalEditor,\n NodeKey,\n} from \"lexical\";\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n $isParagraphNode,\n $isRangeSelection,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n createCommand,\n DRAGSTART_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n LineBreakNode,\n ParagraphNode,\n RootNode,\n SELECTION_CHANGE_COMMAND,\n TextNode,\n} from \"lexical\";\nimport { AlignCenter, AlignLeft, AlignRight, ExternalLink, Link2, Sparkles, Trash2, Type, WrapText } from \"lucide-react\";\nimport * as React from \"react\";\nimport { Suspense, useCallback, useEffect, useRef, useState } from \"react\";\n// import brokenImage from '../images/image-broken.svg';\nimport { toast } from \"sonner\";\nimport { initialConfig } from \"src/constants\";\nimport { $isImageNode, ImagePosition } from \"src/nodes/ImageNode\";\nimport LocalStoragePlugin from \"src/plugins/LocalStoragePlugin\";\n\nimport { AiJsonResponse } from \"../../api/ai\";\nimport { ImageComparisonDialog } from \"../ImageComparisonDialog\";\nimport SignatureCaption from \"../SignatureCaption\";\nimport ImageResizer from \"./ImageResizer\";\n\nconst imageCache = new Set();\n\nexport const RIGHT_CLICK_IMAGE_COMMAND: LexicalCommand<MouseEvent> =\n createCommand(\"RIGHT_CLICK_IMAGE_COMMAND\");\n\nfunction useSuspenseImage(src: string) {\n if (!imageCache.has(src)) {\n throw new Promise((resolve) => {\n const img = new Image();\n img.src = src;\n img.onload = () => {\n imageCache.add(src);\n resolve(null);\n };\n img.onerror = () => {\n imageCache.add(src);\n };\n });\n }\n}\n\nfunction LazyImage({\n altText,\n className,\n imageRef,\n src,\n width,\n height,\n maxWidth,\n onError,\n}: {\n altText: string;\n className: string | null;\n height: \"inherit\" | number;\n imageRef: { current: null | HTMLImageElement };\n maxWidth: number;\n src: string;\n width: \"inherit\" | number;\n onError: () => void;\n}): JSX.Element {\n useSuspenseImage(src);\n const hasExplicitSize =\n typeof width === \"number\" && typeof height === \"number\";\n const computedWidth = typeof width === \"number\" ? width : \"auto\";\n const computedHeight = typeof height === \"number\" ? height : \"auto\";\n\n return (\n <img\n className={className || undefined}\n src={src}\n alt={altText}\n ref={imageRef}\n style={\n hasExplicitSize\n ? {\n // User has set a numeric size or original dimensions are provided\n width: computedWidth,\n height: computedHeight,\n maxWidth: \"100%\",\n }\n : {\n // No dimensions specified - use original image size\n maxWidth: \"100%\",\n height: \"auto\",\n }\n }\n onError={onError}\n draggable=\"false\"\n />\n );\n}\n\n// if the image is broken ; we are showing this component\nfunction BrokenImage(): JSX.Element {\n return (\n <img\n src={\"\"} //TODO: NEED TO ADD BROKEN IMAGE\n style={{\n height: 200,\n opacity: 0.2,\n width: 200,\n }}\n draggable=\"false\"\n />\n );\n}\n\nexport default function ImageComponent({\n src,\n altText,\n nodeKey,\n width,\n height,\n maxWidth,\n resizable,\n showCaption,\n caption,\n captionsEnabled,\n originalPrompt,\n position = \"none\",\n linkUrl,\n}: {\n altText: string;\n caption: LexicalEditor;\n height: \"inherit\" | number;\n maxWidth: number;\n nodeKey: NodeKey;\n resizable: boolean;\n showCaption: boolean;\n src: string;\n width: \"inherit\" | number;\n captionsEnabled: boolean;\n originalPrompt?: string;\n position?: ImagePosition;\n linkUrl?: string;\n}): JSX.Element {\n const imageRef = useRef<null | HTMLImageElement>(null);\n const buttonRef = useRef<HTMLButtonElement | null>(null);\n const [isSelected, setSelected, clearSelection] =\n useLexicalNodeSelection(nodeKey);\n const [isResizing, setIsResizing] = useState<boolean>(false);\n const { isCollabActive } = useCollaborationContext();\n const [editor] = useLexicalComposerContext();\n const [selection, setSelection] = useState<BaseSelection | null>(null);\n const activeEditorRef = useRef<LexicalEditor | null>(null);\n const [isLoadError, setIsLoadError] = useState<boolean>(false);\n const isEditable = useLexicalEditable();\n const [showRefineInput, setShowRefineInput] = useState<boolean>(false);\n const [refinementPrompt, setRefinementPrompt] = useState<string>(\"\");\n const [isRefining, setIsRefining] = useState<boolean>(false);\n const [showComparisonDialog, setShowComparisonDialog] =\n useState<boolean>(false);\n const [newImageUrl, setNewImageUrl] = useState<string>(\"\");\n const [newCombinedPrompt, setNewCombinedPrompt] = useState<string>(\"\");\n const [showLinkPreview, setShowLinkPreview] = useState<boolean>(false);\n const linkPreviewTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const [imageWidth, setImageWidth] = useState<number>(0);\n\n // Position toolbar below image when it's small (under 350px)\n const shouldPositionBelow = imageWidth > 0 && imageWidth < 350;\n\n // Update image width when it changes\n useEffect(() => {\n if (imageRef.current) {\n const updateWidth = () => {\n if (imageRef.current) {\n setImageWidth(imageRef.current.offsetWidth);\n }\n };\n updateWidth();\n\n // Also observe for size changes\n const resizeObserver = new ResizeObserver(updateWidth);\n resizeObserver.observe(imageRef.current);\n\n return () => resizeObserver.disconnect();\n }\n }, [width, height, isSelected]);\n\n /**\n * Deletes the image node when the delete key is pressed.\n */\n const $onDelete = useCallback(\n (payload: KeyboardEvent) => {\n const deleteSelection = $getSelection();\n if (isSelected && $isNodeSelection(deleteSelection)) {\n const event: KeyboardEvent = payload;\n event.preventDefault();\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isImageNode(node)) {\n // Get parent before removing to reset alignment if needed\n const parent = node.getParent();\n node.remove();\n // Reset paragraph alignment to left after removing centered image\n if (parent && $isParagraphNode(parent) && parent.getChildrenSize() === 0) {\n parent.setFormat(\"left\");\n }\n }\n });\n });\n }\n return false;\n },\n [editor, isSelected]\n );\n\n /**\n * Handles enter key to move focus into the caption editor.\n */\n const $onEnter = useCallback(\n (event: KeyboardEvent) => {\n const latestSelection = $getSelection();\n const buttonElem = buttonRef.current;\n if (\n isSelected &&\n $isNodeSelection(latestSelection) &&\n latestSelection.getNodes().length === 1\n ) {\n if (showCaption) {\n // Move focus into nested editor\n $setSelection(null);\n event.preventDefault();\n caption.focus();\n return true;\n } else if (\n buttonElem !== null &&\n buttonElem !== document.activeElement\n ) {\n event.preventDefault();\n buttonElem.focus();\n return true;\n }\n }\n return false;\n },\n [caption, isSelected, showCaption]\n );\n\n /**\n * Handles escape key to reset selection.\n */\n const $onEscape = useCallback(\n (event: KeyboardEvent) => {\n if (\n activeEditorRef.current === caption ||\n buttonRef.current === event.target\n ) {\n $setSelection(null);\n editor.update(() => {\n setSelected(true);\n const parentRootElement = editor.getRootElement();\n if (parentRootElement !== null) {\n parentRootElement.focus();\n }\n });\n return true;\n }\n return false;\n },\n [caption, editor, setSelected]\n );\n\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload;\n\n if (isResizing) {\n return true;\n }\n\n const target = event.target as HTMLElement;\n\n // Check if clicking directly on this image element\n const isClickOnImage = target === imageRef.current;\n\n // Also check if click coordinates are within the image bounds\n // This handles cases where inline images next to text might not receive direct clicks\n let isClickWithinImageBounds = false;\n if (!isClickOnImage && imageRef.current) {\n const imageRect = imageRef.current.getBoundingClientRect();\n isClickWithinImageBounds =\n event.clientX >= imageRect.left &&\n event.clientX <= imageRect.right &&\n event.clientY >= imageRect.top &&\n event.clientY <= imageRect.bottom;\n }\n\n if (isClickOnImage || isClickWithinImageBounds) {\n if (event.shiftKey) {\n setSelected(!isSelected);\n } else {\n clearSelection();\n setSelected(true);\n }\n return true;\n }\n\n return false;\n },\n [isResizing, isSelected, setSelected, clearSelection]\n );\n\n const onRightClick = useCallback(\n (event: MouseEvent): void => {\n editor.getEditorState().read(() => {\n const latestSelection = $getSelection();\n const domElement = event.target as HTMLElement;\n if (\n domElement.tagName === \"IMG\" &&\n $isRangeSelection(latestSelection) &&\n latestSelection.getNodes().length === 1\n ) {\n editor.dispatchCommand(\n RIGHT_CLICK_IMAGE_COMMAND,\n event as MouseEvent\n );\n }\n });\n },\n [editor]\n );\n\n useEffect(() => {\n let isMounted = true;\n const rootElement = editor.getRootElement();\n const unregister = mergeRegister(\n editor.registerUpdateListener(({ editorState }) => {\n if (isMounted) {\n setSelection(editorState.read(() => $getSelection()));\n }\n }),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_, activeEditor) => {\n activeEditorRef.current = activeEditor;\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand<MouseEvent>(\n CLICK_COMMAND,\n onClick,\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand<MouseEvent>(\n RIGHT_CLICK_IMAGE_COMMAND,\n onClick,\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n DRAGSTART_COMMAND,\n (event) => {\n if (event.target === imageRef.current) {\n // Temporary workaround for FF to behave like other browsers.\n // Ideally, this handles drag & drop too (and all browsers).\n event.preventDefault();\n return true;\n }\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n KEY_DELETE_COMMAND,\n $onDelete,\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(\n KEY_BACKSPACE_COMMAND,\n $onDelete,\n COMMAND_PRIORITY_LOW\n ),\n editor.registerCommand(KEY_ENTER_COMMAND, $onEnter, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n $onEscape,\n COMMAND_PRIORITY_LOW\n )\n );\n\n rootElement?.addEventListener(\"contextmenu\", onRightClick);\n\n return () => {\n isMounted = false;\n unregister();\n rootElement?.removeEventListener(\"contextmenu\", onRightClick);\n };\n }, [\n clearSelection,\n editor,\n isResizing,\n isSelected,\n nodeKey,\n $onDelete,\n $onEnter,\n $onEscape,\n onClick,\n onRightClick,\n setSelected,\n ]);\n\n const setShowCaption = () => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isImageNode(node)) {\n node.setShowCaption(true);\n }\n });\n };\n\n const onResizeEnd = (\n nextWidth: \"inherit\" | number,\n nextHeight: \"inherit\" | number\n ) => {\n // Delay hiding the resize bars for click case\n setTimeout(() => {\n setIsResizing(false);\n }, 200);\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isImageNode(node)) {\n node.setWidthAndHeight(nextWidth, nextHeight);\n }\n });\n };\n\n const onResizeStart = () => {\n setIsResizing(true);\n };\n\n const handleOpenInNewTab = (e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n // Check if it's a data URL (base64)\n if (src.startsWith(\"data:\")) {\n // For data URLs, we need to open them in a new tab with the image displayed\n const newWindow = window.open(\"\", \"_blank\");\n if (newWindow) {\n newWindow.document.write(`\n <!DOCTYPE html>\n <html>\n <head>\n <title>${altText || \"Image\"}</title>\n <style>\n body {\n margin: 0;\n display: flex;\n justify-content: center;\n align-items: center;\n min-height: 100vh;\n background-color: #1a1a1a;\n }\n img {\n max-width: 100%;\n max-height: 100vh;\n object-fit: contain;\n }\n </style>\n </head>\n <body>\n <img src=\"${src}\" alt=\"${altText || \"Image\"}\" />\n </body>\n </html>\n `);\n newWindow.document.close();\n }\n } else {\n // For regular URLs, just open them directly\n window.open(src, \"_blank\");\n }\n };\n\n const handleDeleteImage = (e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isImageNode(node)) {\n // Get parent before removing to reset alignment if needed\n const parent = node.getParent();\n node.remove();\n // Reset paragraph alignment to left after removing centered image\n if (parent && $isParagraphNode(parent) && parent.getChildrenSize() === 0) {\n parent.setFormat(\"left\");\n }\n }\n });\n };\n\n const handlePositionChange = (e: React.MouseEvent, newPosition: ImagePosition) => {\n e.preventDefault();\n e.stopPropagation();\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isImageNode(node)) {\n node.setPosition(newPosition);\n }\n });\n };\n\n const handleRefineClick = (e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n setShowRefineInput(!showRefineInput);\n };\n\n // Link preview hover handlers\n const handleImageMouseEnter = useCallback(() => {\n if (linkUrl && !isSelected) {\n // Delay showing the link preview to avoid flickering on quick mouse movements\n linkPreviewTimeoutRef.current = setTimeout(() => {\n setShowLinkPreview(true);\n }, 300);\n }\n }, [linkUrl, isSelected]);\n\n const handleImageMouseLeave = useCallback(() => {\n // Clear the timeout if mouse leaves before preview shows\n if (linkPreviewTimeoutRef.current) {\n clearTimeout(linkPreviewTimeoutRef.current);\n linkPreviewTimeoutRef.current = null;\n }\n setShowLinkPreview(false);\n }, []);\n\n const handleLinkClick = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (linkUrl) {\n window.open(linkUrl, \"_blank\", \"noopener,noreferrer\");\n }\n }, [linkUrl]);\n\n // Clean up timeout on unmount\n useEffect(() => {\n return () => {\n if (linkPreviewTimeoutRef.current) {\n clearTimeout(linkPreviewTimeoutRef.current);\n }\n };\n }, []);\n\n const handleRefineImage = async () => {\n if (!refinementPrompt.trim() || isRefining) return;\n\n setIsRefining(true);\n\n // Show loading toast\n const loadingToast = toast.loading(\"Refining image...\", {\n description: \"This may take 10-30 seconds. Please wait.\",\n });\n\n try {\n // Intelligently combine original prompt with refinement\n let combinedPrompt = refinementPrompt.trim();\n\n // Check if we have an original prompt\n if (originalPrompt && originalPrompt.trim()) {\n const original = originalPrompt.trim();\n const refinement = refinementPrompt.trim();\n\n // Remove common \"add\" prefixes from refinement\n const cleanedRefinement = refinement\n .replace(/^(add|also add|include|with|and)\\s+(some|a|an)\\s+/gi, \"\")\n .replace(/^(add|also add|include|with|and)\\s+/gi, \"\")\n .trim();\n\n // Simple and clear combination - just list both elements\n // This is the most reliable format for DALL-E\n combinedPrompt = `${original} with ${cleanedRefinement}`;\n } else {\n // No original prompt (image was created before this feature)\n // Try to use altText or just use the refinement as-is\n if (altText && altText !== \"Generated image\" && altText.trim()) {\n // Use altText as the original description\n const cleanedRefinement = refinementPrompt\n .trim()\n .replace(/^(add|also add|include|with|and)\\s+(some|a|an)\\s+/gi, \"\")\n .replace(/^(add|also add|include|with|and)\\s+/gi, \"\")\n .trim();\n combinedPrompt = `${altText} with ${cleanedRefinement}`;\n }\n // else: Just use the refinement prompt as-is\n }\n\n // Generate refined image with combined prompt\n const response = await AiJsonResponse({\n content: `Generate Image: ${combinedPrompt}`,\n });\n const htmlString = response?.data;\n\n if (!htmlString) {\n throw new Error(\"Failed to generate image - empty response\");\n }\n\n // Extract image URL from HTML response\n const parser = new DOMParser();\n const dom = parser.parseFromString(htmlString, \"text/html\");\n const imgElement = dom.querySelector(\"img\");\n\n if (!imgElement || !imgElement.src) {\n throw new Error(`No image found in response`);\n }\n\n const generatedImageUrl = imgElement.src;\n\n // Dismiss loading toast and show success\n toast.dismiss(loadingToast);\n toast.success(\"Image refined successfully!\", {\n description: \"Compare the images and choose which to keep.\",\n });\n\n // Store new image URL, combined prompt, and show comparison dialog\n setNewImageUrl(generatedImageUrl);\n setNewCombinedPrompt(combinedPrompt);\n setShowComparisonDialog(true);\n\n // Clear refinement input and close it\n setRefinementPrompt(\"\");\n setShowRefineInput(false);\n } catch (error) {\n // Dismiss loading toast and show error\n toast.dismiss(loadingToast);\n toast.error(\"Failed to refine image\", {\n description:\n error instanceof Error\n ? error.message\n : \"Unknown error. Please try again.\",\n });\n } finally {\n setIsRefining(false);\n }\n };\n\n const handleReplaceImage = () => {\n // Update the image node with new URL and updated prompt\n editor.update(() => {\n const node = $getNodeByKey(nodeKey);\n if ($isImageNode(node)) {\n // Use setter methods which properly call getWritable()\n node.setSrc(newImageUrl);\n node.setOriginalPrompt(newCombinedPrompt);\n\n // Force Lexical to re-render the DecoratorNode by triggering selection change\n const currentSelection = $getSelection();\n if (currentSelection) {\n $setSelection(currentSelection.clone());\n }\n }\n });\n\n // Close dialog and reset\n setShowComparisonDialog(false);\n setNewImageUrl(\"\");\n setNewCombinedPrompt(\"\");\n\n // Show success toast\n toast.success(\"Image replaced successfully!\", {\n description: \"The image has been updated with the refined version.\",\n });\n };\n\n const handleCancelReplace = () => {\n // Just close dialog and reset\n setShowComparisonDialog(false);\n setNewImageUrl(\"\");\n setNewCombinedPrompt(\"\");\n };\n\n const draggable = isSelected && $isNodeSelection(selection) && !isResizing;\n const isFocused = (isSelected || isResizing) && isEditable;\n\n // Get position-based styles for float layouts\n // Note: Float styles are now applied at the ImageNode.createDOM level for proper text wrapping\n // This component only needs basic positioning\n const getPositionStyles = (): React.CSSProperties => {\n // For floated images, use simpler styles since float is on parent span\n if (position === \"left\" || position === \"right\") {\n return {\n position: \"relative\",\n display: \"block\",\n width: \"100%\", // Fill the floated container\n };\n }\n // For full width images, use inline-block so parent's text-align: center works\n if (position === \"full\") {\n return {\n position: \"relative\",\n display: \"inline-block\", // Use inline-block to respect text-align: center from parent\n };\n }\n // For inline alignment options (block-level with alignment)\n if (position === \"inline-left\" || position === \"inline-center\" || position === \"inline-right\") {\n return {\n position: \"relative\",\n display: \"inline-block\", // Use inline-block to respect text-align from parent\n };\n }\n // Default: inline-block for regular images (position \"none\")\n return {\n position: \"relative\",\n display: \"inline-block\",\n };\n };\n\n // Direct click handler as fallback for when Lexical CLICK_COMMAND doesn't fire\n // This happens in dialogs and other contexts where event propagation differs\n const handleDirectClick = useCallback(\n (e: React.MouseEvent) => {\n if (isResizing) {\n return;\n }\n\n // Don't handle if clicking on action buttons, toolbar, or other interactive elements\n if ((e.target as HTMLElement).closest(\"button\")) {\n return;\n }\n\n const target = e.target as HTMLElement;\n\n // Check if clicking directly on the image element\n const isClickOnImage = target === imageRef.current;\n\n // Also check if click coordinates are within the image bounds\n // This handles cases where inline images next to text might not receive direct clicks\n let isClickWithinImageBounds = false;\n if (!isClickOnImage && imageRef.current) {\n const imageRect = imageRef.current.getBoundingClientRect();\n isClickWithinImageBounds =\n e.clientX >= imageRect.left &&\n e.clientX <= imageRect.right &&\n e.clientY >= imageRect.top &&\n e.clientY <= imageRect.bottom;\n }\n\n if (!isClickOnImage && !isClickWithinImageBounds) {\n return;\n }\n\n // Stop propagation only for clicks on the actual image\n e.stopPropagation();\n\n if (e.shiftKey) {\n setSelected(!isSelected);\n } else {\n clearSelection();\n setSelected(true);\n }\n },\n [isResizing, isSelected, setSelected, clearSelection]\n );\n\n return (\n <Suspense fallback={null}>\n <>\n <div\n draggable={draggable}\n style={getPositionStyles()}\n onClick={handleDirectClick}\n onMouseEnter={handleImageMouseEnter}\n onMouseLeave={handleImageMouseLeave}\n >\n {isLoadError ? (\n <BrokenImage />\n ) : (\n <LazyImage\n className={\n isFocused\n ? `focused ${$isNodeSelection(selection) ? \"draggable\" : \"\"}`\n : linkUrl ? \"cteditor-cursor-pointer\" : null\n }\n src={src}\n altText={altText}\n imageRef={imageRef}\n width={width}\n height={height}\n maxWidth={maxWidth}\n onError={() => setIsLoadError(true)}\n />\n )}\n {/* Link Preview Popup - shown on hover when image has a link */}\n {showLinkPreview && linkUrl && !isSelected && (\n <div\n className=\"cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-lg cteditor-border cteditor-border-border cteditor-p-2 cteditor-flex cteditor-items-center cteditor-gap-2\"\n style={{ zIndex: 10 }}\n >\n <Link2 className=\"cteditor-w-4 cteditor-h-4 cteditor-text-muted-foreground cteditor-flex-shrink-0\" />\n <span className=\"cteditor-text-sm cteditor-text-foreground cteditor-truncate cteditor-flex-1\">\n {linkUrl}\n </span>\n <button\n onClick={handleLinkClick}\n className=\"cteditor-px-2 cteditor-py-1 cteditor-text-xs cteditor-rounded cteditor-bg-primary cteditor-text-primary-foreground hover:cteditor-bg-primary/90 cteditor-transition-colors cteditor-flex-shrink-0\"\n >\n Open\n </button>\n </div>\n )}\n {/* Action Buttons - Responsive toolbar that adapts to image size */}\n {isSelected && $isNodeSelection(selection) && !isLoadError && (\n <div\n className={`cteditor-absolute cteditor-flex cteditor-gap-1 cteditor-flex-wrap ${\n shouldPositionBelow\n ? \"cteditor-left-1/2 cteditor--translate-x-1/2 cteditor-bottom-0 cteditor-translate-y-full cteditor-mt-1\"\n : \"cteditor-top-2 cteditor-right-2\"\n }`}\n style={{ zIndex: 10 }}\n >\n {/* Alignment buttons - always visible */}\n <div className=\"cteditor-flex cteditor-items-center cteditor-gap-0.5 cteditor-bg-background/80 cteditor-rounded-md cteditor-shadow-md cteditor-border cteditor-border-border cteditor-p-0.5\">\n {/* Text Wrap (Float) Options */}\n <button\n onClick={(e) => handlePositionChange(e, \"left\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"left\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Wrap text left\"\n title=\"Wrap text left\"\n >\n <WrapText className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" style={{ transform: \"scaleX(-1)\" }} />\n </button>\n <button\n onClick={(e) => handlePositionChange(e, \"right\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"right\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Wrap text right\"\n title=\"Wrap text right\"\n >\n <WrapText className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n\n {/* Separator */}\n <div className=\"cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5\" />\n\n {/* Block Alignment (Inline) Options */}\n <button\n onClick={(e) => handlePositionChange(e, \"inline-left\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"inline-left\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Align left\"\n title=\"Align left (no text wrap)\"\n >\n <AlignLeft className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n <button\n onClick={(e) => handlePositionChange(e, \"inline-center\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"inline-center\" || position === \"full\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Align center\"\n title=\"Align center (no text wrap)\"\n >\n <AlignCenter className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n <button\n onClick={(e) => handlePositionChange(e, \"inline-right\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"inline-right\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Align right\"\n title=\"Align right (no text wrap)\"\n >\n <AlignRight className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n\n {/* Separator */}\n <div className=\"cteditor-w-px cteditor-h-5 cteditor-bg-border cteditor-mx-0.5\" />\n\n {/* Inline (original behavior) */}\n <button\n onClick={(e) => handlePositionChange(e, \"none\")}\n className={`cteditor-p-1.5 cteditor-rounded hover:cteditor-bg-accent cteditor-transition-colors ${position === \"none\" ? \"cteditor-bg-accent\" : \"\"}`}\n aria-label=\"Inline\"\n title=\"Inline with text\"\n >\n <Type className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n </div>\n\n {/* Link button - shown when image has an original link URL */}\n {linkUrl && (\n <button\n onClick={handleLinkClick}\n className=\"cteditor-p-2 cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border\"\n aria-label=\"Visit link\"\n title={`Visit: ${linkUrl}`}\n >\n <Link2 className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n )}\n\n {/* Only show Refine button for AI-generated images (those with originalPrompt) */}\n {originalPrompt && (\n <button\n onClick={(e) => {\n e.stopPropagation();\n handleRefineClick(e);\n }}\n className=\"cteditor-p-2 cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border\"\n aria-label=\"Refine image\"\n title=\"Refine image\"\n >\n <Sparkles className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n )}\n <button\n onClick={(e) => {\n e.stopPropagation();\n handleOpenInNewTab(e);\n }}\n className=\"cteditor-p-2 cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-accent cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border\"\n aria-label=\"Open image in new tab\"\n title=\"Open in new tab\"\n >\n <ExternalLink className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n handleDeleteImage(e);\n }}\n className=\"cteditor-p-2 cteditor-rounded-md cteditor-bg-background/80 hover:cteditor-bg-destructive hover:cteditor-text-destructive-foreground cteditor-transition-colors cteditor-shadow-md cteditor-border cteditor-border-border\"\n aria-label=\"Delete image\"\n title=\"Delete image\"\n >\n <Trash2 className=\"cteditor-w-4 cteditor-h-4 cteditor-text-foreground\" />\n </button>\n </div>\n )}\n {/* Refine Input - Only for AI-generated images */}\n {showRefineInput && isSelected && !isLoadError && originalPrompt && (\n <div\n className=\"cteditor-absolute cteditor-bottom-2 cteditor-left-2 cteditor-right-2 cteditor-bg-background cteditor-rounded-lg cteditor-shadow-xl cteditor-border cteditor-border-border cteditor-p-3\"\n style={{ zIndex: 10 }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={(e) => e.stopPropagation()}\n onKeyUp={(e) => e.stopPropagation()}\n >\n <div className=\"cteditor-flex cteditor-flex-col cteditor-gap-2\">\n <label className=\"cteditor-text-xs cteditor-font-medium cteditor-text-foreground\">\n What else do you want in this scene?\n </label>\n <input\n type=\"text\"\n value={refinementPrompt}\n onChange={(e) => setRefinementPrompt(e.target.value)}\n onKeyDown={(e) => {\n // Stop propagation to prevent editor commands from firing\n e.stopPropagation();\n\n if (\n e.key === \"Enter\" &&\n refinementPrompt.trim() &&\n !isRefining\n ) {\n handleRefineImage();\n }\n if (e.key === \"Escape\") {\n setShowRefineInput(false);\n setRefinementPrompt(\"\");\n }\n }}\n onKeyUp={(e) => {\n // Also stop propagation on keyup\n e.stopPropagation();\n }}\n onClick={(e) => {\n // Prevent click from bubbling to image selection\n e.stopPropagation();\n }}\n placeholder=\"e.g., flying birds, golden sunset, stormy clouds...\"\n className=\"cteditor-w-full cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-border cteditor-border-border cteditor-rounded-md cteditor-bg-background cteditor-text-foreground focus:cteditor-outline-none focus:cteditor-ring-2 focus:cteditor-ring-blue-500\"\n disabled={isRefining}\n autoFocus\n />\n <div className=\"cteditor-flex cteditor-gap-2\">\n <button\n onClick={(e) => {\n e.stopPropagation();\n handleRefineImage();\n }}\n disabled={isRefining || !refinementPrompt.trim()}\n className=\"cteditor-flex-1 cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-blue-500 cteditor-text-white hover:cteditor-bg-blue-600 disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors\"\n >\n {isRefining ? (\n <span className=\"cteditor-flex cteditor-items-center cteditor-justify-center cteditor-gap-2\">\n <span className=\"cteditor-inline-block cteditor-w-4 cteditor-h-4 cteditor-border-2 cteditor-border-white cteditor-border-t-transparent cteditor-rounded-full cteditor-animate-spin\"></span>\n Refining...\n </span>\n ) : (\n \"Refine Image\"\n )}\n </button>\n <button\n onClick={(e) => {\n e.stopPropagation();\n setShowRefineInput(false);\n setRefinementPrompt(\"\");\n }}\n disabled={isRefining}\n className=\"cteditor-px-3 cteditor-py-2 cteditor-text-sm cteditor-rounded-md cteditor-bg-background cteditor-border cteditor-border-border cteditor-text-foreground hover:cteditor-bg-accent disabled:cteditor-opacity-50 disabled:cteditor-cursor-not-allowed cteditor-transition-colors\"\n >\n Cancel\n </button>\n </div>\n </div>\n </div>\n )}\n {/* ImageResizer must be inside the position:relative container for proper absolute positioning */}\n {resizable && $isNodeSelection(selection) && isFocused && (\n <ImageResizer\n showCaption={showCaption}\n setShowCaption={setShowCaption}\n editor={editor}\n buttonRef={buttonRef}\n imageRef={imageRef}\n maxWidth={maxWidth}\n onResizeStart={onResizeStart}\n onResizeEnd={onResizeEnd}\n captionsEnabled={!isLoadError && captionsEnabled}\n />\n )}\n </div>\n\n {/* Caption container must be outside the draggable wrapper to prevent drag issues */}\n {showCaption &&\n (altText.startsWith(\"Signature by\") ? (\n <SignatureCaption caption={caption} />\n ) : (\n <div className=\"image-caption-container\">\n <LexicalNestedComposer\n initialEditor={caption}\n initialNodes={[\n RootNode,\n TextNode,\n LineBreakNode,\n ParagraphNode,\n LinkNode,\n CodeNode,\n ]}\n >\n <AutoFocusPlugin />\n\n <RichTextPlugin\n contentEditable={\n <ContentEditable\n aria-placeholder=\"Enter a caption...\"\n placeholder={() => (\n <span className=\"cteditor-text-xs\">\n Enter a caption...\n </span>\n )}\n className=\"ImageNode__contentEditable\"\n />\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n\n <OnChangePlugin\n onChange={() => {\n //no code\n }}\n />\n <HistoryPlugin />\n <LocalStoragePlugin namespace={initialConfig.namespace} />\n </LexicalNestedComposer>\n </div>\n ))}\n\n {/* Image Comparison Dialog */}\n <ImageComparisonDialog\n open={showComparisonDialog}\n onOpenChange={setShowComparisonDialog}\n oldImageUrl={src}\n newImageUrl={newImageUrl}\n onReplace={handleReplaceImage}\n onCancel={handleCancelReplace}\n />\n </>\n </Suspense>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,QAAQ,iBAAiB,SAAS;AAAA,EACtC,CAAC,QAAQ,EAAE,GAAG,2BAA2B,KAAK,SAAQ,CAAE;AAAA,EACxD,CAAC,QAAQ,EAAE,GAAG,6BAA6B,KAAK,SAAQ,CAAE;AAAA,EAC1D,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,KAAK,SAAQ,CAAE;AACnE,CAAC;ACbD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAM,WAAW,iBAAiB,YAAY;AAAA,EAC5C,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,SAAQ,CAAE;AAAA,EAC/D,CAAC,QAAQ,EAAE,GAAG,6BAA6B,KAAK,SAAQ,CAAE;AAAA,EAC1D,CAAC,YAAY,EAAE,QAAQ,qBAAqB,KAAK,SAAQ,CAAE;AAAA,EAC3D,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,MAAM,KAAK,SAAQ,CAAE;AACnE,CAAC;;ACMM,MAAM,wBAA8D,CAAC;AAAA,EAC1E;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAM;AACJ,6BACG,QAAO,EAAA,MAAY,cAClB,UAAC,qBAAA,eAAA,EAAc,WAAU,iDACvB,UAAA;AAAA,IAAA,qBAAC,cACC,EAAA,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C,UAAU,MAAM;AAAA,cAEhB;AAAA,YAAA;AAAA,UACF;AAAA,8BACC,eAAc,EAAA;AAAA,UACd,oBAAA,oBAAA,EAAmB,WAAW,cAAc,UAAW,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAE5D,EAAA,CAAA;AAAA,IAIJ;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd,aAAa;AAAA,QACb;AAAA,QACA,WAAW;AAAA,QACX,UAAU;AAAA,MAAA;AAAA,IACZ;AAAA,EAAA,EACF,CAAA,EACF,CAAA;AAEJ;","x_google_ignoreList":[0,1]}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r, C, p, H, s, q, u, v } from "./index-0533674e.js";
|
|
2
2
|
import "react/jsx-runtime";
|
|
3
3
|
import "react";
|
|
4
4
|
import "axios";
|
|
@@ -38,12 +38,12 @@ import "@lexical/react/LexicalLinkPlugin";
|
|
|
38
38
|
import "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
39
39
|
import "@lexical/react/useLexicalEditable";
|
|
40
40
|
export {
|
|
41
|
-
|
|
41
|
+
r as ConfigurableEditor,
|
|
42
42
|
C as ConfigurableEditorWithAuth,
|
|
43
|
-
|
|
43
|
+
p as EditorProvider,
|
|
44
44
|
H as HtmlViewProvider,
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
s as defaultEditorConfig,
|
|
46
|
+
q as useEditor,
|
|
47
47
|
u as useHtmlView,
|
|
48
48
|
v as verifyApiKey
|
|
49
49
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DOMConversionMap, DOMExportOutput, EditorConfig, LexicalEditor, LexicalNode, NodeKey, SerializedEditor, SerializedLexicalNode, Spread, DecoratorNode } from '../../node_modules/lexical';
|
|
2
|
-
export type ImagePosition = "none" | "left" | "right" | "full";
|
|
2
|
+
export type ImagePosition = "none" | "left" | "right" | "full" | "inline-left" | "inline-center" | "inline-right";
|
|
3
3
|
export interface ImagePayload {
|
|
4
4
|
altText: string;
|
|
5
5
|
caption?: LexicalEditor;
|
|
@@ -12,6 +12,7 @@ export interface ImagePayload {
|
|
|
12
12
|
captionsEnabled?: boolean;
|
|
13
13
|
originalPrompt?: string;
|
|
14
14
|
position?: ImagePosition;
|
|
15
|
+
linkUrl?: string;
|
|
15
16
|
}
|
|
16
17
|
export type SerializedImageNode = Spread<{
|
|
17
18
|
altText: string;
|
|
@@ -23,6 +24,7 @@ export type SerializedImageNode = Spread<{
|
|
|
23
24
|
width?: number;
|
|
24
25
|
originalPrompt?: string;
|
|
25
26
|
position?: ImagePosition;
|
|
27
|
+
linkUrl?: string;
|
|
26
28
|
}, SerializedLexicalNode>;
|
|
27
29
|
export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
28
30
|
__src: string;
|
|
@@ -35,15 +37,17 @@ export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
|
35
37
|
__captionsEnabled: boolean;
|
|
36
38
|
__originalPrompt: string;
|
|
37
39
|
__position: ImagePosition;
|
|
40
|
+
__linkUrl: string;
|
|
38
41
|
static getType(): string;
|
|
39
42
|
static clone(node: ImageNode): ImageNode;
|
|
40
43
|
static importJSON(serializedNode: SerializedImageNode): ImageNode;
|
|
41
44
|
exportDOM(): DOMExportOutput;
|
|
42
45
|
static importDOM(): DOMConversionMap | null;
|
|
43
|
-
constructor(src: string, altText: string, maxWidth: number, width?: "inherit" | number, height?: "inherit" | number, showCaption?: boolean, caption?: LexicalEditor, captionsEnabled?: boolean, originalPrompt?: string, position?: ImagePosition, key?: NodeKey);
|
|
46
|
+
constructor(src: string, altText: string, maxWidth: number, width?: "inherit" | number, height?: "inherit" | number, showCaption?: boolean, caption?: LexicalEditor, captionsEnabled?: boolean, originalPrompt?: string, position?: ImagePosition, linkUrl?: string, key?: NodeKey);
|
|
44
47
|
exportJSON(): SerializedImageNode;
|
|
45
48
|
setWidthAndHeight(width: "inherit" | number, height: "inherit" | number): void;
|
|
46
49
|
setShowCaption(showCaption: boolean): void;
|
|
50
|
+
private getPositionStyles;
|
|
47
51
|
createDOM(config: EditorConfig): HTMLElement;
|
|
48
52
|
updateDOM(prevNode: ImageNode, dom: HTMLElement): boolean;
|
|
49
53
|
getSrc(): string;
|
|
@@ -53,7 +57,9 @@ export declare class ImageNode extends DecoratorNode<JSX.Element> {
|
|
|
53
57
|
setOriginalPrompt(prompt: string): void;
|
|
54
58
|
getPosition(): ImagePosition;
|
|
55
59
|
setPosition(position: ImagePosition): void;
|
|
60
|
+
getLinkUrl(): string;
|
|
61
|
+
setLinkUrl(linkUrl: string): void;
|
|
56
62
|
decorate(): JSX.Element;
|
|
57
63
|
}
|
|
58
|
-
export declare function $createImageNode({ altText, height, maxWidth, captionsEnabled, src, width, showCaption, caption, key, originalPrompt, position, }: ImagePayload): ImageNode;
|
|
64
|
+
export declare function $createImageNode({ altText, height, maxWidth, captionsEnabled, src, width, showCaption, caption, key, originalPrompt, position, linkUrl, }: ImagePayload): ImageNode;
|
|
59
65
|
export declare function $isImageNode(node: LexicalNode | null | undefined): node is ImageNode;
|