import { FC } from "react"; import { useGlobal, useLocal } from "web-utils"; import { IItem } from "../../../../utils/types/item"; import { FMCompDef } from "../../../../utils/types/meta-fn"; import { Menu, MenuItem } from "../../../../utils/ui/context-menu"; import { EDGlobal, EdMeta, active } from "../../logic/ed-global"; import { EdPropInstanceCode } from "./prop-instance/prop-code"; import { EdPropInstanceOptions } from "./prop-instance/prop-option"; import { reset } from "./prop-instance/prop-reset"; import { EdPropInstanceText } from "./prop-instance/prop-text"; export const EdSidePropInstance: FC<{ meta: EdMeta }> = ({ meta }) => { const p = useGlobal(EDGlobal, "EDITOR"); const local = useLocal({ rightClickEvent: null as any, reset: { mprop: null as any, name: "" }, showJSX: false, }); const item = meta?.item as IItem; if (!item) return null; let filtered = [] as { mprop: FMCompDef; name: string }[]; const mprops = meta.mitem?.get("component")?.get("props"); const comp_id = meta.mitem?.get("component")?.get("id") || ""; const mcprops = p.comp.list[comp_id].doc .getMap("map") .get("root") ?.get("component") ?.get("props"); if (mprops && meta.mitem && mcprops) { mcprops.forEach((m, key) => { let mprop = mprops.get(key); const type = m.get("meta")?.get("type") || "text"; const visible = mprop?.get("visible") || ""; if (meta.propvis) { if (meta.propvis[key] === false) return; } else if (visible) { return; } if (!local.showJSX && type === "content-element") { return; } if (!mprop) { const json = m.toJSON(); const map = new Y.Map() as any; syncronize(map, json); mprops.set(key, map); filtered.push({ mprop: map, name: key }); } else { filtered.push({ mprop, name: key }); } }); filtered = filtered.sort((a, b) => { const aidx = a.mprop.get("idx") || 0; const bidx = b.mprop.get("idx") || 0; return aidx - bidx; }); } return (