fix
This commit is contained in:
parent
cb0a9b5360
commit
334c40176f
File diff suppressed because one or more lines are too long
|
|
@ -273,6 +273,7 @@ export const EDGlobal = {
|
||||||
name: "site",
|
name: "site",
|
||||||
log: "",
|
log: "",
|
||||||
loading: false,
|
loading: false,
|
||||||
|
rebuilding: false,
|
||||||
startup_status: "init" as
|
startup_status: "init" as
|
||||||
| "init"
|
| "init"
|
||||||
| "loading"
|
| "loading"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,10 @@ import { Tooltip } from "../../../../../utils/ui/tooltip";
|
||||||
import { EDGlobal } from "../../../logic/ed-global";
|
import { EDGlobal } from "../../../logic/ed-global";
|
||||||
import {
|
import {
|
||||||
iconDownload,
|
iconDownload,
|
||||||
|
iconHourglass,
|
||||||
|
iconLoading,
|
||||||
iconNewTab,
|
iconNewTab,
|
||||||
|
iconRebuild,
|
||||||
iconScrollOff,
|
iconScrollOff,
|
||||||
iconScrollOn,
|
iconScrollOn,
|
||||||
iconUpload,
|
iconUpload,
|
||||||
|
|
@ -243,6 +246,39 @@ const CodeBody = () => {
|
||||||
dangerouslySetInnerHTML={{ __html: iconNewTab }}
|
dangerouslySetInnerHTML={{ __html: iconNewTab }}
|
||||||
></div>
|
></div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
<Tooltip
|
||||||
|
content="Rebuild"
|
||||||
|
delay={0}
|
||||||
|
placement="bottom"
|
||||||
|
className={cx("flex items-stretch relative")}
|
||||||
|
onClick={async () => {
|
||||||
|
p.ui.popup.code.rebuilding = true;
|
||||||
|
p.render();
|
||||||
|
|
||||||
|
await _api.rebuild(p.site.id);
|
||||||
|
|
||||||
|
alert("Rebuild Done");
|
||||||
|
|
||||||
|
p.ui.popup.code.rebuilding = false;
|
||||||
|
p.render();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={cx(
|
||||||
|
"border-r flex text-center items-center cursor-pointer px-2 transition-all",
|
||||||
|
"border-b-2 border-b-transparent",
|
||||||
|
p.ui.popup.code.rebuilding
|
||||||
|
? "bg-blue-600 text-white"
|
||||||
|
: "hover:bg-blue-50"
|
||||||
|
)}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: !p.ui.popup.code.rebuilding
|
||||||
|
? iconRebuild
|
||||||
|
: iconHourglass,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{p.ui.popup.code.show_log && (
|
{p.ui.popup.code.show_log && (
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,8 @@ export const iconScrollOff = `<svg xmlns="http://www.w3.org/2000/svg" width="13"
|
||||||
|
|
||||||
export const iconUpload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-upload"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>`;
|
export const iconUpload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-upload"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>`;
|
||||||
|
|
||||||
export const iconDownload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`
|
export const iconDownload = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-download"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/></svg>`;
|
||||||
|
|
||||||
|
export const iconRebuild = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pickaxe"><path d="M14.531 12.469 6.619 20.38a1 1 0 1 1-3-3l7.912-7.912"/><path d="M15.686 4.314A12.5 12.5 0 0 0 5.461 2.958 1 1 0 0 0 5.58 4.71a22 22 0 0 1 6.318 3.393"/><path d="M17.7 3.7a1 1 0 0 0-1.4 0l-4.6 4.6a1 1 0 0 0 0 1.4l2.6 2.6a1 1 0 0 0 1.4 0l4.6-4.6a1 1 0 0 0 0-1.4z"/><path d="M19.686 8.314a12.501 12.501 0 0 1 1.356 10.225 1 1 0 0 1-1.751-.119 22 22 0 0 0-3.393-6.319"/></svg>`;
|
||||||
|
|
||||||
|
export const iconHourglass = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-hourglass"><path d="M5 22h14"/><path d="M5 2h14"/><path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22"/><path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2"/></svg>`;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export const EdScriptMonaco: FC<{}> = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!w.monaco_loaded) {
|
if (!w.monaco_loaded) {
|
||||||
w.monaco_loaded = true;
|
w.monaco_loaded = true;
|
||||||
console.clear();
|
setTimeout(console.clear, 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,13 @@ export const EdTreeName = ({
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<Name name={name} is_jsx_prop={is_jsx_prop} meta={node.data} />
|
<Name
|
||||||
|
name={name}
|
||||||
|
is_jsx_prop={is_jsx_prop}
|
||||||
|
meta={node.data}
|
||||||
|
metas={p.page.meta}
|
||||||
|
comps={p.comp.list}
|
||||||
|
/>
|
||||||
{/* <div className={"text-[9px] text-gray-500 -mt-1"}>
|
{/* <div className={"text-[9px] text-gray-500 -mt-1"}>
|
||||||
{node.id} - {item.originalId}
|
{node.id} - {item.originalId}
|
||||||
</div> */}
|
</div> */}
|
||||||
|
|
@ -133,11 +139,13 @@ export const EdTreeName = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Name: FC<{ name: string; is_jsx_prop: boolean; meta?: IMeta }> = ({
|
const Name: FC<{
|
||||||
name,
|
name: string;
|
||||||
is_jsx_prop,
|
is_jsx_prop: boolean;
|
||||||
meta,
|
meta?: IMeta;
|
||||||
}) => {
|
metas: Record<string, IMeta>;
|
||||||
|
comps: Record<string, { meta: Record<string, IMeta> }>;
|
||||||
|
}> = ({ name, is_jsx_prop, meta, comps }) => {
|
||||||
let comp_label = "";
|
let comp_label = "";
|
||||||
if (meta?.item.component?.id) {
|
if (meta?.item.component?.id) {
|
||||||
for (const prop of Object.values(meta?.item.component?.props || {})) {
|
for (const prop of Object.values(meta?.item.component?.props || {})) {
|
||||||
|
|
@ -153,7 +161,29 @@ const Name: FC<{ name: string; is_jsx_prop: boolean; meta?: IMeta }> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_jsx_prop) {
|
if (is_jsx_prop) {
|
||||||
|
let gen_jsx = false;
|
||||||
const comp_id = meta?.item.component?.id;
|
const comp_id = meta?.item.component?.id;
|
||||||
|
let comp = null as null | IMeta;
|
||||||
|
if (comp_id && comps[comp_id] && comps[comp_id].meta) {
|
||||||
|
const key = Object.keys(comps[comp_id].meta).shift();
|
||||||
|
if (key) {
|
||||||
|
comp = comps[comp_id].meta[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
comp &&
|
||||||
|
(comp.item.component?.props[name] || comp.item.component?.props.child)
|
||||||
|
) {
|
||||||
|
for (const child of comp.item.childs) {
|
||||||
|
if (child.name.startsWith("jsx:")) {
|
||||||
|
if ([name, "child"].includes(child.name.substring(4).trim())) {
|
||||||
|
gen_jsx = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!comp_id) gen_jsx = true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={cx("flex items-center space-x-1 pr-1")}>
|
<div className={cx("flex items-center space-x-1 pr-1")}>
|
||||||
|
|
@ -170,7 +200,7 @@ const Name: FC<{ name: string; is_jsx_prop: boolean; meta?: IMeta }> = ({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{meta && meta.mitem && active.comp_id !== comp_id && (
|
{gen_jsx && meta && meta.mitem && active.comp_id !== comp_id && (
|
||||||
<GenerateJSX meta={meta} />
|
<GenerateJSX meta={meta} />
|
||||||
)}
|
)}
|
||||||
{meta && !meta.mitem && (
|
{meta && !meta.mitem && (
|
||||||
|
|
|
||||||
|
|
@ -161,23 +161,11 @@ export const devItem = (
|
||||||
} as any;
|
} as any;
|
||||||
}
|
}
|
||||||
if (c.value) {
|
if (c.value) {
|
||||||
if (props[c.name]?.content) {
|
props[c.name].content = removeEditFromChilds(
|
||||||
props[c.name].content = {
|
[c.value],
|
||||||
...(props[c.name].content as any),
|
compile
|
||||||
childs: [
|
)[0];
|
||||||
removeEditFromChilds([c.value], compile)[0],
|
console.log(props[c.name].content);
|
||||||
],
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
props[c.name].content = {
|
|
||||||
type: "item",
|
|
||||||
id: createId(),
|
|
||||||
name: c.name,
|
|
||||||
childs: [
|
|
||||||
removeEditFromChilds([c.value], compile)[0],
|
|
||||||
],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,14 @@ export const useLocal = <T extends object>(
|
||||||
|
|
||||||
local.data.render = () => {
|
local.data.render = () => {
|
||||||
if (local.ready) {
|
if (local.ready) {
|
||||||
if (Date.now() - local.lastRender < 200) {
|
if (Date.now() - local.lastRender < 300) {
|
||||||
local.lastRenderCount++;
|
local.lastRenderCount++;
|
||||||
} else {
|
} else {
|
||||||
local.lastRenderCount = 0;
|
local.lastRenderCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local.lastRenderCount > 20) {
|
if (local.lastRenderCount > 50) {
|
||||||
throw new Error("local.render more than 20 times in less than 200ms");
|
throw new Error("local.render more than 50 times in less than 300ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
local.lastRender = Date.now();
|
local.lastRender = Date.now();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue