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 { IItem, MItem } from "../../../../utils/types/item";
|
||||
import { FMCompDef, FNCompDef } from "../../../../utils/types/meta-fn";
|
||||
import { IMeta, PG } from "../ed-global";
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { IMeta } from "../ed-global";
|
||||
|
||||
export const assignMitem = (arg: {
|
||||
m: IMeta;
|
||||
|
|
|
|||
|
|
@ -25,9 +25,23 @@ export const EdTreeAction = ({
|
|||
if (!mode && item.adv?.css) mode = "css";
|
||||
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 (
|
||||
<div className="flex items-center pr-1 space-x-1">
|
||||
{item.hidden === "all" && (
|
||||
{!!item.hidden && (
|
||||
<Tooltip content="Hidden: All">
|
||||
<div
|
||||
className="mx-1 cursor-pointer hover:opacity-60"
|
||||
|
|
@ -58,7 +72,9 @@ export const EdTreeAction = ({
|
|||
</Tooltip>
|
||||
)} */}
|
||||
|
||||
{(!comp.enabled || (comp.enabled && comp.id === active.comp_id)) && (
|
||||
{(!comp.enabled ||
|
||||
(comp.enabled && comp.id === active.comp_id) ||
|
||||
child_jsx_has_script) && (
|
||||
<Tooltip
|
||||
content={`Edit ${mode}`}
|
||||
className={cx(
|
||||
|
|
@ -82,7 +98,20 @@ export const EdTreeAction = ({
|
|||
mode === "html" &&
|
||||
`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.type = "item";
|
||||
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 { EDGlobal, IMeta, PG, active } from "../../../../logic/ed-global";
|
||||
import { treeRebuild } from "../../../../logic/tree/build";
|
||||
import { fillID } from "../../../../logic/tree/fill-id";
|
||||
|
||||
export const EdTreeName = ({
|
||||
node,
|
||||
|
|
@ -116,7 +117,7 @@ export const EdTreeName = ({
|
|||
}
|
||||
}}
|
||||
onChange={(e) => {
|
||||
local.rename = e.target.value
|
||||
local.rename = e.target.value;
|
||||
p.render();
|
||||
}}
|
||||
/>
|
||||
|
|
@ -237,7 +238,7 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => {
|
|||
}
|
||||
|
||||
if (mitem) {
|
||||
const genJSX = findDefaultJSX(p, mitem);
|
||||
const genJSX = fillID(findDefaultJSX(p, mitem));
|
||||
const ijson = mitem.toJSON() as IItem;
|
||||
|
||||
mitem.doc?.transact(() => {
|
||||
|
|
@ -250,16 +251,6 @@ const GenerateJSX: FC<{ meta: IMeta }> = ({ meta }) => {
|
|||
id: ijson.id,
|
||||
hidden: false,
|
||||
originalId: ijson.originalId,
|
||||
...(is_child
|
||||
? {
|
||||
adv: {
|
||||
css: "",
|
||||
js: "<>{children}</>",
|
||||
jsBuilt:
|
||||
"render(/* @__PURE__ */ React.createElement(React.Fragment, null, children));\n",
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
});
|
||||
treeRebuild(p);
|
||||
|
|
|
|||
Loading…
Reference in New Issue