wip fix
This commit is contained in:
parent
c47ac70064
commit
e18db3795a
|
|
@ -226,7 +226,7 @@ export const EDGlobal = {
|
||||||
},
|
},
|
||||||
page: {
|
page: {
|
||||||
open: null as null | ((page_id: string) => void),
|
open: null as null | ((page_id: string) => void),
|
||||||
form: null as null | PageItem,
|
form: null as null | Partial<page>,
|
||||||
},
|
},
|
||||||
script: {
|
script: {
|
||||||
open: false,
|
open: false,
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,13 @@ export const EdMain = () => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
"flex flex-1 relative",
|
"flex flex-1 relative overflow-auto ",
|
||||||
css`
|
css`
|
||||||
contain: content;
|
contain: content;
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="absolute overflow-auto inset-0 flex">
|
<div className="absolute inset-0 flex flex-col">
|
||||||
{!!p.page.building && <Loading backdrop={false} />}
|
{!!p.page.building && <Loading backdrop={false} />}
|
||||||
{!p.page.building && code.mode !== "" && (
|
{!p.page.building && code.mode !== "" && (
|
||||||
<View
|
<View
|
||||||
|
|
|
||||||
|
|
@ -34,10 +34,14 @@ export const EdPagePop = () => {
|
||||||
cur = pagePicker.tree.find((e) => e.id === parent_id);
|
cur = pagePicker.tree.find((e) => e.id === parent_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
local.tree.open(parents);
|
if (parents.length === 0) {
|
||||||
|
local.tree.open("page-root");
|
||||||
|
} else {
|
||||||
|
local.tree.open(parents);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, [p.ui.popup.page.open]);
|
}, [p.ui.popup.page.open, p.page.cur.id, pagePicker.site_id]);
|
||||||
|
|
||||||
if (!p.ui.popup.page.open) return null;
|
if (!p.ui.popup.page.open) return null;
|
||||||
|
|
||||||
|
|
@ -106,22 +110,28 @@ export const EdPagePop = () => {
|
||||||
p.ui.popup.page.form = null;
|
p.ui.popup.page.form = null;
|
||||||
p.render();
|
p.render();
|
||||||
}}
|
}}
|
||||||
onSave={async (page) => {
|
onSave={async (page, isNew) => {
|
||||||
p.ui.popup.page.form = null;
|
p.ui.popup.page.form = null;
|
||||||
|
|
||||||
const found = pagePicker.tree.find(
|
if (isNew) {
|
||||||
(e) => e.id === page.id && e.data?.type === "page"
|
p.render();
|
||||||
);
|
await reloadPagePicker(p);
|
||||||
if (found) {
|
navigate(`/ed/${p.site.id}/${page.id}`);
|
||||||
for (const [k, v] of Object.entries(found.data || {})) {
|
} else {
|
||||||
if (page[k]) {
|
const found = pagePicker.tree.find(
|
||||||
(found.data as any)[k] = page[k];
|
(e) => e.id === page.id && e.data?.type === "page"
|
||||||
|
);
|
||||||
|
if (found) {
|
||||||
|
for (const [k, v] of Object.entries(found.data || {})) {
|
||||||
|
if (page[k]) {
|
||||||
|
(found.data as any)[k] = page[k];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
found.text = page.name;
|
||||||
}
|
}
|
||||||
found.text = page.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.render();
|
p.render();
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -128,6 +128,12 @@ export const edPageTreeRender: NodeRender<PageItem> = (
|
||||||
className="btn transition-all bg-white flex items-center border px-1 hover:border-blue-300 hover:bg-blue-100"
|
className="btn transition-all bg-white flex items-center border px-1 hover:border-blue-300 hover:bg-blue-100"
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
p.ui.popup.page.form = {
|
||||||
|
id_site: p.site.id,
|
||||||
|
id_folder: item.id === "root" ? null : item.id,
|
||||||
|
};
|
||||||
|
p.render();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
+ Page
|
+ Page
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,9 @@ export const ScriptMonaco = () => {
|
||||||
tabSize: 2,
|
tabSize: 2,
|
||||||
useTabStops: true,
|
useTabStops: true,
|
||||||
}}
|
}}
|
||||||
|
language={
|
||||||
|
{ css: "scss", js: "typescript", html: "html" }[p.ui.popup.script.mode]
|
||||||
|
}
|
||||||
onMount={async (editor, monaco) => {
|
onMount={async (editor, monaco) => {
|
||||||
local.editor = editor;
|
local.editor = editor;
|
||||||
editor.focus();
|
editor.focus();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue