wip fix
This commit is contained in:
parent
d24446ba17
commit
daaa978626
|
|
@ -1,8 +1,8 @@
|
||||||
|
import { createId } from "@paralleldrive/cuid2";
|
||||||
import { TypedMap } from "yjs-types";
|
import { TypedMap } from "yjs-types";
|
||||||
import { IItem, MItem } from "../../../../utils/types/item";
|
import { IItem, MItem } from "../../../../utils/types/item";
|
||||||
import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn";
|
import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn";
|
||||||
import { IMeta, PG } from "../ed-global";
|
import { IMeta } from "../ed-global";
|
||||||
import { createId } from "@paralleldrive/cuid2";
|
|
||||||
|
|
||||||
export const assignMitem = (arg: {
|
export const assignMitem = (arg: {
|
||||||
m: IMeta;
|
m: IMeta;
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,23 @@ export const EdTreeAction = ({
|
||||||
if (!mode && item.adv?.css) mode = "css";
|
if (!mode && item.adv?.css) mode = "css";
|
||||||
if (!mode && item.adv?.html) mode = "html";
|
if (!mode && item.adv?.html) mode = "html";
|
||||||
|
|
||||||
|
let child_jsx_has_script = false;
|
||||||
|
const child_id = item.component?.props.child.content?.id;
|
||||||
|
if (child_id) {
|
||||||
|
const meta = getMetaById(p, child_id);
|
||||||
|
const item = meta?.item;
|
||||||
|
child_jsx_has_script = true;
|
||||||
|
if (item) {
|
||||||
|
mode = "";
|
||||||
|
if (item.adv?.js) mode = "js";
|
||||||
|
if (!mode && item.adv?.css) mode = "css";
|
||||||
|
if (!mode && item.adv?.html) mode = "html";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex items-center pr-1 space-x-1">
|
<div className="flex items-center pr-1 space-x-1">
|
||||||
{item.hidden === "all" && (
|
{!!item.hidden && (
|
||||||
<Tooltip content="Hidden: All">
|
<Tooltip content="Hidden: All">
|
||||||
<div
|
<div
|
||||||
className="mx-1 cursor-pointer hover:opacity-60"
|
className="mx-1 cursor-pointer hover:opacity-60"
|
||||||
|
|
@ -58,7 +72,9 @@ export const EdTreeAction = ({
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)} */}
|
)} */}
|
||||||
|
|
||||||
{(!comp.enabled || (comp.enabled && comp.id === active.comp_id)) && (
|
{(!comp.enabled ||
|
||||||
|
(comp.enabled && comp.id === active.comp_id) ||
|
||||||
|
child_jsx_has_script) && (
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={`Edit ${mode}`}
|
content={`Edit ${mode}`}
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
@ -82,7 +98,20 @@ export const EdTreeAction = ({
|
||||||
mode === "html" &&
|
mode === "html" &&
|
||||||
`bg-blue-400 text-white border-blue-400 hover:border-blue-500 hover:bg-blue-300`
|
`bg-blue-400 text-white border-blue-400 hover:border-blue-500 hover:bg-blue-300`
|
||||||
)}
|
)}
|
||||||
onClick={() => {
|
onClick={(e) => {
|
||||||
|
if (item.component?.props.child.content?.id) {
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
active.item_id = item.component.props.child.content.id;
|
||||||
|
p.ui.popup.script.open = true;
|
||||||
|
p.ui.popup.script.type = "item";
|
||||||
|
p.ui.popup.script.mode = (mode || "js") as any;
|
||||||
|
p.render();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
p.ui.popup.script.open = true;
|
p.ui.popup.script.open = true;
|
||||||
p.ui.popup.script.type = "item";
|
p.ui.popup.script.type = "item";
|
||||||
p.ui.popup.script.mode = (mode || "js") as any;
|
p.ui.popup.script.mode = (mode || "js") as any;
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { IItem, MItem } from "../../../../../../utils/types/item";
|
||||||
import { Tooltip } from "../../../../../../utils/ui/tooltip";
|
import { Tooltip } from "../../../../../../utils/ui/tooltip";
|
||||||
import { EDGlobal, IMeta, PG, active } from "../../../../logic/ed-global";
|
import { EDGlobal, IMeta, PG, active } from "../../../../logic/ed-global";
|
||||||
import { treeRebuild } from "../../../../logic/tree/build";
|
import { treeRebuild } from "../../../../logic/tree/build";
|
||||||
|
import { fillID } from "../../../../logic/tree/fill-id";
|
||||||
|
|
||||||
export const EdTreeName = ({
|
export const EdTreeName = ({
|
||||||
node,
|
node,
|
||||||
|
|
@ -116,7 +117,7 @@ export const EdTreeName = ({
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
local.rename = e.target.value
|
local.rename = e.target.value;
|
||||||
p.render();
|
p.render();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -237,7 +238,7 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mitem) {
|
if (mitem) {
|
||||||
const genJSX = findDefaultJSX(p, mitem);
|
const genJSX = fillID(findDefaultJSX(p, mitem));
|
||||||
const ijson = mitem.toJSON() as IItem;
|
const ijson = mitem.toJSON() as IItem;
|
||||||
|
|
||||||
mitem.doc?.transact(() => {
|
mitem.doc?.transact(() => {
|
||||||
|
|
@ -250,16 +251,6 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => {
|
||||||
id: ijson.id,
|
id: ijson.id,
|
||||||
hidden: false,
|
hidden: false,
|
||||||
originalId: ijson.originalId,
|
originalId: ijson.originalId,
|
||||||
...(is_child
|
|
||||||
? {
|
|
||||||
adv: {
|
|
||||||
css: "",
|
|
||||||
js: "<>{children}</>",
|
|
||||||
jsBuilt:
|
|
||||||
"render(/* @__PURE__ */ React.createElement(React.Fragment, null, children));\n",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
: {}),
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
treeRebuild(p);
|
treeRebuild(p);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue