@kgalexander/mcreate 0.0.12 → 0.0.13
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-PL5EKNN6.mjs → chunk-LAW7VVEQ.mjs} +409 -145
- package/dist/{core-UL57QVFL.mjs → core-GBVVYXAB.mjs} +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +2657 -1866
- package/dist/index.mjs +1318 -829
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/core/index.tsx
|
|
2
|
-
import { useMemo as useMemo16, useState as
|
|
2
|
+
import { useMemo as useMemo16, useState as useState16, useEffect as useEffect20, useCallback as useCallback16, useRef as useRef11 } from "react";
|
|
3
3
|
import { cloneDeep as cloneDeep2, isEqual, debounce } from "lodash";
|
|
4
4
|
|
|
5
5
|
// src/core/utils/idx.ts
|
|
@@ -1114,7 +1114,6 @@ import lodashGet from "lodash/get";
|
|
|
1114
1114
|
import lodashSet from "lodash/set";
|
|
1115
1115
|
import cloneDeep from "lodash/cloneDeep";
|
|
1116
1116
|
import { castDraft } from "immer";
|
|
1117
|
-
import { toast } from "sonner";
|
|
1118
1117
|
|
|
1119
1118
|
// src/core/editor/utils/generate-id.ts
|
|
1120
1119
|
import { nanoid } from "nanoid";
|
|
@@ -1278,6 +1277,7 @@ function createSocialElement(payload) {
|
|
|
1278
1277
|
"inner-padding": "4px 4px",
|
|
1279
1278
|
"icon-padding": "0px 6px",
|
|
1280
1279
|
"text-padding": "4px 4px",
|
|
1280
|
+
"line-height": "1.4",
|
|
1281
1281
|
...payload?.attributes
|
|
1282
1282
|
},
|
|
1283
1283
|
children: payload?.children || [
|
|
@@ -1312,6 +1312,7 @@ function createSocialItemElement(payload) {
|
|
|
1312
1312
|
target: "_blank",
|
|
1313
1313
|
src: payload?.attributes?.src || "https://cdn-images.mailchimp.com/icons/social-block-v3/block-icons-v3/facebook-icon-color-40.png",
|
|
1314
1314
|
alt: payload?.attributes?.alt || "Facebook",
|
|
1315
|
+
align: "center",
|
|
1315
1316
|
...payload?.attributes
|
|
1316
1317
|
}
|
|
1317
1318
|
};
|
|
@@ -1878,6 +1879,7 @@ var useEditorStore = create()(
|
|
|
1878
1879
|
template: defaultTemplate,
|
|
1879
1880
|
templateId: null,
|
|
1880
1881
|
onSave: null,
|
|
1882
|
+
onToast: null,
|
|
1881
1883
|
previewMode: false,
|
|
1882
1884
|
focusIdx: null,
|
|
1883
1885
|
hoverIdx: null,
|
|
@@ -1902,11 +1904,12 @@ var useEditorStore = create()(
|
|
|
1902
1904
|
// Subscription level (0 = free, 1-3 = paid tiers)
|
|
1903
1905
|
isPaidLevel: 0,
|
|
1904
1906
|
// Initialize store with external template (for npm package usage)
|
|
1905
|
-
initializeWithTemplate: (templateId, template, onSave, isPaidLevel) => {
|
|
1907
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, isPaidLevel) => {
|
|
1906
1908
|
set((state) => {
|
|
1907
1909
|
state.templateId = templateId;
|
|
1908
1910
|
state.template = template;
|
|
1909
1911
|
state.onSave = onSave ?? null;
|
|
1912
|
+
state.onToast = onToast ?? null;
|
|
1910
1913
|
state.isPaidLevel = isPaidLevel ?? 0;
|
|
1911
1914
|
state.templateSize = calculateTemplateSize(template);
|
|
1912
1915
|
state.isAtSizeLimit = false;
|
|
@@ -2053,7 +2056,7 @@ var useEditorStore = create()(
|
|
|
2053
2056
|
}
|
|
2054
2057
|
const elementSize = new Blob([JSON.stringify(newElement)]).size;
|
|
2055
2058
|
if (state.templateSize + elementSize > MAX_TEMPLATE_SIZE) {
|
|
2056
|
-
|
|
2059
|
+
state.onToast?.({ type: "error", message: "Template size limit reached - element would exceed the limit" });
|
|
2057
2060
|
return;
|
|
2058
2061
|
}
|
|
2059
2062
|
const children = parent.children;
|
|
@@ -2092,7 +2095,7 @@ var useEditorStore = create()(
|
|
|
2092
2095
|
}
|
|
2093
2096
|
const sectionSize = new Blob([JSON.stringify(newSection)]).size;
|
|
2094
2097
|
if (state.templateSize + sectionSize > MAX_TEMPLATE_SIZE) {
|
|
2095
|
-
|
|
2098
|
+
state.onToast?.({ type: "error", message: "Template size limit reached" });
|
|
2096
2099
|
return;
|
|
2097
2100
|
}
|
|
2098
2101
|
const children = page.children;
|
|
@@ -2210,7 +2213,7 @@ var useEditorStore = create()(
|
|
|
2210
2213
|
}
|
|
2211
2214
|
).length;
|
|
2212
2215
|
if (regularSectionCount <= 1) {
|
|
2213
|
-
|
|
2216
|
+
state.onToast?.({ type: "error", message: "Cannot delete the last section" });
|
|
2214
2217
|
return;
|
|
2215
2218
|
}
|
|
2216
2219
|
}
|
|
@@ -2343,7 +2346,7 @@ var useEditorStore = create()(
|
|
|
2343
2346
|
const clonedElement = cloneDeep(sourceElement);
|
|
2344
2347
|
const elementSize = new Blob([JSON.stringify(clonedElement)]).size;
|
|
2345
2348
|
if (state.templateSize + elementSize > MAX_TEMPLATE_SIZE) {
|
|
2346
|
-
|
|
2349
|
+
state.onToast?.({ type: "error", message: "Template size limit reached - duplicate would exceed limit" });
|
|
2347
2350
|
return;
|
|
2348
2351
|
}
|
|
2349
2352
|
const parent = getElementAtIdx(state.template, parentIdx);
|
|
@@ -2447,13 +2450,14 @@ var useEditorStore = create()(
|
|
|
2447
2450
|
if (tempDroppedElement) {
|
|
2448
2451
|
const elementSize = new Blob([JSON.stringify(tempDroppedElement)]).size;
|
|
2449
2452
|
if (state.templateSize + elementSize > MAX_TEMPLATE_SIZE) {
|
|
2450
|
-
|
|
2453
|
+
state.onToast?.({ type: "error", message: "Template size limit reached - this element would exceed the limit" });
|
|
2451
2454
|
return;
|
|
2452
2455
|
}
|
|
2453
2456
|
}
|
|
2454
2457
|
}
|
|
2455
2458
|
textElement.data.value.content = beforeContent;
|
|
2456
2459
|
let droppedElement = null;
|
|
2460
|
+
let deletedSectionIndex = null;
|
|
2457
2461
|
if (sourceIdx) {
|
|
2458
2462
|
const sourceParentIdx = getParentIdx(sourceIdx);
|
|
2459
2463
|
if (sourceParentIdx) {
|
|
@@ -2473,6 +2477,7 @@ var useEditorStore = create()(
|
|
|
2473
2477
|
const sectionIndex = getIndexByIdx(sourceSectionIdx);
|
|
2474
2478
|
const sourcePageChildren = sourcePage.children;
|
|
2475
2479
|
sourcePageChildren.splice(sectionIndex, 1);
|
|
2480
|
+
deletedSectionIndex = sectionIndex;
|
|
2476
2481
|
}
|
|
2477
2482
|
} else if (action === "add-text") {
|
|
2478
2483
|
const defaultText = createElementByType("text", { data: { value: { content: "" } } });
|
|
@@ -2498,7 +2503,20 @@ var useEditorStore = create()(
|
|
|
2498
2503
|
console.error("Failed to create new text element");
|
|
2499
2504
|
return;
|
|
2500
2505
|
}
|
|
2501
|
-
|
|
2506
|
+
let adjustedTextElementIdx = textElementIdx;
|
|
2507
|
+
if (deletedSectionIndex !== null) {
|
|
2508
|
+
const textSectionMatch = SECTION_INDEX_REGEX.exec(textElementIdx);
|
|
2509
|
+
if (textSectionMatch) {
|
|
2510
|
+
const textSectionIndex = Number(textSectionMatch[1]);
|
|
2511
|
+
if (deletedSectionIndex < textSectionIndex) {
|
|
2512
|
+
adjustedTextElementIdx = textElementIdx.replace(
|
|
2513
|
+
SECTION_INDEX_REGEX,
|
|
2514
|
+
`content.children.[${textSectionIndex - 1}]`
|
|
2515
|
+
);
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
const parentIdx = getParentIdx(adjustedTextElementIdx);
|
|
2502
2520
|
if (!parentIdx) {
|
|
2503
2521
|
console.error("Parent not found for text element");
|
|
2504
2522
|
return;
|
|
@@ -2508,7 +2526,7 @@ var useEditorStore = create()(
|
|
|
2508
2526
|
console.error("Parent is not a valid container");
|
|
2509
2527
|
return;
|
|
2510
2528
|
}
|
|
2511
|
-
const currentIndex = getIndexByIdx(
|
|
2529
|
+
const currentIndex = getIndexByIdx(adjustedTextElementIdx);
|
|
2512
2530
|
const parentChildren = parent.children;
|
|
2513
2531
|
let adjustedIndex = currentIndex;
|
|
2514
2532
|
if (sourceIdx) {
|
|
@@ -2595,7 +2613,7 @@ var useEditorStore = create()(
|
|
|
2595
2613
|
const elementSize = new Blob([JSON.stringify(sectionColumnElement)]).size;
|
|
2596
2614
|
const approxNewSectionSize = 200;
|
|
2597
2615
|
if (state.templateSize + elementSize + approxNewSectionSize > MAX_TEMPLATE_SIZE) {
|
|
2598
|
-
|
|
2616
|
+
state.onToast?.({ type: "error", message: "Template size limit reached" });
|
|
2599
2617
|
return;
|
|
2600
2618
|
}
|
|
2601
2619
|
}
|
|
@@ -2618,7 +2636,7 @@ var useEditorStore = create()(
|
|
|
2618
2636
|
const pageChildren = page.children;
|
|
2619
2637
|
let adjustedSectionIndex = sectionIndex;
|
|
2620
2638
|
if (sourceIdx) {
|
|
2621
|
-
const srcSectionMatch =
|
|
2639
|
+
const srcSectionMatch = SECTION_INDEX_REGEX.exec(sourceIdx);
|
|
2622
2640
|
if (srcSectionMatch) {
|
|
2623
2641
|
const srcSectionIndex = parseInt(srcSectionMatch[1], 10);
|
|
2624
2642
|
if (srcSectionIndex < sectionIndex) {
|
|
@@ -2694,7 +2712,7 @@ var useEditorStore = create()(
|
|
|
2694
2712
|
if (!sourceIdx) {
|
|
2695
2713
|
const columnSize = new Blob([JSON.stringify(newColumn)]).size;
|
|
2696
2714
|
if (state.templateSize + columnSize > MAX_TEMPLATE_SIZE) {
|
|
2697
|
-
|
|
2715
|
+
state.onToast?.({ type: "error", message: "Template size limit reached" });
|
|
2698
2716
|
return;
|
|
2699
2717
|
}
|
|
2700
2718
|
}
|
|
@@ -2787,7 +2805,7 @@ var useEditorStore = create()(
|
|
|
2787
2805
|
if (!sourceIdx) {
|
|
2788
2806
|
const columnSize = new Blob([JSON.stringify(newColumn)]).size;
|
|
2789
2807
|
if (state.templateSize + columnSize > MAX_TEMPLATE_SIZE) {
|
|
2790
|
-
|
|
2808
|
+
state.onToast?.({ type: "error", message: "Template size limit reached" });
|
|
2791
2809
|
return;
|
|
2792
2810
|
}
|
|
2793
2811
|
}
|
|
@@ -3149,7 +3167,6 @@ var NOT_DRAGGABLE_ELEMENTS = ["page", "social-item", "text", "property-card", "p
|
|
|
3149
3167
|
var IMAGE_SELECTION_VALID_TYPES = ["section", "section-column", "image", "section-property-km", "section-property-single-two", "section-property-triple", "property-card", "property-card-single-two", "property-card-triple", "property-card-triple-item"];
|
|
3150
3168
|
|
|
3151
3169
|
// src/core/editor/components/ShadowDomRenderer.tsx
|
|
3152
|
-
import { toast as toast2 } from "sonner";
|
|
3153
3170
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3154
3171
|
var lastSizeLimitToastTime = 0;
|
|
3155
3172
|
var cssCache = /* @__PURE__ */ new Map();
|
|
@@ -3918,7 +3935,7 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
3918
3935
|
const now = Date.now();
|
|
3919
3936
|
if (now - lastSizeLimitToastTime > 2e3) {
|
|
3920
3937
|
lastSizeLimitToastTime = now;
|
|
3921
|
-
|
|
3938
|
+
useEditorStore.getState().onToast?.({ type: "error", message: "Template size limit reached" });
|
|
3922
3939
|
}
|
|
3923
3940
|
return;
|
|
3924
3941
|
}
|
|
@@ -3980,7 +3997,7 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
3980
3997
|
const now = Date.now();
|
|
3981
3998
|
if (now - lastSizeLimitToastTime > 2e3) {
|
|
3982
3999
|
lastSizeLimitToastTime = now;
|
|
3983
|
-
|
|
4000
|
+
useEditorStore.getState().onToast?.({ type: "error", message: "Template size limit reached" });
|
|
3984
4001
|
}
|
|
3985
4002
|
}
|
|
3986
4003
|
};
|
|
@@ -10998,9 +11015,6 @@ function checkElementPosition(template, elementIdx) {
|
|
|
10998
11015
|
return { isFirstInFirstSection, isFirstInSectionColumn };
|
|
10999
11016
|
}
|
|
11000
11017
|
|
|
11001
|
-
// src/core/editor/components/tiptap-overlay.tsx
|
|
11002
|
-
import { toast as toast3 } from "sonner";
|
|
11003
|
-
|
|
11004
11018
|
// src/components/ui/tooltip.tsx
|
|
11005
11019
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
11006
11020
|
import { jsx as jsx14, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
@@ -11666,7 +11680,7 @@ var TiptapOverlay = () => {
|
|
|
11666
11680
|
if (!textEditing) return null;
|
|
11667
11681
|
return /* @__PURE__ */ jsx21(TiptapOverlayContent, { ...textEditing }, textEditing.idx);
|
|
11668
11682
|
};
|
|
11669
|
-
var TiptapOverlayContent = ({ idx, getReferenceRect, initialWidth, initialHeight, clickX, clickY, content, styles, cursorPosition }) => {
|
|
11683
|
+
var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWidth, initialHeight, clickX, clickY, content, styles, cursorPosition }) => {
|
|
11670
11684
|
const containerRef = useRef4(null);
|
|
11671
11685
|
const setTiptapEditor = useEditorStore((s) => s.setTiptapEditor);
|
|
11672
11686
|
const linkColor = useEditorStore((s) => s.template?.content?.[0]?.data?.value?.linkColor) || "#0000ff";
|
|
@@ -11681,6 +11695,24 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, initialWidth, initialHeight
|
|
|
11681
11695
|
}
|
|
11682
11696
|
};
|
|
11683
11697
|
}, []);
|
|
11698
|
+
useEffect6(() => {
|
|
11699
|
+
const container = containerRef.current;
|
|
11700
|
+
if (!container) return;
|
|
11701
|
+
const observer = new ResizeObserver(() => {
|
|
11702
|
+
const shadowEl = getShadowElement();
|
|
11703
|
+
if (shadowEl) {
|
|
11704
|
+
shadowEl.style.height = `${container.offsetHeight}px`;
|
|
11705
|
+
}
|
|
11706
|
+
});
|
|
11707
|
+
observer.observe(container);
|
|
11708
|
+
return () => {
|
|
11709
|
+
observer.disconnect();
|
|
11710
|
+
const shadowEl = getShadowElement();
|
|
11711
|
+
if (shadowEl) {
|
|
11712
|
+
shadowEl.style.height = "";
|
|
11713
|
+
}
|
|
11714
|
+
};
|
|
11715
|
+
}, [getShadowElement]);
|
|
11684
11716
|
const cleanedContent = useMemo3(() => {
|
|
11685
11717
|
return content.replace(NBSP_P_CONTENT_REGEX, "<p$1></p>").replace(IS_EMPTY_P_CLASS_REGEX, "").replace(IS_EMPTY_HEADING_CLASS_REGEX, "");
|
|
11686
11718
|
}, [content]);
|
|
@@ -11741,7 +11773,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, initialWidth, initialHeight
|
|
|
11741
11773
|
const now = Date.now();
|
|
11742
11774
|
if (now - lastSizeLimitToastRef.current > 2e3) {
|
|
11743
11775
|
lastSizeLimitToastRef.current = now;
|
|
11744
|
-
|
|
11776
|
+
useEditorStore.getState().onToast?.({ type: "error", message: "Template size limit reached" });
|
|
11745
11777
|
}
|
|
11746
11778
|
return true;
|
|
11747
11779
|
}
|
|
@@ -11798,7 +11830,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, initialWidth, initialHeight
|
|
|
11798
11830
|
const now = Date.now();
|
|
11799
11831
|
if (now - lastSizeLimitToastRef.current > 2e3) {
|
|
11800
11832
|
lastSizeLimitToastRef.current = now;
|
|
11801
|
-
|
|
11833
|
+
useEditorStore.getState().onToast?.({ type: "error", message: "Template size limit reached - paste would exceed the limit" });
|
|
11802
11834
|
}
|
|
11803
11835
|
return true;
|
|
11804
11836
|
}
|
|
@@ -12059,7 +12091,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, initialWidth, initialHeight
|
|
|
12059
12091
|
};
|
|
12060
12092
|
|
|
12061
12093
|
// src/core/editor/components/element-float.tsx
|
|
12062
|
-
import { useEffect as
|
|
12094
|
+
import { useEffect as useEffect12, useMemo as useMemo10 } from "react";
|
|
12063
12095
|
import { useFloating as useFloating4, offset as offset4, shift as shift3, flip as flip2, autoUpdate as autoUpdate3 } from "@floating-ui/react";
|
|
12064
12096
|
|
|
12065
12097
|
// src/core/editor/components/float-ui/actions/delete-button.tsx
|
|
@@ -13027,34 +13059,253 @@ var ImageFloat = () => {
|
|
|
13027
13059
|
] });
|
|
13028
13060
|
};
|
|
13029
13061
|
|
|
13030
|
-
// src/core/editor/components/
|
|
13062
|
+
// src/core/editor/components/mlsNumber-menu.tsx
|
|
13063
|
+
import { useState as useState8, useEffect as useEffect11 } from "react";
|
|
13064
|
+
import { HousePlusIcon, TrashIcon as TrashIcon5, XIcon as XIcon2, Loader2Icon } from "lucide-react";
|
|
13065
|
+
|
|
13066
|
+
// src/services/repliers/commands.ts
|
|
13067
|
+
async function getListingByMlsNumber(mlsNumber) {
|
|
13068
|
+
const response = await fetch(`/api/mcommends/repliers/getListingByMlsNumber/${mlsNumber}`, {
|
|
13069
|
+
method: "GET",
|
|
13070
|
+
headers: {
|
|
13071
|
+
"accept": "application/json"
|
|
13072
|
+
}
|
|
13073
|
+
});
|
|
13074
|
+
const data = await response.json();
|
|
13075
|
+
return data;
|
|
13076
|
+
}
|
|
13077
|
+
|
|
13078
|
+
// src/core/editor/components/mlsNumber-menu.tsx
|
|
13031
13079
|
import { Fragment as Fragment14, jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
13080
|
+
var MlsNumberMenu = () => {
|
|
13081
|
+
const { focusIdx, template, updateElement, onToast } = useEditorStore();
|
|
13082
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
13083
|
+
const [inputValue, setInputValue] = useState8("");
|
|
13084
|
+
const [propertyData, setPropertyData] = useState8(null);
|
|
13085
|
+
const [isLoading, setIsLoading] = useState8(false);
|
|
13086
|
+
const propertyElement = focusIdx && template ? getValueByIdx(template, focusIdx) : null;
|
|
13087
|
+
const currentMlsNumber = propertyElement?.data?.value?.mlsNumber || "";
|
|
13088
|
+
useEffect11(() => {
|
|
13089
|
+
setInputValue(currentMlsNumber);
|
|
13090
|
+
setPropertyData(null);
|
|
13091
|
+
}, [focusIdx, currentMlsNumber]);
|
|
13092
|
+
const handleInputChange = (e) => {
|
|
13093
|
+
setInputValue(e.target.value);
|
|
13094
|
+
};
|
|
13095
|
+
const handleKeyDown = (e) => {
|
|
13096
|
+
if (e.key === "Enter") {
|
|
13097
|
+
handleDone();
|
|
13098
|
+
}
|
|
13099
|
+
if (e.key === "Escape") {
|
|
13100
|
+
setIsOpen(false);
|
|
13101
|
+
}
|
|
13102
|
+
};
|
|
13103
|
+
const handleClear = () => {
|
|
13104
|
+
setInputValue("");
|
|
13105
|
+
setPropertyData(null);
|
|
13106
|
+
};
|
|
13107
|
+
const handleClearPreview = () => {
|
|
13108
|
+
setPropertyData(null);
|
|
13109
|
+
};
|
|
13110
|
+
const handleApplyToCard = () => {
|
|
13111
|
+
if (!focusIdx || !propertyElement || !propertyData) return;
|
|
13112
|
+
console.log(propertyData);
|
|
13113
|
+
const imageUrl = propertyData.images?.[0] ? `https://cdn.repliers.io/${propertyData.images[0]}` : propertyElement.attributes?.["image-src"];
|
|
13114
|
+
updateElement(focusIdx, {
|
|
13115
|
+
data: {
|
|
13116
|
+
value: {
|
|
13117
|
+
...propertyElement.data?.value,
|
|
13118
|
+
mlsNumber: propertyData.mlsNumber
|
|
13119
|
+
}
|
|
13120
|
+
},
|
|
13121
|
+
attributes: {
|
|
13122
|
+
...propertyElement.attributes,
|
|
13123
|
+
"image-src": imageUrl,
|
|
13124
|
+
"price": String(propertyData.listPrice || 0),
|
|
13125
|
+
"address": `${propertyData.address?.streetNumber || ""} ${propertyData.address?.streetName || ""}`.trim(),
|
|
13126
|
+
"city": `${propertyData.address?.city || ""}, ${propertyData.address?.state || ""} ${propertyData.address?.zip || ""}`.trim(),
|
|
13127
|
+
"beds": String(propertyData.details?.numBedrooms || "--"),
|
|
13128
|
+
"baths": String(propertyData.details?.numBathrooms || "--"),
|
|
13129
|
+
"sqft": String(propertyData.details?.sqft || "--"),
|
|
13130
|
+
"status": propertyData.standardStatus || propertyData.status || "Active",
|
|
13131
|
+
"brokerage": propertyData.office?.brokerageName || ""
|
|
13132
|
+
}
|
|
13133
|
+
});
|
|
13134
|
+
setPropertyData(null);
|
|
13135
|
+
setIsOpen(false);
|
|
13136
|
+
};
|
|
13137
|
+
const handleDone = async () => {
|
|
13138
|
+
if (inputValue.trim()) {
|
|
13139
|
+
setIsLoading(true);
|
|
13140
|
+
try {
|
|
13141
|
+
const data = await getListingByMlsNumber(inputValue.trim());
|
|
13142
|
+
if (data.error) {
|
|
13143
|
+
onToast?.({ type: "error", message: data.error });
|
|
13144
|
+
return;
|
|
13145
|
+
}
|
|
13146
|
+
setPropertyData(data);
|
|
13147
|
+
} catch (error) {
|
|
13148
|
+
console.warn("Failed to fetch listing:", error);
|
|
13149
|
+
const message = error instanceof Error ? error.message : "Failed to fetch listing";
|
|
13150
|
+
onToast?.({ type: "error", message });
|
|
13151
|
+
} finally {
|
|
13152
|
+
setIsLoading(false);
|
|
13153
|
+
}
|
|
13154
|
+
}
|
|
13155
|
+
};
|
|
13156
|
+
return /* @__PURE__ */ jsxs22(DropdownMenu, { open: isOpen, onOpenChange: setIsOpen, children: [
|
|
13157
|
+
/* @__PURE__ */ jsxs22(Tooltip, { children: [
|
|
13158
|
+
/* @__PURE__ */ jsx37(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx37(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs22(
|
|
13159
|
+
Button,
|
|
13160
|
+
{
|
|
13161
|
+
variant: "ghost",
|
|
13162
|
+
className: "shadow-none transition-none cursor-pointer rounded-full outline-none h-[34px]",
|
|
13163
|
+
children: [
|
|
13164
|
+
/* @__PURE__ */ jsx37(HousePlusIcon, { className: "size-4" }),
|
|
13165
|
+
/* @__PURE__ */ jsx37("p", { children: "MLS" })
|
|
13166
|
+
]
|
|
13167
|
+
}
|
|
13168
|
+
) }) }),
|
|
13169
|
+
/* @__PURE__ */ jsx37(TooltipContent, { side: "bottom", children: "Enter MLS Number" })
|
|
13170
|
+
] }),
|
|
13171
|
+
/* @__PURE__ */ jsxs22(DropdownMenuContent, { side: "bottom", className: "w-[250px] p-3 shadow-lg z-50001", children: [
|
|
13172
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex flex-col gap-2", children: [
|
|
13173
|
+
/* @__PURE__ */ jsx37(Label, { children: "Enter MLS Number" }),
|
|
13174
|
+
/* @__PURE__ */ jsx37(
|
|
13175
|
+
Input,
|
|
13176
|
+
{
|
|
13177
|
+
type: "text",
|
|
13178
|
+
placeholder: "e.g., W1234567",
|
|
13179
|
+
className: "w-full rounded-[12px] shadow-none h-[44px]",
|
|
13180
|
+
value: inputValue,
|
|
13181
|
+
onChange: handleInputChange,
|
|
13182
|
+
onKeyDown: handleKeyDown,
|
|
13183
|
+
autoFocus: true
|
|
13184
|
+
}
|
|
13185
|
+
)
|
|
13186
|
+
] }),
|
|
13187
|
+
/* @__PURE__ */ jsx37(Separator, { className: "my-2" }),
|
|
13188
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex flex-row justify-between items-center", children: [
|
|
13189
|
+
/* @__PURE__ */ jsx37("div", { className: "flex flex-row", children: /* @__PURE__ */ jsxs22(Tooltip, { children: [
|
|
13190
|
+
/* @__PURE__ */ jsx37(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx37(
|
|
13191
|
+
Button,
|
|
13192
|
+
{
|
|
13193
|
+
variant: "ghost",
|
|
13194
|
+
size: "icon",
|
|
13195
|
+
className: "shadow-none transition-none cursor-pointer rounded-full outline-none",
|
|
13196
|
+
onClick: handleClear,
|
|
13197
|
+
disabled: !inputValue,
|
|
13198
|
+
children: /* @__PURE__ */ jsx37(TrashIcon5, {})
|
|
13199
|
+
}
|
|
13200
|
+
) }),
|
|
13201
|
+
/* @__PURE__ */ jsx37(TooltipContent, { side: "bottom", className: "z-50001", children: "Clear" })
|
|
13202
|
+
] }) }),
|
|
13203
|
+
/* @__PURE__ */ jsx37("div", { children: /* @__PURE__ */ jsx37(
|
|
13204
|
+
Button,
|
|
13205
|
+
{
|
|
13206
|
+
variant: "default",
|
|
13207
|
+
className: "shadow-none transition-none cursor-pointer rounded-[12px] outline-none",
|
|
13208
|
+
onClick: handleDone,
|
|
13209
|
+
disabled: isLoading || !inputValue.trim(),
|
|
13210
|
+
children: isLoading ? /* @__PURE__ */ jsx37(Loader2Icon, { className: "size-4 animate-spin" }) : "Done"
|
|
13211
|
+
}
|
|
13212
|
+
) })
|
|
13213
|
+
] }),
|
|
13214
|
+
propertyData && /* @__PURE__ */ jsxs22(Fragment14, { children: [
|
|
13215
|
+
/* @__PURE__ */ jsx37(Separator, { className: "my-2" }),
|
|
13216
|
+
/* @__PURE__ */ jsxs22("div", { className: "rounded-[12px] border overflow-hidden bg-card", children: [
|
|
13217
|
+
/* @__PURE__ */ jsxs22("div", { className: "relative", children: [
|
|
13218
|
+
/* @__PURE__ */ jsx37(
|
|
13219
|
+
"img",
|
|
13220
|
+
{
|
|
13221
|
+
src: `https://cdn.repliers.io/${propertyData.images?.[0]}`,
|
|
13222
|
+
alt: "Property",
|
|
13223
|
+
className: "w-full h-[120px] object-cover"
|
|
13224
|
+
}
|
|
13225
|
+
),
|
|
13226
|
+
/* @__PURE__ */ jsx37(
|
|
13227
|
+
Button,
|
|
13228
|
+
{
|
|
13229
|
+
variant: "ghost",
|
|
13230
|
+
size: "icon",
|
|
13231
|
+
className: "absolute top-1 right-1 h-6 w-6 bg-black/50 hover:bg-black/70 rounded-full",
|
|
13232
|
+
onClick: handleClearPreview,
|
|
13233
|
+
children: /* @__PURE__ */ jsx37(XIcon2, { className: "size-3 text-white" })
|
|
13234
|
+
}
|
|
13235
|
+
)
|
|
13236
|
+
] }),
|
|
13237
|
+
/* @__PURE__ */ jsxs22("div", { className: "p-2 flex flex-col gap-1", children: [
|
|
13238
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex items-center justify-between", children: [
|
|
13239
|
+
/* @__PURE__ */ jsx37("span", { className: "font-semibold text-sm", children: formatPrice(String(propertyData.listPrice || 0)) }),
|
|
13240
|
+
/* @__PURE__ */ jsx37("span", { className: "text-xs px-2 py-0.5 rounded-full bg-green-100 text-green-700", children: propertyData.standardStatus || propertyData.status })
|
|
13241
|
+
] }),
|
|
13242
|
+
/* @__PURE__ */ jsxs22("div", { className: "text-sm", children: [
|
|
13243
|
+
propertyData.address?.streetNumber,
|
|
13244
|
+
" ",
|
|
13245
|
+
propertyData.address?.streetName
|
|
13246
|
+
] }),
|
|
13247
|
+
/* @__PURE__ */ jsxs22("div", { className: "text-xs text-muted-foreground", children: [
|
|
13248
|
+
propertyData.address?.city,
|
|
13249
|
+
", ",
|
|
13250
|
+
propertyData.address?.state,
|
|
13251
|
+
" ",
|
|
13252
|
+
propertyData.address?.zip
|
|
13253
|
+
] }),
|
|
13254
|
+
/* @__PURE__ */ jsxs22("div", { className: "text-xs text-muted-foreground", children: [
|
|
13255
|
+
propertyData.details?.numBedrooms,
|
|
13256
|
+
" bd | ",
|
|
13257
|
+
propertyData.details?.numBathrooms,
|
|
13258
|
+
" ba | ",
|
|
13259
|
+
formatNumber(String(propertyData.details?.sqft || "--")),
|
|
13260
|
+
" sf"
|
|
13261
|
+
] }),
|
|
13262
|
+
propertyData.office?.brokerageName && /* @__PURE__ */ jsx37("div", { className: "text-xs text-muted-foreground truncate", children: propertyData.office.brokerageName }),
|
|
13263
|
+
/* @__PURE__ */ jsx37(
|
|
13264
|
+
Button,
|
|
13265
|
+
{
|
|
13266
|
+
variant: "default",
|
|
13267
|
+
size: "sm",
|
|
13268
|
+
className: "w-full mt-2 rounded-[12px]",
|
|
13269
|
+
onClick: handleApplyToCard,
|
|
13270
|
+
children: "Apply to Card"
|
|
13271
|
+
}
|
|
13272
|
+
)
|
|
13273
|
+
] })
|
|
13274
|
+
] })
|
|
13275
|
+
] })
|
|
13276
|
+
] })
|
|
13277
|
+
] });
|
|
13278
|
+
};
|
|
13279
|
+
|
|
13280
|
+
// src/core/editor/components/element-gear/property/float.tsx
|
|
13281
|
+
import { Fragment as Fragment15, jsx as jsx38, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
13032
13282
|
function PropertyFloat() {
|
|
13033
13283
|
const { href, hasHref } = useHref();
|
|
13034
|
-
return /* @__PURE__ */
|
|
13035
|
-
hasHref && /* @__PURE__ */
|
|
13036
|
-
/* @__PURE__ */
|
|
13284
|
+
return /* @__PURE__ */ jsxs23(Fragment15, { children: [
|
|
13285
|
+
hasHref && /* @__PURE__ */ jsx38(FloatLinkPreview, { href }),
|
|
13286
|
+
/* @__PURE__ */ jsx38(HrefMenu, {}),
|
|
13287
|
+
/* @__PURE__ */ jsx38(MlsNumberMenu, {})
|
|
13037
13288
|
] });
|
|
13038
13289
|
}
|
|
13039
13290
|
|
|
13040
13291
|
// src/core/editor/components/element-gear/property/triple/float.tsx
|
|
13041
|
-
import { Fragment as
|
|
13292
|
+
import { Fragment as Fragment16, jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
13042
13293
|
var PropertyTripleItemFloat = () => {
|
|
13043
13294
|
const { href, hasHref } = useHref();
|
|
13044
|
-
return /* @__PURE__ */
|
|
13045
|
-
hasHref && /* @__PURE__ */
|
|
13046
|
-
/* @__PURE__ */
|
|
13295
|
+
return /* @__PURE__ */ jsxs24(Fragment16, { children: [
|
|
13296
|
+
hasHref && /* @__PURE__ */ jsx39(FloatLinkPreview, { href }),
|
|
13297
|
+
/* @__PURE__ */ jsx39(HrefMenu, {})
|
|
13047
13298
|
] });
|
|
13048
13299
|
};
|
|
13049
13300
|
|
|
13050
13301
|
// src/core/editor/components/float-ui/container.tsx
|
|
13051
|
-
import { jsx as
|
|
13302
|
+
import { jsx as jsx40 } from "react/jsx-runtime";
|
|
13052
13303
|
var FloatUIContainer = ({ ref, style, className, children }) => {
|
|
13053
|
-
return /* @__PURE__ */
|
|
13304
|
+
return /* @__PURE__ */ jsx40("div", { ref, style, className, children });
|
|
13054
13305
|
};
|
|
13055
13306
|
|
|
13056
13307
|
// src/core/editor/components/element-float.tsx
|
|
13057
|
-
import { jsx as
|
|
13308
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
13058
13309
|
var FLOAT_COMPONENTS = {
|
|
13059
13310
|
"button": ButtonFloat,
|
|
13060
13311
|
"section": SectionFloat,
|
|
@@ -13078,7 +13329,7 @@ var ElementFloat = ({ getReferenceRect, focusIdx, elementType }) => {
|
|
|
13078
13329
|
if (!focusIdx || isDragging || textEditing) return null;
|
|
13079
13330
|
const FloatComponent = FLOAT_COMPONENTS[elementType];
|
|
13080
13331
|
if (!FloatComponent) return null;
|
|
13081
|
-
return /* @__PURE__ */
|
|
13332
|
+
return /* @__PURE__ */ jsx41(
|
|
13082
13333
|
ElementFloatContent,
|
|
13083
13334
|
{
|
|
13084
13335
|
getReferenceRect,
|
|
@@ -13107,7 +13358,7 @@ var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
|
13107
13358
|
// Keep within viewport
|
|
13108
13359
|
]
|
|
13109
13360
|
});
|
|
13110
|
-
|
|
13361
|
+
useEffect12(() => {
|
|
13111
13362
|
const rect = getReferenceRect();
|
|
13112
13363
|
if (!rect || !refs.floating.current) return;
|
|
13113
13364
|
refs.setPositionReference(virtualReference);
|
|
@@ -13122,16 +13373,16 @@ var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
|
13122
13373
|
);
|
|
13123
13374
|
return cleanup;
|
|
13124
13375
|
}, [getReferenceRect, refs, update, virtualReference]);
|
|
13125
|
-
return /* @__PURE__ */
|
|
13376
|
+
return /* @__PURE__ */ jsx41(FloatUIContainer, { ref: refs.setFloating, style: floatingStyles, className: "bg-white flex items-center justify-center border border-1 h-[36px] w-fit shadow-md rounded-full z-50", children: /* @__PURE__ */ jsx41(FloatComponent, {}) });
|
|
13126
13377
|
};
|
|
13127
13378
|
|
|
13128
13379
|
// src/core/editor/components/scaling/divider-scale.tsx
|
|
13129
|
-
import { useMemo as useMemo11, useEffect as
|
|
13380
|
+
import { useMemo as useMemo11, useEffect as useEffect13, useState as useState9, useRef as useRef5, useCallback as useCallback10 } from "react";
|
|
13130
13381
|
import { useFloating as useFloating5, offset as offset5, autoUpdate as autoUpdate4 } from "@floating-ui/react";
|
|
13131
|
-
import { jsx as
|
|
13382
|
+
import { jsx as jsx42, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
13132
13383
|
var DividerScale = ({ getReferenceRect }) => {
|
|
13133
|
-
const [dimensions, setDimensions] =
|
|
13134
|
-
const [activeSide, setActiveSide] =
|
|
13384
|
+
const [dimensions, setDimensions] = useState9({ width: 0, height: 0 });
|
|
13385
|
+
const [activeSide, setActiveSide] = useState9(null);
|
|
13135
13386
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13136
13387
|
const { currentWidth, currentAlign } = useMemo11(() => {
|
|
13137
13388
|
if (!focusIdx || !template) return { currentWidth: 100, currentAlign: "center" };
|
|
@@ -13193,7 +13444,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13193
13444
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13194
13445
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13195
13446
|
}, [handlePointerMove, setIsScaling]);
|
|
13196
|
-
|
|
13447
|
+
useEffect13(() => {
|
|
13197
13448
|
return () => {
|
|
13198
13449
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13199
13450
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13214,7 +13465,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13214
13465
|
offset5(({ rects }) => -rects.reference.height)
|
|
13215
13466
|
]
|
|
13216
13467
|
});
|
|
13217
|
-
|
|
13468
|
+
useEffect13(() => {
|
|
13218
13469
|
const rect = getReferenceRect();
|
|
13219
13470
|
if (!rect || !refs.floating.current) return;
|
|
13220
13471
|
refs.setPositionReference(virtualReference);
|
|
@@ -13241,7 +13492,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13241
13492
|
}, [getReferenceRect, refs, update, virtualReference]);
|
|
13242
13493
|
const showLeftHandle = currentAlign !== "left";
|
|
13243
13494
|
const showRightHandle = currentAlign !== "right";
|
|
13244
|
-
return /* @__PURE__ */
|
|
13495
|
+
return /* @__PURE__ */ jsxs25(
|
|
13245
13496
|
"div",
|
|
13246
13497
|
{
|
|
13247
13498
|
ref: refs.setFloating,
|
|
@@ -13253,14 +13504,14 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13253
13504
|
},
|
|
13254
13505
|
className: "relative flex flex-row items-center justify-between",
|
|
13255
13506
|
children: [
|
|
13256
|
-
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */
|
|
13507
|
+
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */ jsx42(
|
|
13257
13508
|
"div",
|
|
13258
13509
|
{
|
|
13259
13510
|
onPointerDown: (e) => handlePointerDown(e, "left"),
|
|
13260
13511
|
className: `w-[18px] h-[18px] cursor-ew-resize bg-background shadow-md border rounded-full absolute -left-[9px] top-1/2 -translate-y-1/2 touch-none select-none ${activeSide === "left" ? "bg-blue-400 border-blue-300" : "hover:bg-blue-400 hover:border-blue-300"}`
|
|
13261
13512
|
}
|
|
13262
13513
|
),
|
|
13263
|
-
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */
|
|
13514
|
+
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */ jsx42(
|
|
13264
13515
|
"div",
|
|
13265
13516
|
{
|
|
13266
13517
|
onPointerDown: (e) => handlePointerDown(e, "right"),
|
|
@@ -13273,12 +13524,12 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13273
13524
|
};
|
|
13274
13525
|
|
|
13275
13526
|
// src/core/editor/components/scaling/button-scale.tsx
|
|
13276
|
-
import { useMemo as useMemo12, useEffect as
|
|
13527
|
+
import { useMemo as useMemo12, useEffect as useEffect14, useState as useState10, useRef as useRef6, useCallback as useCallback11 } from "react";
|
|
13277
13528
|
import { useFloating as useFloating6, offset as offset6, autoUpdate as autoUpdate5 } from "@floating-ui/react";
|
|
13278
|
-
import { jsx as
|
|
13529
|
+
import { jsx as jsx43, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
13279
13530
|
var ButtonScale = ({ getReferenceRect }) => {
|
|
13280
|
-
const [dimensions, setDimensions] =
|
|
13281
|
-
const [activeSide, setActiveSide] =
|
|
13531
|
+
const [dimensions, setDimensions] = useState10({ width: 0, height: 0 });
|
|
13532
|
+
const [activeSide, setActiveSide] = useState10(null);
|
|
13282
13533
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13283
13534
|
const { currentWidth, currentHeight, currentAlign } = useMemo12(() => {
|
|
13284
13535
|
if (!focusIdx || !template) {
|
|
@@ -13361,7 +13612,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13361
13612
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13362
13613
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13363
13614
|
}, [handlePointerMove, setIsScaling]);
|
|
13364
|
-
|
|
13615
|
+
useEffect14(() => {
|
|
13365
13616
|
return () => {
|
|
13366
13617
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13367
13618
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13382,7 +13633,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13382
13633
|
offset6(({ rects }) => -rects.reference.height)
|
|
13383
13634
|
]
|
|
13384
13635
|
});
|
|
13385
|
-
|
|
13636
|
+
useEffect14(() => {
|
|
13386
13637
|
const rect = getReferenceRect();
|
|
13387
13638
|
if (!rect || !refs.floating.current) return;
|
|
13388
13639
|
refs.setPositionReference(virtualReference);
|
|
@@ -13411,7 +13662,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13411
13662
|
const showRightHandle = currentAlign !== "right";
|
|
13412
13663
|
const handleBaseClass = "bg-background shadow-md border rounded-full absolute touch-none select-none pointer-events-auto";
|
|
13413
13664
|
const getHandleActiveClass = (side) => activeSide === side ? "bg-blue-400 border-blue-300" : "hover:bg-blue-400 hover:border-blue-300";
|
|
13414
|
-
return /* @__PURE__ */
|
|
13665
|
+
return /* @__PURE__ */ jsxs26(
|
|
13415
13666
|
"div",
|
|
13416
13667
|
{
|
|
13417
13668
|
ref: refs.setFloating,
|
|
@@ -13423,28 +13674,28 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13423
13674
|
},
|
|
13424
13675
|
className: "relative pointer-events-none",
|
|
13425
13676
|
children: [
|
|
13426
|
-
(activeSide === null || activeSide === "top") && /* @__PURE__ */
|
|
13677
|
+
(activeSide === null || activeSide === "top") && /* @__PURE__ */ jsx43(
|
|
13427
13678
|
"div",
|
|
13428
13679
|
{
|
|
13429
13680
|
onPointerDown: (e) => handlePointerDown(e, "top"),
|
|
13430
13681
|
className: `w-[18px] h-[8px] cursor-ns-resize ${handleBaseClass} left-1/2 -translate-x-1/2 -top-[4px] ${getHandleActiveClass("top")}`
|
|
13431
13682
|
}
|
|
13432
13683
|
),
|
|
13433
|
-
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */
|
|
13684
|
+
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */ jsx43(
|
|
13434
13685
|
"div",
|
|
13435
13686
|
{
|
|
13436
13687
|
onPointerDown: (e) => handlePointerDown(e, "right"),
|
|
13437
13688
|
className: `w-[8px] h-[18px] cursor-ew-resize ${handleBaseClass} top-1/2 -translate-y-1/2 -right-[4px] ${getHandleActiveClass("right")}`
|
|
13438
13689
|
}
|
|
13439
13690
|
),
|
|
13440
|
-
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */
|
|
13691
|
+
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */ jsx43(
|
|
13441
13692
|
"div",
|
|
13442
13693
|
{
|
|
13443
13694
|
onPointerDown: (e) => handlePointerDown(e, "bottom"),
|
|
13444
13695
|
className: `w-[18px] h-[8px] cursor-ns-resize ${handleBaseClass} left-1/2 -translate-x-1/2 -bottom-[4px] ${getHandleActiveClass("bottom")}`
|
|
13445
13696
|
}
|
|
13446
13697
|
),
|
|
13447
|
-
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */
|
|
13698
|
+
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */ jsx43(
|
|
13448
13699
|
"div",
|
|
13449
13700
|
{
|
|
13450
13701
|
onPointerDown: (e) => handlePointerDown(e, "left"),
|
|
@@ -13457,12 +13708,12 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13457
13708
|
};
|
|
13458
13709
|
|
|
13459
13710
|
// src/core/editor/components/scaling/image-scale.tsx
|
|
13460
|
-
import { useMemo as useMemo13, useEffect as
|
|
13711
|
+
import { useMemo as useMemo13, useEffect as useEffect15, useState as useState11, useRef as useRef7, useCallback as useCallback12 } from "react";
|
|
13461
13712
|
import { useFloating as useFloating7, offset as offset7, autoUpdate as autoUpdate6 } from "@floating-ui/react";
|
|
13462
|
-
import { jsx as
|
|
13713
|
+
import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
13463
13714
|
var ImageScale = ({ getReferenceRect }) => {
|
|
13464
|
-
const [dimensions, setDimensions] =
|
|
13465
|
-
const [activeSide, setActiveSide] =
|
|
13715
|
+
const [dimensions, setDimensions] = useState11({ width: 0, height: 0 });
|
|
13716
|
+
const [activeSide, setActiveSide] = useState11(null);
|
|
13466
13717
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13467
13718
|
const { currentWidth, currentHeight, currentAlign } = useMemo13(() => {
|
|
13468
13719
|
if (!focusIdx || !template) {
|
|
@@ -13540,7 +13791,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13540
13791
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13541
13792
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13542
13793
|
}, [handlePointerMove, setIsScaling]);
|
|
13543
|
-
|
|
13794
|
+
useEffect15(() => {
|
|
13544
13795
|
return () => {
|
|
13545
13796
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13546
13797
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13561,7 +13812,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13561
13812
|
offset7(({ rects }) => -rects.reference.height)
|
|
13562
13813
|
]
|
|
13563
13814
|
});
|
|
13564
|
-
|
|
13815
|
+
useEffect15(() => {
|
|
13565
13816
|
const rect = getReferenceRect();
|
|
13566
13817
|
if (!rect || !refs.floating.current) return;
|
|
13567
13818
|
refs.setPositionReference(virtualReference);
|
|
@@ -13590,7 +13841,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13590
13841
|
const showRightHandle = currentAlign !== "right";
|
|
13591
13842
|
const handleBaseClass = "bg-background shadow-md border rounded-full absolute touch-none select-none pointer-events-auto";
|
|
13592
13843
|
const getHandleActiveClass = (side) => activeSide === side ? "bg-blue-400 border-blue-300" : "hover:bg-blue-400 hover:border-blue-300";
|
|
13593
|
-
return /* @__PURE__ */
|
|
13844
|
+
return /* @__PURE__ */ jsxs27(
|
|
13594
13845
|
"div",
|
|
13595
13846
|
{
|
|
13596
13847
|
ref: refs.setFloating,
|
|
@@ -13602,28 +13853,28 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13602
13853
|
},
|
|
13603
13854
|
className: "relative pointer-events-none",
|
|
13604
13855
|
children: [
|
|
13605
|
-
(activeSide === null || activeSide === "top") && /* @__PURE__ */
|
|
13856
|
+
(activeSide === null || activeSide === "top") && /* @__PURE__ */ jsx44(
|
|
13606
13857
|
"div",
|
|
13607
13858
|
{
|
|
13608
13859
|
onPointerDown: (e) => handlePointerDown(e, "top"),
|
|
13609
13860
|
className: `w-[18px] h-[8px] cursor-ns-resize ${handleBaseClass} left-1/2 -translate-x-1/2 -top-[4px] ${getHandleActiveClass("top")}`
|
|
13610
13861
|
}
|
|
13611
13862
|
),
|
|
13612
|
-
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */
|
|
13863
|
+
showRightHandle && (activeSide === null || activeSide === "right") && /* @__PURE__ */ jsx44(
|
|
13613
13864
|
"div",
|
|
13614
13865
|
{
|
|
13615
13866
|
onPointerDown: (e) => handlePointerDown(e, "right"),
|
|
13616
13867
|
className: `w-[8px] h-[18px] cursor-ew-resize ${handleBaseClass} top-1/2 -translate-y-1/2 -right-[4px] ${getHandleActiveClass("right")}`
|
|
13617
13868
|
}
|
|
13618
13869
|
),
|
|
13619
|
-
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */
|
|
13870
|
+
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */ jsx44(
|
|
13620
13871
|
"div",
|
|
13621
13872
|
{
|
|
13622
13873
|
onPointerDown: (e) => handlePointerDown(e, "bottom"),
|
|
13623
13874
|
className: `w-[18px] h-[8px] cursor-ns-resize ${handleBaseClass} left-1/2 -translate-x-1/2 -bottom-[4px] ${getHandleActiveClass("bottom")}`
|
|
13624
13875
|
}
|
|
13625
13876
|
),
|
|
13626
|
-
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */
|
|
13877
|
+
showLeftHandle && (activeSide === null || activeSide === "left") && /* @__PURE__ */ jsx44(
|
|
13627
13878
|
"div",
|
|
13628
13879
|
{
|
|
13629
13880
|
onPointerDown: (e) => handlePointerDown(e, "left"),
|
|
@@ -13636,12 +13887,12 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13636
13887
|
};
|
|
13637
13888
|
|
|
13638
13889
|
// src/core/editor/components/scaling/spacer-scale.tsx
|
|
13639
|
-
import { useMemo as useMemo14, useEffect as
|
|
13890
|
+
import { useMemo as useMemo14, useEffect as useEffect16, useState as useState12, useRef as useRef8, useCallback as useCallback13 } from "react";
|
|
13640
13891
|
import { useFloating as useFloating8, offset as offset8, autoUpdate as autoUpdate7 } from "@floating-ui/react";
|
|
13641
|
-
import { jsx as
|
|
13892
|
+
import { jsx as jsx45, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
13642
13893
|
var SpacerScale = ({ getReferenceRect }) => {
|
|
13643
|
-
const [dimensions, setDimensions] =
|
|
13644
|
-
const [activeSide, setActiveSide] =
|
|
13894
|
+
const [dimensions, setDimensions] = useState12({ width: 0, height: 0 });
|
|
13895
|
+
const [activeSide, setActiveSide] = useState12(null);
|
|
13645
13896
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13646
13897
|
const currentHeight = useMemo14(() => {
|
|
13647
13898
|
if (!focusIdx || !template) return 12;
|
|
@@ -13692,7 +13943,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13692
13943
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13693
13944
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13694
13945
|
}, [handlePointerMove, setIsScaling]);
|
|
13695
|
-
|
|
13946
|
+
useEffect16(() => {
|
|
13696
13947
|
return () => {
|
|
13697
13948
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13698
13949
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13713,7 +13964,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13713
13964
|
offset8(({ rects }) => -rects.reference.height)
|
|
13714
13965
|
]
|
|
13715
13966
|
});
|
|
13716
|
-
|
|
13967
|
+
useEffect16(() => {
|
|
13717
13968
|
const rect = getReferenceRect();
|
|
13718
13969
|
if (!rect || !refs.floating.current) return;
|
|
13719
13970
|
refs.setPositionReference(virtualReference);
|
|
@@ -13740,7 +13991,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13740
13991
|
}, [getReferenceRect, refs, update, virtualReference]);
|
|
13741
13992
|
const handleBaseClass = "bg-background shadow-md border rounded-full absolute touch-none select-none pointer-events-auto";
|
|
13742
13993
|
const getHandleActiveClass = (side) => activeSide === side ? "bg-blue-400 border-blue-300" : "hover:bg-blue-400 hover:border-blue-300";
|
|
13743
|
-
return /* @__PURE__ */
|
|
13994
|
+
return /* @__PURE__ */ jsxs28(
|
|
13744
13995
|
"div",
|
|
13745
13996
|
{
|
|
13746
13997
|
ref: refs.setFloating,
|
|
@@ -13752,14 +14003,14 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13752
14003
|
},
|
|
13753
14004
|
className: "relative pointer-events-none",
|
|
13754
14005
|
children: [
|
|
13755
|
-
(activeSide === null || activeSide === "top") && /* @__PURE__ */
|
|
14006
|
+
(activeSide === null || activeSide === "top") && /* @__PURE__ */ jsx45(
|
|
13756
14007
|
"div",
|
|
13757
14008
|
{
|
|
13758
14009
|
onPointerDown: (e) => handlePointerDown(e, "top"),
|
|
13759
14010
|
className: `w-[18px] h-[8px] cursor-ns-resize ${handleBaseClass} left-1/2 -translate-x-1/2 -top-[4px] ${getHandleActiveClass("top")}`
|
|
13760
14011
|
}
|
|
13761
14012
|
),
|
|
13762
|
-
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */
|
|
14013
|
+
(activeSide === null || activeSide === "bottom") && /* @__PURE__ */ jsx45(
|
|
13763
14014
|
"div",
|
|
13764
14015
|
{
|
|
13765
14016
|
onPointerDown: (e) => handlePointerDown(e, "bottom"),
|
|
@@ -13772,11 +14023,11 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13772
14023
|
};
|
|
13773
14024
|
|
|
13774
14025
|
// src/core/editor/components/scaling/column-scale.tsx
|
|
13775
|
-
import { useMemo as useMemo15, useEffect as
|
|
13776
|
-
import { Fragment as
|
|
14026
|
+
import { useMemo as useMemo15, useEffect as useEffect17, useState as useState13, useRef as useRef9, useCallback as useCallback14 } from "react";
|
|
14027
|
+
import { Fragment as Fragment17, jsx as jsx46 } from "react/jsx-runtime";
|
|
13777
14028
|
var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
13778
|
-
const [activeDivider, setActiveDivider] =
|
|
13779
|
-
const [columnRects, setColumnRects] =
|
|
14029
|
+
const [activeDivider, setActiveDivider] = useState13(null);
|
|
14030
|
+
const [columnRects, setColumnRects] = useState13([]);
|
|
13780
14031
|
const { template, setIsScaling, setFocusIdx, stopTextEditing } = useEditorStore();
|
|
13781
14032
|
const columnWidths = useMemo15(() => {
|
|
13782
14033
|
if (!template) return [];
|
|
@@ -13816,7 +14067,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
13816
14067
|
});
|
|
13817
14068
|
setColumnRects(rects);
|
|
13818
14069
|
}, [shadowRoot, sectionColumnIdx]);
|
|
13819
|
-
|
|
14070
|
+
useEffect17(() => {
|
|
13820
14071
|
updateColumnRects();
|
|
13821
14072
|
let animationId;
|
|
13822
14073
|
const updateLoop = () => {
|
|
@@ -13896,7 +14147,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
13896
14147
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13897
14148
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13898
14149
|
}, [handlePointerMove, setIsScaling]);
|
|
13899
|
-
|
|
14150
|
+
useEffect17(() => {
|
|
13900
14151
|
return () => {
|
|
13901
14152
|
document.removeEventListener("pointermove", handlePointerMove);
|
|
13902
14153
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
@@ -13907,7 +14158,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
13907
14158
|
}
|
|
13908
14159
|
const handleBaseClass = "bg-background shadow-md border rounded-full touch-none select-none pointer-events-auto";
|
|
13909
14160
|
const getHandleActiveClass = (index) => activeDivider === index ? "bg-blue-400 border-blue-300" : "hover:bg-blue-400 hover:border-blue-300";
|
|
13910
|
-
return /* @__PURE__ */
|
|
14161
|
+
return /* @__PURE__ */ jsx46(Fragment17, { children: columnRects.slice(0, -1).map((rect, index) => {
|
|
13911
14162
|
const nextRect = columnRects[index + 1];
|
|
13912
14163
|
const handleLeft = rect.right;
|
|
13913
14164
|
const handleTop = Math.min(rect.top, nextRect.top);
|
|
@@ -13915,7 +14166,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
13915
14166
|
if (activeDivider !== null && activeDivider !== index) {
|
|
13916
14167
|
return null;
|
|
13917
14168
|
}
|
|
13918
|
-
return /* @__PURE__ */
|
|
14169
|
+
return /* @__PURE__ */ jsx46(
|
|
13919
14170
|
"div",
|
|
13920
14171
|
{
|
|
13921
14172
|
onPointerDown: (e) => handlePointerDown(e, index),
|
|
@@ -13935,9 +14186,9 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
13935
14186
|
};
|
|
13936
14187
|
|
|
13937
14188
|
// src/core/editor/hooks/use-undo-redo-keyboard.ts
|
|
13938
|
-
import { useEffect as
|
|
14189
|
+
import { useEffect as useEffect18 } from "react";
|
|
13939
14190
|
function useUndoRedoKeyboard() {
|
|
13940
|
-
|
|
14191
|
+
useEffect18(() => {
|
|
13941
14192
|
const handler = (e) => {
|
|
13942
14193
|
const isMeta = e.metaKey || e.ctrlKey;
|
|
13943
14194
|
if (!isMeta || e.key.toLowerCase() !== "z") return;
|
|
@@ -13958,11 +14209,11 @@ function useUndoRedoKeyboard() {
|
|
|
13958
14209
|
}
|
|
13959
14210
|
|
|
13960
14211
|
// src/components/ui/spinner.tsx
|
|
13961
|
-
import { Loader2Icon } from "lucide-react";
|
|
13962
|
-
import { jsx as
|
|
14212
|
+
import { Loader2Icon as Loader2Icon2 } from "lucide-react";
|
|
14213
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
13963
14214
|
function Spinner({ className, ...props }) {
|
|
13964
|
-
return /* @__PURE__ */
|
|
13965
|
-
|
|
14215
|
+
return /* @__PURE__ */ jsx47(
|
|
14216
|
+
Loader2Icon2,
|
|
13966
14217
|
{
|
|
13967
14218
|
role: "status",
|
|
13968
14219
|
"aria-label": "Loading",
|
|
@@ -13976,7 +14227,7 @@ function Spinner({ className, ...props }) {
|
|
|
13976
14227
|
import { EyeIcon } from "lucide-react";
|
|
13977
14228
|
|
|
13978
14229
|
// src/render/useMjmlCompiler.ts
|
|
13979
|
-
import { useState as
|
|
14230
|
+
import { useState as useState14, useCallback as useCallback15 } from "react";
|
|
13980
14231
|
async function compileMjml(mjml) {
|
|
13981
14232
|
console.log("Compiling MJML", mjml);
|
|
13982
14233
|
const response = await fetch("/api/mrender", {
|
|
@@ -13993,14 +14244,14 @@ async function compileMjml(mjml) {
|
|
|
13993
14244
|
}
|
|
13994
14245
|
|
|
13995
14246
|
// src/core/editor/components/preview.tsx
|
|
13996
|
-
import { useEffect as
|
|
13997
|
-
import { jsx as
|
|
14247
|
+
import { useEffect as useEffect19, useState as useState15, useRef as useRef10 } from "react";
|
|
14248
|
+
import { jsx as jsx48, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
13998
14249
|
function Preview() {
|
|
13999
14250
|
const { template, setPreviewMode, previewMode, isPaidLevel } = useEditorStore();
|
|
14000
|
-
const [html, setHtml] =
|
|
14001
|
-
const [isLoading, setIsLoading] =
|
|
14251
|
+
const [html, setHtml] = useState15("");
|
|
14252
|
+
const [isLoading, setIsLoading] = useState15(false);
|
|
14002
14253
|
const lastTemplateRef = useRef10("");
|
|
14003
|
-
|
|
14254
|
+
useEffect19(() => {
|
|
14004
14255
|
if (typeof window === "undefined" || !previewMode) {
|
|
14005
14256
|
if (!previewMode) {
|
|
14006
14257
|
setHtml("");
|
|
@@ -14033,37 +14284,37 @@ function Preview() {
|
|
|
14033
14284
|
};
|
|
14034
14285
|
convertMjml();
|
|
14035
14286
|
}, [template, previewMode]);
|
|
14036
|
-
return /* @__PURE__ */
|
|
14037
|
-
/* @__PURE__ */
|
|
14038
|
-
/* @__PURE__ */
|
|
14287
|
+
return /* @__PURE__ */ jsxs29(Dialog, { open: previewMode, onOpenChange: setPreviewMode, children: [
|
|
14288
|
+
/* @__PURE__ */ jsxs29(Tooltip, { children: [
|
|
14289
|
+
/* @__PURE__ */ jsx48(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx48(
|
|
14039
14290
|
Button,
|
|
14040
14291
|
{
|
|
14041
14292
|
variant: "ghost",
|
|
14042
14293
|
className: "shadow-none transition-none cursor-pointer",
|
|
14043
14294
|
size: "icon",
|
|
14044
14295
|
onClick: () => setPreviewMode(true),
|
|
14045
|
-
children: /* @__PURE__ */
|
|
14296
|
+
children: /* @__PURE__ */ jsx48(EyeIcon, {})
|
|
14046
14297
|
}
|
|
14047
14298
|
) }),
|
|
14048
|
-
/* @__PURE__ */
|
|
14299
|
+
/* @__PURE__ */ jsx48(TooltipContent, { side: "bottom", className: "z-51", children: "Preview" })
|
|
14049
14300
|
] }),
|
|
14050
|
-
/* @__PURE__ */
|
|
14051
|
-
/* @__PURE__ */
|
|
14052
|
-
/* @__PURE__ */
|
|
14301
|
+
/* @__PURE__ */ jsxs29(DialogContent, { className: "max-w-[1200px] sm:max-w-[1200px]", children: [
|
|
14302
|
+
/* @__PURE__ */ jsx48(DialogTitle, { children: "Preview" }),
|
|
14303
|
+
/* @__PURE__ */ jsx48("div", { className: "w-full h-full max-h-[600px]", children: isLoading ? /* @__PURE__ */ jsx48("div", { className: "flex items-center justify-center h-[600px]", children: /* @__PURE__ */ jsx48("p", { children: "Generating preview..." }) }) : /* @__PURE__ */ jsx48("iframe", { srcDoc: html, className: "w-full h-[600px]" }) })
|
|
14053
14304
|
] })
|
|
14054
14305
|
] });
|
|
14055
14306
|
}
|
|
14056
14307
|
|
|
14057
14308
|
// src/core/editor/components/history.tsx
|
|
14058
14309
|
import { Redo2Icon, Undo2Icon } from "lucide-react";
|
|
14059
|
-
import { Fragment as
|
|
14310
|
+
import { Fragment as Fragment18, jsx as jsx49, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
14060
14311
|
var History = () => {
|
|
14061
14312
|
const { undo, redo } = useEditorStore();
|
|
14062
14313
|
const canUndo = useEditorStore((s) => s.historyIndex > 0);
|
|
14063
14314
|
const canRedo = useEditorStore((s) => s.historyIndex < s.history.length - 1);
|
|
14064
|
-
return /* @__PURE__ */
|
|
14065
|
-
/* @__PURE__ */
|
|
14066
|
-
/* @__PURE__ */
|
|
14315
|
+
return /* @__PURE__ */ jsxs30(Fragment18, { children: [
|
|
14316
|
+
/* @__PURE__ */ jsxs30(Tooltip, { children: [
|
|
14317
|
+
/* @__PURE__ */ jsx49(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx49(
|
|
14067
14318
|
Button,
|
|
14068
14319
|
{
|
|
14069
14320
|
variant: "ghost",
|
|
@@ -14071,13 +14322,13 @@ var History = () => {
|
|
|
14071
14322
|
size: "icon",
|
|
14072
14323
|
disabled: !canUndo,
|
|
14073
14324
|
onClick: undo,
|
|
14074
|
-
children: /* @__PURE__ */
|
|
14325
|
+
children: /* @__PURE__ */ jsx49(Undo2Icon, {})
|
|
14075
14326
|
}
|
|
14076
14327
|
) }),
|
|
14077
|
-
/* @__PURE__ */
|
|
14328
|
+
/* @__PURE__ */ jsx49(TooltipContent, { side: "bottom", children: "Undo (Ctrl+Z)" })
|
|
14078
14329
|
] }),
|
|
14079
|
-
/* @__PURE__ */
|
|
14080
|
-
/* @__PURE__ */
|
|
14330
|
+
/* @__PURE__ */ jsxs30(Tooltip, { children: [
|
|
14331
|
+
/* @__PURE__ */ jsx49(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx49(
|
|
14081
14332
|
Button,
|
|
14082
14333
|
{
|
|
14083
14334
|
variant: "ghost",
|
|
@@ -14085,16 +14336,16 @@ var History = () => {
|
|
|
14085
14336
|
size: "icon",
|
|
14086
14337
|
disabled: !canRedo,
|
|
14087
14338
|
onClick: redo,
|
|
14088
|
-
children: /* @__PURE__ */
|
|
14339
|
+
children: /* @__PURE__ */ jsx49(Redo2Icon, {})
|
|
14089
14340
|
}
|
|
14090
14341
|
) }),
|
|
14091
|
-
/* @__PURE__ */
|
|
14342
|
+
/* @__PURE__ */ jsx49(TooltipContent, { side: "bottom", children: "Redo (Ctrl+Shift+Z)" })
|
|
14092
14343
|
] })
|
|
14093
14344
|
] });
|
|
14094
14345
|
};
|
|
14095
14346
|
|
|
14096
14347
|
// src/core/index.tsx
|
|
14097
|
-
import { jsx as
|
|
14348
|
+
import { jsx as jsx50, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
14098
14349
|
var MAILLOW_EMAIL_EDITOR_VERSION = "0.0.1";
|
|
14099
14350
|
function getSectionColumnIdx(idx, template) {
|
|
14100
14351
|
let current = idx;
|
|
@@ -14158,12 +14409,12 @@ function Editor({ setEditorLoading }) {
|
|
|
14158
14409
|
const startTextEditing = useEditorStore((state) => state.startTextEditing);
|
|
14159
14410
|
const pendingTextEditRequest = useEditorStore((state) => state.pendingTextEditRequest);
|
|
14160
14411
|
const clearPendingTextEditRequest = useEditorStore((state) => state.clearPendingTextEditRequest);
|
|
14161
|
-
const [renderData, setRenderData] =
|
|
14162
|
-
const [isEditing, setIsEditing] =
|
|
14163
|
-
const [dropIndicator, setDropIndicator] =
|
|
14164
|
-
const [dropTargetIdx, setDropTargetIdx] =
|
|
14412
|
+
const [renderData, setRenderData] = useState16(null);
|
|
14413
|
+
const [isEditing, setIsEditing] = useState16(false);
|
|
14414
|
+
const [dropIndicator, setDropIndicator] = useState16(null);
|
|
14415
|
+
const [dropTargetIdx, setDropTargetIdx] = useState16(null);
|
|
14165
14416
|
const shadowRootRef = useRef11(null);
|
|
14166
|
-
const [hasSelectedElement, setHasSelectedElement] =
|
|
14417
|
+
const [hasSelectedElement, setHasSelectedElement] = useState16(false);
|
|
14167
14418
|
const dragParentIdxRef = useRef11(null);
|
|
14168
14419
|
const dragPositionIndexRef = useRef11(0);
|
|
14169
14420
|
const createNewSectionRef = useRef11(false);
|
|
@@ -14178,8 +14429,13 @@ function Editor({ setEditorLoading }) {
|
|
|
14178
14429
|
const sectionRectCacheRef = useRef11(/* @__PURE__ */ new Map());
|
|
14179
14430
|
const companyFooterCacheRef = useRef11(void 0);
|
|
14180
14431
|
const lastSyncedTemplateRef = useRef11(null);
|
|
14181
|
-
|
|
14182
|
-
|
|
14432
|
+
const prevTextEditingIdxRef = useRef11(null);
|
|
14433
|
+
useEffect20(() => {
|
|
14434
|
+
const currentIdx = textEditing?.idx ?? null;
|
|
14435
|
+
const prevIdx = prevTextEditingIdxRef.current;
|
|
14436
|
+
const switchedTarget = currentIdx !== null && prevIdx !== null && currentIdx !== prevIdx;
|
|
14437
|
+
prevTextEditingIdxRef.current = currentIdx;
|
|
14438
|
+
if (!isEditing && (!textEditing || switchedTarget)) {
|
|
14183
14439
|
if (template === lastSyncedTemplateRef.current) {
|
|
14184
14440
|
return;
|
|
14185
14441
|
}
|
|
@@ -14188,13 +14444,13 @@ function Editor({ setEditorLoading }) {
|
|
|
14188
14444
|
}
|
|
14189
14445
|
lastSyncedTemplateRef.current = template;
|
|
14190
14446
|
}
|
|
14191
|
-
}, [template, renderData, isEditing]);
|
|
14192
|
-
|
|
14447
|
+
}, [template, renderData, isEditing, textEditing]);
|
|
14448
|
+
useEffect20(() => {
|
|
14193
14449
|
if (renderData && setEditorLoading) {
|
|
14194
14450
|
setEditorLoading(false);
|
|
14195
14451
|
}
|
|
14196
14452
|
}, [renderData, setEditorLoading]);
|
|
14197
|
-
|
|
14453
|
+
useEffect20(() => {
|
|
14198
14454
|
if (!pendingTextEditRequest || !shadowRootRef.current) return;
|
|
14199
14455
|
const { idx, cursorPosition } = pendingTextEditRequest;
|
|
14200
14456
|
const blockNode = shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
@@ -14236,10 +14492,14 @@ function Editor({ setEditorLoading }) {
|
|
|
14236
14492
|
const element = shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
14237
14493
|
return element ? element.getBoundingClientRect() : null;
|
|
14238
14494
|
};
|
|
14239
|
-
|
|
14495
|
+
const getShadowElement = () => {
|
|
14496
|
+
if (!shadowRootRef.current) return null;
|
|
14497
|
+
return shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
14498
|
+
};
|
|
14499
|
+
startTextEditing({ idx, getReferenceRect: getReferenceRect2, getShadowElement, initialWidth: blockRect.width, initialHeight: blockRect.height, clickX, clickY, content, styles, cursorPosition });
|
|
14240
14500
|
clearPendingTextEditRequest();
|
|
14241
14501
|
}, [pendingTextEditRequest, clearPendingTextEditRequest, startTextEditing]);
|
|
14242
|
-
|
|
14502
|
+
useEffect20(() => {
|
|
14243
14503
|
if (isDragging && dataTransfer) {
|
|
14244
14504
|
const currentTemplate = useEditorStore.getState().template;
|
|
14245
14505
|
templateCacheRef.current = currentTemplate;
|
|
@@ -14255,9 +14515,9 @@ function Editor({ setEditorLoading }) {
|
|
|
14255
14515
|
sectionRectCacheRef.current.clear();
|
|
14256
14516
|
}
|
|
14257
14517
|
}, [isDragging, dataTransfer]);
|
|
14258
|
-
const [html, setHtml] =
|
|
14518
|
+
const [html, setHtml] = useState16("");
|
|
14259
14519
|
const lastRenderDataRef = useRef11("");
|
|
14260
|
-
|
|
14520
|
+
useEffect20(() => {
|
|
14261
14521
|
if (typeof window === "undefined" || !renderData) {
|
|
14262
14522
|
setHtml("");
|
|
14263
14523
|
lastRenderDataRef.current = "";
|
|
@@ -14354,7 +14614,11 @@ function Editor({ setEditorLoading }) {
|
|
|
14354
14614
|
const element = shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
14355
14615
|
return element ? element.getBoundingClientRect() : null;
|
|
14356
14616
|
};
|
|
14357
|
-
|
|
14617
|
+
const getShadowElement = () => {
|
|
14618
|
+
if (!shadowRootRef.current) return null;
|
|
14619
|
+
return shadowRootRef.current.querySelector(`.node-idx-${CSS.escape(idx)}`);
|
|
14620
|
+
};
|
|
14621
|
+
startTextEditing({ idx, getReferenceRect: getReferenceRect2, getShadowElement, initialWidth, initialHeight, clickX, clickY, content, styles });
|
|
14358
14622
|
},
|
|
14359
14623
|
[startTextEditing]
|
|
14360
14624
|
);
|
|
@@ -14967,9 +15231,9 @@ function Editor({ setEditorLoading }) {
|
|
|
14967
15231
|
[template.content[0]?.data?.value?.showCompanyFooter]
|
|
14968
15232
|
);
|
|
14969
15233
|
if (!html) {
|
|
14970
|
-
return /* @__PURE__ */
|
|
15234
|
+
return /* @__PURE__ */ jsx50("div", { className: "maillow-editor flex items-center justify-center h-[500px]", children: /* @__PURE__ */ jsx50(Spinner, {}) });
|
|
14971
15235
|
}
|
|
14972
|
-
return /* @__PURE__ */
|
|
15236
|
+
return /* @__PURE__ */ jsxs31(
|
|
14973
15237
|
"div",
|
|
14974
15238
|
{
|
|
14975
15239
|
className: "maillow-editor relative ",
|
|
@@ -14980,7 +15244,7 @@ function Editor({ setEditorLoading }) {
|
|
|
14980
15244
|
justifyContent: "center"
|
|
14981
15245
|
},
|
|
14982
15246
|
children: [
|
|
14983
|
-
/* @__PURE__ */
|
|
15247
|
+
/* @__PURE__ */ jsx50(
|
|
14984
15248
|
"div",
|
|
14985
15249
|
{
|
|
14986
15250
|
className: `editor-container rounded-b-[12px] border-t-1 border-t-accent max-w-[626px]`,
|
|
@@ -14990,7 +15254,7 @@ function Editor({ setEditorLoading }) {
|
|
|
14990
15254
|
backgroundColor: "#f5f5f5",
|
|
14991
15255
|
overflow: "auto"
|
|
14992
15256
|
},
|
|
14993
|
-
children: /* @__PURE__ */
|
|
15257
|
+
children: /* @__PURE__ */ jsx50(
|
|
14994
15258
|
ShadowDomRenderer,
|
|
14995
15259
|
{
|
|
14996
15260
|
html,
|
|
@@ -15019,9 +15283,9 @@ function Editor({ setEditorLoading }) {
|
|
|
15019
15283
|
)
|
|
15020
15284
|
}
|
|
15021
15285
|
),
|
|
15022
|
-
/* @__PURE__ */
|
|
15023
|
-
/* @__PURE__ */
|
|
15024
|
-
!isDragging && !isScaling && hasSelectedElement && focusIdx && selectedElement?.type && /* @__PURE__ */
|
|
15286
|
+
/* @__PURE__ */ jsx50(ElementsSuggestions, {}),
|
|
15287
|
+
/* @__PURE__ */ jsx50(TiptapOverlay, {}),
|
|
15288
|
+
!isDragging && !isScaling && hasSelectedElement && focusIdx && selectedElement?.type && /* @__PURE__ */ jsx50(
|
|
15025
15289
|
ElementFloat,
|
|
15026
15290
|
{
|
|
15027
15291
|
getReferenceRect,
|
|
@@ -15029,7 +15293,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15029
15293
|
elementType: selectedElement.type
|
|
15030
15294
|
}
|
|
15031
15295
|
),
|
|
15032
|
-
!isScaling && hasSelectedElement && focusIdx && canDragSelectedElement && !NOT_DRAGGABLE_ELEMENTS.includes(selectedElement.type) && /* @__PURE__ */
|
|
15296
|
+
!isScaling && hasSelectedElement && focusIdx && canDragSelectedElement && !NOT_DRAGGABLE_ELEMENTS.includes(selectedElement.type) && /* @__PURE__ */ jsx50(
|
|
15033
15297
|
DragButton,
|
|
15034
15298
|
{
|
|
15035
15299
|
getReferenceRect,
|
|
@@ -15038,17 +15302,17 @@ function Editor({ setEditorLoading }) {
|
|
|
15038
15302
|
isDragging
|
|
15039
15303
|
}
|
|
15040
15304
|
),
|
|
15041
|
-
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "divider" && /* @__PURE__ */
|
|
15042
|
-
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "button" && /* @__PURE__ */
|
|
15043
|
-
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "image" && /* @__PURE__ */
|
|
15044
|
-
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "space" && /* @__PURE__ */
|
|
15305
|
+
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "divider" && /* @__PURE__ */ jsx50(DividerScale, { getReferenceRect }),
|
|
15306
|
+
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "button" && /* @__PURE__ */ jsx50(ButtonScale, { getReferenceRect }),
|
|
15307
|
+
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "image" && /* @__PURE__ */ jsx50(ImageScale, { getReferenceRect }),
|
|
15308
|
+
!isDragging && hasSelectedElement && focusIdx && selectedElement?.type === "space" && /* @__PURE__ */ jsx50(SpacerScale, { getReferenceRect }),
|
|
15045
15309
|
!isDragging && hasSelectedElement && focusIdx && renderData && (() => {
|
|
15046
15310
|
const sectionColumnIdx = getSectionColumnIdx(focusIdx, renderData);
|
|
15047
15311
|
if (!sectionColumnIdx) return null;
|
|
15048
15312
|
const sectionColumn = getValueByIdx(renderData, sectionColumnIdx);
|
|
15049
15313
|
if (!sectionColumn || sectionColumn.type !== "section-column") return null;
|
|
15050
15314
|
if (!sectionColumn.children || sectionColumn.children.length < 2) return null;
|
|
15051
|
-
return /* @__PURE__ */
|
|
15315
|
+
return /* @__PURE__ */ jsx50(
|
|
15052
15316
|
ColumnScale,
|
|
15053
15317
|
{
|
|
15054
15318
|
sectionColumnIdx,
|