This commit is contained in:
Rizky 2024-03-23 12:28:29 +07:00
parent 5633cd93ae
commit 36459857d9
7 changed files with 22 additions and 21 deletions

File diff suppressed because one or more lines are too long

View File

@ -38,12 +38,7 @@ export const assignMitem = (arg: {
} else { } else {
let parent = meta[m.parent.id]; let parent = meta[m.parent.id];
if ( if (!parent.mitem && m.parent.instance_id && meta[m.parent.instance_id]) {
!parent.mitem &&
m.parent.instance_id &&
meta[m.parent.instance_id] &&
meta[m.parent.instance_id].mitem
) {
parent = meta[m.parent.instance_id]; parent = meta[m.parent.instance_id];
} }
@ -77,17 +72,20 @@ export const assignMitem = (arg: {
} }
} else { } else {
parent.mitem.get("childs")?.forEach((child) => { parent.mitem.get("childs")?.forEach((child) => {
if (child && child.get && child.get("id") === m.item.id) { const id = child && child.get && child.get("id");
const original_id = child && child.get && child.get("originalId");
if (typeof id === "string" && id === m.item.id) {
m.mitem = child;
} else if (
typeof original_id === "string" &&
original_id === m.item.originalId
) {
m.mitem = child; m.mitem = child;
} }
}); });
} }
} }
if (m.item.name === "nav_menu") {
console.log(m);
}
if (m.item.component?.props) { if (m.item.component?.props) {
for (const [prop_name, v] of Object.entries(m.item.component.props)) { for (const [prop_name, v] of Object.entries(m.item.component.props)) {
let mprop = m.mitem?.get("component")?.get("props")?.get(prop_name); let mprop = m.mitem?.get("component")?.get("props")?.get(prop_name);

View File

@ -13,6 +13,7 @@ export const edActionCopy = async (p: PG, item: IContent) => {
const walk = (_item: IContent) => { const walk = (_item: IContent) => {
let item = _item; let item = _item;
if (item.type !== "text") { if (item.type !== "text") {
if (item.type === "item" && item.component?.props) { if (item.type === "item" && item.component?.props) {
for (const [k, v] of Object.entries(item.component.props)) { for (const [k, v] of Object.entries(item.component.props)) {
@ -23,9 +24,10 @@ export const edActionCopy = async (p: PG, item: IContent) => {
} }
for (const [key, child] of Object.entries(item.childs)) { for (const [key, child] of Object.entries(item.childs)) {
if (child && Object.keys(child).length === 1) { if (child && Object.keys(child).length <= 2) {
const meta = p.page.meta[child.id]; const meta = p.page.meta[child.id];
if (meta) { if (meta) {
console.log(meta.item);
const new_child = deepClone(meta.item); const new_child = deepClone(meta.item);
item.childs[key as any] = new_child; item.childs[key as any] = new_child;
walk(new_child); walk(new_child);

View File

@ -24,7 +24,7 @@ export const edActionCut = async (p: PG, item: IContent) => {
} }
for (const [key, child] of Object.entries(item.childs)) { for (const [key, child] of Object.entries(item.childs)) {
if (child && Object.keys(child).length === 1) { if (child && Object.keys(child).length <= 2) {
const meta = p.page.meta[child.id]; const meta = p.page.meta[child.id];
if (meta) { if (meta) {
const new_child = deepClone(meta.item); const new_child = deepClone(meta.item);

View File

@ -103,7 +103,7 @@ export const genComp = (p: GenMetaP, arg: GenMetaArg) => {
for (const child of Object.values(item.childs)) { for (const child of Object.values(item.childs)) {
if (child?.name?.startsWith("jsx:")) continue; if (child?.name?.startsWith("jsx:")) continue;
if (child && Object.keys(child).length > 1) { if (child && Object.keys(child).length > 2) {
genMeta( genMeta(
{ ...p, mode: "comp" }, { ...p, mode: "comp" },
{ {

View File

@ -8,7 +8,7 @@ export const simplifyItemChild = (item: IItem) => {
newitem.childs = []; newitem.childs = [];
if (v && Array.isArray(v)) { if (v && Array.isArray(v)) {
for (const child of v) { for (const child of v) {
newitem.childs.push({ id: child.id }); newitem.childs.push({ id: child.id, originalId: child.originalId });
} }
} }
} else { } else {

View File

@ -43,8 +43,6 @@ export const createViPassProp = (
"props.meta.item.component.props.child.content.childs" "props.meta.item.component.props.child.content.childs"
) as unknown as any[]; ) as unknown as any[];
console.log(children);
if (Array.isArray(children)) { if (Array.isArray(children)) {
let is_meta = true; let is_meta = true;
for (const c of children) { for (const c of children) {
@ -62,9 +60,12 @@ export const createViPassProp = (
} }
if (cmeta) { if (cmeta) {
if (Object.keys(cmeta.item).length === 1 && cmeta.mitem) { if (Object.keys(cmeta.item).length <= 2) {
cmeta.item = cmeta.mitem.toJSON() as any; if (cmeta.mitem) {
cmeta.item = cmeta.mitem.toJSON() as any;
}
} }
return ( return (
<ViRender <ViRender
key={item.id} key={item.id}