wip fix
This commit is contained in:
parent
a9c671a88b
commit
a71800d7e5
|
|
@ -1,21 +1,33 @@
|
||||||
import { useGlobal } from "web-utils";
|
import { useGlobal } from "web-utils";
|
||||||
import { w } from "../../../../../utils/types/general";
|
import { w } from "../../../../../utils/types/general";
|
||||||
import { ToolbarBox } from "../../../../../utils/ui/box";
|
import { ToolbarBox } from "../../../../../utils/ui/box";
|
||||||
|
import { applyEnv } from "../../../../vi/load/load-snapshot";
|
||||||
import { EDGlobal } from "../../../logic/ed-global";
|
import { EDGlobal } from "../../../logic/ed-global";
|
||||||
|
import { treeRebuild } from "../../../logic/tree/build";
|
||||||
|
|
||||||
export const ResponsiveToggle = () => {
|
export const ResponsiveToggle = () => {
|
||||||
const c = useGlobal(EDGlobal, "EDITOR");
|
const p = useGlobal(EDGlobal, "EDITOR");
|
||||||
const mode = c.mode;
|
const mode = p.mode;
|
||||||
const activeModeClassName = "border-b-2 border-blue-500";
|
const activeModeClassName = "border-b-2 border-blue-500";
|
||||||
|
|
||||||
|
const render = () => {
|
||||||
|
const code = p.code["site"].doc;
|
||||||
|
if (code) {
|
||||||
|
const src = code.getMap("map").get("files")?.get("index.js");
|
||||||
|
applyEnv(p, src);
|
||||||
|
treeRebuild(p);
|
||||||
|
p.render();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const box = {
|
const box = {
|
||||||
mobile: {
|
mobile: {
|
||||||
onClick() {
|
onClick() {
|
||||||
c.mode = "mobile";
|
p.mode = "mobile";
|
||||||
w.isMobile = true;
|
w.isMobile = true;
|
||||||
w.isDesktop = false;
|
w.isDesktop = false;
|
||||||
localStorage.setItem("prasi-editor-mode", "mobile");
|
localStorage.setItem("prasi-editor-mode", "mobile");
|
||||||
c.render();
|
render();
|
||||||
},
|
},
|
||||||
className: cx(mode === "mobile" && activeModeClassName),
|
className: cx(mode === "mobile" && activeModeClassName),
|
||||||
content: (
|
content: (
|
||||||
|
|
@ -37,11 +49,11 @@ export const ResponsiveToggle = () => {
|
||||||
},
|
},
|
||||||
desktop: {
|
desktop: {
|
||||||
onClick() {
|
onClick() {
|
||||||
c.mode = "desktop";
|
p.mode = "desktop";
|
||||||
w.isMobile = false;
|
w.isMobile = false;
|
||||||
w.isDesktop = true;
|
w.isDesktop = true;
|
||||||
localStorage.setItem("prasi-editor-mode", "desktop");
|
localStorage.setItem("prasi-editor-mode", "desktop");
|
||||||
c.render();
|
render();
|
||||||
},
|
},
|
||||||
className: cx(mode === "desktop" && activeModeClassName),
|
className: cx(mode === "desktop" && activeModeClassName),
|
||||||
content: (
|
content: (
|
||||||
|
|
@ -63,9 +75,9 @@ export const ResponsiveToggle = () => {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const items: any[] = [];
|
const items: any[] = [];
|
||||||
if (c.site.responsive === "mobile-only") {
|
if (p.site.responsive === "mobile-only") {
|
||||||
items.push(box.mobile);
|
items.push(box.mobile);
|
||||||
} else if (c.site.responsive === "desktop-only") {
|
} else if (p.site.responsive === "desktop-only") {
|
||||||
items.push(box.desktop);
|
items.push(box.desktop);
|
||||||
} else {
|
} else {
|
||||||
items.push(box.mobile);
|
items.push(box.mobile);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,4 @@
|
||||||
import React, {
|
import React, { FC, ReactElement, useCallback, useEffect } from "react";
|
||||||
FC,
|
|
||||||
ReactElement,
|
|
||||||
useCallback,
|
|
||||||
useEffect,
|
|
||||||
useTransition,
|
|
||||||
} from "react";
|
|
||||||
import { useLocal } from "web-utils";
|
import { useLocal } from "web-utils";
|
||||||
|
|
||||||
export const FieldNumUnit: FC<{
|
export const FieldNumUnit: FC<{
|
||||||
|
|
@ -65,7 +59,6 @@ export const FieldNumUnit: FC<{
|
||||||
}
|
}
|
||||||
local.unit = unit || unt || "px";
|
local.unit = unit || unt || "px";
|
||||||
|
|
||||||
|
|
||||||
if (!local.focus) {
|
if (!local.focus) {
|
||||||
local.val_str = local.val + "";
|
local.val_str = local.val + "";
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +155,8 @@ export const FieldNumUnit: FC<{
|
||||||
)}
|
)}
|
||||||
disabled={!!disabled}
|
disabled={!!disabled}
|
||||||
value={typeof disabled === "string" ? disabled : local.val_str}
|
value={typeof disabled === "string" ? disabled : local.val_str}
|
||||||
onFocus={() => {
|
onFocus={(e) => {
|
||||||
|
e.currentTarget.select();
|
||||||
local.focus = true;
|
local.focus = true;
|
||||||
local.render();
|
local.render();
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ export const viLoadSnapshot = async (p: PG) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyEnv = (p: PG, src?: string) => {
|
export const applyEnv = (p: PG, src?: string) => {
|
||||||
if (src) {
|
if (src) {
|
||||||
const w = window as any;
|
const w = window as any;
|
||||||
const module = evalCJS(src);
|
const module = evalCJS(src);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ export const baseTypings = `
|
||||||
const children: RNode;
|
const children: RNode;
|
||||||
|
|
||||||
const PassProp: FC<Record<string, any> & { children: React.ReactNode }>;
|
const PassProp: FC<Record<string, any> & { children: React.ReactNode }>;
|
||||||
const PassChild: FC<{ name: string }>;
|
|
||||||
const Preload: FC<{ url: string[] }>;
|
const Preload: FC<{ url: string[] }>;
|
||||||
const apiurl: string;
|
const apiurl: string;
|
||||||
const pageid: string;
|
const pageid: string;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue