import { useGlobal } from "web-utils"; import { jscript } from "../../utils/script/jscript"; import { Loading } from "../../utils/ui/loading"; import { EdLeft } from "./ed-left"; import { EdMid } from "./ed-mid"; import { EdRight } from "./ed-right"; import { EDGlobal } from "./logic/ed-global"; import { edInit } from "./logic/ed-init"; import { edRoute } from "./logic/ed-route"; import { edUndoManager } from "./logic/ed-undo"; import { EdMain } from "./panel/main/main"; import { EdPageHistoryMain } from "./panel/main/main-history"; import { EdPane } from "./panel/main/pane-resize"; import { EdPopApi } from "./panel/popup/api/api-server"; import { EdPopCode } from "./panel/popup/code/code"; import { EdPopCompGroup } from "./panel/popup/comp/comp-group"; import { EdPopComp } from "./panel/popup/comp/comp-popup"; import { EdPopPage } from "./panel/popup/page/page-popup"; import { EdPopScript } from "./panel/popup/script/pop-script"; import { EdPopSite } from "./panel/popup/site/site-popup"; import { iconVSCode } from "./panel/popup/code/icons"; import { isLocalhost } from "../../utils/ui/is-localhost"; import { w } from "../../utils/types/general"; import { edInitSync } from "./logic/ed-sync"; export const EdBase = () => { const p = useGlobal(EDGlobal, "EDITOR"); w.editorRender = p.render; edUndoManager(p); if (p.status === "init") { edInit(p); } edRoute(p); const vscode_url = isLocalhost() ? "http://localhost:8443?" : "https://prasi-vsc.avolut.com/?tkn=prasi&"; if (p.status === "load-site") { return (
{p.site.name || p.site.id}
{`page-${p.status}`}
{p.site.id && (
Open VSCode
)}
} /> ); } if (p.status === "site-not-found" || p.status === "page-not-found") { return (
{p.status === "site-not-found" ? "Site not found" : "Page not found"}
); } const Editor = jscript.editor; return (
{ w.pointer_active = false; }} onPointerEnter={() => { w.pointer_active = true; }} >
{p.status === "ready" && ( <> )}
{p.page.history.id ? ( ) : (
{p.status !== "ready" ? ( ) : ( <> {location.search !== "?norender" ? ( ) : (
Editor Render: Disabled
)} )}
)}
<> {Editor && !jscript.editorLoaded && (
{ jscript.editorLoaded = true; p.render(); }} />
)} {w.offline && (
Reconnecting, changes are not saved...
)} {w.sync_too_long && (
{ w.sync_too_long = false; p.render(); }} className={cx( css` position: fixed; bottom: 20px; left: 0px; right: 0px; z-index: 999; `, "flex justify-center cursor-pointer" )} >
Sync taking too long...
{ location.reload(); }} > Reload Page
)}
); }; const style = css` .toolbar-box { display: flex; align-items: stretch; border-left: 1px solid #ececeb; border-right: 1px solid #ececeb; margin: 0px 0px 0px 5px; .label { display: flex; user-select: none; align-items: center; font-size: 10px; margin-top: 1px; color: #999; text-transform: uppercase; } .items { display: flex; align-items: stretch; margin-left: 5px; color: #555; border-left: 1px solid transparent; .item { display: flex; align-items: center; cursor: pointer; user-select: none; border-right: 1px solid transparent; padding: 5px; border-radius: 0px; &:hover { background: #ececeb; } &.disabled { color: #ccc; cursor: default; } } .item:last-child { border-top-right-radius: 2px; border-bottom-right-radius: 2px; } } &.no-label { padding-left: 0px; margin-left: 0px; .items { margin-left: 0px; } } &:hover { border: 1px solid black; .items { color: #111; border-left: 1px solid #ececeb; .item { border-right: 1px solid #ececeb; } } } } `; export const mobileCSS = css` background-color: white; background-image: linear-gradient(45deg, #fafafa 25%, transparent 25%), linear-gradient(-45deg, #fafafa 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #fafafa 75%), linear-gradient(-45deg, transparent 75%, #fafafa 75%); background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0px; `;