@kgalexander/mcreate 0.0.13 → 0.0.15
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-LAW7VVEQ.mjs → chunk-XSQHR5MC.mjs} +269 -350
- package/dist/{core-GBVVYXAB.mjs → core-66YYN7ME.mjs} +1 -1
- package/dist/index.d.mts +24 -3
- package/dist/index.d.ts +24 -3
- package/dist/index.js +988 -788
- package/dist/index.mjs +749 -476
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/core/index.tsx
|
|
2
|
-
import { useMemo as
|
|
2
|
+
import { useMemo as useMemo17, useState as useState16, useEffect as useEffect20, useCallback as useCallback17, useRef as useRef11 } from "react";
|
|
3
3
|
import { cloneDeep as cloneDeep2, isEqual, debounce } from "lodash";
|
|
4
4
|
|
|
5
5
|
// src/core/utils/idx.ts
|
|
@@ -1587,8 +1587,8 @@ function createSectionPropertyTripleElement(payload) {
|
|
|
1587
1587
|
|
|
1588
1588
|
// templates/empty.json
|
|
1589
1589
|
var empty_default = {
|
|
1590
|
-
id: "
|
|
1591
|
-
name: "
|
|
1590
|
+
id: "1",
|
|
1591
|
+
name: "Playground Demo",
|
|
1592
1592
|
version: "1.0.0",
|
|
1593
1593
|
published: true,
|
|
1594
1594
|
creator: "Kevin Guerrero",
|
|
@@ -1633,7 +1633,7 @@ var empty_default = {
|
|
|
1633
1633
|
tagName: "mj-text",
|
|
1634
1634
|
data: {
|
|
1635
1635
|
value: {
|
|
1636
|
-
content: '<p class="paragraph" style=" padding: 4px 0; font-family: Arial, sans-serif;"
|
|
1636
|
+
content: '<p class="paragraph" style=" padding: 4px 0; font-family: Arial, sans-serif;">Welcome to our Open House! Please join us for a tour of this beautiful home.</p>'
|
|
1637
1637
|
}
|
|
1638
1638
|
},
|
|
1639
1639
|
attributes: {
|
|
@@ -1646,180 +1646,6 @@ var empty_default = {
|
|
|
1646
1646
|
}
|
|
1647
1647
|
]
|
|
1648
1648
|
},
|
|
1649
|
-
{
|
|
1650
|
-
type: "section-property-km",
|
|
1651
|
-
tagName: "mj-section",
|
|
1652
|
-
data: { value: { columnRows: 1, columnWidths: [] } },
|
|
1653
|
-
attributes: { "background-color": "#FFFFFF", padding: "12px 12px 12px 12px" },
|
|
1654
|
-
children: [
|
|
1655
|
-
{
|
|
1656
|
-
type: "column",
|
|
1657
|
-
tagName: "mj-column",
|
|
1658
|
-
data: { value: {} },
|
|
1659
|
-
attributes: { "background-color": "#FFFFFF", width: "500px", padding: "0px", border: "1px solid #dddddd", "border-radius": "0px" },
|
|
1660
|
-
children: [
|
|
1661
|
-
{
|
|
1662
|
-
type: "property-card",
|
|
1663
|
-
tagName: "mj-colproperty",
|
|
1664
|
-
data: { value: {} },
|
|
1665
|
-
attributes: {
|
|
1666
|
-
"image-src": "https://cornerstonepropertymgmt.com/wp-content/themes/cornerstone/assets/img/nofeaturedimage.jpg",
|
|
1667
|
-
"image-alt": "Beautiful modern home with pool",
|
|
1668
|
-
description: "Beautiful modern home with pool",
|
|
1669
|
-
price: "1000000",
|
|
1670
|
-
address: "123 Main Street",
|
|
1671
|
-
city: "Austin, TX 78701",
|
|
1672
|
-
beds: "",
|
|
1673
|
-
baths: "2",
|
|
1674
|
-
sqft: "1,850",
|
|
1675
|
-
href: "https://www.zillow.com/homedetails/126-Cara-Mia-Ln-Galloway-NJ-08205/68297408_zpid/?rtoken=6acd62a8-1848-41ed-919b-0034083eafca~X1-ZUu7aphk9l2689_9ej1i&utm_campaign=emo-instantsearchdigest&utm_source=email&utm_term=urn%3Amsg%3A20251026011813e84b11d632bb8725&utm_medium=email&utm_content=forsaleimage&sse=X1-SSsyx4z97dhglz0000000000_1pt02&srp=H4sIAAAAAAAAAHWRwXKDIBCGn8ZjokKQeOh0YpOZ9Nihh94yRNfozAoOYFrz9FXR1h7KgVn%2B799lF8JKN2DDUpuLlQjhswVp8uqtA9MLJx08BTwLCGlkm%2BlOFXaIA3rw4idY588bvtuyNElSEpCXQQK5JpTtk4h6YnXnKo9ouiWcUco8UdqsSMIp2fOAHz00cKu1EoCQuyGYu2CZb8TT18LLSRwtt3nw3rfg0VSQzTXLGh2Yacr1VLU9IJ7HZ1mrd4ndbHNmiJbGQMkrgsgrrfG%2FhFKi%2Fc24wt9XbOp5HDZaFpeVdyjE9BknZTRiA8otEw77R7wRwvZfu0fKi%2BqGj%2BhnXeLWRWR08uM33zV%2BmeABAAA%3D",
|
|
1676
|
-
status: "Empty",
|
|
1677
|
-
"status-color": "#B8B8B8",
|
|
1678
|
-
"is-new": "",
|
|
1679
|
-
"is-open-house": "1",
|
|
1680
|
-
"open-house-date": "2026-01-29",
|
|
1681
|
-
"open-house-time": "01:00-13:07",
|
|
1682
|
-
brokerage: "Keller Williams Atlantic Shore",
|
|
1683
|
-
"mls-logo": "https://t4.ftcdn.net/jpg/06/71/92/37/360_F_671923740_x0zOL3OIuUAnSF6sr7PuznCI5bQFKhI0.jpg",
|
|
1684
|
-
"border-radius": "0px",
|
|
1685
|
-
border: "1px solid #dddddd",
|
|
1686
|
-
"font-family": "Arial, sans-serif",
|
|
1687
|
-
"text-color": "#000000",
|
|
1688
|
-
"price-text-color": "",
|
|
1689
|
-
"details-text-color": "",
|
|
1690
|
-
"address-text-color": "",
|
|
1691
|
-
"brokerage-text-color": "#535364",
|
|
1692
|
-
"description-text-color": "",
|
|
1693
|
-
"mls-logo-text-color": "",
|
|
1694
|
-
"status-text-color": "",
|
|
1695
|
-
"new-text-color": "",
|
|
1696
|
-
"open-house-text-color": ""
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
]
|
|
1700
|
-
}
|
|
1701
|
-
]
|
|
1702
|
-
},
|
|
1703
|
-
{
|
|
1704
|
-
type: "section-property-single-two",
|
|
1705
|
-
tagName: "mj-section",
|
|
1706
|
-
data: { value: { columnRows: 1, columnWidths: [] } },
|
|
1707
|
-
attributes: { "background-color": "#FFFFFF", padding: "12px 12px 12px 12px" },
|
|
1708
|
-
children: [
|
|
1709
|
-
{
|
|
1710
|
-
type: "column",
|
|
1711
|
-
tagName: "mj-column",
|
|
1712
|
-
data: { value: {} },
|
|
1713
|
-
attributes: { "background-color": "#FFFFFF", width: "500px", padding: "0px", border: "1px solid #dddddd", "border-radius": "12px" },
|
|
1714
|
-
children: [
|
|
1715
|
-
{
|
|
1716
|
-
type: "property-card-single-two",
|
|
1717
|
-
tagName: "mj-propertysingletwo",
|
|
1718
|
-
data: { value: {} },
|
|
1719
|
-
attributes: {
|
|
1720
|
-
"image-src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRXddI94MwjUVz5M4CyDxZhSkIIwWbyDF59_w&s",
|
|
1721
|
-
"image-alt": "Beautiful modern home with pool",
|
|
1722
|
-
description: "Beautiful modern home with pool",
|
|
1723
|
-
price: "324203492034",
|
|
1724
|
-
address: "123 Main Street",
|
|
1725
|
-
city: "Austin, TX 78701",
|
|
1726
|
-
beds: "",
|
|
1727
|
-
baths: "",
|
|
1728
|
-
sqft: "",
|
|
1729
|
-
href: "https://www.zillow.com/homedetails/126-Cara-Mia-Ln-Galloway-NJ-08205/68297408_zpid/?rtoken=6acd62a8-1848-41ed-919b-0034083eafca~X1-ZUu7aphk9l2689_9ej1i&utm_campaign=emo-instantsearchdigest&utm_source=email&utm_term=urn%3Amsg%3A20251026011813e84b11d632bb8725&utm_medium=email&utm_content=forsaleimage&sse=X1-SSsyx4z97dhglz0000000000_1pt02&srp=H4sIAAAAAAAAAHWRwXKDIBCGn8ZjokKQeOh0YpOZ9Nihh94yRNfozAoOYFrz9FXR1h7KgVn%2B799lF8JKN2DDUpuLlQjhswVp8uqtA9MLJx08BTwLCGlkm%2BlOFXaIA3rw4idY588bvtuyNElSEpCXQQK5JpTtk4h6YnXnKo9ouiWcUco8UdqsSMIp2fOAHz00cKu1EoCQuyGYu2CZb8TT18LLSRwtt3nw3rfg0VSQzTXLGh2Yacr1VLU9IJ7HZ1mrd4ndbHNmiJbGQMkrgsgrrfG%2FhFKi%2Fc24wt9XbOp5HDZaFpeVdyjE9BknZTRiA8otEw77R7wRwvZfu0fKi%2BqGj%2BhnXeLWRWR08uM33zV%2BmeABAAA%3D",
|
|
1730
|
-
status: "Just Listed",
|
|
1731
|
-
"status-color": "#008000",
|
|
1732
|
-
"is-new": "1",
|
|
1733
|
-
"is-open-house": "",
|
|
1734
|
-
"open-house-date": "03/25",
|
|
1735
|
-
"open-house-time": "12pm-1pm",
|
|
1736
|
-
brokerage: "Keller Williams Atlantic Shore",
|
|
1737
|
-
"mls-logo": "https://t4.ftcdn.net/jpg/06/71/92/37/360_F_671923740_x0zOL3OIuUAnSF6sr7PuznCI5bQFKhI0.jpg",
|
|
1738
|
-
"border-radius": "12px",
|
|
1739
|
-
border: "1x solid #dddddd",
|
|
1740
|
-
"font-family": "Arial, sans-serif",
|
|
1741
|
-
"text-color": "#000000"
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
]
|
|
1745
|
-
}
|
|
1746
|
-
]
|
|
1747
|
-
},
|
|
1748
|
-
{
|
|
1749
|
-
type: "section-property-triple",
|
|
1750
|
-
tagName: "mj-section",
|
|
1751
|
-
data: { value: { columnRows: 1, columnWidths: [] } },
|
|
1752
|
-
attributes: { "background-color": "#FFFFFF", padding: "12px" },
|
|
1753
|
-
children: [
|
|
1754
|
-
{
|
|
1755
|
-
type: "column",
|
|
1756
|
-
tagName: "mj-column",
|
|
1757
|
-
data: { value: {} },
|
|
1758
|
-
attributes: { "background-color": "transparent", padding: "0px", "css-class": "property-triple-section-column", width: "500px" },
|
|
1759
|
-
children: [
|
|
1760
|
-
{
|
|
1761
|
-
type: "property-card-triple",
|
|
1762
|
-
tagName: "mj-propertytriple",
|
|
1763
|
-
data: { value: {} },
|
|
1764
|
-
attributes: {
|
|
1765
|
-
width: "100%",
|
|
1766
|
-
gap: "24px",
|
|
1767
|
-
"border-radius": "8px",
|
|
1768
|
-
border: "1px solid #d1d1d5",
|
|
1769
|
-
"image-height": "102px",
|
|
1770
|
-
"font-family": "Arial, sans-serif",
|
|
1771
|
-
"text-color": "#000000",
|
|
1772
|
-
"background-color": "#FFFFFF"
|
|
1773
|
-
},
|
|
1774
|
-
children: [
|
|
1775
|
-
{
|
|
1776
|
-
type: "property-card-triple-item",
|
|
1777
|
-
tagName: "mj-propertytripleitem",
|
|
1778
|
-
data: { value: {} },
|
|
1779
|
-
attributes: {
|
|
1780
|
-
"image-src": "https://photos.zillowstatic.com/fp/a8e605d336d0b5a94d91828aee3c0afb-p_i.jpg",
|
|
1781
|
-
href: "",
|
|
1782
|
-
price: "$320,000",
|
|
1783
|
-
beds: "3",
|
|
1784
|
-
baths: "2",
|
|
1785
|
-
sqft: "1,385",
|
|
1786
|
-
city: "Egg Harbor City"
|
|
1787
|
-
}
|
|
1788
|
-
},
|
|
1789
|
-
{
|
|
1790
|
-
type: "property-card-triple-item",
|
|
1791
|
-
tagName: "mj-propertytripleitem",
|
|
1792
|
-
data: { value: {} },
|
|
1793
|
-
attributes: {
|
|
1794
|
-
"image-src": "https://photos.zillowstatic.com/fp/4d72133271685e778a0126b3defd9854-p_i.jpg",
|
|
1795
|
-
href: "",
|
|
1796
|
-
price: "$282,000",
|
|
1797
|
-
beds: "2",
|
|
1798
|
-
baths: "2",
|
|
1799
|
-
sqft: "1,224",
|
|
1800
|
-
city: "Egg Harbor"
|
|
1801
|
-
}
|
|
1802
|
-
},
|
|
1803
|
-
{
|
|
1804
|
-
type: "property-card-triple-item",
|
|
1805
|
-
tagName: "mj-propertytripleitem",
|
|
1806
|
-
data: { value: {} },
|
|
1807
|
-
attributes: {
|
|
1808
|
-
"image-src": "https://photos.zillowstatic.com/fp/26e69f22548989c0e4d1ec372ce178e0-p_i.jpg",
|
|
1809
|
-
href: "",
|
|
1810
|
-
price: "$484,900",
|
|
1811
|
-
beds: "3",
|
|
1812
|
-
baths: "1",
|
|
1813
|
-
sqft: "1,417",
|
|
1814
|
-
city: "Egg Harbor"
|
|
1815
|
-
}
|
|
1816
|
-
}
|
|
1817
|
-
]
|
|
1818
|
-
}
|
|
1819
|
-
]
|
|
1820
|
-
}
|
|
1821
|
-
]
|
|
1822
|
-
},
|
|
1823
1649
|
{
|
|
1824
1650
|
type: "section",
|
|
1825
1651
|
tagName: "mj-section",
|
|
@@ -1871,7 +1697,6 @@ var defaultTemplate = {
|
|
|
1871
1697
|
id: page.id || generateId()
|
|
1872
1698
|
}))
|
|
1873
1699
|
};
|
|
1874
|
-
var MAX_PAID_LEVEL = 3;
|
|
1875
1700
|
var useEditorStore = create()(
|
|
1876
1701
|
devtools(
|
|
1877
1702
|
immer((set) => ({
|
|
@@ -1880,6 +1705,7 @@ var useEditorStore = create()(
|
|
|
1880
1705
|
templateId: null,
|
|
1881
1706
|
onSave: null,
|
|
1882
1707
|
onToast: null,
|
|
1708
|
+
onExit: null,
|
|
1883
1709
|
previewMode: false,
|
|
1884
1710
|
focusIdx: null,
|
|
1885
1711
|
hoverIdx: null,
|
|
@@ -1903,14 +1729,22 @@ var useEditorStore = create()(
|
|
|
1903
1729
|
isSaving: false,
|
|
1904
1730
|
// Subscription level (0 = free, 1-3 = paid tiers)
|
|
1905
1731
|
isPaidLevel: 0,
|
|
1732
|
+
// User data
|
|
1733
|
+
images: [],
|
|
1734
|
+
userData: null,
|
|
1735
|
+
// Render sync
|
|
1736
|
+
renderSyncNeeded: 0,
|
|
1906
1737
|
// Initialize store with external template (for npm package usage)
|
|
1907
|
-
initializeWithTemplate: (templateId, template, onSave, onToast,
|
|
1738
|
+
initializeWithTemplate: (templateId, template, onSave, onToast, data, onExit) => {
|
|
1908
1739
|
set((state) => {
|
|
1909
1740
|
state.templateId = templateId;
|
|
1910
1741
|
state.template = template;
|
|
1911
1742
|
state.onSave = onSave ?? null;
|
|
1912
1743
|
state.onToast = onToast ?? null;
|
|
1913
|
-
state.
|
|
1744
|
+
state.onExit = onExit ?? null;
|
|
1745
|
+
state.isPaidLevel = data?.isPaidLevel ?? 0;
|
|
1746
|
+
state.images = data?.images ?? [];
|
|
1747
|
+
state.userData = data?.userData ?? null;
|
|
1914
1748
|
state.templateSize = calculateTemplateSize(template);
|
|
1915
1749
|
state.isAtSizeLimit = false;
|
|
1916
1750
|
state.history = [cloneDeep(template)];
|
|
@@ -2176,6 +2010,7 @@ var useEditorStore = create()(
|
|
|
2176
2010
|
return;
|
|
2177
2011
|
}
|
|
2178
2012
|
Object.assign(element, updates);
|
|
2013
|
+
state2.renderSyncNeeded += 1;
|
|
2179
2014
|
});
|
|
2180
2015
|
},
|
|
2181
2016
|
// Update element content (for contenteditable)
|
|
@@ -3138,6 +2973,17 @@ var LINK_TYPES = [
|
|
|
3138
2973
|
prefix: "tel:"
|
|
3139
2974
|
}
|
|
3140
2975
|
];
|
|
2976
|
+
var LINK_PRESETS = {
|
|
2977
|
+
Phone: [
|
|
2978
|
+
{ label: "Personal Phone", key: "personal_phone_number" },
|
|
2979
|
+
{ label: "Office Phone", key: "office_phone_number" },
|
|
2980
|
+
{ label: "Business Phone", key: "business_phone_number" }
|
|
2981
|
+
],
|
|
2982
|
+
Website: [
|
|
2983
|
+
{ label: "Team Website", key: "team_website" },
|
|
2984
|
+
{ label: "Brokerage Website", key: "brokerage_website" }
|
|
2985
|
+
]
|
|
2986
|
+
};
|
|
3141
2987
|
var detectLinkType = (href) => {
|
|
3142
2988
|
if (href.startsWith("mailto:")) return LINK_TYPES[0];
|
|
3143
2989
|
if (href.startsWith("tel:")) return LINK_TYPES[2];
|
|
@@ -3164,7 +3010,18 @@ var MAX_LINE_HEIGHT = 3;
|
|
|
3164
3010
|
var LINE_HEIGHT_STEP = 0.1;
|
|
3165
3011
|
var HIDDEN_SELECTION_VISUAL_ELEMENTS = ["text", "divider", "column"];
|
|
3166
3012
|
var NOT_DRAGGABLE_ELEMENTS = ["page", "social-item", "text", "property-card", "property-card-single-two", "property-card-triple", "property-card-triple-item"];
|
|
3167
|
-
var
|
|
3013
|
+
var EDITOR_COLORS = {
|
|
3014
|
+
/** Purple — drag/drop state */
|
|
3015
|
+
drag: {
|
|
3016
|
+
solid: "rgb(59, 130, 246)",
|
|
3017
|
+
half: "rgba(59, 130, 246, 0.5)"
|
|
3018
|
+
},
|
|
3019
|
+
/** Blue — hover/selection state */
|
|
3020
|
+
hover: {
|
|
3021
|
+
solid: "rgb(59, 130, 246)",
|
|
3022
|
+
half: "rgba(59, 130, 246, 0.5)"
|
|
3023
|
+
}
|
|
3024
|
+
};
|
|
3168
3025
|
|
|
3169
3026
|
// src/core/editor/components/ShadowDomRenderer.tsx
|
|
3170
3027
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -3176,6 +3033,7 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3176
3033
|
if (cached) return cached;
|
|
3177
3034
|
const hiddenSelectors = !isDragButtonHovered && HIDDEN_SELECTION_VISUAL_ELEMENTS.length > 0 ? HIDDEN_SELECTION_VISUAL_ELEMENTS.map((type) => `.node-type-${type}`).join(", ") : null;
|
|
3178
3035
|
const css = `
|
|
3036
|
+
|
|
3179
3037
|
/* Base reset for email content */
|
|
3180
3038
|
* {
|
|
3181
3039
|
box-sizing: border-box;
|
|
@@ -3192,32 +3050,32 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3192
3050
|
|
|
3193
3051
|
/* Hover state - uses CSS variable for dynamic color */
|
|
3194
3052
|
.${EMAIL_BLOCK_CLASS_NAME}.is-hovered {
|
|
3195
|
-
outline-color: var(--outline-color-hover,
|
|
3053
|
+
outline-color: var(--outline-color-hover, ${EDITOR_COLORS.hover.half});
|
|
3196
3054
|
}
|
|
3197
3055
|
|
|
3198
3056
|
/* Selected state - uses CSS variable for dynamic color */
|
|
3199
3057
|
.${EMAIL_BLOCK_CLASS_NAME}.is-selected {
|
|
3200
|
-
outline-color: var(--outline-color,
|
|
3058
|
+
outline-color: var(--outline-color, ${EDITOR_COLORS.hover.solid});
|
|
3201
3059
|
}
|
|
3202
3060
|
|
|
3203
3061
|
/* Drop target state - highlight section being dropped into */
|
|
3204
3062
|
.${EMAIL_BLOCK_CLASS_NAME}.is-drop-target {
|
|
3205
|
-
outline-color:
|
|
3063
|
+
outline-color: ${EDITOR_COLORS.drag.solid} !important;
|
|
3206
3064
|
}
|
|
3207
3065
|
|
|
3208
3066
|
/* Column selection in section-column - 50% opacity blue */
|
|
3209
3067
|
.${EMAIL_BLOCK_CLASS_NAME}.is-column-selected {
|
|
3210
|
-
outline-color:
|
|
3068
|
+
outline-color: ${EDITOR_COLORS.hover.half};
|
|
3211
3069
|
}
|
|
3212
3070
|
|
|
3213
3071
|
/* Column hover when child element is hovered - 50% opacity blue */
|
|
3214
3072
|
.${EMAIL_BLOCK_CLASS_NAME}.is-column-hover-parent {
|
|
3215
|
-
outline-color:
|
|
3073
|
+
outline-color: ${EDITOR_COLORS.hover.half};
|
|
3216
3074
|
}
|
|
3217
3075
|
|
|
3218
3076
|
/* Card selection in property-card-triple - 50% opacity blue */
|
|
3219
3077
|
.${EMAIL_BLOCK_CLASS_NAME}.is-card-selected {
|
|
3220
|
-
outline-color:
|
|
3078
|
+
outline-color: ${EDITOR_COLORS.hover.half};
|
|
3221
3079
|
}
|
|
3222
3080
|
|
|
3223
3081
|
/* Hide selection visual for configured elements (unless drag button hovered) */
|
|
@@ -3237,12 +3095,12 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3237
3095
|
outline-color: transparent !important;
|
|
3238
3096
|
}
|
|
3239
3097
|
.node-type-button.is-selected > table {
|
|
3240
|
-
outline: 2px solid var(--outline-color,
|
|
3098
|
+
outline: 2px solid var(--outline-color, ${EDITOR_COLORS.hover.solid});
|
|
3241
3099
|
outline-offset: -2px;
|
|
3242
3100
|
border-radius: 2px;
|
|
3243
3101
|
}
|
|
3244
3102
|
.node-type-button.is-hovered:not(.is-selected) > table {
|
|
3245
|
-
outline: 2px solid var(--outline-color-hover,
|
|
3103
|
+
outline: 2px solid var(--outline-color-hover, ${EDITOR_COLORS.hover.half});
|
|
3246
3104
|
outline-offset: -2px;
|
|
3247
3105
|
border-radius: 2px;
|
|
3248
3106
|
}
|
|
@@ -3255,12 +3113,12 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3255
3113
|
outline-color: transparent !important;
|
|
3256
3114
|
}
|
|
3257
3115
|
.node-type-image.is-selected table td {
|
|
3258
|
-
outline: 2px solid var(--outline-color,
|
|
3116
|
+
outline: 2px solid var(--outline-color, ${EDITOR_COLORS.hover.solid});
|
|
3259
3117
|
outline-offset: -2px;
|
|
3260
3118
|
border-radius: 2px;
|
|
3261
3119
|
}
|
|
3262
3120
|
.node-type-image.is-hovered:not(.is-selected) table td {
|
|
3263
|
-
outline: 2px solid var(--outline-color-hover,
|
|
3121
|
+
outline: 2px solid var(--outline-color-hover, ${EDITOR_COLORS.hover.half});
|
|
3264
3122
|
outline-offset: -2px;
|
|
3265
3123
|
border-radius: 2px;
|
|
3266
3124
|
}
|
|
@@ -3278,7 +3136,7 @@ function getEditorStyles(isDragButtonHovered, textEditingIdx) {
|
|
|
3278
3136
|
/* Drop indicator - uses CSS variable for dynamic color */
|
|
3279
3137
|
.drop-indicator {
|
|
3280
3138
|
position: absolute;
|
|
3281
|
-
background-color: var(--outline-color,
|
|
3139
|
+
background-color: var(--outline-color, ${EDITOR_COLORS.hover.solid});
|
|
3282
3140
|
pointer-events: none;
|
|
3283
3141
|
z-index: 1000;
|
|
3284
3142
|
}
|
|
@@ -3589,8 +3447,8 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
3589
3447
|
contentWrapper.className = "shadow-content";
|
|
3590
3448
|
contentWrapper.innerHTML = html;
|
|
3591
3449
|
contentWrapper.style.setProperty("--company-footer-opacity", showCompanyFooter ? "1" : "0.25");
|
|
3592
|
-
contentWrapper.style.setProperty("--outline-color", isDragging ?
|
|
3593
|
-
contentWrapper.style.setProperty("--outline-color-hover", isDragging ?
|
|
3450
|
+
contentWrapper.style.setProperty("--outline-color", isDragging ? EDITOR_COLORS.drag.solid : EDITOR_COLORS.hover.solid);
|
|
3451
|
+
contentWrapper.style.setProperty("--outline-color-hover", isDragging ? EDITOR_COLORS.drag.half : EDITOR_COLORS.hover.half);
|
|
3594
3452
|
const template = useEditorStore.getState().template;
|
|
3595
3453
|
const linkColor2 = template?.content?.[0]?.data?.value?.linkColor || "#0000ff";
|
|
3596
3454
|
contentWrapper.style.setProperty("--link-color", linkColor2);
|
|
@@ -3610,8 +3468,8 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
3610
3468
|
if (!shadowRootRef.current) return;
|
|
3611
3469
|
const contentWrapper = shadowRootRef.current.querySelector(".shadow-content");
|
|
3612
3470
|
if (contentWrapper) {
|
|
3613
|
-
contentWrapper.style.setProperty("--outline-color", isDragging ?
|
|
3614
|
-
contentWrapper.style.setProperty("--outline-color-hover", isDragging ?
|
|
3471
|
+
contentWrapper.style.setProperty("--outline-color", isDragging ? EDITOR_COLORS.drag.solid : EDITOR_COLORS.hover.solid);
|
|
3472
|
+
contentWrapper.style.setProperty("--outline-color-hover", isDragging ? EDITOR_COLORS.drag.half : EDITOR_COLORS.hover.half);
|
|
3615
3473
|
contentWrapper.style.setProperty("--company-footer-opacity", showCompanyFooter ? "1" : "0.25");
|
|
3616
3474
|
const template = useEditorStore.getState().template;
|
|
3617
3475
|
const linkColor2 = template?.content?.[0]?.data?.value?.linkColor || "#0000ff";
|
|
@@ -4071,11 +3929,11 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
4071
3929
|
width: 3,
|
|
4072
3930
|
height: dropIndicator.height
|
|
4073
3931
|
},
|
|
4074
|
-
backgroundColor: isDragging ?
|
|
3932
|
+
backgroundColor: isDragging ? EDITOR_COLORS.drag.solid : EDITOR_COLORS.hover.solid,
|
|
4075
3933
|
borderRadius: 2,
|
|
4076
3934
|
pointerEvents: "none",
|
|
4077
3935
|
zIndex: 9999,
|
|
4078
|
-
boxShadow: isDragging ?
|
|
3936
|
+
boxShadow: isDragging ? `0 0 4px ${EDITOR_COLORS.drag.half}` : `0 0 4px ${EDITOR_COLORS.hover.half}`
|
|
4079
3937
|
},
|
|
4080
3938
|
children: (dropIndicator.isNewSection || dropIndicator.isSplitSection) && /* @__PURE__ */ jsx(
|
|
4081
3939
|
"div",
|
|
@@ -4085,7 +3943,7 @@ var ShadowDomRenderer = memo(function ShadowDomRenderer2({
|
|
|
4085
3943
|
top: "50%",
|
|
4086
3944
|
left: "50%",
|
|
4087
3945
|
transform: "translate(-50%, -50%)",
|
|
4088
|
-
backgroundColor:
|
|
3946
|
+
backgroundColor: EDITOR_COLORS.drag.solid,
|
|
4089
3947
|
color: "white",
|
|
4090
3948
|
fontSize: 12,
|
|
4091
3949
|
fontWeight: 600,
|
|
@@ -12091,7 +11949,7 @@ var TiptapOverlayContent = ({ idx, getReferenceRect, getShadowElement, initialWi
|
|
|
12091
11949
|
};
|
|
12092
11950
|
|
|
12093
11951
|
// src/core/editor/components/element-float.tsx
|
|
12094
|
-
import { useEffect as useEffect12, useMemo as
|
|
11952
|
+
import { useEffect as useEffect12, useMemo as useMemo11 } from "react";
|
|
12095
11953
|
import { useFloating as useFloating4, offset as offset4, shift as shift3, flip as flip2, autoUpdate as autoUpdate3 } from "@floating-ui/react";
|
|
12096
11954
|
|
|
12097
11955
|
// src/core/editor/components/float-ui/actions/delete-button.tsx
|
|
@@ -12145,7 +12003,7 @@ var DuplicateButton = () => {
|
|
|
12145
12003
|
};
|
|
12146
12004
|
|
|
12147
12005
|
// src/core/editor/components/href-menu.tsx
|
|
12148
|
-
import { useState as useState3, useEffect as useEffect7 } from "react";
|
|
12006
|
+
import { useState as useState3, useEffect as useEffect7, useCallback as useCallback4, useMemo as useMemo5 } from "react";
|
|
12149
12007
|
|
|
12150
12008
|
// src/components/ui/dropdown-menu.tsx
|
|
12151
12009
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
@@ -12322,19 +12180,36 @@ var useHref = () => {
|
|
|
12322
12180
|
import { jsx as jsx25, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
12323
12181
|
var HrefMenu = () => {
|
|
12324
12182
|
const { href, setHref, clearHref, copyHref, hasHref } = useHref();
|
|
12183
|
+
const userData = useEditorStore((s) => s.userData);
|
|
12325
12184
|
const [isOpen, setIsOpen] = useState3(false);
|
|
12326
12185
|
const [inputValue, setInputValue] = useState3("");
|
|
12327
12186
|
const [showCopied, setShowCopied] = useState3(false);
|
|
12328
12187
|
const [linkType, setLinkType] = useState3(LINK_TYPES[1]);
|
|
12329
12188
|
const [isLinkTypeOpen, setIsLinkTypeOpen] = useState3(false);
|
|
12189
|
+
const [isPresetOpen, setIsPresetOpen] = useState3(false);
|
|
12190
|
+
console.log("userData", userData);
|
|
12191
|
+
const availablePresets = useMemo5(() => {
|
|
12192
|
+
const presetDefs = LINK_PRESETS[linkType.name] ?? [];
|
|
12193
|
+
if (!userData) return [];
|
|
12194
|
+
const all = presetDefs.filter((p) => userData[p.key]).map((p) => ({ ...p, value: String(userData[p.key]) }));
|
|
12195
|
+
if (!inputValue) return all;
|
|
12196
|
+
const query = inputValue.toLowerCase();
|
|
12197
|
+
return all.filter((p) => p.value.toLowerCase().includes(query));
|
|
12198
|
+
}, [linkType.name, userData, inputValue]);
|
|
12199
|
+
const handlePresetSelect = useCallback4((value) => {
|
|
12200
|
+
setInputValue(value);
|
|
12201
|
+
setIsPresetOpen(false);
|
|
12202
|
+
}, []);
|
|
12330
12203
|
useEffect7(() => {
|
|
12331
12204
|
if (isOpen) {
|
|
12332
12205
|
setLinkType(detectLinkType(href));
|
|
12333
12206
|
setInputValue(stripPrefix(href));
|
|
12207
|
+
setIsPresetOpen(true);
|
|
12334
12208
|
}
|
|
12335
12209
|
}, [isOpen, href]);
|
|
12336
12210
|
const handleInputChange = (e) => {
|
|
12337
12211
|
setInputValue(e.target.value);
|
|
12212
|
+
setIsPresetOpen(true);
|
|
12338
12213
|
};
|
|
12339
12214
|
const buildHref = (value) => {
|
|
12340
12215
|
if (!value) return "";
|
|
@@ -12344,15 +12219,22 @@ var HrefMenu = () => {
|
|
|
12344
12219
|
if (value.startsWith(linkType.prefix)) return value;
|
|
12345
12220
|
return linkType.prefix + value;
|
|
12346
12221
|
};
|
|
12222
|
+
const handleInputClick = () => {
|
|
12223
|
+
if (availablePresets.length > 0) {
|
|
12224
|
+
setIsPresetOpen(true);
|
|
12225
|
+
}
|
|
12226
|
+
};
|
|
12347
12227
|
const handleInputBlur = () => {
|
|
12348
12228
|
setHref(buildHref(inputValue));
|
|
12349
12229
|
};
|
|
12350
12230
|
const handleKeyDown = (e) => {
|
|
12351
12231
|
if (e.key === "Enter") {
|
|
12352
12232
|
setHref(buildHref(inputValue));
|
|
12233
|
+
setIsPresetOpen(false);
|
|
12353
12234
|
setIsOpen(false);
|
|
12354
12235
|
}
|
|
12355
12236
|
if (e.key === "Escape") {
|
|
12237
|
+
setIsPresetOpen(false);
|
|
12356
12238
|
setIsOpen(false);
|
|
12357
12239
|
}
|
|
12358
12240
|
};
|
|
@@ -12395,55 +12277,85 @@ var HrefMenu = () => {
|
|
|
12395
12277
|
/* @__PURE__ */ jsxs12(DropdownMenuContent, { side: "bottom", className: "w-[250px] p-3 shadow-lg z-50001", children: [
|
|
12396
12278
|
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col gap-2", children: [
|
|
12397
12279
|
/* @__PURE__ */ jsx25(Label, { children: "Enter a link" }),
|
|
12398
|
-
/* @__PURE__ */ jsxs12(
|
|
12399
|
-
/* @__PURE__ */ jsx25(
|
|
12400
|
-
Input,
|
|
12401
|
-
{
|
|
12402
|
-
type: linkType.inputType,
|
|
12403
|
-
placeholder: linkType.placeholder,
|
|
12404
|
-
className: "w-full rounded-[12px] shadow-none pl-12 h-[44px]",
|
|
12405
|
-
value: inputValue,
|
|
12406
|
-
onChange: handleInputChange,
|
|
12407
|
-
onBlur: handleInputBlur,
|
|
12408
|
-
onKeyDown: handleKeyDown,
|
|
12409
|
-
autoFocus: true
|
|
12410
|
-
}
|
|
12411
|
-
),
|
|
12412
|
-
/* @__PURE__ */ jsxs12(Popover, { open: isLinkTypeOpen, onOpenChange: setIsLinkTypeOpen, children: [
|
|
12413
|
-
/* @__PURE__ */ jsxs12(Tooltip, { children: [
|
|
12414
|
-
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(Button, { size: "icon", variant: "ghost", className: "absolute shadow-none rounded-[12px] left-1.5 top-1/2 -translate-y-1/2 h-[34px] w-[34px] cursor-pointer", children: /* @__PURE__ */ jsx25(linkType.icon, {}) }) }) }),
|
|
12415
|
-
/* @__PURE__ */ jsx25(TooltipContent, { side: "top", className: "z-50001", children: "Link Type" })
|
|
12416
|
-
] }),
|
|
12280
|
+
/* @__PURE__ */ jsxs12(Popover, { open: isPresetOpen && availablePresets.length > 0, onOpenChange: setIsPresetOpen, children: [
|
|
12281
|
+
/* @__PURE__ */ jsx25(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs12("div", { className: "relative", children: [
|
|
12417
12282
|
/* @__PURE__ */ jsx25(
|
|
12418
|
-
|
|
12283
|
+
Input,
|
|
12419
12284
|
{
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
className: "w-[
|
|
12423
|
-
|
|
12424
|
-
|
|
12425
|
-
|
|
12426
|
-
|
|
12427
|
-
|
|
12428
|
-
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
|
|
12285
|
+
type: linkType.inputType,
|
|
12286
|
+
placeholder: linkType.placeholder,
|
|
12287
|
+
className: "w-full rounded-[12px] shadow-none pl-12 h-[44px]",
|
|
12288
|
+
value: inputValue,
|
|
12289
|
+
onChange: handleInputChange,
|
|
12290
|
+
onClick: handleInputClick,
|
|
12291
|
+
onBlur: handleInputBlur,
|
|
12292
|
+
onKeyDown: handleKeyDown,
|
|
12293
|
+
autoFocus: true
|
|
12294
|
+
}
|
|
12295
|
+
),
|
|
12296
|
+
/* @__PURE__ */ jsxs12(Popover, { open: isLinkTypeOpen, onOpenChange: setIsLinkTypeOpen, children: [
|
|
12297
|
+
/* @__PURE__ */ jsxs12(Tooltip, { children: [
|
|
12298
|
+
/* @__PURE__ */ jsx25(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx25(Button, { size: "icon", variant: "ghost", className: "absolute shadow-none rounded-[12px] left-1.5 top-1/2 -translate-y-1/2 h-[34px] w-[34px] cursor-pointer", children: /* @__PURE__ */ jsx25(linkType.icon, {}) }) }) }),
|
|
12299
|
+
/* @__PURE__ */ jsx25(TooltipContent, { side: "top", className: "z-50001", children: "Link Type" })
|
|
12300
|
+
] }),
|
|
12301
|
+
/* @__PURE__ */ jsx25(
|
|
12302
|
+
PopoverContent,
|
|
12303
|
+
{
|
|
12304
|
+
side: "bottom",
|
|
12305
|
+
align: "start",
|
|
12306
|
+
className: "w-[160px] p-1 z-50001",
|
|
12307
|
+
onPointerDownOutside: (e) => e.preventDefault(),
|
|
12308
|
+
children: LINK_TYPES.map((type) => /* @__PURE__ */ jsxs12(
|
|
12309
|
+
Button,
|
|
12310
|
+
{
|
|
12311
|
+
variant: "ghost",
|
|
12312
|
+
className: "w-full justify-between shadow-none cursor-pointer",
|
|
12313
|
+
onClick: (e) => {
|
|
12314
|
+
e.stopPropagation();
|
|
12315
|
+
setLinkType(type);
|
|
12316
|
+
setIsLinkTypeOpen(false);
|
|
12317
|
+
},
|
|
12318
|
+
children: [
|
|
12319
|
+
/* @__PURE__ */ jsxs12("span", { className: "flex items-center gap-2", children: [
|
|
12320
|
+
/* @__PURE__ */ jsx25(type.icon, { className: "size-4" }),
|
|
12321
|
+
type.name
|
|
12322
|
+
] }),
|
|
12323
|
+
linkType.name === type.name && /* @__PURE__ */ jsx25(CheckIcon3, { className: "size-4" })
|
|
12324
|
+
]
|
|
12433
12325
|
},
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
|
|
12437
|
-
|
|
12438
|
-
|
|
12439
|
-
|
|
12440
|
-
|
|
12326
|
+
type.name
|
|
12327
|
+
))
|
|
12328
|
+
}
|
|
12329
|
+
)
|
|
12330
|
+
] })
|
|
12331
|
+
] }) }),
|
|
12332
|
+
/* @__PURE__ */ jsx25(
|
|
12333
|
+
PopoverContent,
|
|
12334
|
+
{
|
|
12335
|
+
side: "bottom",
|
|
12336
|
+
align: "start",
|
|
12337
|
+
className: "w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden z-50001",
|
|
12338
|
+
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
12339
|
+
children: /* @__PURE__ */ jsx25("div", { className: "flex flex-col max-h-[200px] overflow-y-auto", children: availablePresets.map((preset) => /* @__PURE__ */ jsxs12(
|
|
12340
|
+
"button",
|
|
12341
|
+
{
|
|
12342
|
+
className: `flex items-center justify-between px-3 py-2 text-sm hover:bg-accent cursor-pointer ${inputValue === preset.value ? "bg-accent font-medium" : ""}`,
|
|
12343
|
+
onMouseDown: (e) => {
|
|
12344
|
+
e.preventDefault();
|
|
12345
|
+
handlePresetSelect(preset.value);
|
|
12441
12346
|
},
|
|
12442
|
-
|
|
12443
|
-
|
|
12444
|
-
|
|
12445
|
-
|
|
12446
|
-
|
|
12347
|
+
children: [
|
|
12348
|
+
/* @__PURE__ */ jsxs12("div", { className: "flex flex-col items-start gap-0.5", children: [
|
|
12349
|
+
/* @__PURE__ */ jsx25("span", { className: "text-xs text-muted-foreground", children: preset.label }),
|
|
12350
|
+
/* @__PURE__ */ jsx25("span", { className: "text-sm", children: preset.value })
|
|
12351
|
+
] }),
|
|
12352
|
+
inputValue === preset.value && /* @__PURE__ */ jsx25(CheckIcon3, { className: "w-4 h-4 shrink-0" })
|
|
12353
|
+
]
|
|
12354
|
+
},
|
|
12355
|
+
preset.key
|
|
12356
|
+
)) })
|
|
12357
|
+
}
|
|
12358
|
+
)
|
|
12447
12359
|
] })
|
|
12448
12360
|
] }),
|
|
12449
12361
|
/* @__PURE__ */ jsx25(Separator, { className: "my-2" }),
|
|
@@ -12508,11 +12420,11 @@ var ButtonFloat = () => {
|
|
|
12508
12420
|
import { ChevronsLeftRightIcon, ChevronsRightLeftIcon, MoreHorizontalIcon } from "lucide-react";
|
|
12509
12421
|
|
|
12510
12422
|
// src/core/editor/hooks/use-full-width-toggle.ts
|
|
12511
|
-
import { useCallback as
|
|
12423
|
+
import { useCallback as useCallback5, useMemo as useMemo6 } from "react";
|
|
12512
12424
|
import { get as lodashGet3 } from "lodash";
|
|
12513
12425
|
function useFullWidthToggle() {
|
|
12514
12426
|
const { focusIdx, template, updateElement } = useEditorStore();
|
|
12515
|
-
const { element, isFullWidth } =
|
|
12427
|
+
const { element, isFullWidth } = useMemo6(() => {
|
|
12516
12428
|
if (!focusIdx || !template) return { element: null, isFullWidth: false };
|
|
12517
12429
|
const path = focusIdx.startsWith("content.") ? focusIdx.replace("content.", "content[0].").replace(/\.\[(\d+)\]/g, "[$1]") : focusIdx;
|
|
12518
12430
|
const el = lodashGet3(template, path);
|
|
@@ -12521,7 +12433,7 @@ function useFullWidthToggle() {
|
|
|
12521
12433
|
isFullWidth: el?.attributes?.["full-width"] === "full-width"
|
|
12522
12434
|
};
|
|
12523
12435
|
}, [focusIdx, template]);
|
|
12524
|
-
const handleToggleFullWidth =
|
|
12436
|
+
const handleToggleFullWidth = useCallback5(() => {
|
|
12525
12437
|
if (!focusIdx || !element) return;
|
|
12526
12438
|
const newAttributes = { ...element.attributes };
|
|
12527
12439
|
if (isFullWidth) {
|
|
@@ -12558,11 +12470,11 @@ var SectionFloat = () => {
|
|
|
12558
12470
|
import { CheckIcon as CheckIcon4, ChevronsLeftRightIcon as ChevronsLeftRightIcon2, ChevronsRightLeftIcon as ChevronsRightLeftIcon2, Layers2Icon, MoreHorizontalIcon as MoreHorizontalIcon2 } from "lucide-react";
|
|
12559
12471
|
|
|
12560
12472
|
// src/core/editor/hooks/use-no-wrap.ts
|
|
12561
|
-
import { useCallback as
|
|
12473
|
+
import { useCallback as useCallback6, useMemo as useMemo7 } from "react";
|
|
12562
12474
|
import { get as lodashGet4 } from "lodash";
|
|
12563
12475
|
function useNoWrap() {
|
|
12564
12476
|
const { focusIdx, template, updateElement } = useEditorStore();
|
|
12565
|
-
const { element, noWrap } =
|
|
12477
|
+
const { element, noWrap } = useMemo7(() => {
|
|
12566
12478
|
if (!focusIdx || !template) return { element: null, noWrap: false };
|
|
12567
12479
|
const path = focusIdx.startsWith("content.") ? focusIdx.replace("content.", "content[0].").replace(/\.\[(\d+)\]/g, "[$1]") : focusIdx;
|
|
12568
12480
|
const el = lodashGet4(template, path);
|
|
@@ -12571,7 +12483,7 @@ function useNoWrap() {
|
|
|
12571
12483
|
noWrap: el?.data?.value?.noWrap === true
|
|
12572
12484
|
};
|
|
12573
12485
|
}, [focusIdx, template]);
|
|
12574
|
-
const handleToggleNoWrap =
|
|
12486
|
+
const handleToggleNoWrap = useCallback6(() => {
|
|
12575
12487
|
if (!focusIdx || !element) return;
|
|
12576
12488
|
updateElement(focusIdx, {
|
|
12577
12489
|
data: {
|
|
@@ -12702,7 +12614,7 @@ import { Accessibility, MoreHorizontalIcon as MoreHorizontalIcon4, TrashIcon as
|
|
|
12702
12614
|
import { useState as useState6, useEffect as useEffect9 } from "react";
|
|
12703
12615
|
|
|
12704
12616
|
// src/core/editor/components/social-item-menu.tsx
|
|
12705
|
-
import { useState as useState5, useEffect as useEffect8, useMemo as
|
|
12617
|
+
import { useState as useState5, useEffect as useEffect8, useMemo as useMemo8, useCallback as useCallback7 } from "react";
|
|
12706
12618
|
import { PencilIcon as PencilIcon3, CheckIcon as CheckIcon5, CopyIcon as CopyIcon4 } from "lucide-react";
|
|
12707
12619
|
import { get as lodashGet5 } from "lodash";
|
|
12708
12620
|
import { jsx as jsx33, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
@@ -12713,7 +12625,7 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
12713
12625
|
const [contentInputValue, setContentInputValue] = useState5("");
|
|
12714
12626
|
const { href, setHref, copyHref } = useHref();
|
|
12715
12627
|
const { focusIdx, template, updateElement } = useEditorStore();
|
|
12716
|
-
const element =
|
|
12628
|
+
const element = useMemo8(() => {
|
|
12717
12629
|
if (!focusIdx || !template) return null;
|
|
12718
12630
|
const path = focusIdx.startsWith("content.") ? focusIdx.replace("content.", "content[0].").replace(/\.?\[(\d+)\]/g, "[$1]") : focusIdx;
|
|
12719
12631
|
return lodashGet5(template, path);
|
|
@@ -12725,12 +12637,12 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
12725
12637
|
setContentInputValue(content);
|
|
12726
12638
|
}
|
|
12727
12639
|
}, [isOpen, href, content]);
|
|
12728
|
-
const handleCopy =
|
|
12640
|
+
const handleCopy = useCallback7(async () => {
|
|
12729
12641
|
await copyHref();
|
|
12730
12642
|
setShowCopied(true);
|
|
12731
12643
|
setTimeout(() => setShowCopied(false), 2e3);
|
|
12732
12644
|
}, [copyHref]);
|
|
12733
|
-
const handleDone =
|
|
12645
|
+
const handleDone = useCallback7(() => {
|
|
12734
12646
|
setHref(normalizeWebsiteUrl(hrefInputValue));
|
|
12735
12647
|
if (focusIdx && element) {
|
|
12736
12648
|
updateElement(focusIdx, {
|
|
@@ -12826,11 +12738,11 @@ var SocialItemMenu = ({ hasHref }) => {
|
|
|
12826
12738
|
};
|
|
12827
12739
|
|
|
12828
12740
|
// src/core/editor/hooks/use-alt.ts
|
|
12829
|
-
import { useMemo as
|
|
12741
|
+
import { useMemo as useMemo9, useCallback as useCallback8 } from "react";
|
|
12830
12742
|
import { get as lodashGet6 } from "lodash";
|
|
12831
12743
|
var useAlt = () => {
|
|
12832
12744
|
const { focusIdx, updateElement, template } = useEditorStore();
|
|
12833
|
-
const { element, alt } =
|
|
12745
|
+
const { element, alt } = useMemo9(() => {
|
|
12834
12746
|
if (!focusIdx || !template) {
|
|
12835
12747
|
return { element: null, alt: "" };
|
|
12836
12748
|
}
|
|
@@ -12841,13 +12753,13 @@ var useAlt = () => {
|
|
|
12841
12753
|
alt: el?.attributes?.alt || ""
|
|
12842
12754
|
};
|
|
12843
12755
|
}, [focusIdx, template]);
|
|
12844
|
-
const setAlt =
|
|
12756
|
+
const setAlt = useCallback8((text2) => {
|
|
12845
12757
|
if (!focusIdx || !element) return;
|
|
12846
12758
|
updateElement(focusIdx, {
|
|
12847
12759
|
attributes: { ...element.attributes, alt: text2 }
|
|
12848
12760
|
});
|
|
12849
12761
|
}, [focusIdx, element, updateElement]);
|
|
12850
|
-
const clearAlt =
|
|
12762
|
+
const clearAlt = useCallback8(() => {
|
|
12851
12763
|
if (!focusIdx || !element) return;
|
|
12852
12764
|
updateElement(focusIdx, {
|
|
12853
12765
|
attributes: { ...element.attributes, alt: "" }
|
|
@@ -12961,7 +12873,7 @@ var DividerFloat = () => {
|
|
|
12961
12873
|
// src/core/editor/components/element-gear/image/float.tsx
|
|
12962
12874
|
import { Accessibility as Accessibility2, CheckIcon as CheckIcon6, MoreHorizontalIcon as MoreHorizontalIcon5, Proportions } from "lucide-react";
|
|
12963
12875
|
import lodashGet7 from "lodash/get";
|
|
12964
|
-
import { useState as useState7, useEffect as useEffect10, useMemo as
|
|
12876
|
+
import { useState as useState7, useEffect as useEffect10, useMemo as useMemo10, useCallback as useCallback9 } from "react";
|
|
12965
12877
|
import { Fragment as Fragment13, jsx as jsx36, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
12966
12878
|
var ImageFloat = () => {
|
|
12967
12879
|
const { href, hasHref } = useHref();
|
|
@@ -12970,7 +12882,7 @@ var ImageFloat = () => {
|
|
|
12970
12882
|
const [showMoreView, setShowMoreView] = useState7(null);
|
|
12971
12883
|
const [dropdownOpen, setDropdownOpen] = useState7(false);
|
|
12972
12884
|
const [altInputValue, setAltInputValue] = useState7("");
|
|
12973
|
-
const { element, isFluidOnMobile } =
|
|
12885
|
+
const { element, isFluidOnMobile } = useMemo10(() => {
|
|
12974
12886
|
if (!focusIdx || !template) return { element: null, isFluidOnMobile: false };
|
|
12975
12887
|
const path = focusIdx.startsWith("content.") ? focusIdx.replace("content.", "content[0].").replace(/\.\[(\d+)\]/g, "[$1]") : focusIdx;
|
|
12976
12888
|
const el = lodashGet7(template, path);
|
|
@@ -12979,7 +12891,7 @@ var ImageFloat = () => {
|
|
|
12979
12891
|
isFluidOnMobile: el?.attributes?.["fluid-on-mobile"] === "true"
|
|
12980
12892
|
};
|
|
12981
12893
|
}, [focusIdx, template]);
|
|
12982
|
-
const toggleFluidOnMobile =
|
|
12894
|
+
const toggleFluidOnMobile = useCallback9(() => {
|
|
12983
12895
|
if (!focusIdx || !element) return;
|
|
12984
12896
|
const newAttributes = { ...element.attributes };
|
|
12985
12897
|
if (isFluidOnMobile) {
|
|
@@ -13338,7 +13250,7 @@ var ElementFloat = ({ getReferenceRect, focusIdx, elementType }) => {
|
|
|
13338
13250
|
);
|
|
13339
13251
|
};
|
|
13340
13252
|
var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
13341
|
-
const virtualReference =
|
|
13253
|
+
const virtualReference = useMemo11(() => ({
|
|
13342
13254
|
getBoundingClientRect: () => {
|
|
13343
13255
|
const rect = getReferenceRect();
|
|
13344
13256
|
if (!rect) {
|
|
@@ -13377,14 +13289,14 @@ var ElementFloatContent = ({ getReferenceRect, FloatComponent }) => {
|
|
|
13377
13289
|
};
|
|
13378
13290
|
|
|
13379
13291
|
// src/core/editor/components/scaling/divider-scale.tsx
|
|
13380
|
-
import { useMemo as
|
|
13292
|
+
import { useMemo as useMemo12, useEffect as useEffect13, useState as useState9, useRef as useRef5, useCallback as useCallback11 } from "react";
|
|
13381
13293
|
import { useFloating as useFloating5, offset as offset5, autoUpdate as autoUpdate4 } from "@floating-ui/react";
|
|
13382
13294
|
import { jsx as jsx42, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
13383
13295
|
var DividerScale = ({ getReferenceRect }) => {
|
|
13384
13296
|
const [dimensions, setDimensions] = useState9({ width: 0, height: 0 });
|
|
13385
13297
|
const [activeSide, setActiveSide] = useState9(null);
|
|
13386
13298
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13387
|
-
const { currentWidth, currentAlign } =
|
|
13299
|
+
const { currentWidth, currentAlign } = useMemo12(() => {
|
|
13388
13300
|
if (!focusIdx || !template) return { currentWidth: 100, currentAlign: "center" };
|
|
13389
13301
|
const element = getValueByIdx(template, focusIdx);
|
|
13390
13302
|
const rawWidth = element?.attributes?.width;
|
|
@@ -13394,12 +13306,12 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13394
13306
|
return { currentWidth: width, currentAlign: align };
|
|
13395
13307
|
}, [focusIdx, template]);
|
|
13396
13308
|
const dragRef = useRef5(null);
|
|
13397
|
-
const getContainerWidth =
|
|
13309
|
+
const getContainerWidth = useCallback11(() => {
|
|
13398
13310
|
const rect = getReferenceRect();
|
|
13399
13311
|
if (!rect || currentWidth <= 0) return null;
|
|
13400
13312
|
return rect.width / (currentWidth / 100);
|
|
13401
13313
|
}, [getReferenceRect, currentWidth]);
|
|
13402
|
-
const handlePointerDown =
|
|
13314
|
+
const handlePointerDown = useCallback11((e, side) => {
|
|
13403
13315
|
e.preventDefault();
|
|
13404
13316
|
e.stopPropagation();
|
|
13405
13317
|
const containerWidth = getContainerWidth();
|
|
@@ -13417,7 +13329,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13417
13329
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13418
13330
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13419
13331
|
}, [getContainerWidth, currentWidth, currentAlign, setIsScaling]);
|
|
13420
|
-
const handlePointerMove =
|
|
13332
|
+
const handlePointerMove = useCallback11((e) => {
|
|
13421
13333
|
if (!dragRef.current) return;
|
|
13422
13334
|
const { startX, startWidth, containerWidth, side, align } = dragRef.current;
|
|
13423
13335
|
const deltaX = e.clientX - startX;
|
|
@@ -13437,7 +13349,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13437
13349
|
}
|
|
13438
13350
|
});
|
|
13439
13351
|
}, []);
|
|
13440
|
-
const handlePointerUp =
|
|
13352
|
+
const handlePointerUp = useCallback11(() => {
|
|
13441
13353
|
setActiveSide(null);
|
|
13442
13354
|
setIsScaling(false);
|
|
13443
13355
|
dragRef.current = null;
|
|
@@ -13450,7 +13362,7 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13450
13362
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13451
13363
|
};
|
|
13452
13364
|
}, [handlePointerMove, handlePointerUp]);
|
|
13453
|
-
const virtualReference =
|
|
13365
|
+
const virtualReference = useMemo12(() => ({
|
|
13454
13366
|
getBoundingClientRect: () => {
|
|
13455
13367
|
const rect = getReferenceRect();
|
|
13456
13368
|
if (!rect) {
|
|
@@ -13524,14 +13436,14 @@ var DividerScale = ({ getReferenceRect }) => {
|
|
|
13524
13436
|
};
|
|
13525
13437
|
|
|
13526
13438
|
// src/core/editor/components/scaling/button-scale.tsx
|
|
13527
|
-
import { useMemo as
|
|
13439
|
+
import { useMemo as useMemo13, useEffect as useEffect14, useState as useState10, useRef as useRef6, useCallback as useCallback12 } from "react";
|
|
13528
13440
|
import { useFloating as useFloating6, offset as offset6, autoUpdate as autoUpdate5 } from "@floating-ui/react";
|
|
13529
13441
|
import { jsx as jsx43, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
13530
13442
|
var ButtonScale = ({ getReferenceRect }) => {
|
|
13531
13443
|
const [dimensions, setDimensions] = useState10({ width: 0, height: 0 });
|
|
13532
13444
|
const [activeSide, setActiveSide] = useState10(null);
|
|
13533
13445
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13534
|
-
const { currentWidth, currentHeight, currentAlign } =
|
|
13446
|
+
const { currentWidth, currentHeight, currentAlign } = useMemo13(() => {
|
|
13535
13447
|
if (!focusIdx || !template) {
|
|
13536
13448
|
return { currentWidth: 24, currentHeight: 44, currentAlign: "center" };
|
|
13537
13449
|
}
|
|
@@ -13546,12 +13458,12 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13546
13458
|
return { currentWidth: width, currentHeight: height, currentAlign: align };
|
|
13547
13459
|
}, [focusIdx, template]);
|
|
13548
13460
|
const dragRef = useRef6(null);
|
|
13549
|
-
const getContainerWidth =
|
|
13461
|
+
const getContainerWidth = useCallback12(() => {
|
|
13550
13462
|
const rect = getReferenceRect();
|
|
13551
13463
|
if (!rect || currentWidth <= 0) return null;
|
|
13552
13464
|
return rect.width / (currentWidth / 100);
|
|
13553
13465
|
}, [getReferenceRect, currentWidth]);
|
|
13554
|
-
const handlePointerDown =
|
|
13466
|
+
const handlePointerDown = useCallback12((e, side) => {
|
|
13555
13467
|
e.preventDefault();
|
|
13556
13468
|
e.stopPropagation();
|
|
13557
13469
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -13573,7 +13485,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13573
13485
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13574
13486
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13575
13487
|
}, [getContainerWidth, currentWidth, currentHeight, currentAlign, setIsScaling]);
|
|
13576
|
-
const handlePointerMove =
|
|
13488
|
+
const handlePointerMove = useCallback12((e) => {
|
|
13577
13489
|
if (!dragRef.current) return;
|
|
13578
13490
|
const { startX, startY, startWidth, startHeight, containerWidth, side, align } = dragRef.current;
|
|
13579
13491
|
const state = useEditorStore.getState();
|
|
@@ -13605,7 +13517,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13605
13517
|
});
|
|
13606
13518
|
}
|
|
13607
13519
|
}, []);
|
|
13608
|
-
const handlePointerUp =
|
|
13520
|
+
const handlePointerUp = useCallback12(() => {
|
|
13609
13521
|
setActiveSide(null);
|
|
13610
13522
|
setIsScaling(false);
|
|
13611
13523
|
dragRef.current = null;
|
|
@@ -13618,7 +13530,7 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13618
13530
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13619
13531
|
};
|
|
13620
13532
|
}, [handlePointerMove, handlePointerUp]);
|
|
13621
|
-
const virtualReference =
|
|
13533
|
+
const virtualReference = useMemo13(() => ({
|
|
13622
13534
|
getBoundingClientRect: () => {
|
|
13623
13535
|
const rect = getReferenceRect();
|
|
13624
13536
|
if (!rect) {
|
|
@@ -13708,14 +13620,14 @@ var ButtonScale = ({ getReferenceRect }) => {
|
|
|
13708
13620
|
};
|
|
13709
13621
|
|
|
13710
13622
|
// src/core/editor/components/scaling/image-scale.tsx
|
|
13711
|
-
import { useMemo as
|
|
13623
|
+
import { useMemo as useMemo14, useEffect as useEffect15, useState as useState11, useRef as useRef7, useCallback as useCallback13 } from "react";
|
|
13712
13624
|
import { useFloating as useFloating7, offset as offset7, autoUpdate as autoUpdate6 } from "@floating-ui/react";
|
|
13713
13625
|
import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
13714
13626
|
var ImageScale = ({ getReferenceRect }) => {
|
|
13715
13627
|
const [dimensions, setDimensions] = useState11({ width: 0, height: 0 });
|
|
13716
13628
|
const [activeSide, setActiveSide] = useState11(null);
|
|
13717
13629
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13718
|
-
const { currentWidth, currentHeight, currentAlign } =
|
|
13630
|
+
const { currentWidth, currentHeight, currentAlign } = useMemo14(() => {
|
|
13719
13631
|
if (!focusIdx || !template) {
|
|
13720
13632
|
return { currentWidth: 0, currentHeight: 0, currentAlign: "center" };
|
|
13721
13633
|
}
|
|
@@ -13730,7 +13642,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13730
13642
|
return { currentWidth: width, currentHeight: height, currentAlign: align };
|
|
13731
13643
|
}, [focusIdx, template]);
|
|
13732
13644
|
const dragRef = useRef7(null);
|
|
13733
|
-
const handlePointerDown =
|
|
13645
|
+
const handlePointerDown = useCallback13((e, side) => {
|
|
13734
13646
|
e.preventDefault();
|
|
13735
13647
|
e.stopPropagation();
|
|
13736
13648
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -13753,7 +13665,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13753
13665
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13754
13666
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13755
13667
|
}, [getReferenceRect, currentWidth, currentHeight, currentAlign, setIsScaling]);
|
|
13756
|
-
const handlePointerMove =
|
|
13668
|
+
const handlePointerMove = useCallback13((e) => {
|
|
13757
13669
|
if (!dragRef.current) return;
|
|
13758
13670
|
const { startX, startY, startWidth, startHeight, side, align } = dragRef.current;
|
|
13759
13671
|
const state = useEditorStore.getState();
|
|
@@ -13784,7 +13696,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13784
13696
|
});
|
|
13785
13697
|
}
|
|
13786
13698
|
}, []);
|
|
13787
|
-
const handlePointerUp =
|
|
13699
|
+
const handlePointerUp = useCallback13(() => {
|
|
13788
13700
|
setActiveSide(null);
|
|
13789
13701
|
setIsScaling(false);
|
|
13790
13702
|
dragRef.current = null;
|
|
@@ -13797,7 +13709,7 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13797
13709
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13798
13710
|
};
|
|
13799
13711
|
}, [handlePointerMove, handlePointerUp]);
|
|
13800
|
-
const virtualReference =
|
|
13712
|
+
const virtualReference = useMemo14(() => ({
|
|
13801
13713
|
getBoundingClientRect: () => {
|
|
13802
13714
|
const rect = getReferenceRect();
|
|
13803
13715
|
if (!rect) {
|
|
@@ -13887,14 +13799,14 @@ var ImageScale = ({ getReferenceRect }) => {
|
|
|
13887
13799
|
};
|
|
13888
13800
|
|
|
13889
13801
|
// src/core/editor/components/scaling/spacer-scale.tsx
|
|
13890
|
-
import { useMemo as
|
|
13802
|
+
import { useMemo as useMemo15, useEffect as useEffect16, useState as useState12, useRef as useRef8, useCallback as useCallback14 } from "react";
|
|
13891
13803
|
import { useFloating as useFloating8, offset as offset8, autoUpdate as autoUpdate7 } from "@floating-ui/react";
|
|
13892
13804
|
import { jsx as jsx45, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
13893
13805
|
var SpacerScale = ({ getReferenceRect }) => {
|
|
13894
13806
|
const [dimensions, setDimensions] = useState12({ width: 0, height: 0 });
|
|
13895
13807
|
const [activeSide, setActiveSide] = useState12(null);
|
|
13896
13808
|
const { focusIdx, template, setIsScaling } = useEditorStore();
|
|
13897
|
-
const currentHeight =
|
|
13809
|
+
const currentHeight = useMemo15(() => {
|
|
13898
13810
|
if (!focusIdx || !template) return 12;
|
|
13899
13811
|
const element = getValueByIdx(template, focusIdx);
|
|
13900
13812
|
const rawHeight = element?.attributes?.height;
|
|
@@ -13902,7 +13814,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13902
13814
|
return isNaN(parsedHeight) ? 12 : Math.max(12, Math.min(200, parsedHeight));
|
|
13903
13815
|
}, [focusIdx, template]);
|
|
13904
13816
|
const dragRef = useRef8(null);
|
|
13905
|
-
const handlePointerDown =
|
|
13817
|
+
const handlePointerDown = useCallback14((e, side) => {
|
|
13906
13818
|
e.preventDefault();
|
|
13907
13819
|
e.stopPropagation();
|
|
13908
13820
|
if (document.activeElement instanceof HTMLElement) {
|
|
@@ -13918,7 +13830,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13918
13830
|
document.addEventListener("pointermove", handlePointerMove);
|
|
13919
13831
|
document.addEventListener("pointerup", handlePointerUp);
|
|
13920
13832
|
}, [currentHeight, setIsScaling]);
|
|
13921
|
-
const handlePointerMove =
|
|
13833
|
+
const handlePointerMove = useCallback14((e) => {
|
|
13922
13834
|
if (!dragRef.current) return;
|
|
13923
13835
|
const { startY, startHeight, side } = dragRef.current;
|
|
13924
13836
|
const state = useEditorStore.getState();
|
|
@@ -13936,7 +13848,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13936
13848
|
}
|
|
13937
13849
|
});
|
|
13938
13850
|
}, []);
|
|
13939
|
-
const handlePointerUp =
|
|
13851
|
+
const handlePointerUp = useCallback14(() => {
|
|
13940
13852
|
setActiveSide(null);
|
|
13941
13853
|
setIsScaling(false);
|
|
13942
13854
|
dragRef.current = null;
|
|
@@ -13949,7 +13861,7 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
13949
13861
|
document.removeEventListener("pointerup", handlePointerUp);
|
|
13950
13862
|
};
|
|
13951
13863
|
}, [handlePointerMove, handlePointerUp]);
|
|
13952
|
-
const virtualReference =
|
|
13864
|
+
const virtualReference = useMemo15(() => ({
|
|
13953
13865
|
getBoundingClientRect: () => {
|
|
13954
13866
|
const rect = getReferenceRect();
|
|
13955
13867
|
if (!rect) {
|
|
@@ -14023,19 +13935,19 @@ var SpacerScale = ({ getReferenceRect }) => {
|
|
|
14023
13935
|
};
|
|
14024
13936
|
|
|
14025
13937
|
// src/core/editor/components/scaling/column-scale.tsx
|
|
14026
|
-
import { useMemo as
|
|
13938
|
+
import { useMemo as useMemo16, useEffect as useEffect17, useState as useState13, useRef as useRef9, useCallback as useCallback15 } from "react";
|
|
14027
13939
|
import { Fragment as Fragment17, jsx as jsx46 } from "react/jsx-runtime";
|
|
14028
13940
|
var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
14029
13941
|
const [activeDivider, setActiveDivider] = useState13(null);
|
|
14030
13942
|
const [columnRects, setColumnRects] = useState13([]);
|
|
14031
13943
|
const { template, setIsScaling, setFocusIdx, stopTextEditing } = useEditorStore();
|
|
14032
|
-
const columnWidths =
|
|
13944
|
+
const columnWidths = useMemo16(() => {
|
|
14033
13945
|
if (!template) return [];
|
|
14034
13946
|
const sectionColumn = getValueByIdx(template, sectionColumnIdx);
|
|
14035
13947
|
return sectionColumn?.data?.value?.columnWidths || [];
|
|
14036
13948
|
}, [template, sectionColumnIdx]);
|
|
14037
13949
|
const dragRef = useRef9(null);
|
|
14038
|
-
const updateColumnRects =
|
|
13950
|
+
const updateColumnRects = useCallback15(() => {
|
|
14039
13951
|
if (!shadowRoot) return;
|
|
14040
13952
|
const allColumns = shadowRoot.querySelectorAll(".node-type-column");
|
|
14041
13953
|
const matchingColumns = [];
|
|
@@ -14080,7 +13992,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14080
13992
|
const parseWidth = (width) => {
|
|
14081
13993
|
return parseFloat(width.replace("%", ""));
|
|
14082
13994
|
};
|
|
14083
|
-
const handlePointerDown =
|
|
13995
|
+
const handlePointerDown = useCallback15((e, dividerIndex) => {
|
|
14084
13996
|
e.preventDefault();
|
|
14085
13997
|
e.stopPropagation();
|
|
14086
13998
|
stopTextEditing();
|
|
@@ -14106,7 +14018,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14106
14018
|
document.addEventListener("pointermove", handlePointerMove);
|
|
14107
14019
|
document.addEventListener("pointerup", handlePointerUp);
|
|
14108
14020
|
}, [columnRects, columnWidths, setIsScaling]);
|
|
14109
|
-
const handlePointerMove =
|
|
14021
|
+
const handlePointerMove = useCallback15((e) => {
|
|
14110
14022
|
if (!dragRef.current) return;
|
|
14111
14023
|
const { startX, leftColIndex, rightColIndex, startLeftWidth, startRightWidth, sectionWidth, allWidths } = dragRef.current;
|
|
14112
14024
|
const deltaX = e.clientX - startX;
|
|
@@ -14140,7 +14052,7 @@ var ColumnScale = ({ sectionColumnIdx, shadowRoot }) => {
|
|
|
14140
14052
|
}
|
|
14141
14053
|
});
|
|
14142
14054
|
}, [sectionColumnIdx]);
|
|
14143
|
-
const handlePointerUp =
|
|
14055
|
+
const handlePointerUp = useCallback15(() => {
|
|
14144
14056
|
setActiveDivider(null);
|
|
14145
14057
|
setIsScaling(false);
|
|
14146
14058
|
dragRef.current = null;
|
|
@@ -14227,7 +14139,7 @@ function Spinner({ className, ...props }) {
|
|
|
14227
14139
|
import { EyeIcon } from "lucide-react";
|
|
14228
14140
|
|
|
14229
14141
|
// src/render/useMjmlCompiler.ts
|
|
14230
|
-
import { useState as useState14, useCallback as
|
|
14142
|
+
import { useState as useState14, useCallback as useCallback16 } from "react";
|
|
14231
14143
|
async function compileMjml(mjml) {
|
|
14232
14144
|
console.log("Compiling MJML", mjml);
|
|
14233
14145
|
const response = await fetch("/api/mrender", {
|
|
@@ -14392,6 +14304,8 @@ function Editor({ setEditorLoading }) {
|
|
|
14392
14304
|
const dataTransfer = useEditorStore((state) => state.dataTransfer);
|
|
14393
14305
|
const textEditing = useEditorStore((state) => state.textEditing);
|
|
14394
14306
|
const isScaling = useEditorStore((state) => state.isScaling);
|
|
14307
|
+
const canvasBackgroundColor = useEditorStore((s) => s.template?.content?.[0]?.attributes?.["background-color"]) || "#f5f5f5";
|
|
14308
|
+
const renderSyncNeeded = useEditorStore((state) => state.renderSyncNeeded);
|
|
14395
14309
|
const setFocusIdx = useEditorStore((state) => state.setFocusIdx);
|
|
14396
14310
|
const setHoverIdx = useEditorStore((state) => state.setHoverIdx);
|
|
14397
14311
|
const updateElementContent = useEditorStore((state) => state.updateElementContent);
|
|
@@ -14430,12 +14344,17 @@ function Editor({ setEditorLoading }) {
|
|
|
14430
14344
|
const companyFooterCacheRef = useRef11(void 0);
|
|
14431
14345
|
const lastSyncedTemplateRef = useRef11(null);
|
|
14432
14346
|
const prevTextEditingIdxRef = useRef11(null);
|
|
14347
|
+
const lastRenderSyncNeededRef = useRef11(0);
|
|
14433
14348
|
useEffect20(() => {
|
|
14434
14349
|
const currentIdx = textEditing?.idx ?? null;
|
|
14435
14350
|
const prevIdx = prevTextEditingIdxRef.current;
|
|
14436
14351
|
const switchedTarget = currentIdx !== null && prevIdx !== null && currentIdx !== prevIdx;
|
|
14437
14352
|
prevTextEditingIdxRef.current = currentIdx;
|
|
14438
|
-
|
|
14353
|
+
const forceSync = renderSyncNeeded > lastRenderSyncNeededRef.current;
|
|
14354
|
+
if (forceSync) {
|
|
14355
|
+
lastRenderSyncNeededRef.current = renderSyncNeeded;
|
|
14356
|
+
}
|
|
14357
|
+
if (forceSync || !isEditing && (!textEditing || switchedTarget)) {
|
|
14439
14358
|
if (template === lastSyncedTemplateRef.current) {
|
|
14440
14359
|
return;
|
|
14441
14360
|
}
|
|
@@ -14444,7 +14363,7 @@ function Editor({ setEditorLoading }) {
|
|
|
14444
14363
|
}
|
|
14445
14364
|
lastSyncedTemplateRef.current = template;
|
|
14446
14365
|
}
|
|
14447
|
-
}, [template, renderData, isEditing, textEditing]);
|
|
14366
|
+
}, [template, renderData, isEditing, textEditing, renderSyncNeeded]);
|
|
14448
14367
|
useEffect20(() => {
|
|
14449
14368
|
if (renderData && setEditorLoading) {
|
|
14450
14369
|
setEditorLoading(false);
|
|
@@ -14544,13 +14463,13 @@ function Editor({ setEditorLoading }) {
|
|
|
14544
14463
|
};
|
|
14545
14464
|
convertMjml();
|
|
14546
14465
|
}, [renderData]);
|
|
14547
|
-
const debouncedUpdateContent =
|
|
14466
|
+
const debouncedUpdateContent = useMemo17(
|
|
14548
14467
|
() => debounce((contentIdx, content) => {
|
|
14549
14468
|
updateElementContent(contentIdx, content);
|
|
14550
14469
|
}, 200),
|
|
14551
14470
|
[updateElementContent]
|
|
14552
14471
|
);
|
|
14553
|
-
const handleElementClick =
|
|
14472
|
+
const handleElementClick = useCallback17(
|
|
14554
14473
|
(idx) => {
|
|
14555
14474
|
if (isInsideCompanyFooter(idx, template)) {
|
|
14556
14475
|
return;
|
|
@@ -14563,7 +14482,7 @@ function Editor({ setEditorLoading }) {
|
|
|
14563
14482
|
},
|
|
14564
14483
|
[setFocusIdx, template]
|
|
14565
14484
|
);
|
|
14566
|
-
const handleElementHover =
|
|
14485
|
+
const handleElementHover = useCallback17(
|
|
14567
14486
|
(idx) => {
|
|
14568
14487
|
if (!isDragging) {
|
|
14569
14488
|
if (idx) {
|
|
@@ -14577,19 +14496,19 @@ function Editor({ setEditorLoading }) {
|
|
|
14577
14496
|
},
|
|
14578
14497
|
[isDragging, setHoverIdx, template]
|
|
14579
14498
|
);
|
|
14580
|
-
const handleContentInput =
|
|
14499
|
+
const handleContentInput = useCallback17(
|
|
14581
14500
|
(contentIdx, content) => {
|
|
14582
14501
|
debouncedUpdateContent(contentIdx, content);
|
|
14583
14502
|
},
|
|
14584
14503
|
[debouncedUpdateContent]
|
|
14585
14504
|
);
|
|
14586
|
-
const handleEditingStart =
|
|
14505
|
+
const handleEditingStart = useCallback17(() => {
|
|
14587
14506
|
setIsEditing(true);
|
|
14588
14507
|
}, []);
|
|
14589
|
-
const handleEditingEnd =
|
|
14508
|
+
const handleEditingEnd = useCallback17(() => {
|
|
14590
14509
|
setIsEditing(false);
|
|
14591
14510
|
}, []);
|
|
14592
|
-
const handleSlashCommand =
|
|
14511
|
+
const handleSlashCommand = useCallback17(
|
|
14593
14512
|
(cursorRect) => {
|
|
14594
14513
|
setSlashCommand({
|
|
14595
14514
|
isActive: true,
|
|
@@ -14604,10 +14523,10 @@ function Editor({ setEditorLoading }) {
|
|
|
14604
14523
|
},
|
|
14605
14524
|
[setSlashCommand]
|
|
14606
14525
|
);
|
|
14607
|
-
const handleSlashCommandClose =
|
|
14526
|
+
const handleSlashCommandClose = useCallback17(() => {
|
|
14608
14527
|
clearSlashCommand();
|
|
14609
14528
|
}, [clearSlashCommand]);
|
|
14610
|
-
const handleTextEditStart =
|
|
14529
|
+
const handleTextEditStart = useCallback17(
|
|
14611
14530
|
(idx, initialWidth, initialHeight, clickX, clickY, content, styles) => {
|
|
14612
14531
|
const getReferenceRect2 = () => {
|
|
14613
14532
|
if (!shadowRootRef.current) return null;
|
|
@@ -14622,11 +14541,11 @@ function Editor({ setEditorLoading }) {
|
|
|
14622
14541
|
},
|
|
14623
14542
|
[startTextEditing]
|
|
14624
14543
|
);
|
|
14625
|
-
const findParentSectionIdx =
|
|
14544
|
+
const findParentSectionIdx = useCallback17((idx) => {
|
|
14626
14545
|
const match = /^(content\.children\.\[\d+\])/.exec(idx);
|
|
14627
14546
|
return match ? match[1] : null;
|
|
14628
14547
|
}, []);
|
|
14629
|
-
const handleDragOver =
|
|
14548
|
+
const handleDragOver = useCallback17(
|
|
14630
14549
|
(_e, dragInfo) => {
|
|
14631
14550
|
const currentDataTransfer = useEditorStore.getState().dataTransfer;
|
|
14632
14551
|
if (!currentDataTransfer) return;
|
|
@@ -15037,7 +14956,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15037
14956
|
[findParentSectionIdx]
|
|
15038
14957
|
// Only dependency is the helper function
|
|
15039
14958
|
);
|
|
15040
|
-
const handleDrop =
|
|
14959
|
+
const handleDrop = useCallback17(
|
|
15041
14960
|
(_e, _dragInfo) => {
|
|
15042
14961
|
const currentDataTransfer = useEditorStore.getState().dataTransfer;
|
|
15043
14962
|
if (!currentDataTransfer) return;
|
|
@@ -15176,7 +15095,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15176
15095
|
},
|
|
15177
15096
|
[addElement, addElementInNewSection, moveElement, moveElementToNewSection, splitTextAndInsertElement, splitSectionAndInsertElement, setIsDragging, setIsDragButtonHovered, setDataTransfer, setHoverIdx]
|
|
15178
15097
|
);
|
|
15179
|
-
const handleDragLeave =
|
|
15098
|
+
const handleDragLeave = useCallback17(() => {
|
|
15180
15099
|
setDropIndicator(null);
|
|
15181
15100
|
setDropTargetIdx(null);
|
|
15182
15101
|
dragParentIdxRef.current = null;
|
|
@@ -15192,13 +15111,13 @@ function Editor({ setEditorLoading }) {
|
|
|
15192
15111
|
sectionElementCacheRef.current.clear();
|
|
15193
15112
|
sectionRectCacheRef.current.clear();
|
|
15194
15113
|
}, []);
|
|
15195
|
-
const handleShadowRootRef =
|
|
15114
|
+
const handleShadowRootRef = useCallback17((shadowRoot) => {
|
|
15196
15115
|
shadowRootRef.current = shadowRoot;
|
|
15197
15116
|
}, []);
|
|
15198
|
-
const handleSelectionRectChange =
|
|
15117
|
+
const handleSelectionRectChange = useCallback17((rect) => {
|
|
15199
15118
|
setHasSelectedElement(rect !== null);
|
|
15200
15119
|
}, []);
|
|
15201
|
-
const getReferenceRect =
|
|
15120
|
+
const getReferenceRect = useCallback17(() => {
|
|
15202
15121
|
if (!shadowRootRef.current || !focusIdx) return null;
|
|
15203
15122
|
const selectedEl = shadowRootRef.current.querySelector(
|
|
15204
15123
|
`.node-idx-${CSS.escape(focusIdx)}`
|
|
@@ -15226,7 +15145,7 @@ function Editor({ setEditorLoading }) {
|
|
|
15226
15145
|
}, [focusIdx]);
|
|
15227
15146
|
const selectedElement = focusIdx && renderData ? getValueByIdx(renderData, focusIdx) : null;
|
|
15228
15147
|
const canDragSelectedElement = selectedElement && selectedElement.type !== "column" && !(focusIdx && renderData && isInsideCompanyFooter(focusIdx, renderData));
|
|
15229
|
-
const showCompanyFooter =
|
|
15148
|
+
const showCompanyFooter = useMemo17(
|
|
15230
15149
|
() => template.content[0]?.data?.value?.showCompanyFooter ?? true,
|
|
15231
15150
|
[template.content[0]?.data?.value?.showCompanyFooter]
|
|
15232
15151
|
);
|
|
@@ -15244,43 +15163,45 @@ function Editor({ setEditorLoading }) {
|
|
|
15244
15163
|
justifyContent: "center"
|
|
15245
15164
|
},
|
|
15246
15165
|
children: [
|
|
15247
|
-
/* @__PURE__ */
|
|
15166
|
+
/* @__PURE__ */ jsxs31(
|
|
15248
15167
|
"div",
|
|
15249
15168
|
{
|
|
15250
|
-
className: `editor-container rounded-b-[12px]
|
|
15169
|
+
className: `editor-container rounded-b-[12px] max-w-[626px] w-[626px] [@media(max-width:950px)]:max-w-[100%] [@media(max-width:950px)]:w-[100%] `,
|
|
15251
15170
|
style: {
|
|
15252
|
-
width: "626px",
|
|
15253
15171
|
height: "100%",
|
|
15254
|
-
backgroundColor:
|
|
15172
|
+
backgroundColor: canvasBackgroundColor,
|
|
15255
15173
|
overflow: "auto"
|
|
15256
15174
|
},
|
|
15257
|
-
children:
|
|
15258
|
-
|
|
15259
|
-
|
|
15260
|
-
|
|
15261
|
-
|
|
15262
|
-
|
|
15263
|
-
|
|
15264
|
-
|
|
15265
|
-
|
|
15266
|
-
|
|
15267
|
-
|
|
15268
|
-
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15274
|
-
|
|
15275
|
-
|
|
15276
|
-
|
|
15277
|
-
|
|
15278
|
-
|
|
15279
|
-
|
|
15280
|
-
|
|
15281
|
-
|
|
15282
|
-
|
|
15283
|
-
|
|
15175
|
+
children: [
|
|
15176
|
+
/* @__PURE__ */ jsx50("div", { className: "w-full h-[4px] bg-black opacity-10" }),
|
|
15177
|
+
/* @__PURE__ */ jsx50(
|
|
15178
|
+
ShadowDomRenderer,
|
|
15179
|
+
{
|
|
15180
|
+
html,
|
|
15181
|
+
focusIdx,
|
|
15182
|
+
hoverIdx,
|
|
15183
|
+
dropIndicator,
|
|
15184
|
+
dropTargetIdx,
|
|
15185
|
+
isDragging,
|
|
15186
|
+
isDragButtonHovered,
|
|
15187
|
+
textEditingIdx: textEditing?.idx || null,
|
|
15188
|
+
showCompanyFooter,
|
|
15189
|
+
onElementClick: handleElementClick,
|
|
15190
|
+
onElementHover: handleElementHover,
|
|
15191
|
+
onContentInput: handleContentInput,
|
|
15192
|
+
onEditingStart: handleEditingStart,
|
|
15193
|
+
onEditingEnd: handleEditingEnd,
|
|
15194
|
+
onDragOver: handleDragOver,
|
|
15195
|
+
onDrop: handleDrop,
|
|
15196
|
+
onDragLeave: handleDragLeave,
|
|
15197
|
+
onSelectionRectChange: handleSelectionRectChange,
|
|
15198
|
+
onShadowRootRef: handleShadowRootRef,
|
|
15199
|
+
onSlashCommand: handleSlashCommand,
|
|
15200
|
+
onSlashCommandClose: handleSlashCommandClose,
|
|
15201
|
+
onTextEditStart: handleTextEditStart
|
|
15202
|
+
}
|
|
15203
|
+
)
|
|
15204
|
+
]
|
|
15284
15205
|
}
|
|
15285
15206
|
),
|
|
15286
15207
|
/* @__PURE__ */ jsx50(ElementsSuggestions, {}),
|
|
@@ -15336,7 +15257,6 @@ export {
|
|
|
15336
15257
|
parsePrice,
|
|
15337
15258
|
json2mjml,
|
|
15338
15259
|
MAX_TEMPLATE_SIZE,
|
|
15339
|
-
MAX_PAID_LEVEL,
|
|
15340
15260
|
useEditorStore,
|
|
15341
15261
|
BUTTON_ALIGNMENTS,
|
|
15342
15262
|
ALIGNMENT_ICONS,
|
|
@@ -15355,7 +15275,6 @@ export {
|
|
|
15355
15275
|
MIN_LINE_HEIGHT,
|
|
15356
15276
|
MAX_LINE_HEIGHT,
|
|
15357
15277
|
LINE_HEIGHT_STEP,
|
|
15358
|
-
IMAGE_SELECTION_VALID_TYPES,
|
|
15359
15278
|
setupDragImage,
|
|
15360
15279
|
getElementDisplayName,
|
|
15361
15280
|
cn,
|