@kgalexander/mcreate 0.0.16 → 0.0.17
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/{chunk-L3OWFBEU.mjs → chunk-GZLWB3EZ.mjs} +122 -117
- package/dist/{core-AMEHYBIM.mjs → core-JDSYY73O.mjs} +1 -1
- package/dist/index.js +786 -1186
- package/dist/index.mjs +638 -1043
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/core/index.tsx
|
|
2
|
-
import { useMemo as useMemo18, useState as useState17, useEffect as
|
|
2
|
+
import { useMemo as useMemo18, useState as useState17, useEffect as useEffect16, useCallback as useCallback20, useRef as useRef12 } from "react";
|
|
3
3
|
import { cloneDeep as cloneDeep2, isEqual, debounce } from "lodash";
|
|
4
4
|
|
|
5
5
|
// src/core/utils/idx.ts
|
|
@@ -3386,7 +3386,7 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3386
3386
|
|
|
3387
3387
|
background-color: var(--background);
|
|
3388
3388
|
border-radius: 4px;
|
|
3389
|
-
padding:
|
|
3389
|
+
padding: 0px;
|
|
3390
3390
|
border: 1px solid var(--border);
|
|
3391
3391
|
color: #000000;
|
|
3392
3392
|
}
|
|
@@ -10798,7 +10798,7 @@ var index_default = Link;
|
|
|
10798
10798
|
|
|
10799
10799
|
// src/core/editor/components/tiptap-overlay.tsx
|
|
10800
10800
|
import { useFloating as useFloating4, autoUpdate as autoUpdate2, offset as offset4 } from "@floating-ui/react";
|
|
10801
|
-
import { useEffect as
|
|
10801
|
+
import { useEffect as useEffect6, useRef as useRef5, useMemo as useMemo4, useState as useState3 } from "react";
|
|
10802
10802
|
|
|
10803
10803
|
// src/core/editor/extensions/inverse-placeholder.ts
|
|
10804
10804
|
import { Plugin as Plugin12, PluginKey as PluginKey10 } from "@tiptap/pm/state";
|
|
@@ -11200,7 +11200,7 @@ function TooltipContent({
|
|
|
11200
11200
|
import { BotIcon } from "lucide-react";
|
|
11201
11201
|
|
|
11202
11202
|
// src/core/editor/components/text-link-menu.tsx
|
|
11203
|
-
import { useState as useState2,
|
|
11203
|
+
import { useState as useState2, useCallback as useCallback4 } from "react";
|
|
11204
11204
|
|
|
11205
11205
|
// src/components/ui/input.tsx
|
|
11206
11206
|
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
@@ -11315,12 +11315,13 @@ var TextLinkMenu = ({ editor }) => {
|
|
|
11315
11315
|
const [isLinkTypeOpen, setIsLinkTypeOpen] = useState2(false);
|
|
11316
11316
|
const currentHref = editor.getAttributes("link").href || "";
|
|
11317
11317
|
const hasLink = !!currentHref;
|
|
11318
|
-
|
|
11319
|
-
|
|
11318
|
+
const handleOpenChange = useCallback4((open) => {
|
|
11319
|
+
setIsOpen(open);
|
|
11320
|
+
if (open) {
|
|
11320
11321
|
setLinkType(detectLinkType(currentHref));
|
|
11321
11322
|
setInputValue(stripPrefix(currentHref));
|
|
11322
11323
|
}
|
|
11323
|
-
}, [
|
|
11324
|
+
}, [currentHref]);
|
|
11324
11325
|
const handleInputChange = (e) => {
|
|
11325
11326
|
setInputValue(e.target.value);
|
|
11326
11327
|
};
|
|
@@ -11357,7 +11358,7 @@ var TextLinkMenu = ({ editor }) => {
|
|
|
11357
11358
|
editor.chain().focus().unsetLink().run();
|
|
11358
11359
|
setInputValue("");
|
|
11359
11360
|
};
|
|
11360
|
-
return /* @__PURE__ */ jsxs7(Popover, { open: isOpen, onOpenChange:
|
|
11361
|
+
return /* @__PURE__ */ jsxs7(Popover, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
11361
11362
|
/* @__PURE__ */ jsxs7(Tooltip, { children: [
|
|
11362
11363
|
/* @__PURE__ */ jsx20(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx20(PopoverTrigger, { asChild: true, children: hasLink ? /* @__PURE__ */ jsx20(
|
|
11363
11364
|
Button,
|
|
@@ -11819,7 +11820,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
11819
11820
|
const lastSizeLimitToastRef = useRef5(0);
|
|
11820
11821
|
const hasContentChangedRef = useRef5(false);
|
|
11821
11822
|
const storeRefs = useEditorStoreRefs();
|
|
11822
|
-
|
|
11823
|
+
useEffect6(() => {
|
|
11823
11824
|
return () => {
|
|
11824
11825
|
const isUndoRedoAction = useEditorStore.getState().isUndoRedoAction;
|
|
11825
11826
|
if (hasContentChangedRef.current && !isUndoRedoAction) {
|
|
@@ -11827,7 +11828,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
11827
11828
|
}
|
|
11828
11829
|
};
|
|
11829
11830
|
}, []);
|
|
11830
|
-
|
|
11831
|
+
useEffect6(() => {
|
|
11831
11832
|
const container = containerRef.current;
|
|
11832
11833
|
if (!container) return;
|
|
11833
11834
|
const observer = new ResizeObserver(() => {
|
|
@@ -11872,7 +11873,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
11872
11873
|
// Move up by reference height to overlay exactly
|
|
11873
11874
|
]
|
|
11874
11875
|
});
|
|
11875
|
-
|
|
11876
|
+
useEffect6(() => {
|
|
11876
11877
|
const rect = getReferenceRect();
|
|
11877
11878
|
if (!rect || !refs.floating.current) return;
|
|
11878
11879
|
refs.setPositionReference(virtualReference);
|
|
@@ -12056,7 +12057,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12056
12057
|
}
|
|
12057
12058
|
});
|
|
12058
12059
|
const [currentLinkHref, setCurrentLinkHref] = useState3("");
|
|
12059
|
-
|
|
12060
|
+
useEffect6(() => {
|
|
12060
12061
|
if (!editor) return;
|
|
12061
12062
|
setTiptapEditor(editor);
|
|
12062
12063
|
const updateLinkHref = () => {
|
|
@@ -12071,7 +12072,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12071
12072
|
editor.off("transaction", updateLinkHref);
|
|
12072
12073
|
};
|
|
12073
12074
|
}, [editor, setTiptapEditor]);
|
|
12074
|
-
|
|
12075
|
+
useEffect6(() => {
|
|
12075
12076
|
if (editor) {
|
|
12076
12077
|
const timer = setTimeout(() => {
|
|
12077
12078
|
if (cursorPosition === "end") {
|
|
@@ -12100,7 +12101,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12100
12101
|
return () => clearTimeout(timer);
|
|
12101
12102
|
}
|
|
12102
12103
|
}, [editor, clickX, clickY, cursorPosition]);
|
|
12103
|
-
|
|
12104
|
+
useEffect6(() => {
|
|
12104
12105
|
const handleClickOutside = (e) => {
|
|
12105
12106
|
const target = e.target;
|
|
12106
12107
|
if (containerRef.current && containerRef.current.contains(target)) {
|
|
@@ -12224,7 +12225,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12224
12225
|
.tiptap-overlay .ProseMirror .merge-field-tag {
|
|
12225
12226
|
background-color: var(--background);
|
|
12226
12227
|
border-radius: 4px;
|
|
12227
|
-
padding:
|
|
12228
|
+
padding: 0px;
|
|
12228
12229
|
border: 1px solid var(--border);
|
|
12229
12230
|
color: #000000;
|
|
12230
12231
|
}
|
|
@@ -12279,7 +12280,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12279
12280
|
};
|
|
12280
12281
|
|
|
12281
12282
|
// src/core/editor/components/element-float.tsx
|
|
12282
|
-
import { useEffect as
|
|
12283
|
+
import { useEffect as useEffect8, useMemo as useMemo12 } from "react";
|
|
12283
12284
|
import { useFloating as useFloating5, offset as offset5, shift as shift4, flip as flip3, autoUpdate as autoUpdate3 } from "@floating-ui/react";
|
|
12284
12285
|
|
|
12285
12286
|
// src/core/editor/components/float-ui/actions/delete-button.tsx
|
|
@@ -12333,7 +12334,7 @@ var DuplicateButton = () => {
|
|
|
12333
12334
|
};
|
|
12334
12335
|
|
|
12335
12336
|
// src/core/editor/components/href-menu.tsx
|
|
12336
|
-
import { useState as useState4,
|
|
12337
|
+
import { useState as useState4, useCallback as useCallback6, useMemo as useMemo6 } from "react";
|
|
12337
12338
|
|
|
12338
12339
|
// src/components/ui/dropdown-menu.tsx
|
|
12339
12340
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
@@ -12460,7 +12461,7 @@ function DropdownMenuSubContent({
|
|
|
12460
12461
|
import { CheckIcon as CheckIcon3, CopyIcon as CopyIcon3, LinkIcon as LinkIcon3, PencilIcon as PencilIcon2, TrashIcon as TrashIcon3 } from "lucide-react";
|
|
12461
12462
|
|
|
12462
12463
|
// src/core/editor/hooks/use-href.ts
|
|
12463
|
-
import { useMemo as useMemo5, useCallback as
|
|
12464
|
+
import { useMemo as useMemo5, useCallback as useCallback5 } from "react";
|
|
12464
12465
|
import { get as lodashGet2 } from "lodash";
|
|
12465
12466
|
var useHref = () => {
|
|
12466
12467
|
const { focusIdx, updateElement, template } = useEditorStore();
|
|
@@ -12475,19 +12476,19 @@ var useHref = () => {
|
|
|
12475
12476
|
href: el?.attributes?.href || ""
|
|
12476
12477
|
};
|
|
12477
12478
|
}, [focusIdx, template]);
|
|
12478
|
-
const setHref =
|
|
12479
|
+
const setHref = useCallback5((url) => {
|
|
12479
12480
|
if (!focusIdx || !element) return;
|
|
12480
12481
|
updateElement(focusIdx, {
|
|
12481
12482
|
attributes: { ...element.attributes, href: url }
|
|
12482
12483
|
});
|
|
12483
12484
|
}, [focusIdx, element, updateElement]);
|
|
12484
|
-
const clearHref =
|
|
12485
|
+
const clearHref = useCallback5(() => {
|
|
12485
12486
|
if (!focusIdx || !element) return;
|
|
12486
12487
|
updateElement(focusIdx, {
|
|
12487
12488
|
attributes: { ...element.attributes, href: "" }
|
|
12488
12489
|
});
|
|
12489
12490
|
}, [focusIdx, element, updateElement]);
|
|
12490
|
-
const copyHref =
|
|
12491
|
+
const copyHref = useCallback5(async () => {
|
|
12491
12492
|
if (href) {
|
|
12492
12493
|
try {
|
|
12493
12494
|
await navigator.clipboard.writeText(href);
|
|
@@ -12526,17 +12527,18 @@ var HrefMenu = () => {
|
|
|
12526
12527
|
const query = inputValue.toLowerCase();
|
|
12527
12528
|
return all.filter((p) => p.value.toLowerCase().includes(query));
|
|
12528
12529
|
}, [linkType.name, userData, inputValue]);
|
|
12529
|
-
const handlePresetSelect =
|
|
12530
|
+
const handlePresetSelect = useCallback6((value) => {
|
|
12530
12531
|
setInputValue(value);
|
|
12531
12532
|
setIsPresetOpen(false);
|
|
12532
12533
|
}, []);
|
|
12533
|
-
|
|
12534
|
-
|
|
12534
|
+
const handleOpenChange = useCallback6((open) => {
|
|
12535
|
+
setIsOpen(open);
|
|
12536
|
+
if (open) {
|
|
12535
12537
|
setLinkType(detectLinkType(href));
|
|
12536
12538
|
setInputValue(stripPrefix(href));
|
|
12537
12539
|
setIsPresetOpen(true);
|
|
12538
12540
|
}
|
|
12539
|
-
}, [
|
|
12541
|
+
}, [href]);
|
|
12540
12542
|
const handleInputChange = (e) => {
|
|
12541
12543
|
setInputValue(e.target.value);
|
|
12542
12544
|
setIsPresetOpen(true);
|
|
@@ -12581,7 +12583,7 @@ var HrefMenu = () => {
|
|
|
12581
12583
|
setHref(buildHref(inputValue));
|
|
12582
12584
|
setIsOpen(false);
|
|
12583
12585
|
};
|
|
12584
|
-
return /* @__PURE__ */ jsxs13(DropdownMenu, { open: isOpen, onOpenChange:
|
|
12586
|
+
return /* @__PURE__ */ jsxs13(DropdownMenu, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
12585
12587
|
/* @__PURE__ */ jsxs13(Tooltip, { children: [
|
|
12586
12588
|
/* @__PURE__ */ jsx26(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx26(DropdownMenuTrigger, { asChild: true, children: hasHref ? /* @__PURE__ */ jsx26(
|
|
12587
12589
|
Button,
|
|
@@ -12750,7 +12752,7 @@ var ButtonFloat = () => {
|
|
|
12750
12752
|
import { ChevronsLeftRightIcon, ChevronsRightLeftIcon, MoreHorizontalIcon } from "lucide-react";
|
|
12751
12753
|
|
|
12752
12754
|
// src/core/editor/hooks/use-full-width-toggle.ts
|
|
12753
|
-
import { useCallback as
|
|
12755
|
+
import { useCallback as useCallback7, useMemo as useMemo7 } from "react";
|
|
12754
12756
|
import { get as lodashGet3 } from "lodash";
|
|
12755
12757
|
function useFullWidthToggle() {
|
|
12756
12758
|
const { focusIdx, template, updateElement } = useEditorStore();
|
|
@@ -12763,7 +12765,7 @@ function useFullWidthToggle() {
|
|
|
12763
12765
|
isFullWidth: el?.attributes?.["full-width"] === "full-width"
|
|
12764
12766
|
};
|
|
12765
12767
|
}, [focusIdx, template]);
|
|
12766
|
-
const handleToggleFullWidth =
|
|
12768
|
+
const handleToggleFullWidth = useCallback7(() => {
|
|
12767
12769
|
if (!focusIdx || !element) return;
|
|
12768
12770
|
const newAttributes = { ...element.attributes };
|
|
12769
12771
|
if (isFullWidth) {
|
|
@@ -12800,7 +12802,7 @@ var SectionFloat = () => {
|
|
|
12800
12802
|
import { CheckIcon as CheckIcon4, ChevronsLeftRightIcon as ChevronsLeftRightIcon2, ChevronsRightLeftIcon as ChevronsRightLeftIcon2, Layers2Icon, MoreHorizontalIcon as MoreHorizontalIcon2 } from "lucide-react";
|
|
12801
12803
|
|
|
12802
12804
|
// src/core/editor/hooks/use-no-wrap.ts
|
|
12803
|
-
import { useCallback as
|
|
12805
|
+
import { useCallback as useCallback8, useMemo as useMemo8 } from "react";
|
|
12804
12806
|
import { get as lodashGet4 } from "lodash";
|
|
12805
12807
|
function useNoWrap() {
|
|
12806
12808
|
const { focusIdx, template, updateElement } = useEditorStore();
|
|
@@ -12813,7 +12815,7 @@ function useNoWrap() {
|
|
|
12813
12815
|
noWrap: el?.data?.value?.noWrap === true
|
|
12814
12816
|
};
|
|
12815
12817
|
}, [focusIdx, template]);
|
|
12816
|
-
const handleToggleNoWrap =
|
|
12818
|
+
const handleToggleNoWrap = useCallback8(() => {
|
|
12817
12819
|
if (!focusIdx || !element) return;
|
|
12818
12820
|
updateElement(focusIdx, {
|
|
12819
12821
|
data: {
|
|
@@ -12941,10 +12943,10 @@ function Textarea({ className, ...props }) {
|
|
|
12941
12943
|
|
|
12942
12944
|
// src/core/editor/components/element-gear/social-item/float.tsx
|
|
12943
12945
|
import { Accessibility, MoreHorizontalIcon as MoreHorizontalIcon4, TrashIcon as TrashIcon4 } from "lucide-react";
|
|
12944
|
-
import { useState as useState7,
|
|
12946
|
+
import { useState as useState7, useCallback as useCallback11 } from "react";
|
|
12945
12947
|
|
|
12946
12948
|
// src/core/editor/components/social-item-menu.tsx
|
|
12947
|
-
import { useState as useState6,
|
|
12949
|
+
import { useState as useState6, useMemo as useMemo9, useCallback as useCallback9 } from "react";
|
|
12948
12950
|
import { PencilIcon as PencilIcon3, CheckIcon as CheckIcon5, CopyIcon as CopyIcon4 } from "lucide-react";
|
|
12949
12951
|
import { get as lodashGet5 } from "lodash";
|
|
12950
12952
|
import { jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
@@ -12961,18 +12963,19 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
12961
12963
|
return lodashGet5(template, path);
|
|
12962
12964
|
}, [focusIdx, template]);
|
|
12963
12965
|
const content = element?.data?.value?.content || "";
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
+
const handleOpenChange = useCallback9((open) => {
|
|
12967
|
+
setIsOpen(open);
|
|
12968
|
+
if (open) {
|
|
12966
12969
|
setHrefInputValue(href);
|
|
12967
12970
|
setContentInputValue(content);
|
|
12968
12971
|
}
|
|
12969
|
-
}, [
|
|
12970
|
-
const handleCopy =
|
|
12972
|
+
}, [href, content]);
|
|
12973
|
+
const handleCopy = useCallback9(async () => {
|
|
12971
12974
|
await copyHref();
|
|
12972
12975
|
setShowCopied(true);
|
|
12973
12976
|
setTimeout(() => setShowCopied(false), 2e3);
|
|
12974
12977
|
}, [copyHref]);
|
|
12975
|
-
const handleDone =
|
|
12978
|
+
const handleDone = useCallback9(() => {
|
|
12976
12979
|
setHref(normalizeWebsiteUrl(hrefInputValue));
|
|
12977
12980
|
if (focusIdx && element) {
|
|
12978
12981
|
updateElement(focusIdx, {
|
|
@@ -12986,7 +12989,7 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
12986
12989
|
}
|
|
12987
12990
|
setIsOpen(false);
|
|
12988
12991
|
}, [hrefInputValue, contentInputValue, setHref, focusIdx, element, updateElement]);
|
|
12989
|
-
return /* @__PURE__ */ jsxs19(DropdownMenu, { open: isOpen, onOpenChange:
|
|
12992
|
+
return /* @__PURE__ */ jsxs19(DropdownMenu, { open: isOpen, onOpenChange: handleOpenChange, children: [
|
|
12990
12993
|
/* @__PURE__ */ jsxs19(Tooltip, { children: [
|
|
12991
12994
|
/* @__PURE__ */ jsx34(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx34(DropdownMenuTrigger, { asChild: true, children: hasHref ? /* @__PURE__ */ jsx34(
|
|
12992
12995
|
Button,
|
|
@@ -13068,7 +13071,7 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
13068
13071
|
};
|
|
13069
13072
|
|
|
13070
13073
|
// src/core/editor/hooks/use-alt.ts
|
|
13071
|
-
import { useMemo as useMemo10, useCallback as
|
|
13074
|
+
import { useMemo as useMemo10, useCallback as useCallback10 } from "react";
|
|
13072
13075
|
import { get as lodashGet6 } from "lodash";
|
|
13073
13076
|
var useAlt = () => {
|
|
13074
13077
|
const { focusIdx, updateElement, template } = useEditorStore();
|
|
@@ -13083,13 +13086,13 @@ var useAlt = () => {
|
|
|
13083
13086
|
alt: el?.attributes?.alt || ""
|
|
13084
13087
|
};
|
|
13085
13088
|
}, [focusIdx, template]);
|
|
13086
|
-
const setAlt =
|
|
13089
|
+
const setAlt = useCallback10((text2) => {
|
|
13087
13090
|
if (!focusIdx || !element) return;
|
|
13088
13091
|
updateElement(focusIdx, {
|
|
13089
13092
|
attributes: { ...element.attributes, alt: text2 }
|
|
13090
13093
|
});
|
|
13091
13094
|
}, [focusIdx, element, updateElement]);
|
|
13092
|
-
const clearAlt =
|
|
13095
|
+
const clearAlt = useCallback10(() => {
|
|
13093
13096
|
if (!focusIdx || !element) return;
|
|
13094
13097
|
updateElement(focusIdx, {
|
|
13095
13098
|
attributes: { ...element.attributes, alt: "" }
|
|
@@ -13115,11 +13118,12 @@ var SocialItemFloat = () => {
|
|
|
13115
13118
|
const parentSocial = focusIdx ? getParentByIdx(template, focusIdx) : null;
|
|
13116
13119
|
const childrenCount = parentSocial?.children?.length || 0;
|
|
13117
13120
|
const canDelete = childrenCount > 1;
|
|
13118
|
-
|
|
13119
|
-
|
|
13121
|
+
const handleDropdownOpenChange = useCallback11((open) => {
|
|
13122
|
+
setDropdownOpen(open);
|
|
13123
|
+
if (open) {
|
|
13120
13124
|
setAltInputValue(alt);
|
|
13121
13125
|
}
|
|
13122
|
-
}, [
|
|
13126
|
+
}, [alt]);
|
|
13123
13127
|
const handleSaveAlt = () => {
|
|
13124
13128
|
setAlt(altInputValue);
|
|
13125
13129
|
setDropdownOpen(false);
|
|
@@ -13145,7 +13149,7 @@ var SocialItemFloat = () => {
|
|
|
13145
13149
|
) }),
|
|
13146
13150
|
/* @__PURE__ */ jsx35(TooltipContent, { side: "bottom", children: canDelete ? "Delete" : "Cannot delete last item" })
|
|
13147
13151
|
] }),
|
|
13148
|
-
/* @__PURE__ */ jsxs20(DropdownMenu, { open: dropdownOpen, onOpenChange:
|
|
13152
|
+
/* @__PURE__ */ jsxs20(DropdownMenu, { open: dropdownOpen, onOpenChange: handleDropdownOpenChange, children: [
|
|
13149
13153
|
/* @__PURE__ */ jsxs20(Tooltip, { children: [
|
|
13150
13154
|
/* @__PURE__ */ jsx35(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx35(Button, { variant: "ghost", size: "icon", className: floatButtonVariants, children: /* @__PURE__ */ jsx35(MoreHorizontalIcon4, { className: "w-4 h-4" }) }) }) }),
|
|
13151
13155
|
/* @__PURE__ */ jsx35(TooltipContent, { side: "bottom", children: "More" })
|
|
@@ -13203,7 +13207,7 @@ var DividerFloat = () => {
|
|
|
13203
13207
|
// src/core/editor/components/element-gear/image/float.tsx
|
|
13204
13208
|
import { Accessibility as Accessibility2, CheckIcon as CheckIcon6, MoreHorizontalIcon as MoreHorizontalIcon5, Proportions } from "lucide-react";
|
|
13205
13209
|
import lodashGet7 from "lodash/get";
|
|
13206
|
-
import { useState as useState8,
|
|
13210
|
+
import { useState as useState8, useMemo as useMemo11, useCallback as useCallback12 } from "react";
|
|
13207
13211
|
import { Fragment as Fragment13, jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
13208
13212
|
var ImageFloat = () => {
|
|
13209
13213
|
const { href, hasHref } = useHref();
|
|
@@ -13221,7 +13225,7 @@ var ImageFloat = () => {
|
|
|
13221
13225
|
isFluidOnMobile: el?.attributes?.["fluid-on-mobile"] === "true"
|
|
13222
13226
|
};
|
|
13223
13227
|
}, [focusIdx, template]);
|
|
13224
|
-
const toggleFluidOnMobile =
|
|
13228
|
+
const toggleFluidOnMobile = useCallback12(() => {
|
|
13225
13229
|
if (!focusIdx || !element) return;
|
|
13226
13230
|
const newAttributes = { ...element.attributes };
|
|
13227
13231
|
if (isFluidOnMobile) {
|
|
@@ -13231,11 +13235,12 @@ var ImageFloat = () => {
|
|
|
13231
13235
|
}
|
|
13232
13236
|
updateElement(focusIdx, { attributes: newAttributes });
|
|
13233
13237
|
}, [focusIdx, element, isFluidOnMobile, updateElement]);
|
|
13234
|
-
|
|
13235
|
-
|
|
13238
|
+
const handleDropdownOpenChange = useCallback12((open) => {
|
|
13239
|
+
setDropdownOpen(open);
|
|
13240
|
+
if (open) {
|
|
13236
13241
|
setAltInputValue(alt);
|
|
13237
13242
|
}
|
|
13238
|
-
}, [
|
|
13243
|
+
}, [alt]);
|
|
13239
13244
|
const handleSaveAlt = () => {
|
|
13240
13245
|
setAlt(altInputValue);
|
|
13241
13246
|
setDropdownOpen(false);
|
|
@@ -13245,7 +13250,7 @@ var ImageFloat = () => {
|
|
|
13245
13250
|
/* @__PURE__ */ jsx37(HrefMenu, {}),
|
|
13246
13251
|
/* @__PURE__ */ jsx37(DuplicateButton, {}),
|
|
13247
13252
|
/* @__PURE__ */ jsx37(DeleteButton, {}),
|
|
13248
|
-
/* @__PURE__ */ jsxs22(DropdownMenu, { open: dropdownOpen, onOpenChange:
|
|
13253
|
+
/* @__PURE__ */ jsxs22(DropdownMenu, { open: dropdownOpen, onOpenChange: handleDropdownOpenChange, children: [
|
|
13249
13254
|
/* @__PURE__ */ jsxs22(Tooltip, { children: [
|
|
13250
13255
|
/* @__PURE__ */ jsx37(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx37(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx37(Button, { variant: "ghost", size: "icon", className: floatButtonVariants, children: /* @__PURE__ */ jsx37(MoreHorizontalIcon5, { className: "w-4 h-4" }) }) }) }),
|
|
13251
13256
|
/* @__PURE__ */ jsx37(TooltipContent, { side: "bottom", children: "More" })
|
|
@@ -13302,7 +13307,7 @@ var ImageFloat = () => {
|
|
|
13302
13307
|
};
|
|
13303
13308
|
|
|
13304
13309
|
// src/core/editor/components/mlsNumber-menu.tsx
|
|
13305
|
-
import { useState as useState9, useEffect as
|
|
13310
|
+
import { useState as useState9, useEffect as useEffect7 } from "react";
|
|
13306
13311
|
import { HousePlusIcon, TrashIcon as TrashIcon5, XIcon as XIcon2, Loader2Icon } from "lucide-react";
|
|
13307
13312
|
|
|
13308
13313
|
// src/services/repliers/commands.ts
|
|
@@ -13327,7 +13332,7 @@ var MlsNumberMenu = () => {
|
|
|
13327
13332
|
const [isLoading, setIsLoading] = useState9(false);
|
|
13328
13333
|
const propertyElement = focusIdx && template ? getValueByIdx(template, focusIdx) : null;
|
|
13329
13334
|
const currentMlsNumber = propertyElement?.data?.value?.mlsNumber || "";
|
|
13330
|
-
|
|
13335
|
+
useEffect7(() => {
|
|
13331
13336
|
setInputValue(currentMlsNumber);
|
|
13332
13337
|
setPropertyData(null);
|
|
13333
13338
|
}, [focusIdx, currentMlsNumber]);
|
|
@@ -13600,7 +13605,7 @@ var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
|
13600
13605
|
// Keep within viewport
|
|
13601
13606
|
]
|
|
13602
13607
|
});
|
|
13603
|
-
|
|
13608
|
+
useEffect8(() => {
|
|
13604
13609
|
const rect = getReferenceRect();
|
|
13605
13610
|
if (!rect || !refs.floating.current) return;
|
|
13606
13611
|
refs.setPositionReference(virtualReference);
|
|
@@ -13619,7 +13624,7 @@ var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
|
13619
13624
|
};
|
|
13620
13625
|
|
|
13621
13626
|
// src/core/editor/components/scaling/divider-scale.tsx
|
|
13622
|
-
import { useMemo as useMemo13, useEffect as
|
|
13627
|
+
import { useMemo as useMemo13, useEffect as useEffect9, useState as useState10, useRef as useRef6, useCallback as useCallback14 } from "react";
|
|
13623
13628
|
import { useFloating as useFloating6, offset as offset6, autoUpdate as autoUpdate4 } from "@floating-ui/react";
|
|
13624
13629
|
import { jsx as jsx43, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
13625
13630
|
var DividerScale = ({ getReferenceRect }) => {
|
|
@@ -13636,12 +13641,12 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13636
13641
|
return { currentWidth: width, currentAlign: align };
|
|
13637
13642
|
}, [focusIdx, template]);
|
|
13638
13643
|
const dragRef = useRef6(null);
|
|
13639
|
-
const getContainerWidth =
|
|
13644
|
+
const getContainerWidth = useCallback14(() => {
|
|
13640
13645
|
const rect = getReferenceRect();
|
|
13641
13646
|
if (!rect || currentWidth <= 0) return null;
|
|
13642
13647
|
return rect.width / (currentWidth / 100);
|
|
13643
13648
|
}, [getReferenceRect, currentWidth]);
|
|
13644
|
-
const handlePointerDown =
|
|
13649
|
+
const handlePointerDown = useCallback14((e, side) => {
|
|
13645
13650
|
e.preventDefault();
|
|
13646
13651
|
e.stopPropagation();
|
|
13647
13652
|
const containerWidth = getContainerWidth();
|
|
@@ -13659,7 +13664,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13659
13664
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13660
13665
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13661
13666
|
}, [getContainerWidth, currentWidth, currentAlign, setIsScaling]);
|
|
13662
|
-
const handlePointerMove =
|
|
13667
|
+
const handlePointerMove = useCallback14((e) => {
|
|
13663
13668
|
if (!dragRef.current) return;
|
|
13664
13669
|
const { startX, startWidth, containerWidth, side, align } = dragRef.current;
|
|
13665
13670
|
const deltaX = e.clientX - startX;
|
|
@@ -13679,14 +13684,14 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13679
13684
|
}
|
|
13680
13685
|
});
|
|
13681
13686
|
}, []);
|
|
13682
|
-
const handlePointerUp =
|
|
13687
|
+
const handlePointerUp = useCallback14(() => {
|
|
13683
13688
|
setActiveSide(null);
|
|
13684
13689
|
setIsScaling(false);
|
|
13685
13690
|
dragRef.current = null;
|
|
13686
13691
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13687
13692
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13688
13693
|
}, [handlePointerMove, setIsScaling]);
|
|
13689
|
-
|
|
13694
|
+
useEffect9(() => {
|
|
13690
13695
|
return () => {
|
|
13691
13696
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13692
13697
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13707,7 +13712,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13707
13712
|
offset6(({ rects }) => -rects.reference.height)
|
|
13708
13713
|
]
|
|
13709
13714
|
});
|
|
13710
|
-
|
|
13715
|
+
useEffect9(() => {
|
|
13711
13716
|
const rect = getReferenceRect();
|
|
13712
13717
|
if (!rect || !refs.floating.current) return;
|
|
13713
13718
|
refs.setPositionReference(virtualReference);
|
|
@@ -13766,7 +13771,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13766
13771
|
};
|
|
13767
13772
|
|
|
13768
13773
|
// src/core/editor/components/scaling/button-scale.tsx
|
|
13769
|
-
import { useMemo as useMemo14, useEffect as
|
|
13774
|
+
import { useMemo as useMemo14, useEffect as useEffect10, useState as useState11, useRef as useRef7, useCallback as useCallback15 } from "react";
|
|
13770
13775
|
import { useFloating as useFloating7, offset as offset7, autoUpdate as autoUpdate5 } from "@floating-ui/react";
|
|
13771
13776
|
import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
13772
13777
|
var ButtonScale = ({ getReferenceRect }) => {
|
|
@@ -13788,12 +13793,12 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13788
13793
|
return { currentWidth: width, currentHeight: height, currentAlign: align };
|
|
13789
13794
|
}, [focusIdx, template]);
|
|
13790
13795
|
const dragRef = useRef7(null);
|
|
13791
|
-
const getContainerWidth =
|
|
13796
|
+
const getContainerWidth = useCallback15(() => {
|
|
13792
13797
|
const rect = getReferenceRect();
|
|
13793
13798
|
if (!rect || currentWidth <= 0) return null;
|
|
13794
13799
|
return rect.width / (currentWidth / 100);
|
|
13795
13800
|
}, [getReferenceRect, currentWidth]);
|
|
13796
|
-
const handlePointerDown =
|
|
13801
|
+
const handlePointerDown = useCallback15((e, side) => {
|
|
13797
13802
|
e.preventDefault();
|
|
13798
13803
|
e.stopPropagation();
|
|
13799
13804
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -13815,7 +13820,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13815
13820
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13816
13821
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13817
13822
|
}, [getContainerWidth, currentWidth, currentHeight, currentAlign, setIsScaling]);
|
|
13818
|
-
const handlePointerMove =
|
|
13823
|
+
const handlePointerMove = useCallback15((e) => {
|
|
13819
13824
|
if (!dragRef.current) return;
|
|
13820
13825
|
const { startX, startY, startWidth, startHeight, containerWidth, side, align } = dragRef.current;
|
|
13821
13826
|
const state = useEditorStore.getState();
|
|
@@ -13847,14 +13852,14 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13847
13852
|
});
|
|
13848
13853
|
}
|
|
13849
13854
|
}, []);
|
|
13850
|
-
const handlePointerUp =
|
|
13855
|
+
const handlePointerUp = useCallback15(() => {
|
|
13851
13856
|
setActiveSide(null);
|
|
13852
13857
|
setIsScaling(false);
|
|
13853
13858
|
dragRef.current = null;
|
|
13854
13859
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13855
13860
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13856
13861
|
}, [handlePointerMove, setIsScaling]);
|
|
13857
|
-
|
|
13862
|
+
useEffect10(() => {
|
|
13858
13863
|
return () => {
|
|
13859
13864
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13860
13865
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13875,7 +13880,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13875
13880
|
offset7(({ rects }) => -rects.reference.height)
|
|
13876
13881
|
]
|
|
13877
13882
|
});
|
|
13878
|
-
|
|
13883
|
+
useEffect10(() => {
|
|
13879
13884
|
const rect = getReferenceRect();
|
|
13880
13885
|
if (!rect || !refs.floating.current) return;
|
|
13881
13886
|
refs.setPositionReference(virtualReference);
|
|
@@ -13950,7 +13955,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13950
13955
|
};
|
|
13951
13956
|
|
|
13952
13957
|
// src/core/editor/components/scaling/image-scale.tsx
|
|
13953
|
-
import { useMemo as useMemo15, useEffect as
|
|
13958
|
+
import { useMemo as useMemo15, useEffect as useEffect11, useState as useState12, useRef as useRef8, useCallback as useCallback16 } from "react";
|
|
13954
13959
|
import { useFloating as useFloating8, offset as offset8, autoUpdate as autoUpdate6 } from "@floating-ui/react";
|
|
13955
13960
|
import { jsx as jsx45, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
13956
13961
|
var isCorner = (side) => side === "top-left" || side === "top-right" || side === "bottom-left" || side === "bottom-right";
|
|
@@ -13973,7 +13978,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13973
13978
|
return { currentWidth: width, currentHeight: height, currentAlign: align };
|
|
13974
13979
|
}, [focusIdx, template]);
|
|
13975
13980
|
const dragRef = useRef8(null);
|
|
13976
|
-
const handlePointerDown =
|
|
13981
|
+
const handlePointerDown = useCallback16((e, side) => {
|
|
13977
13982
|
e.preventDefault();
|
|
13978
13983
|
e.stopPropagation();
|
|
13979
13984
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -13997,7 +14002,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13997
14002
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13998
14003
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13999
14004
|
}, [getReferenceRect, currentWidth, currentHeight, currentAlign, setIsScaling]);
|
|
14000
|
-
const handlePointerMove =
|
|
14005
|
+
const handlePointerMove = useCallback16((e) => {
|
|
14001
14006
|
if (!dragRef.current) return;
|
|
14002
14007
|
const { startX, startY, startWidth, startHeight, side, align } = dragRef.current;
|
|
14003
14008
|
const state = useEditorStore.getState();
|
|
@@ -14056,14 +14061,14 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
14056
14061
|
});
|
|
14057
14062
|
}
|
|
14058
14063
|
}, []);
|
|
14059
|
-
const handlePointerUp =
|
|
14064
|
+
const handlePointerUp = useCallback16(() => {
|
|
14060
14065
|
setActiveSide(null);
|
|
14061
14066
|
setIsScaling(false);
|
|
14062
14067
|
dragRef.current = null;
|
|
14063
14068
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14064
14069
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
14065
14070
|
}, [handlePointerMove, setIsScaling]);
|
|
14066
|
-
|
|
14071
|
+
useEffect11(() => {
|
|
14067
14072
|
return () => {
|
|
14068
14073
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14069
14074
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -14084,7 +14089,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
14084
14089
|
offset8(({ rects }) => -rects.reference.height)
|
|
14085
14090
|
]
|
|
14086
14091
|
});
|
|
14087
|
-
|
|
14092
|
+
useEffect11(() => {
|
|
14088
14093
|
const rect = getReferenceRect();
|
|
14089
14094
|
if (!rect || !refs.floating.current) return;
|
|
14090
14095
|
refs.setPositionReference(virtualReference);
|
|
@@ -14191,7 +14196,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
14191
14196
|
};
|
|
14192
14197
|
|
|
14193
14198
|
// src/core/editor/components/scaling/spacer-scale.tsx
|
|
14194
|
-
import { useMemo as useMemo16, useEffect as
|
|
14199
|
+
import { useMemo as useMemo16, useEffect as useEffect12, useState as useState13, useRef as useRef9, useCallback as useCallback17 } from "react";
|
|
14195
14200
|
import { useFloating as useFloating9, offset as offset9, autoUpdate as autoUpdate7 } from "@floating-ui/react";
|
|
14196
14201
|
import { jsx as jsx46, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
14197
14202
|
var SpacerScale = ({ getReferenceRect }) => {
|
|
@@ -14206,7 +14211,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14206
14211
|
return isNaN(parsedHeight) ? 12 : Math.max(12, Math.min(200, parsedHeight));
|
|
14207
14212
|
}, [focusIdx, template]);
|
|
14208
14213
|
const dragRef = useRef9(null);
|
|
14209
|
-
const handlePointerDown =
|
|
14214
|
+
const handlePointerDown = useCallback17((e, side) => {
|
|
14210
14215
|
e.preventDefault();
|
|
14211
14216
|
e.stopPropagation();
|
|
14212
14217
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -14222,7 +14227,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14222
14227
|
document.addEventListener("pointermove", handlePointerMove);
|
|
14223
14228
|
document.addEventListener("pointerup", handlePointerUp);
|
|
14224
14229
|
}, [currentHeight, setIsScaling]);
|
|
14225
|
-
const handlePointerMove =
|
|
14230
|
+
const handlePointerMove = useCallback17((e) => {
|
|
14226
14231
|
if (!dragRef.current) return;
|
|
14227
14232
|
const { startY, startHeight, side } = dragRef.current;
|
|
14228
14233
|
const state = useEditorStore.getState();
|
|
@@ -14240,14 +14245,14 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14240
14245
|
}
|
|
14241
14246
|
});
|
|
14242
14247
|
}, []);
|
|
14243
|
-
const handlePointerUp =
|
|
14248
|
+
const handlePointerUp = useCallback17(() => {
|
|
14244
14249
|
setActiveSide(null);
|
|
14245
14250
|
setIsScaling(false);
|
|
14246
14251
|
dragRef.current = null;
|
|
14247
14252
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14248
14253
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
14249
14254
|
}, [handlePointerMove, setIsScaling]);
|
|
14250
|
-
|
|
14255
|
+
useEffect12(() => {
|
|
14251
14256
|
return () => {
|
|
14252
14257
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14253
14258
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -14268,7 +14273,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14268
14273
|
offset9(({ rects }) => -rects.reference.height)
|
|
14269
14274
|
]
|
|
14270
14275
|
});
|
|
14271
|
-
|
|
14276
|
+
useEffect12(() => {
|
|
14272
14277
|
const rect = getReferenceRect();
|
|
14273
14278
|
if (!rect || !refs.floating.current) return;
|
|
14274
14279
|
refs.setPositionReference(virtualReference);
|
|
@@ -14327,7 +14332,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14327
14332
|
};
|
|
14328
14333
|
|
|
14329
14334
|
// src/core/editor/components/scaling/column-scale.tsx
|
|
14330
|
-
import { useMemo as useMemo17, useEffect as
|
|
14335
|
+
import { useMemo as useMemo17, useEffect as useEffect13, useState as useState14, useRef as useRef10, useCallback as useCallback18 } from "react";
|
|
14331
14336
|
import { Fragment as Fragment17, jsx as jsx47 } from "react/jsx-runtime";
|
|
14332
14337
|
var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
14333
14338
|
const [activeDivider, setActiveDivider] = useState14(null);
|
|
@@ -14339,7 +14344,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14339
14344
|
return sectionColumn?.data?.value?.columnWidths || [];
|
|
14340
14345
|
}, [template, sectionColumnIdx]);
|
|
14341
14346
|
const dragRef = useRef10(null);
|
|
14342
|
-
const updateColumnRects =
|
|
14347
|
+
const updateColumnRects = useCallback18(() => {
|
|
14343
14348
|
if (!shadowRoot) return;
|
|
14344
14349
|
const allColumns = shadowRoot.querySelectorAll(".node-type-column");
|
|
14345
14350
|
const matchingColumns = [];
|
|
@@ -14371,7 +14376,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14371
14376
|
});
|
|
14372
14377
|
setColumnRects(rects);
|
|
14373
14378
|
}, [shadowRoot, sectionColumnIdx]);
|
|
14374
|
-
|
|
14379
|
+
useEffect13(() => {
|
|
14375
14380
|
updateColumnRects();
|
|
14376
14381
|
let animationId;
|
|
14377
14382
|
const updateLoop = () => {
|
|
@@ -14384,7 +14389,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14384
14389
|
const parseWidth = (width) => {
|
|
14385
14390
|
return parseFloat(width.replace("%", ""));
|
|
14386
14391
|
};
|
|
14387
|
-
const handlePointerDown =
|
|
14392
|
+
const handlePointerDown = useCallback18((e, dividerIndex) => {
|
|
14388
14393
|
e.preventDefault();
|
|
14389
14394
|
e.stopPropagation();
|
|
14390
14395
|
stopTextEditing();
|
|
@@ -14410,7 +14415,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14410
14415
|
document.addEventListener("pointermove", handlePointerMove);
|
|
14411
14416
|
document.addEventListener("pointerup", handlePointerUp);
|
|
14412
14417
|
}, [columnRects, columnWidths, setIsScaling]);
|
|
14413
|
-
const handlePointerMove =
|
|
14418
|
+
const handlePointerMove = useCallback18((e) => {
|
|
14414
14419
|
if (!dragRef.current) return;
|
|
14415
14420
|
const { startX, leftColIndex, rightColIndex, startLeftWidth, startRightWidth, sectionWidth, allWidths } = dragRef.current;
|
|
14416
14421
|
const deltaX = e.clientX - startX;
|
|
@@ -14444,14 +14449,14 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14444
14449
|
}
|
|
14445
14450
|
});
|
|
14446
14451
|
}, [sectionColumnIdx]);
|
|
14447
|
-
const handlePointerUp =
|
|
14452
|
+
const handlePointerUp = useCallback18(() => {
|
|
14448
14453
|
setActiveDivider(null);
|
|
14449
14454
|
setIsScaling(false);
|
|
14450
14455
|
dragRef.current = null;
|
|
14451
14456
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14452
14457
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
14453
14458
|
}, [handlePointerMove, setIsScaling]);
|
|
14454
|
-
|
|
14459
|
+
useEffect13(() => {
|
|
14455
14460
|
return () => {
|
|
14456
14461
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
14457
14462
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -14490,9 +14495,9 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14490
14495
|
};
|
|
14491
14496
|
|
|
14492
14497
|
// src/core/editor/hooks/use-undo-redo-keyboard.ts
|
|
14493
|
-
import { useEffect as
|
|
14498
|
+
import { useEffect as useEffect14 } from "react";
|
|
14494
14499
|
function useUndoRedoKeyboard() {
|
|
14495
|
-
|
|
14500
|
+
useEffect14(() => {
|
|
14496
14501
|
const handler = (e) => {
|
|
14497
14502
|
const isMeta = e.metaKey || e.ctrlKey;
|
|
14498
14503
|
if (!isMeta || e.key.toLowerCase() !== "z") return;
|
|
@@ -14531,7 +14536,7 @@ function Spinner({ className, ...props }) {
|
|
|
14531
14536
|
import { EyeIcon, SendIcon, Monitor, Smartphone } from "lucide-react";
|
|
14532
14537
|
|
|
14533
14538
|
// src/render/useMjmlCompiler.ts
|
|
14534
|
-
import { useState as useState15, useCallback as
|
|
14539
|
+
import { useState as useState15, useCallback as useCallback19 } from "react";
|
|
14535
14540
|
async function compileMjml(mjml) {
|
|
14536
14541
|
console.log("Compiling MJML", mjml);
|
|
14537
14542
|
const response = await fetch("/api/mrender", {
|
|
@@ -14548,7 +14553,7 @@ async function compileMjml(mjml) {
|
|
|
14548
14553
|
}
|
|
14549
14554
|
|
|
14550
14555
|
// src/core/editor/components/preview.tsx
|
|
14551
|
-
import { useEffect as
|
|
14556
|
+
import { useEffect as useEffect15, useState as useState16, useRef as useRef11 } from "react";
|
|
14552
14557
|
|
|
14553
14558
|
// src/validate/helpers.ts
|
|
14554
14559
|
var MERGE_FIELD_REGEX2 = /\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g;
|
|
@@ -14642,7 +14647,7 @@ function Preview() {
|
|
|
14642
14647
|
const [deviceMode, setDeviceMode] = useState16("desktop");
|
|
14643
14648
|
const [preview_validations, setPreviewValidations] = useState16({ invalid_merge_fields: [], missing_links: [], is_over_size_limit: false, placeholder_property_images: 0 });
|
|
14644
14649
|
const [mjmlErrors, setMjmlErrors] = useState16([]);
|
|
14645
|
-
|
|
14650
|
+
useEffect15(() => {
|
|
14646
14651
|
if (typeof window === "undefined" || !previewMode) {
|
|
14647
14652
|
if (!previewMode) {
|
|
14648
14653
|
setHtml("");
|
|
@@ -14947,9 +14952,10 @@ function Editor({ setEditorLoading }) {
|
|
|
14947
14952
|
const lastSyncedTemplateRef = useRef12(null);
|
|
14948
14953
|
const prevTextEditingIdxRef = useRef12(null);
|
|
14949
14954
|
const lastRenderSyncNeededRef = useRef12(0);
|
|
14955
|
+
const hasNotifiedLoadedRef = useRef12(false);
|
|
14950
14956
|
const imageReplaceTargetRef = useRef12(null);
|
|
14951
14957
|
const imagePreviewOriginalSrcRef = useRef12(null);
|
|
14952
|
-
|
|
14958
|
+
useEffect16(() => {
|
|
14953
14959
|
const currentIdx = textEditing?.idx ?? null;
|
|
14954
14960
|
const prevIdx = prevTextEditingIdxRef.current;
|
|
14955
14961
|
const switchedTarget = currentIdx !== null && prevIdx !== null && currentIdx !== prevIdx;
|
|
@@ -14964,16 +14970,15 @@ function Editor({ setEditorLoading }) {
|
|
|
14964
14970
|
}
|
|
14965
14971
|
if (!isEqual(template, renderData)) {
|
|
14966
14972
|
setRenderData(cloneDeep2(template));
|
|
14973
|
+
if (!hasNotifiedLoadedRef.current && setEditorLoading) {
|
|
14974
|
+
hasNotifiedLoadedRef.current = true;
|
|
14975
|
+
setEditorLoading(false);
|
|
14976
|
+
}
|
|
14967
14977
|
}
|
|
14968
14978
|
lastSyncedTemplateRef.current = template;
|
|
14969
14979
|
}
|
|
14970
|
-
}, [template, renderData, isEditing, textEditing, renderSyncNeeded]);
|
|
14971
|
-
|
|
14972
|
-
if (renderData && setEditorLoading) {
|
|
14973
|
-
setEditorLoading(false);
|
|
14974
|
-
}
|
|
14975
|
-
}, [renderData, setEditorLoading]);
|
|
14976
|
-
useEffect21(() => {
|
|
14980
|
+
}, [template, renderData, isEditing, textEditing, renderSyncNeeded, setEditorLoading]);
|
|
14981
|
+
useEffect16(() => {
|
|
14977
14982
|
if (!pendingTextEditRequest || !shadowRootRef.current) return;
|
|
14978
14983
|
const { idx, cursorPosition } = pendingTextEditRequest;
|
|
14979
14984
|
const blockNode = shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
@@ -15022,7 +15027,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15022
15027
|
startTextEditing({ idx, getReferenceRect: getReferenceRect2, getShadowElement, initialWidth: blockRect.width, initialHeight: blockRect.height, clickX, clickY, content, styles, cursorPosition });
|
|
15023
15028
|
clearPendingTextEditRequest();
|
|
15024
15029
|
}, [pendingTextEditRequest, clearPendingTextEditRequest, startTextEditing]);
|
|
15025
|
-
|
|
15030
|
+
useEffect16(() => {
|
|
15026
15031
|
if (isDragging && dataTransfer) {
|
|
15027
15032
|
const currentTemplate = useEditorStore.getState().template;
|
|
15028
15033
|
templateCacheRef.current = currentTemplate;
|
|
@@ -15040,7 +15045,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15040
15045
|
}, [isDragging, dataTransfer]);
|
|
15041
15046
|
const [html, setHtml] = useState17("");
|
|
15042
15047
|
const lastRenderDataRef = useRef12("");
|
|
15043
|
-
|
|
15048
|
+
useEffect16(() => {
|
|
15044
15049
|
if (typeof window === "undefined" || !renderData) {
|
|
15045
15050
|
setHtml("");
|
|
15046
15051
|
lastRenderDataRef.current = "";
|
|
@@ -15073,7 +15078,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15073
15078
|
}, 200),
|
|
15074
15079
|
[updateElementContent]
|
|
15075
15080
|
);
|
|
15076
|
-
const handleElementClick =
|
|
15081
|
+
const handleElementClick = useCallback20(
|
|
15077
15082
|
(idx) => {
|
|
15078
15083
|
if (isInsideCompanyFooter(idx, template)) {
|
|
15079
15084
|
return;
|
|
@@ -15086,7 +15091,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15086
15091
|
},
|
|
15087
15092
|
[setFocusIdx, template]
|
|
15088
15093
|
);
|
|
15089
|
-
const handleElementHover =
|
|
15094
|
+
const handleElementHover = useCallback20(
|
|
15090
15095
|
(idx) => {
|
|
15091
15096
|
if (!isDragging) {
|
|
15092
15097
|
if (idx) {
|
|
@@ -15100,19 +15105,19 @@ function Editor({ setEditorLoading }) {
|
|
|
15100
15105
|
},
|
|
15101
15106
|
[isDragging, setHoverIdx, template]
|
|
15102
15107
|
);
|
|
15103
|
-
const handleContentInput =
|
|
15108
|
+
const handleContentInput = useCallback20(
|
|
15104
15109
|
(contentIdx, content) => {
|
|
15105
15110
|
debouncedUpdateContent(contentIdx, content);
|
|
15106
15111
|
},
|
|
15107
15112
|
[debouncedUpdateContent]
|
|
15108
15113
|
);
|
|
15109
|
-
const handleEditingStart =
|
|
15114
|
+
const handleEditingStart = useCallback20(() => {
|
|
15110
15115
|
setIsEditing(true);
|
|
15111
15116
|
}, []);
|
|
15112
|
-
const handleEditingEnd =
|
|
15117
|
+
const handleEditingEnd = useCallback20(() => {
|
|
15113
15118
|
setIsEditing(false);
|
|
15114
15119
|
}, []);
|
|
15115
|
-
const handleSlashCommand =
|
|
15120
|
+
const handleSlashCommand = useCallback20(
|
|
15116
15121
|
(cursorRect) => {
|
|
15117
15122
|
setSlashCommand({
|
|
15118
15123
|
isActive: true,
|
|
@@ -15127,10 +15132,10 @@ function Editor({ setEditorLoading }) {
|
|
|
15127
15132
|
},
|
|
15128
15133
|
[setSlashCommand]
|
|
15129
15134
|
);
|
|
15130
|
-
const handleSlashCommandClose =
|
|
15135
|
+
const handleSlashCommandClose = useCallback20(() => {
|
|
15131
15136
|
clearSlashCommand();
|
|
15132
15137
|
}, [clearSlashCommand]);
|
|
15133
|
-
const handleTextEditStart =
|
|
15138
|
+
const handleTextEditStart = useCallback20(
|
|
15134
15139
|
(idx, initialWidth, initialHeight, clickX, clickY, content, styles) => {
|
|
15135
15140
|
const getReferenceRect2 = () => {
|
|
15136
15141
|
if (!shadowRootRef.current) return null;
|
|
@@ -15145,11 +15150,11 @@ function Editor({ setEditorLoading }) {
|
|
|
15145
15150
|
},
|
|
15146
15151
|
[startTextEditing]
|
|
15147
15152
|
);
|
|
15148
|
-
const findParentSectionIdx =
|
|
15153
|
+
const findParentSectionIdx = useCallback20((idx) => {
|
|
15149
15154
|
const match = /^(content\.children\.\[\d+\])/.exec(idx);
|
|
15150
15155
|
return match ? match[1] : null;
|
|
15151
15156
|
}, []);
|
|
15152
|
-
const handleDragOver =
|
|
15157
|
+
const handleDragOver = useCallback20(
|
|
15153
15158
|
(_e, dragInfo) => {
|
|
15154
15159
|
const currentDataTransfer = useEditorStore.getState().dataTransfer;
|
|
15155
15160
|
if (!currentDataTransfer) return;
|
|
@@ -15608,7 +15613,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15608
15613
|
[findParentSectionIdx]
|
|
15609
15614
|
// Only dependency is the helper function
|
|
15610
15615
|
);
|
|
15611
|
-
const handleDrop =
|
|
15616
|
+
const handleDrop = useCallback20(
|
|
15612
15617
|
(_e, _dragInfo) => {
|
|
15613
15618
|
const currentDataTransfer = useEditorStore.getState().dataTransfer;
|
|
15614
15619
|
if (!currentDataTransfer) return;
|
|
@@ -15792,7 +15797,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15792
15797
|
},
|
|
15793
15798
|
[addElement, addElementInNewSection, moveElement, moveElementToNewSection, splitTextAndInsertElement, splitSectionAndInsertElement, setIsDragging, setIsDragButtonHovered, setDataTransfer, setHoverIdx]
|
|
15794
15799
|
);
|
|
15795
|
-
const handleDragLeave =
|
|
15800
|
+
const handleDragLeave = useCallback20(() => {
|
|
15796
15801
|
setDropIndicator(null);
|
|
15797
15802
|
setDropTargetIdx(null);
|
|
15798
15803
|
dragParentIdxRef.current = null;
|
|
@@ -15813,13 +15818,13 @@ function Editor({ setEditorLoading }) {
|
|
|
15813
15818
|
sectionElementCacheRef.current.clear();
|
|
15814
15819
|
sectionRectCacheRef.current.clear();
|
|
15815
15820
|
}, []);
|
|
15816
|
-
const handleShadowRootRef =
|
|
15821
|
+
const handleShadowRootRef = useCallback20((shadowRoot) => {
|
|
15817
15822
|
shadowRootRef.current = shadowRoot;
|
|
15818
15823
|
}, []);
|
|
15819
|
-
const handleSelectionRectChange =
|
|
15824
|
+
const handleSelectionRectChange = useCallback20((rect) => {
|
|
15820
15825
|
setHasSelectedElement(rect !== null);
|
|
15821
15826
|
}, []);
|
|
15822
|
-
const getReferenceRect =
|
|
15827
|
+
const getReferenceRect = useCallback20(() => {
|
|
15823
15828
|
if (!shadowRootRef.current || !focusIdx) return null;
|
|
15824
15829
|
const selectedEl = shadowRootRef.current.querySelector(
|
|
15825
15830
|
`.node-idx-${CSS.escape(focusIdx)}`
|