@particle-academy/fancy-cms-ui 0.0.1-dev.16 → 0.0.1-dev.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editor.cjs +14 -13
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.js +14 -13
- package/dist/editor.js.map +1 -1
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -412,7 +412,7 @@ function NodeInspector({
|
|
|
412
412
|
}) {
|
|
413
413
|
const base = node.style.base ?? {};
|
|
414
414
|
const setT = (patch) => onTransform({ ...transform, ...patch });
|
|
415
|
-
const handled = /* @__PURE__ */ new Set(["content", "label"]);
|
|
415
|
+
const handled = /* @__PURE__ */ new Set(["content", "label", "html"]);
|
|
416
416
|
const extraKeys = Object.keys(node.props).filter(
|
|
417
417
|
(k) => !handled.has(k) && (["string", "number", "boolean"].includes(typeof node.props[k]) || isBinding(node.props[k]))
|
|
418
418
|
);
|
|
@@ -427,14 +427,11 @@ function NodeInspector({
|
|
|
427
427
|
/* @__PURE__ */ jsx("button", { type: "button", style: iconBtn, title: "Close", onClick: onClose, children: "\u2715" })
|
|
428
428
|
] }),
|
|
429
429
|
/* @__PURE__ */ jsxs("div", { style: body, children: [
|
|
430
|
-
"content" in node.props ? /* @__PURE__ */
|
|
431
|
-
"
|
|
432
|
-
{
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
onChange: (e) => onProps({ content: e.target.value })
|
|
436
|
-
}
|
|
437
|
-
) }) : null,
|
|
430
|
+
"content" in node.props || node.type === "richtext" ? /* @__PURE__ */ jsxs("p", { style: { fontSize: 11, color: "var(--fg-3, #94a3b8)", margin: "0 0 12px", lineHeight: 1.45, paddingBottom: 12, borderBottom: "1px solid #1e293b" }, children: [
|
|
431
|
+
"\u270E Edit the text ",
|
|
432
|
+
/* @__PURE__ */ jsx("strong", { children: "directly on the page" }),
|
|
433
|
+
" \u2014 click in and type. This panel is for layout, style, and bindings."
|
|
434
|
+
] }) : null,
|
|
438
435
|
"label" in node.props ? /* @__PURE__ */ jsx(Group, { label: "Label", children: /* @__PURE__ */ jsx("input", { style: input2, value: String(node.props.label ?? ""), onChange: (e) => onProps({ label: e.target.value }) }) }) : null,
|
|
439
436
|
extraKeys.length ? /* @__PURE__ */ jsx(Group, { label: "Properties", children: extraKeys.map((k) => /* @__PURE__ */ jsx(PropField, { name: k, value: node.props[k], onChange: (v) => onProps({ [k]: v }) }, k)) }) : null,
|
|
440
437
|
/* @__PURE__ */ jsxs(Group, { label: "Position & size", children: [
|
|
@@ -842,13 +839,17 @@ function EditablePage({
|
|
|
842
839
|
};
|
|
843
840
|
}, [measureBox, ed.state.doc]);
|
|
844
841
|
useEffect(() => {
|
|
845
|
-
|
|
846
|
-
const
|
|
847
|
-
if (!
|
|
842
|
+
const t = selNode?.type;
|
|
843
|
+
const editable = t === "text" || t === "heading" || t === "richtext";
|
|
844
|
+
if (!editing || !selection || !pageRef.current || !editable) return;
|
|
845
|
+
const wrapper = pageRef.current.querySelector(`[data-cms="${cssEscape2(selection)}"]`);
|
|
846
|
+
if (!wrapper) return;
|
|
847
|
+
const isRich = t === "richtext";
|
|
848
|
+
const el = (isRich ? wrapper.firstElementChild : wrapper) ?? wrapper;
|
|
848
849
|
el.setAttribute("contenteditable", "true");
|
|
849
850
|
el.style.outline = "none";
|
|
850
851
|
el.focus();
|
|
851
|
-
const commit = () => ed.apply({ t: "set_props", id: selection, patch: { content: el.innerText } });
|
|
852
|
+
const commit = () => ed.apply({ t: "set_props", id: selection, patch: isRich ? { html: el.innerHTML } : { content: el.innerText } });
|
|
852
853
|
el.addEventListener("blur", commit);
|
|
853
854
|
return () => {
|
|
854
855
|
el.removeEventListener("blur", commit);
|