fix
This commit is contained in:
parent
2d228cf2f7
commit
4bc0ae6881
|
|
@ -6,7 +6,8 @@ import { EText } from "./e-text";
|
||||||
export const EItem: FC<{
|
export const EItem: FC<{
|
||||||
id: string;
|
id: string;
|
||||||
fromProp?: boolean;
|
fromProp?: boolean;
|
||||||
}> = ({ id, fromProp }) => {
|
_scopeIndex?: Record<string, any>;
|
||||||
|
}> = ({ id, fromProp, _scopeIndex }) => {
|
||||||
return (
|
return (
|
||||||
<ErrorBox id={id}>
|
<ErrorBox id={id}>
|
||||||
<ERender id={id} fromProp={fromProp}>
|
<ERender id={id} fromProp={fromProp}>
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,8 @@ export const ERender: FC<{
|
||||||
id: string;
|
id: string;
|
||||||
children?: (childs: IContent[]) => ReactNode;
|
children?: (childs: IContent[]) => ReactNode;
|
||||||
fromProp?: boolean;
|
fromProp?: boolean;
|
||||||
}> = ({ id, children }) => {
|
_scopeIndex?: Record<string, any>;
|
||||||
|
}> = ({ id, children, _scopeIndex }) => {
|
||||||
const p = useGlobal(EditorGlobal, "EDITOR");
|
const p = useGlobal(EditorGlobal, "EDITOR");
|
||||||
const meta = p.treeMeta[id];
|
const meta = p.treeMeta[id];
|
||||||
|
|
||||||
|
|
@ -31,10 +32,6 @@ export const ERender: FC<{
|
||||||
}
|
}
|
||||||
let item = meta.item;
|
let item = meta.item;
|
||||||
|
|
||||||
if (item.hidden) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
meta.parent_prop &&
|
meta.parent_prop &&
|
||||||
typeof item.adv?.js === "string" &&
|
typeof item.adv?.js === "string" &&
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ import { ERender } from "./e-render";
|
||||||
export const EText: FC<{
|
export const EText: FC<{
|
||||||
id: string;
|
id: string;
|
||||||
fromProp?: boolean;
|
fromProp?: boolean;
|
||||||
}> = ({ id, fromProp }) => {
|
_scopeIndex?: Record<string, any>;
|
||||||
|
}> = ({ id, fromProp, _scopeIndex }) => {
|
||||||
return (
|
return (
|
||||||
<ErrorBox id={id}>
|
<ErrorBox id={id}>
|
||||||
<ERender id={id} fromProp={fromProp} />
|
<ERender id={id} fromProp={fromProp} />
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ export type ItemMeta = {
|
||||||
mitem?: MContent;
|
mitem?: MContent;
|
||||||
item: IContent;
|
item: IContent;
|
||||||
parent_id: string;
|
parent_id: string;
|
||||||
|
indexedScope: Record<string, any>;
|
||||||
parent_comp?: WithRequired<ItemMeta, "comp"> & { item: IItem };
|
parent_comp?: WithRequired<ItemMeta, "comp"> & { item: IItem };
|
||||||
parent_prop?: ItemMeta;
|
parent_prop?: ItemMeta;
|
||||||
scope?: any;
|
scope?: any;
|
||||||
|
|
@ -150,7 +151,10 @@ export const EditorGlobal = {
|
||||||
text: string;
|
text: string;
|
||||||
data: { meta: ItemMeta; idx: number };
|
data: { meta: ItemMeta; idx: number };
|
||||||
}[],
|
}[],
|
||||||
|
treePending: null as null | Promise<void>,
|
||||||
treeMeta: {} as Record<string, ItemMeta>,
|
treeMeta: {} as Record<string, ItemMeta>,
|
||||||
|
cachedParentID: {} as Record<string, string>,
|
||||||
|
compInstance: {} as Record<string, Record<string, string>>,
|
||||||
|
|
||||||
/** components */
|
/** components */
|
||||||
comp: null as null | {
|
comp: null as null | {
|
||||||
|
|
@ -177,7 +181,6 @@ export const EditorGlobal = {
|
||||||
},
|
},
|
||||||
compDirectEdit: false,
|
compDirectEdit: false,
|
||||||
compLoading: {} as Record<string, true>,
|
compLoading: {} as Record<string, true>,
|
||||||
compInstance: {} as Record<string, Record<string, string>>,
|
|
||||||
|
|
||||||
/** routing */
|
/** routing */
|
||||||
pagePreload: {} as Record<string, true>,
|
pagePreload: {} as Record<string, true>,
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,7 @@ export const rebuildTree = async (
|
||||||
p: PG,
|
p: PG,
|
||||||
opt?: { render?: () => void; mode?: REBUILD_MODE; note: string }
|
opt?: { render?: () => void; mode?: REBUILD_MODE; note: string }
|
||||||
) => {
|
) => {
|
||||||
if (p.pendingRebuild || p.focused) {
|
p.treePending = new Promise<void>(async (resolve) => {
|
||||||
return;
|
|
||||||
}
|
|
||||||
p.pendingRebuild = true;
|
|
||||||
|
|
||||||
const _render = () => {
|
const _render = () => {
|
||||||
if (opt?.render) {
|
if (opt?.render) {
|
||||||
opt?.render();
|
opt?.render();
|
||||||
|
|
@ -56,28 +52,6 @@ export const rebuildTree = async (
|
||||||
await mpage?.doc?.transact(async () => {
|
await mpage?.doc?.transact(async () => {
|
||||||
let parent_id = "root";
|
let parent_id = "root";
|
||||||
let includeTree = p.comp?.id ? false : true;
|
let includeTree = p.comp?.id ? false : true;
|
||||||
// const pageName = p.mpage?.getMap("map").get("name") as string;
|
|
||||||
// if (
|
|
||||||
// p.layout.section &&
|
|
||||||
// p.layout.content &&
|
|
||||||
// !pageName.startsWith("layout:")
|
|
||||||
// ) {
|
|
||||||
// await walk(p, mode, {
|
|
||||||
// item: p.layout.section,
|
|
||||||
// parent_id: "root",
|
|
||||||
// depth: 0,
|
|
||||||
// idx: 0,
|
|
||||||
// includeTree: false,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// parent_id = p.layout.content.id;
|
|
||||||
// p.layout.content.type = "item";
|
|
||||||
// if (p.layout.content.type === "item") {
|
|
||||||
// p.layout.content.childs = (p.page?.content_tree.childs ||
|
|
||||||
// []) as unknown as IItem[];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
mpage?.get("childs")?.map(async (mitem) => {
|
mpage?.get("childs")?.map(async (mitem) => {
|
||||||
await walk(p, mode, {
|
await walk(p, mode, {
|
||||||
|
|
@ -103,8 +77,11 @@ export const rebuildTree = async (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p.pendingRebuild = false;
|
resolve();
|
||||||
|
p.treePending = null;
|
||||||
|
|
||||||
_render();
|
_render();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const walk = async (
|
export const walk = async (
|
||||||
|
|
@ -125,7 +102,6 @@ export const walk = async (
|
||||||
}
|
}
|
||||||
) => {
|
) => {
|
||||||
let item = val.item as IContent;
|
let item = val.item as IContent;
|
||||||
|
|
||||||
let mitem = val.mitem;
|
let mitem = val.mitem;
|
||||||
|
|
||||||
if (val.mitem) {
|
if (val.mitem) {
|
||||||
|
|
@ -172,6 +148,7 @@ export const walk = async (
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item) {
|
if (item) {
|
||||||
|
if (item.hidden) return;
|
||||||
let comp: ItemMeta["comp"] = undefined as any;
|
let comp: ItemMeta["comp"] = undefined as any;
|
||||||
|
|
||||||
if (item.type === "item" && item.component?.id) {
|
if (item.type === "item" && item.component?.id) {
|
||||||
|
|
@ -242,7 +219,7 @@ export const walk = async (
|
||||||
const meta: ItemMeta = {
|
const meta: ItemMeta = {
|
||||||
mitem: mitem,
|
mitem: mitem,
|
||||||
item,
|
item,
|
||||||
parent_id: val.parent_id,
|
parent_id: p.cachedParentID[item.id] || val.parent_id,
|
||||||
parent_comp: val.parent_comp as any,
|
parent_comp: val.parent_comp as any,
|
||||||
depth: val.depth || 0,
|
depth: val.depth || 0,
|
||||||
elprop: createElProp(item, p),
|
elprop: createElProp(item, p),
|
||||||
|
|
@ -252,6 +229,7 @@ export const walk = async (
|
||||||
hover: p.item.sideHover ? false : p.item.hover === item.id,
|
hover: p.item.sideHover ? false : p.item.hover === item.id,
|
||||||
active: p.item.sideHover ? false : p.item.active === item.id,
|
active: p.item.sideHover ? false : p.item.active === item.id,
|
||||||
}),
|
}),
|
||||||
|
indexedScope: p.treeMeta[item.id] ? p.treeMeta[item.id].indexedScope : {},
|
||||||
comp,
|
comp,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -167,10 +167,15 @@ export const ETreeBody: FC<{ tree: NodeModel<NodeMeta>[]; meta?: any }> = ({
|
||||||
[tree]
|
[tree]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onOut = useCallback(() => {
|
||||||
|
p.item.hover = "";
|
||||||
|
p.softRender.all();
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
if (p.pendingRebuild) {
|
if (p.treePending) {
|
||||||
await waitUntil(() => !p.pendingRebuild);
|
await p.treePending;
|
||||||
}
|
}
|
||||||
const open = new Set<string>();
|
const open = new Set<string>();
|
||||||
|
|
||||||
|
|
@ -252,7 +257,10 @@ export const ETreeBody: FC<{ tree: NodeModel<NodeMeta>[]; meta?: any }> = ({
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
|
<DndProvider backend={MultiBackend} options={getBackendOptions()}>
|
||||||
<div className="flex flex-col items-stretch bg-white right-0 left-0">
|
<div
|
||||||
|
className="flex flex-col items-stretch bg-white right-0 left-0"
|
||||||
|
onPointerOut={onOut}
|
||||||
|
>
|
||||||
{local.rightClick.node && (
|
{local.rightClick.node && (
|
||||||
<ETreeRightClick
|
<ETreeRightClick
|
||||||
node={local.rightClick.node}
|
node={local.rightClick.node}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ export const rebuildTree = async (
|
||||||
p.treePending = null;
|
p.treePending = null;
|
||||||
|
|
||||||
if (_.render !== false) {
|
if (_.render !== false) {
|
||||||
console.log("rendering");
|
|
||||||
p.render();
|
p.render();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -67,7 +66,7 @@ const walk = async (
|
||||||
const treeMeta = val.treeMeta;
|
const treeMeta = val.treeMeta;
|
||||||
let item = val.item as IContent;
|
let item = val.item as IContent;
|
||||||
|
|
||||||
if (item.hidden) return;
|
if (item.hidden === 'all') return;
|
||||||
|
|
||||||
if (val.parent_comp) {
|
if (val.parent_comp) {
|
||||||
const pchild_ids = val.parent_comp.comp?.child_ids;
|
const pchild_ids = val.parent_comp.comp?.child_ids;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue