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