wip fix code
This commit is contained in:
parent
3d57ce6c97
commit
579e4495f1
|
|
@ -41,39 +41,41 @@ export const code_edit: SAction["code"]["edit"] = async function (
|
|||
|
||||
if (mitem) {
|
||||
if (arg.type === "adv") {
|
||||
const mode = arg.mode;
|
||||
let adv = mitem.get("adv");
|
||||
if (!adv) {
|
||||
mitem.set("adv", new Y.Map() as any);
|
||||
adv = mitem.get("adv");
|
||||
}
|
||||
const res = await transform(`render(${src})`, {
|
||||
jsx: "transform",
|
||||
format: "cjs",
|
||||
loader: "tsx",
|
||||
minify: true,
|
||||
sourcemap: "inline",
|
||||
});
|
||||
doc?.transact(() => {
|
||||
const mode = arg.mode;
|
||||
let adv = mitem.get("adv");
|
||||
if (!adv) {
|
||||
mitem.set("adv", new Y.Map() as any);
|
||||
adv = mitem.get("adv");
|
||||
}
|
||||
|
||||
if (adv) {
|
||||
try {
|
||||
const res = await transform(`render(${src})`, {
|
||||
jsx: "transform",
|
||||
format: "cjs",
|
||||
loader: "tsx",
|
||||
minify: true,
|
||||
sourcemap: "inline",
|
||||
});
|
||||
|
||||
doc?.transact(() => {
|
||||
if (adv) {
|
||||
try {
|
||||
if (adv) {
|
||||
adv.set(mode, src);
|
||||
if (mode === "js") {
|
||||
adv.set("jsBuilt", res.code);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
g.log.error(e);
|
||||
}
|
||||
} catch (e) {
|
||||
g.log.error(e);
|
||||
}
|
||||
|
||||
if (mode === "js") {
|
||||
return parseJs(adv.get("js")) || false;
|
||||
if (mode === "js") {
|
||||
const res = parseJs(adv.get("js")) || false;
|
||||
if (res) {
|
||||
mitem.set("script", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
const mprop = mitem
|
||||
.get("component")
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ export const prepContentTree = async (
|
|||
meta,
|
||||
on: {
|
||||
visit(meta, item) {
|
||||
if (meta.item.adv?.js) {
|
||||
meta.item.script = parseJs(meta.item.adv.js);
|
||||
if (item.adv?.js) {
|
||||
item.script = parseJs(item.adv.js);
|
||||
}
|
||||
|
||||
if (item.component?.id) {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ export const scopeMapExportImport = (p: PG, meta: IMeta, parents: IMeta[]) => {
|
|||
}
|
||||
}
|
||||
|
||||
console.log(def);
|
||||
|
||||
if (def) {
|
||||
const ex = extractExportImport(p, m, imports);
|
||||
if (next_parent) {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ export const declareScope = async (
|
|||
for (const [filename, src] of Object.entries(v)) {
|
||||
if (!added.has(filename)) {
|
||||
added.add(filename);
|
||||
|
||||
addScope(p, monaco, filename, src);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ effect={async (local) => {
|
|||
onClick={() => {
|
||||
p.script.do_edit(
|
||||
`\
|
||||
<PassProp idx={0} children={children} />
|
||||
<PassProp key={0} children={children} />
|
||||
`,
|
||||
false
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ export type IItem = {
|
|||
linktag?: FNLinkTag;
|
||||
mobile?: IItem;
|
||||
adv?: FNAdv;
|
||||
script?: ReturnType<typeof parseJs>;
|
||||
type: "item";
|
||||
component?: FNComponent;
|
||||
childs: (IItem | IText)[];
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { parseJs } from "../../../../srv/ws/sync/editor/parser/parse-js";
|
||||
import {
|
||||
FMAdv,
|
||||
FMBackground,
|
||||
|
|
@ -32,6 +33,7 @@ export type BasicItem = {
|
|||
font?: FNFont;
|
||||
dim?: FNDimension;
|
||||
border?: FNBorder;
|
||||
script?: ReturnType<typeof parseJs>;
|
||||
};
|
||||
|
||||
export type MBasicItem = {
|
||||
|
|
@ -41,7 +43,7 @@ export type MBasicItem = {
|
|||
component?: FMComponent;
|
||||
dim?: FMDimension;
|
||||
layout?: FMLayout;
|
||||
linktag?: FMLinkTag;
|
||||
adv?: FMAdv;
|
||||
border?: FMBorder;
|
||||
script?: ReturnType<typeof parseJs>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue