wip fix master prop
This commit is contained in:
parent
2f74afcd30
commit
51c9df4954
|
|
@ -1,6 +1,5 @@
|
||||||
FROM oven/bun:1.0.18-debian as base
|
FROM oven/bun:1.0.18-debian as base
|
||||||
WORKDIR /app/prasi/repo
|
WORKDIR /app/prasi/repo
|
||||||
COPY . .
|
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get install git curl gnupg zip unzip -yq
|
RUN apt-get install git curl gnupg zip unzip -yq
|
||||||
|
|
@ -12,6 +11,8 @@ RUN apt-get install nodejs -yq
|
||||||
|
|
||||||
RUN npm i -g @parcel/watcher node-gyp-build-optional-packages node-gyp pnpm
|
RUN npm i -g @parcel/watcher node-gyp-build-optional-packages node-gyp pnpm
|
||||||
RUN PATH="/usr/lib/node_modules/npm/bin:$PATH"
|
RUN PATH="/usr/lib/node_modules/npm/bin:$PATH"
|
||||||
|
|
||||||
|
COPY . .
|
||||||
RUN bun install
|
RUN bun install
|
||||||
RUN bun run build
|
RUN bun run build
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export const prepCodeSnapshot = async (id_site: string, mode: CodeMode) => {
|
||||||
doc.on("update", async (e, origin) => {
|
doc.on("update", async (e, origin) => {
|
||||||
const bin = Y.encodeStateAsUpdate(doc);
|
const bin = Y.encodeStateAsUpdate(doc);
|
||||||
|
|
||||||
if (snap && snap.type === "code") {
|
if (typeof snap !== "undefined" && snap.type === "code") {
|
||||||
snap.build[mode].bin = bin;
|
snap.build[mode].bin = bin;
|
||||||
snapshot.update({
|
snapshot.update({
|
||||||
id: id_site,
|
id: id_site,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { pushTreeNode } from "../tree/build/push-tree";
|
||||||
import { isTextEditing } from "../active/is-editing";
|
import { isTextEditing } from "../active/is-editing";
|
||||||
import { assignMitem } from "../tree/assign-mitem";
|
import { assignMitem } from "../tree/assign-mitem";
|
||||||
import { createId } from "@paralleldrive/cuid2";
|
import { createId } from "@paralleldrive/cuid2";
|
||||||
|
import { waitUntil } from "web-utils";
|
||||||
|
|
||||||
export const loadcomp = {
|
export const loadcomp = {
|
||||||
timeout: 0 as any,
|
timeout: 0 as any,
|
||||||
|
|
@ -45,6 +46,8 @@ export const loadCompSnapshot = async (
|
||||||
comp_id: string,
|
comp_id: string,
|
||||||
snapshot: Uint8Array
|
snapshot: Uint8Array
|
||||||
) => {
|
) => {
|
||||||
|
if (p.comp.list[comp_id]) return;
|
||||||
|
|
||||||
const doc = new Y.Doc() as DComp;
|
const doc = new Y.Doc() as DComp;
|
||||||
Y.applyUpdate(doc as any, decompress(snapshot));
|
Y.applyUpdate(doc as any, decompress(snapshot));
|
||||||
const mitem = doc.getMap("map").get("root");
|
const mitem = doc.getMap("map").get("root");
|
||||||
|
|
@ -102,8 +105,6 @@ export const loadCompSnapshot = async (
|
||||||
if (isTextEditing()) {
|
if (isTextEditing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
treeRebuild(p, { note: "load-comp" });
|
|
||||||
p.render();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -142,7 +143,7 @@ export const updateComponentMeta = async (
|
||||||
let result = Object.entries(comps);
|
let result = Object.entries(comps);
|
||||||
|
|
||||||
for (const [id_comp, comp] of result) {
|
for (const [id_comp, comp] of result) {
|
||||||
if (comp && comp.snapshot) {
|
if (comp && comp.snapshot && !p.comp.list[id_comp]) {
|
||||||
await loadCompSnapshot(p, id_comp, comp.snapshot);
|
await loadCompSnapshot(p, id_comp, comp.snapshot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -156,7 +157,7 @@ export const updateComponentMeta = async (
|
||||||
meta,
|
meta,
|
||||||
mode: "comp",
|
mode: "comp",
|
||||||
on: {
|
on: {
|
||||||
visit(m) {
|
async visit(m) {
|
||||||
pushTreeNode(p, m, meta, tree);
|
pushTreeNode(p, m, meta, tree);
|
||||||
|
|
||||||
assignMitem({
|
assignMitem({
|
||||||
|
|
|
||||||
|
|
@ -58,12 +58,14 @@ export const treeRebuild = async (p: PG, arg?: { note?: string }) => {
|
||||||
mitem,
|
mitem,
|
||||||
meta,
|
meta,
|
||||||
new_prop_jsx(meta, mprops, prop_name, prop_val) {
|
new_prop_jsx(meta, mprops, prop_name, prop_val) {
|
||||||
transact.list.push(() => {
|
// if (prop_val.meta?.type === "content-element") {
|
||||||
const map = new Y.Map();
|
// transact.list.push(() => {
|
||||||
if (prop_val.content) prop_val.content.id = createId();
|
// const map = new Y.Map();
|
||||||
syncronize(map, prop_val);
|
// if (prop_val.content) prop_val.content.id = createId();
|
||||||
mprops.set(prop_name, map as any);
|
// syncronize(map, prop_val);
|
||||||
});
|
// mprops.set(prop_name, map as any);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {
|
||||||
PlaceholderRender,
|
PlaceholderRender,
|
||||||
getBackendOptions,
|
getBackendOptions,
|
||||||
} from "@minoru/react-dnd-treeview";
|
} from "@minoru/react-dnd-treeview";
|
||||||
import { FC } from "react";
|
import { FC, useState } from "react";
|
||||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||||
import { useGlobal, useLocal } from "web-utils";
|
import { useGlobal, useLocal } from "web-utils";
|
||||||
import { IItem } from "../../../../utils/types/item";
|
import { IItem } from "../../../../utils/types/item";
|
||||||
|
|
@ -20,14 +20,19 @@ const propRef = {
|
||||||
|
|
||||||
export const EdSidePropComp: FC<{ meta: IMeta }> = ({ meta }) => {
|
export const EdSidePropComp: FC<{ meta: IMeta }> = ({ meta }) => {
|
||||||
const p = useGlobal(EDGlobal, "EDITOR");
|
const p = useGlobal(EDGlobal, "EDITOR");
|
||||||
const local = useLocal({});
|
|
||||||
const item = meta?.item as IItem;
|
const item = meta?.item as IItem;
|
||||||
|
const [_, set] = useState({});
|
||||||
|
const render = () => {
|
||||||
|
set({});
|
||||||
|
};
|
||||||
|
propPopover.render = render;
|
||||||
if (!item) return null;
|
if (!item) return null;
|
||||||
|
|
||||||
const TypedTree = DNDTree<PropItem>;
|
const TypedTree = DNDTree<PropItem>;
|
||||||
|
|
||||||
let filtered = [] as NodeModel<PropItem>[];
|
let filtered = [] as NodeModel<PropItem>[];
|
||||||
let mprops = meta.mitem?.get("component")?.get("props");
|
let mprops = meta.mitem?.get("component")?.get("props");
|
||||||
|
|
||||||
if (!mprops) {
|
if (!mprops) {
|
||||||
const mcomp = meta.mitem?.get("component");
|
const mcomp = meta.mitem?.get("component");
|
||||||
if (mcomp) {
|
if (mcomp) {
|
||||||
|
|
@ -119,8 +124,8 @@ export const EdSidePropComp: FC<{ meta: IMeta }> = ({ meta }) => {
|
||||||
render={(node, params) => (
|
render={(node, params) => (
|
||||||
<EdPropCompTreeItem
|
<EdPropCompTreeItem
|
||||||
node={node}
|
node={node}
|
||||||
|
render={render}
|
||||||
params={params}
|
params={params}
|
||||||
render={local.render}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
rootId={"root"}
|
rootId={"root"}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { fillID } from "../../../logic/tree/fill-id";
|
||||||
|
|
||||||
export const propPopover = {
|
export const propPopover = {
|
||||||
name: "",
|
name: "",
|
||||||
render: {} as Record<string, () => void>,
|
render: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EdPropPopoverForm: FC<{
|
export const EdPropPopoverForm: FC<{
|
||||||
|
|
@ -23,10 +23,30 @@ export const EdPropPopoverForm: FC<{
|
||||||
const mmeta = mprop.get("meta");
|
const mmeta = mprop.get("meta");
|
||||||
const local = useLocal({
|
const local = useLocal({
|
||||||
name,
|
name,
|
||||||
|
rename_timeout: null as any,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!mmeta) return null;
|
if (!mmeta) return null;
|
||||||
const type = mmeta.get("type");
|
const type = mmeta.get("type");
|
||||||
|
|
||||||
|
const rename = () => {
|
||||||
|
const keys = Object.keys(mprop.parent?.toJSON());
|
||||||
|
if ([...keys, ...invalidKeyword].includes(local.name)) {
|
||||||
|
alert(`Cannot use "${local.name}" as name`);
|
||||||
|
local.name = name;
|
||||||
|
local.render();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mprop.doc?.transact(() => {
|
||||||
|
const parent = mprop.parent as TypedMap<Record<string, FMCompDef>>;
|
||||||
|
parent.set(local.name, parent.get(name)?.clone() as any);
|
||||||
|
parent.delete(name);
|
||||||
|
});
|
||||||
|
propPopover.name = local.name;
|
||||||
|
propPopover.render();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cx(
|
className={cx(
|
||||||
|
|
@ -72,6 +92,7 @@ export const EdPropPopoverForm: FC<{
|
||||||
} else {
|
} else {
|
||||||
mmeta.set("type", e.type as any);
|
mmeta.set("type", e.type as any);
|
||||||
}
|
}
|
||||||
|
propPopover.render();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{e.label}
|
{e.label}
|
||||||
|
|
@ -91,26 +112,12 @@ export const EdPropPopoverForm: FC<{
|
||||||
local.name = e.currentTarget.value
|
local.name = e.currentTarget.value
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/\W/gi, "_");
|
.replace(/\W/gi, "_");
|
||||||
|
|
||||||
local.render();
|
local.render();
|
||||||
}}
|
}}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
if (local.name !== name) {
|
if (local.name !== name) {
|
||||||
const keys = Object.keys(mprop.parent?.toJSON());
|
rename();
|
||||||
if ([...keys, ...invalidKeyword].includes(local.name)) {
|
|
||||||
alert(`Cannot use "${local.name}" as name`);
|
|
||||||
local.name = name;
|
|
||||||
local.render();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mprop.doc?.transact(() => {
|
|
||||||
const parent = mprop.parent as TypedMap<
|
|
||||||
Record<string, FMCompDef>
|
|
||||||
>;
|
|
||||||
parent.set(local.name, parent.get(name)?.clone() as any);
|
|
||||||
parent.delete(name);
|
|
||||||
});
|
|
||||||
propPopover.name = local.name;
|
|
||||||
local.render();
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ export const EdPropCompTreeItem: FC<{
|
||||||
render: () => void;
|
render: () => void;
|
||||||
}> = ({ node, params, render }) => {
|
}> = ({ node, params, render }) => {
|
||||||
const local = useLocal({ closing: false });
|
const local = useLocal({ closing: false });
|
||||||
propPopover.render[node.text] = local.render;
|
|
||||||
|
|
||||||
if (node.id === "root") {
|
if (node.id === "root") {
|
||||||
return <></>;
|
return <></>;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue