@jbpark/live-editor 4.3.0 → 4.4.0
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/README.ko.md +2 -7
- package/README.md +2 -7
- package/dist/{ast-BFbDWO-l.js → ast-dYb78955.js} +128 -38
- package/dist/ast-dYb78955.js.map +1 -0
- package/dist/{compile-0Dvp8zp5.js → compile-DDfk5P25.js} +3 -3
- package/dist/{compile-0Dvp8zp5.js.map → compile-DDfk5P25.js.map} +1 -1
- package/dist/{constants-CKvdqZtO.js → constants-h1JAgOeW.js} +4 -2
- package/dist/constants-h1JAgOeW.js.map +1 -0
- package/dist/{context-93X3gyfJ.js → context-DB5kW3qe.js} +2 -2
- package/dist/{context-93X3gyfJ.js.map → context-DB5kW3qe.js.map} +1 -1
- package/dist/{core-B3ruccKb.js → core-CRsAGpei.js} +2 -2
- package/dist/{core-B3ruccKb.js.map → core-CRsAGpei.js.map} +1 -1
- package/dist/{detect-typescript-5MV4mCM7.js → detect-typescript-CCj9ALXc.js} +2 -2
- package/dist/{detect-typescript-5MV4mCM7.js.map → detect-typescript-CCj9ALXc.js.map} +1 -1
- package/dist/dnd/index.d.ts +2 -2
- package/dist/dnd/index.js +1 -1
- package/dist/{dnd-Z1KS16Fy.js → dnd-BE5ZizqX.js} +168 -44
- package/dist/dnd-BE5ZizqX.js.map +1 -0
- package/dist/{document-cEEdFERz.js → document-BDn_f08_.js} +42 -41
- package/dist/document-BDn_f08_.js.map +1 -0
- package/dist/editor/index.js +2 -2
- package/dist/{editor-DvMruljw.js → editor-DQ8Q--qR.js} +2 -2
- package/dist/{editor-DvMruljw.js.map → editor-DQ8Q--qR.js.map} +1 -1
- package/dist/{index-CtlUYnWq.d.ts → index-Dgh1JTX3.d.ts} +13 -4
- package/dist/{index-w3kLcCXl.d.ts → index-f7ijuNTa.d.ts} +17 -5
- package/dist/index.d.ts +4 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/preview/index.js +2 -2
- package/dist/{preview-C_UzpGWh.js → preview-BnaCEFsF.js} +2 -2
- package/dist/{preview-C_UzpGWh.js.map → preview-BnaCEFsF.js.map} +1 -1
- package/dist/provider/index.js +1 -1
- package/dist/{sections-GJQ63uEB.js → sections-CBVMO8Jl.js} +3 -3
- package/dist/{sections-GJQ63uEB.js.map → sections-CBVMO8Jl.js.map} +1 -1
- package/dist/{use-dynamic-tailwind-DpbjmATF.js → use-dynamic-tailwind-Bcipc1hL.js} +43 -2
- package/dist/use-dynamic-tailwind-Bcipc1hL.js.map +1 -0
- package/dist/utils/ast/index.d.ts +2 -2
- package/dist/utils/ast/index.js +3 -3
- package/dist/utils/index.js +4 -4
- package/package.json +6 -6
- package/dist/ast-BFbDWO-l.js.map +0 -1
- package/dist/constants-CKvdqZtO.js.map +0 -1
- package/dist/dnd-Z1KS16Fy.js.map +0 -1
- package/dist/document-cEEdFERz.js.map +0 -1
- package/dist/use-dynamic-tailwind-DpbjmATF.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as require_lib, _ as nanoid, c as inspectDocument, h as replaceIds, m as fillIdsFrom, n as createSectionPreviewCache, r as fillSectionIds, w as __toESM } from "./document-
|
|
2
|
-
import { c as RESERVED_BINDING_PROPERTIES, o as DRAGGABLE_ITEMS, r as DATA_ATTR, t as BINDING_PROP } from "./constants-
|
|
1
|
+
import { S as require_lib, _ as nanoid, c as inspectDocument, h as replaceIds, m as fillIdsFrom, n as createSectionPreviewCache, r as fillSectionIds, w as __toESM } from "./document-BDn_f08_.js";
|
|
2
|
+
import { c as RESERVED_BINDING_PROPERTIES, o as DRAGGABLE_ITEMS, r as DATA_ATTR, t as BINDING_PROP } from "./constants-h1JAgOeW.js";
|
|
3
3
|
import { i as usePreview } from "./states-Ci1AvoQ9.js";
|
|
4
|
-
import {
|
|
4
|
+
import { E as readNodeBindings, F as parseValue, M as extractObjectProperties, P as parseArrayExpression, S as getStructuredValue, _ as moveSelectedIndices, a as getChildrenSignatures, c as appendArrayItem, d as moveArrayItems, g as canStructurallyEditArray, h as updateArrayItemValue, i as updateAll, j as extractNodeValue, k as canLosslesslyEvaluateSource, l as duplicateArrayItems, m as updateArrayItemProperty, p as removeArrayItems, s as extract, t as validateBindingValue, u as moveArrayItem, v as findEditableChildren, y as getCurrentValue } from "./ast-dYb78955.js";
|
|
5
5
|
import { t as cn } from "./cn-CAnad2vL.js";
|
|
6
|
-
import { o as preloadScripts } from "./compile-
|
|
7
|
-
import { a as Frame, i as useStableModules, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-
|
|
8
|
-
import { t as Core } from "./core-
|
|
9
|
-
import { a as replaceSections, n as extractSections, r as generateSection } from "./sections-
|
|
6
|
+
import { o as preloadScripts } from "./compile-DDfk5P25.js";
|
|
7
|
+
import { a as Frame, i as useStableModules, n as useCompiledModule, t as useDynamicTailwind } from "./use-dynamic-tailwind-Bcipc1hL.js";
|
|
8
|
+
import { t as Core } from "./core-CRsAGpei.js";
|
|
9
|
+
import { a as replaceSections, n as extractSections, r as generateSection } from "./sections-CBVMO8Jl.js";
|
|
10
10
|
import { n as Error$1, t as ErrorBoundary } from "./boundary-B17cepvm.js";
|
|
11
11
|
import { Children, createContext, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
12
12
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -73,6 +73,21 @@ const pickElement = (section, overlay, x, y) => {
|
|
|
73
73
|
while (element && element !== section && !hasId(element)) element = element.parentElement ?? element.parentNode?.host ?? null;
|
|
74
74
|
return element === section ? null : element;
|
|
75
75
|
};
|
|
76
|
+
const findElementById = (section, id) => {
|
|
77
|
+
const selector = `[${DATA_ATTR.ID}="${CSS.escape(id)}"]`;
|
|
78
|
+
const roots = [section];
|
|
79
|
+
for (const root of roots) {
|
|
80
|
+
const found = root.querySelector(selector);
|
|
81
|
+
if (found) return found;
|
|
82
|
+
root.querySelectorAll("iframe").forEach((frame) => {
|
|
83
|
+
if (frame.contentDocument) roots.push(frame.contentDocument);
|
|
84
|
+
});
|
|
85
|
+
root.querySelectorAll("*").forEach((element) => {
|
|
86
|
+
if (element.shadowRoot) roots.push(element.shadowRoot);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
};
|
|
76
91
|
const viewportRect = (element) => {
|
|
77
92
|
const rect = element.getBoundingClientRect();
|
|
78
93
|
let x = rect.left;
|
|
@@ -204,13 +219,16 @@ const toPanelBindingData = (node, id, binding) => ({
|
|
|
204
219
|
value: getStructuredValue(node, binding.property, binding.type),
|
|
205
220
|
rawValue: getCurrentValue(node, binding.property),
|
|
206
221
|
...!canEditBindingValue(node, binding) && { canEditValue: false },
|
|
207
|
-
...isAttributeAbsent(node, binding) && { present: false }
|
|
222
|
+
...isAttributeAbsent(node, binding) && { present: false },
|
|
223
|
+
element: {
|
|
224
|
+
tagName: node.tagName || "element",
|
|
225
|
+
text: node.textContent.replace(/\s+/g, " ").trim()
|
|
226
|
+
}
|
|
208
227
|
});
|
|
209
228
|
const resolvePanelBindings = (node) => {
|
|
210
229
|
const id = readAttribute(node, "data-id");
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const parsed = node.bindings ?? parseBinding(bindingAttr);
|
|
230
|
+
if (!id) return null;
|
|
231
|
+
const parsed = readNodeBindings(node);
|
|
214
232
|
if (!parsed.length) return null;
|
|
215
233
|
return {
|
|
216
234
|
id,
|
|
@@ -638,8 +656,8 @@ const createPendingCommit = () => {
|
|
|
638
656
|
}
|
|
639
657
|
};
|
|
640
658
|
};
|
|
641
|
-
const bindingsInJSX = (source) => {
|
|
642
|
-
const nodes = extract(source);
|
|
659
|
+
const bindingsInJSX = (source, bindingOptions) => {
|
|
660
|
+
const nodes = extract(source, bindingOptions);
|
|
643
661
|
const container = nodes.find((n) => n.bindings?.some((b) => b.property === "children"));
|
|
644
662
|
if (container) return [container];
|
|
645
663
|
const bindings = [];
|
|
@@ -649,7 +667,7 @@ const bindingsInJSX = (source) => {
|
|
|
649
667
|
});
|
|
650
668
|
return bindings;
|
|
651
669
|
};
|
|
652
|
-
const parseSource = (value) => {
|
|
670
|
+
const parseSource = (value, bindingOptions) => {
|
|
653
671
|
const ast = parseArrayExpression(value);
|
|
654
672
|
if (!ast) return {
|
|
655
673
|
objectItems: [],
|
|
@@ -678,7 +696,7 @@ const parseSource = (value) => {
|
|
|
678
696
|
if (!import_lib.isObjectProperty(prop) || !import_lib.isIdentifier(prop.key) || !(import_lib.isJSXElement(prop.value) || import_lib.isJSXFragment(prop.value))) return;
|
|
679
697
|
const propertyName = prop.key.name;
|
|
680
698
|
try {
|
|
681
|
-
const found = bindingsInJSX(value.slice(prop.value.start, prop.value.end));
|
|
699
|
+
const found = bindingsInJSX(value.slice(prop.value.start, prop.value.end), bindingOptions);
|
|
682
700
|
if (found.length > 0) jsxBindings[propertyName] = found;
|
|
683
701
|
else jsxFallbacks[propertyName] = value.slice(prop.value.start, prop.value.end);
|
|
684
702
|
} catch (error) {
|
|
@@ -736,9 +754,9 @@ const removeIds = (ids, indices) => {
|
|
|
736
754
|
return ids.filter((_, index) => !indices.has(index));
|
|
737
755
|
};
|
|
738
756
|
const useDndItems = (value, { render, onChange, onNodeChange } = {}) => {
|
|
739
|
-
const {
|
|
757
|
+
const { reportError, bindingOptions } = useDndEditOptions();
|
|
758
|
+
const { objectItems, primitiveItems, parseError } = useMemo(() => parseSource(value, bindingOptions), [value, bindingOptions]);
|
|
740
759
|
const canEditStructure = useMemo(() => canStructurallyEditArray(value), [value]);
|
|
741
|
-
const { reportError } = useDndEditOptions();
|
|
742
760
|
const reportErrorRef = useRef(reportError);
|
|
743
761
|
useEffect(() => {
|
|
744
762
|
reportErrorRef.current = reportError;
|
|
@@ -1456,10 +1474,29 @@ const groupBindingsById = (bindings) => {
|
|
|
1456
1474
|
}
|
|
1457
1475
|
return [...groups.values()];
|
|
1458
1476
|
};
|
|
1477
|
+
const describeElement = (binding) => {
|
|
1478
|
+
const { tagName = "element", text = "" } = binding.element ?? {};
|
|
1479
|
+
return {
|
|
1480
|
+
tagName,
|
|
1481
|
+
text,
|
|
1482
|
+
label: text ? `${tagName} "${text}"` : tagName
|
|
1483
|
+
};
|
|
1484
|
+
};
|
|
1485
|
+
const nodeIdOf = (target) => target instanceof Element && target.closest("[data-node-id]")?.getAttribute("data-node-id") || null;
|
|
1459
1486
|
const Panel$1 = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canMoveDown = false, bindings, onNodeChange, readOnly = false }) => {
|
|
1460
1487
|
const groups = groupBindingsById(bindings);
|
|
1461
1488
|
const rootRef = useRef(null);
|
|
1462
|
-
const
|
|
1489
|
+
const inspector = useContext(DndInspectorContext);
|
|
1490
|
+
const pickedId = (inspector?.picked ?? null)?.id;
|
|
1491
|
+
const highlight = inspector?.highlight;
|
|
1492
|
+
const [hoveredId, setHoveredId] = useState(null);
|
|
1493
|
+
const [focusedId, setFocusedId] = useState(null);
|
|
1494
|
+
const targetId = hoveredId ?? focusedId;
|
|
1495
|
+
useEffect(() => {
|
|
1496
|
+
if (!highlight) return;
|
|
1497
|
+
highlight(targetId);
|
|
1498
|
+
return () => highlight(null);
|
|
1499
|
+
}, [highlight, targetId]);
|
|
1463
1500
|
useEffect(() => {
|
|
1464
1501
|
const root = rootRef.current;
|
|
1465
1502
|
if (!root || !pickedId) return;
|
|
@@ -1486,6 +1523,12 @@ const Panel$1 = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canM
|
|
|
1486
1523
|
});
|
|
1487
1524
|
return /* @__PURE__ */ jsxs("div", {
|
|
1488
1525
|
ref: rootRef,
|
|
1526
|
+
onPointerOver: (e) => setHoveredId(nodeIdOf(e.target)),
|
|
1527
|
+
onPointerLeave: () => setHoveredId(null),
|
|
1528
|
+
onFocus: (e) => setFocusedId(nodeIdOf(e.target)),
|
|
1529
|
+
onBlur: (e) => {
|
|
1530
|
+
if (!e.currentTarget.contains(e.relatedTarget)) setFocusedId(null);
|
|
1531
|
+
},
|
|
1489
1532
|
className: cn("h-full space-y-4 p-4", "overflow-x-hidden overflow-y-auto"),
|
|
1490
1533
|
children: [
|
|
1491
1534
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -1526,14 +1569,28 @@ const Panel$1 = ({ item, onDelete, onMoveUp, onMoveDown, canMoveUp = false, canM
|
|
|
1526
1569
|
className: "text-xs text-gray-400",
|
|
1527
1570
|
children: "No editable elements."
|
|
1528
1571
|
}),
|
|
1529
|
-
groups.map((group) =>
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1572
|
+
groups.map((group) => {
|
|
1573
|
+
const element = describeElement(group[0]);
|
|
1574
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1575
|
+
"data-node-id": group[0].id,
|
|
1576
|
+
role: "group",
|
|
1577
|
+
"aria-label": element.label,
|
|
1578
|
+
className: "rounded data-[picked]:ring-2 data-[picked]:ring-blue-400\n data-[picked]:ring-offset-2",
|
|
1579
|
+
children: [groups.length > 1 && /* @__PURE__ */ jsxs("div", {
|
|
1580
|
+
className: "mb-2 flex min-w-0 items-baseline gap-1.5 border-b\n border-gray-100 pb-1 text-xs",
|
|
1581
|
+
children: [/* @__PURE__ */ jsx("code", {
|
|
1582
|
+
className: "shrink-0 text-gray-500",
|
|
1583
|
+
children: element.tagName
|
|
1584
|
+
}), element.text && /* @__PURE__ */ jsx("span", {
|
|
1585
|
+
className: "truncate text-gray-400",
|
|
1586
|
+
children: element.text
|
|
1587
|
+
})]
|
|
1588
|
+
}), /* @__PURE__ */ jsx(FieldGroup, {
|
|
1589
|
+
bindings: group,
|
|
1590
|
+
onNodeChange
|
|
1591
|
+
})]
|
|
1592
|
+
}, group[0].id);
|
|
1593
|
+
})
|
|
1537
1594
|
]
|
|
1538
1595
|
});
|
|
1539
1596
|
};
|
|
@@ -1770,7 +1827,7 @@ const NAVIGATION_KEYS = {
|
|
|
1770
1827
|
Home: "first",
|
|
1771
1828
|
End: "last"
|
|
1772
1829
|
};
|
|
1773
|
-
const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy: _onCopy, nodeRef, onNavigate, onDeleteKey, inspecting = false, onInspectMove, onInspectPick, onInspectLeave }) => {
|
|
1830
|
+
const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy: _onCopy, onMoveUp, onMoveDown, canMoveUp = false, canMoveDown = false, nodeRef, onNavigate, onDeleteKey, inspecting = false, onInspectMove, onInspectPick, onInspectLeave }) => {
|
|
1774
1831
|
const { attributes, listeners, setNodeRef, setActivatorNodeRef, transform, transition, isDragging, isOver, active } = useSortable({
|
|
1775
1832
|
id,
|
|
1776
1833
|
disabled: inspecting
|
|
@@ -1814,6 +1871,10 @@ const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy
|
|
|
1814
1871
|
e.stopPropagation();
|
|
1815
1872
|
_onCopy?.(id);
|
|
1816
1873
|
};
|
|
1874
|
+
const press = (action) => (e) => {
|
|
1875
|
+
e.stopPropagation();
|
|
1876
|
+
action?.();
|
|
1877
|
+
};
|
|
1817
1878
|
return /* @__PURE__ */ jsxs("div", {
|
|
1818
1879
|
ref: setRefs,
|
|
1819
1880
|
style,
|
|
@@ -1835,14 +1896,31 @@ const Sortable = ({ id, children, selected, onClick, onDelete: _onDelete, onCopy
|
|
|
1835
1896
|
children,
|
|
1836
1897
|
selected && /* @__PURE__ */ jsxs(Space, {
|
|
1837
1898
|
className: cn("absolute top-1 right-1 z-60"),
|
|
1838
|
-
children: [
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1899
|
+
children: [
|
|
1900
|
+
onMoveUp && /* @__PURE__ */ jsx(Button, {
|
|
1901
|
+
icon: /* @__PURE__ */ jsx(ChevronUp, {}),
|
|
1902
|
+
disabled: !canMoveUp,
|
|
1903
|
+
onClick: press(onMoveUp),
|
|
1904
|
+
"aria-label": "Move section up"
|
|
1905
|
+
}),
|
|
1906
|
+
onMoveDown && /* @__PURE__ */ jsx(Button, {
|
|
1907
|
+
icon: /* @__PURE__ */ jsx(ChevronDown, {}),
|
|
1908
|
+
disabled: !canMoveDown,
|
|
1909
|
+
onClick: press(onMoveDown),
|
|
1910
|
+
"aria-label": "Move section down"
|
|
1911
|
+
}),
|
|
1912
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1913
|
+
icon: /* @__PURE__ */ jsx(Copy, {}),
|
|
1914
|
+
onClick: onCopy,
|
|
1915
|
+
"aria-label": "Duplicate section"
|
|
1916
|
+
}),
|
|
1917
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1918
|
+
danger: true,
|
|
1919
|
+
icon: /* @__PURE__ */ jsx(Trash, {}),
|
|
1920
|
+
onClick: onDelete,
|
|
1921
|
+
"aria-label": "Delete section"
|
|
1922
|
+
})
|
|
1923
|
+
]
|
|
1846
1924
|
})
|
|
1847
1925
|
]
|
|
1848
1926
|
});
|
|
@@ -2152,7 +2230,7 @@ const conditionalModifiers = (args) => {
|
|
|
2152
2230
|
return restrictToVerticalAxis(args);
|
|
2153
2231
|
};
|
|
2154
2232
|
const NO_MODULES = {};
|
|
2155
|
-
const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange: _onChange, className, items = [], frame, dynamicTailwind = false, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, onNodePick, children, ...restProps }) => {
|
|
2233
|
+
const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange: _onChange, className, items = [], frame, dynamicTailwind = false, provider, renderField, onEditError, renderSectionFallback, shouldForceSectionFallback, onBeforeDelete, sectionNameFallback, containerId, bindings: bindingRegistry, bindingKeys, onNodePick, children, ...restProps }) => {
|
|
2156
2234
|
const modules = useStableModules(_modules);
|
|
2157
2235
|
const [mobilePaletteOpen, setMobilePaletteOpen] = useState(false);
|
|
2158
2236
|
const { breakpoint } = useResponsiveSize();
|
|
@@ -2212,6 +2290,8 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2212
2290
|
const [inspecting, setInspecting] = useState(false);
|
|
2213
2291
|
const [picked, setPicked] = useState(null);
|
|
2214
2292
|
const [highlight, setHighlight] = useState(null);
|
|
2293
|
+
const [fieldTarget, setFieldTarget] = useState(null);
|
|
2294
|
+
const [fieldRect, setFieldRect] = useState(null);
|
|
2215
2295
|
if (picked && picked.sectionId !== selectedId) setPicked(null);
|
|
2216
2296
|
const stopInspecting = useCallback(() => {
|
|
2217
2297
|
setInspecting(false);
|
|
@@ -2230,7 +2310,8 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2230
2310
|
activate: () => setInspecting(true),
|
|
2231
2311
|
deactivate: stopInspecting,
|
|
2232
2312
|
toggle: () => inspecting ? stopInspecting() : setInspecting(true),
|
|
2233
|
-
picked
|
|
2313
|
+
picked,
|
|
2314
|
+
highlight: setFieldTarget
|
|
2234
2315
|
};
|
|
2235
2316
|
const onInspectMove = (section, overlay, x, y) => {
|
|
2236
2317
|
const element = pickElement(section, overlay, x, y);
|
|
@@ -2296,6 +2377,35 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2296
2377
|
if (neighbor) focusSection(neighbor.id);
|
|
2297
2378
|
});
|
|
2298
2379
|
};
|
|
2380
|
+
const onMoveButton = (id, direction) => {
|
|
2381
|
+
const to = sections.findIndex((section) => section.id === id) + (direction === "up" ? -1 : 1);
|
|
2382
|
+
moveSection(id, direction);
|
|
2383
|
+
if (to === 0 || to === sections.length - 1) focusSection(id);
|
|
2384
|
+
};
|
|
2385
|
+
useEffect(() => {
|
|
2386
|
+
const section = selectedId === null ? null : sectionNodes.get(selectedId);
|
|
2387
|
+
if (!fieldTarget || !section) return;
|
|
2388
|
+
let frame = 0;
|
|
2389
|
+
const measure = () => {
|
|
2390
|
+
cancelAnimationFrame(frame);
|
|
2391
|
+
frame = requestAnimationFrame(() => {
|
|
2392
|
+
const element = findElementById(section, fieldTarget);
|
|
2393
|
+
setFieldRect(element ? viewportRect(element) : null);
|
|
2394
|
+
});
|
|
2395
|
+
};
|
|
2396
|
+
measure();
|
|
2397
|
+
window.addEventListener("scroll", measure, true);
|
|
2398
|
+
window.addEventListener("resize", measure);
|
|
2399
|
+
return () => {
|
|
2400
|
+
cancelAnimationFrame(frame);
|
|
2401
|
+
window.removeEventListener("scroll", measure, true);
|
|
2402
|
+
window.removeEventListener("resize", measure);
|
|
2403
|
+
};
|
|
2404
|
+
}, [
|
|
2405
|
+
fieldTarget,
|
|
2406
|
+
selectedId,
|
|
2407
|
+
sectionNodes
|
|
2408
|
+
]);
|
|
2299
2409
|
useEffect(() => {
|
|
2300
2410
|
if (selectedId === null) return;
|
|
2301
2411
|
const frame = requestAnimationFrame(() => {
|
|
@@ -2311,6 +2421,10 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2311
2421
|
if (!next.id) return;
|
|
2312
2422
|
patch(next);
|
|
2313
2423
|
};
|
|
2424
|
+
const bindingOptions = useMemo(() => ({
|
|
2425
|
+
bindings: bindingRegistry,
|
|
2426
|
+
bindingKeys
|
|
2427
|
+
}), [bindingRegistry, bindingKeys]);
|
|
2314
2428
|
const selectedCode = selectedItem?.code;
|
|
2315
2429
|
const selectedSectionId = selectedItem?.id;
|
|
2316
2430
|
const { fields, updatedCode, parseError } = useMemo(() => {
|
|
@@ -2322,7 +2436,7 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2322
2436
|
try {
|
|
2323
2437
|
const updated = fillIdsFrom(selectedCode, selectedSectionId ?? "");
|
|
2324
2438
|
return {
|
|
2325
|
-
fields: extract(updated),
|
|
2439
|
+
fields: extract(updated, bindingOptions),
|
|
2326
2440
|
updatedCode: updated !== selectedCode ? updated : selectedCode,
|
|
2327
2441
|
parseError: null
|
|
2328
2442
|
};
|
|
@@ -2334,7 +2448,11 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2334
2448
|
parseError: { error: e }
|
|
2335
2449
|
};
|
|
2336
2450
|
}
|
|
2337
|
-
}, [
|
|
2451
|
+
}, [
|
|
2452
|
+
selectedCode,
|
|
2453
|
+
selectedSectionId,
|
|
2454
|
+
bindingOptions
|
|
2455
|
+
]);
|
|
2338
2456
|
useEffect(() => {
|
|
2339
2457
|
if (missingContainer !== null) reportErrorRef.current({
|
|
2340
2458
|
type: "parse",
|
|
@@ -2366,7 +2484,7 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2366
2484
|
label,
|
|
2367
2485
|
property,
|
|
2368
2486
|
value: changeValue
|
|
2369
|
-
})));
|
|
2487
|
+
})), bindingOptions);
|
|
2370
2488
|
if (!result.success) {
|
|
2371
2489
|
const { id, label, property } = changes[result.index];
|
|
2372
2490
|
reportError({
|
|
@@ -2408,7 +2526,8 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2408
2526
|
bindings,
|
|
2409
2527
|
onNodeChange: onFieldChange,
|
|
2410
2528
|
onNodesChange: commitChanges,
|
|
2411
|
-
readOnly: stale
|
|
2529
|
+
readOnly: stale,
|
|
2530
|
+
bindingOptions
|
|
2412
2531
|
};
|
|
2413
2532
|
const canvas = /* @__PURE__ */ jsxs(Fragment, { children: [stale && /* @__PURE__ */ jsx("div", {
|
|
2414
2533
|
role: "status",
|
|
@@ -2449,6 +2568,10 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2449
2568
|
onClick: () => onSelect(section.id),
|
|
2450
2569
|
onDelete,
|
|
2451
2570
|
onCopy,
|
|
2571
|
+
onMoveUp: () => onMoveButton(section.id, "up"),
|
|
2572
|
+
onMoveDown: () => onMoveButton(section.id, "down"),
|
|
2573
|
+
canMoveUp: index > 0,
|
|
2574
|
+
canMoveDown: index < sections.length - 1,
|
|
2452
2575
|
nodeRef: sectionNodes.register(section.id),
|
|
2453
2576
|
onNavigate: (to) => onNavigate(section.id, to),
|
|
2454
2577
|
onDeleteKey: () => onDeleteKey(section.id),
|
|
@@ -2490,7 +2613,8 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2490
2613
|
children: /* @__PURE__ */ jsxs(DndEditOptionsContext.Provider, {
|
|
2491
2614
|
value: {
|
|
2492
2615
|
renderField,
|
|
2493
|
-
reportError
|
|
2616
|
+
reportError,
|
|
2617
|
+
bindingOptions
|
|
2494
2618
|
},
|
|
2495
2619
|
children: [/* @__PURE__ */ jsx(DndRegionContext.Provider, {
|
|
2496
2620
|
value: {
|
|
@@ -2508,7 +2632,7 @@ const Dnd$1 = ({ value: _value, props, modules: _modules = NO_MODULES, onChange:
|
|
|
2508
2632
|
value: inspector,
|
|
2509
2633
|
children: Children.toArray(children).length ? children : /* @__PURE__ */ jsx(Layout, {})
|
|
2510
2634
|
})
|
|
2511
|
-
}), /* @__PURE__ */ jsx(InspectorHighlight, { rect: inspecting ? highlight : null })]
|
|
2635
|
+
}), /* @__PURE__ */ jsx(InspectorHighlight, { rect: inspecting ? highlight : fieldTarget ? fieldRect : null })]
|
|
2512
2636
|
})
|
|
2513
2637
|
}), /* @__PURE__ */ jsx(DragOverlay, { children: /* @__PURE__ */ jsx(Overlay, {
|
|
2514
2638
|
sections,
|
|
@@ -2541,4 +2665,4 @@ const useChildrenEditor = useDndChildren;
|
|
|
2541
2665
|
//#endregion
|
|
2542
2666
|
export { useDndPanel as _, Layout as a, Field as c, isStructuralFieldKind as d, useDndChildren as f, useDndPalette as g, useDndLayout as h, Canvas as i, useDndItems as l, withPanelCommit as m, useChildrenEditor as n, Palette as o, resolvePanelBindings as p, useItemsEditor as r, Panel as s, Dnd as t, getFieldKind as u, DraggableItem as v, useDndInspector as y };
|
|
2543
2667
|
|
|
2544
|
-
//# sourceMappingURL=dnd-
|
|
2668
|
+
//# sourceMappingURL=dnd-BE5ZizqX.js.map
|