wip fix
This commit is contained in:
parent
9e39b7d0fd
commit
65da157965
|
|
@ -126,6 +126,7 @@ export type EdMeta = {
|
||||||
el?: ReactElement;
|
el?: ReactElement;
|
||||||
is_layout?: boolean;
|
is_layout?: boolean;
|
||||||
jsx_prop_name?: string;
|
jsx_prop_name?: string;
|
||||||
|
jsx_prop_root?: boolean;
|
||||||
/** script related meta **/
|
/** script related meta **/
|
||||||
jsx_scope_id?: string;
|
jsx_scope_id?: string;
|
||||||
propval?: Record<string, any>;
|
propval?: Record<string, any>;
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ export const syncWalkMap = (
|
||||||
parent_item: EdMeta["parent_item"];
|
parent_item: EdMeta["parent_item"];
|
||||||
parent_mcomp?: EdMeta["parent_mcomp"];
|
parent_mcomp?: EdMeta["parent_mcomp"];
|
||||||
jsx_prop_name?: string;
|
jsx_prop_name?: string;
|
||||||
|
jsx_prop_root?: boolean;
|
||||||
skip_add_tree?: boolean;
|
skip_add_tree?: boolean;
|
||||||
tree_root_id: string;
|
tree_root_id: string;
|
||||||
each?: (meta: EdMeta) => void;
|
each?: (meta: EdMeta) => void;
|
||||||
|
|
@ -239,6 +240,7 @@ export const syncWalkMap = (
|
||||||
tree_root_id: arg.tree_root_id,
|
tree_root_id: arg.tree_root_id,
|
||||||
mitem: mcontent,
|
mitem: mcontent,
|
||||||
jsx_prop_name: k,
|
jsx_prop_name: k,
|
||||||
|
jsx_prop_root: true,
|
||||||
parent_mcomp: { minstance, meta, mcomp },
|
parent_mcomp: { minstance, meta, mcomp },
|
||||||
parent_item: { id: item.id, mitem: mitem as MItem },
|
parent_item: { id: item.id, mitem: mitem as MItem },
|
||||||
portal: arg.portal,
|
portal: arg.portal,
|
||||||
|
|
@ -279,6 +281,7 @@ export const syncWalkMap = (
|
||||||
is_layout: arg.is_layout,
|
is_layout: arg.is_layout,
|
||||||
item,
|
item,
|
||||||
jsx_prop_name: arg.jsx_prop_name,
|
jsx_prop_name: arg.jsx_prop_name,
|
||||||
|
jsx_prop_root: arg.jsx_prop_root,
|
||||||
mitem: mitem as MItem,
|
mitem: mitem as MItem,
|
||||||
parent_item,
|
parent_item,
|
||||||
parent_mcomp: arg.parent_mcomp,
|
parent_mcomp: arg.parent_mcomp,
|
||||||
|
|
@ -311,6 +314,7 @@ export const syncWalkMap = (
|
||||||
is_layout: arg.is_layout,
|
is_layout: arg.is_layout,
|
||||||
tree_root_id: arg.tree_root_id,
|
tree_root_id: arg.tree_root_id,
|
||||||
mitem: e,
|
mitem: e,
|
||||||
|
jsx_prop_name: arg.jsx_prop_name,
|
||||||
parent_item: { id: item.id, mitem: mitem as MItem },
|
parent_item: { id: item.id, mitem: mitem as MItem },
|
||||||
parent_mcomp: arg.parent_mcomp,
|
parent_mcomp: arg.parent_mcomp,
|
||||||
portal: arg.portal,
|
portal: arg.portal,
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ export const EdMain = () => {
|
||||||
},
|
},
|
||||||
set(meta) {
|
set(meta) {
|
||||||
const outer = getOuterItem(meta);
|
const outer = getOuterItem(meta);
|
||||||
|
console.log(meta);
|
||||||
|
|
||||||
if (outer) {
|
if (outer) {
|
||||||
active.item_id = outer.id;
|
active.item_id = outer.id;
|
||||||
}
|
}
|
||||||
|
|
@ -154,6 +156,9 @@ export const EdMain = () => {
|
||||||
|
|
||||||
const getOuterItem = (meta: EdMeta) => {
|
const getOuterItem = (meta: EdMeta) => {
|
||||||
let cur: undefined | EdMeta = meta;
|
let cur: undefined | EdMeta = meta;
|
||||||
|
|
||||||
|
if (cur.jsx_prop_name) return meta.item;
|
||||||
|
|
||||||
while (cur.parent_mcomp) {
|
while (cur.parent_mcomp) {
|
||||||
cur = cur.parent_mcomp.meta;
|
cur = cur.parent_mcomp.meta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ export const ScriptMonaco = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
clearTimeout(scriptEdit.timeout);
|
||||||
(async () => {
|
(async () => {
|
||||||
const editor = local.editor;
|
const editor = local.editor;
|
||||||
const monaco = local.monaco;
|
const monaco = local.monaco;
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,6 @@ else metaOptions = resOpt;
|
||||||
local.render();
|
local.render();
|
||||||
}}
|
}}
|
||||||
onChange={(sel) => {
|
onChange={(sel) => {
|
||||||
console.log(sel);
|
|
||||||
if (!sel) {
|
if (!sel) {
|
||||||
local.val = evalue;
|
local.val = evalue;
|
||||||
local.isOpen = false;
|
local.isOpen = false;
|
||||||
|
|
|
||||||
|
|
@ -29,35 +29,12 @@ export const nodeRender: NodeRender<EdMeta> = (node, prm) => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.data?.jsx_prop_name) {
|
if (node.data?.jsx_prop_root && node.data?.jsx_prop_name) {
|
||||||
const meta = getMetaById(p, node.data?.parent_item.id);
|
const meta = getMetaById(p, node.data?.parent_item.id);
|
||||||
if (meta) {
|
if (meta) {
|
||||||
if (meta.propvis) {
|
if (meta.propvis) {
|
||||||
jsxPropVisCache[meta.item.id] = meta.propvis;
|
jsxPropVisCache[meta.item.id] = meta.propvis;
|
||||||
if (meta.propvis[node.data.jsx_prop_name] === false) return <></>;
|
if (meta.propvis[node.data.jsx_prop_name] === false) return <></>;
|
||||||
} else {
|
|
||||||
if (jsxPropVisCache[meta.item.id]) {
|
|
||||||
meta.propvis = jsxPropVisCache[meta.item.id];
|
|
||||||
if (meta.propvis) {
|
|
||||||
if (meta.propvis[node.data.jsx_prop_name] === false) return <></>;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!jsxPropLoadingRender[meta.item.id]) {
|
|
||||||
setTimeout(p.render, 100);
|
|
||||||
setTimeout(p.render, 500);
|
|
||||||
jsxPropLoadingRender[meta.item.id] = node.data.jsx_prop_name;
|
|
||||||
}
|
|
||||||
if (jsxPropLoadingRender[meta.item.id] === node.data.jsx_prop_name) {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className={"relative border-b flex items-stretch min-h-[26px]"}
|
|
||||||
>
|
|
||||||
<Loading backdrop={false} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <></>;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export const oldLoadCode = async (v: VG) => {
|
||||||
exports: {} as any,
|
exports: {} as any,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
exec(site.js_compiled, scope);
|
await exec(site.js_compiled, scope);
|
||||||
if (scope.module.exports) {
|
if (scope.module.exports) {
|
||||||
for (const [k, v] of Object.entries(scope.module.exports)) {
|
for (const [k, v] of Object.entries(scope.module.exports)) {
|
||||||
w.exports[k] = v;
|
w.exports[k] = v;
|
||||||
|
|
|
||||||
|
|
@ -37,12 +37,5 @@ export const ViewMetaChildren: FC<{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return <>{Object.values(children)}</>;
|
||||||
<>
|
|
||||||
{/* <div className={"text-[9px] text-gray-500 -mt-1"}>
|
|
||||||
{item.id} - {item.originalId}
|
|
||||||
</div> */}
|
|
||||||
{Object.values(children)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import hash_sum from "hash-sum";
|
import hash_sum from "hash-sum";
|
||||||
import { FC, ReactNode, useEffect } from "react";
|
import { FC, ReactNode, isValidElement, useEffect } from "react";
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
import { produceCSS } from "../../../../utils/css/gen";
|
import { produceCSS } from "../../../../utils/css/gen";
|
||||||
import { createAPI, createDB } from "../../../../utils/script/init-api";
|
import { createAPI, createDB } from "../../../../utils/script/init-api";
|
||||||
|
|
@ -170,8 +170,16 @@ export const ViewMetaScript: FC<{
|
||||||
},
|
},
|
||||||
useEffect: useEffect,
|
useEffect: useEffect,
|
||||||
render: (jsx: ReactNode) => {
|
render: (jsx: ReactNode) => {
|
||||||
output.jsx = jsx;
|
if (isValidElement(jsx)) {
|
||||||
renderLimit[v.current.page_id][item.id].cache = output.jsx;
|
// output.jsx = (
|
||||||
|
// <>
|
||||||
|
// <div className={"absolute bg-white px-1 z-10 text-[9px] text-gray-500 -mt-1"}>{item.id}</div>
|
||||||
|
// {jsx}
|
||||||
|
// </>
|
||||||
|
// );
|
||||||
|
output.jsx = jsx;
|
||||||
|
renderLimit[v.current.page_id][item.id].cache = output.jsx;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,8 @@ export const compPropVal = (
|
||||||
prop.value
|
prop.value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (prop.meta?.type === "content-element") {
|
}
|
||||||
|
if (prop.meta?.type === "content-element") {
|
||||||
if (!(typeof value === "object" && !!value && value._jsx)) {
|
if (!(typeof value === "object" && !!value && value._jsx)) {
|
||||||
const id = `${meta.item.id}-${name}`;
|
const id = `${meta.item.id}-${name}`;
|
||||||
if (!jsxProps[id]) {
|
if (!jsxProps[id]) {
|
||||||
|
|
@ -79,14 +80,7 @@ export const compPropVal = (
|
||||||
let parent = v.meta[parent_id];
|
let parent = v.meta[parent_id];
|
||||||
|
|
||||||
if (meta && parent) {
|
if (meta && parent) {
|
||||||
if (v.scope) {
|
meta.parent_item.id = parent_id;
|
||||||
while (parent) {
|
|
||||||
if (v.scope[parent.item.id]) {
|
|
||||||
v.scope[prop.content.id] = v.scope[parent.item.id];
|
|
||||||
}
|
|
||||||
parent = v.meta[parent.parent_item.id];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewMeta
|
<ViewMeta
|
||||||
|
|
@ -106,6 +100,7 @@ export const compPropVal = (
|
||||||
|
|
||||||
result[name] = value;
|
result[name] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta.propval = result;
|
meta.propval = result;
|
||||||
|
|
||||||
const propvis: any = {};
|
const propvis: any = {};
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,15 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
|
||||||
const id = path[path.length - 1].replace(".d.ts", "");
|
const id = path[path.length - 1].replace(".d.ts", "");
|
||||||
|
|
||||||
if (type === "prop") {
|
if (type === "prop") {
|
||||||
|
if (p.ui.popup.script.type === "item") {
|
||||||
|
p.ui.popup.script.open = false;
|
||||||
|
p.render();
|
||||||
|
setTimeout(() => {
|
||||||
|
p.ui.popup.script.open = true;
|
||||||
|
p.render();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
p.ui.popup.script.prop_name = path[1];
|
p.ui.popup.script.prop_name = path[1];
|
||||||
p.ui.popup.script.type = "prop-instance";
|
p.ui.popup.script.type = "prop-instance";
|
||||||
p.ui.popup.script.prop_kind = "value";
|
p.ui.popup.script.prop_kind = "value";
|
||||||
|
|
@ -66,7 +75,16 @@ export const jsMount = async (editor: MonacoEditor, monaco: Monaco, p?: PG) => {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
p.ui.popup.script.type = "item";
|
if (p.ui.popup.script.type !== "item") {
|
||||||
|
p.ui.popup.script.open = false;
|
||||||
|
p.ui.popup.script.type = "item";
|
||||||
|
p.ui.popup.script.prop_name = "";
|
||||||
|
p.render();
|
||||||
|
setTimeout(() => {
|
||||||
|
p.ui.popup.script.open = true;
|
||||||
|
p.render();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comp_id) {
|
if (comp_id) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "bun run --hot ./pkgs/core/index.ts dev",
|
"dev": "bun run --hot ./pkgs/core/index.ts dev",
|
||||||
"clean": "rm -rf app/static && rm -rf app/web/.parcel-cache",
|
"clean": "rm -rf data/lmdb && rm -rf app/static && rm -rf app/web/.parcel-cache",
|
||||||
"build": "bun run --silent ./pkgs/core/build.ts",
|
"build": "bun run --silent ./pkgs/core/build.ts",
|
||||||
"build-site": "bun run --silent ./pkgs/core/build-site.ts",
|
"build-site": "bun run --silent ./pkgs/core/build-site.ts",
|
||||||
"db-pull": "bun run ./pkgs/crm -rf data && rore/db-pull.ts",
|
"db-pull": "bun run ./pkgs/crm -rf data && rore/db-pull.ts",
|
||||||
|
|
@ -29,4 +29,4 @@
|
||||||
"fdir": "^6.1.0",
|
"fdir": "^6.1.0",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue