Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
wip getting access to body right
Oleg Isonene3541061f20a
diff --git a/apps/designer/app/canvas/canvas.tsx b/apps/designer/app/canvas/canvas.tsxindex 092e5a0e03..e1a4da37d1 100644--- a/apps/designer/app/canvas/canvas.tsx+++ b/apps/designer/app/canvas/canvas.tsx@@ -11,11 +11,9 @@ import {WrapperComponent,globalStyles,useSubscribe,-} from "@webstudio-is/react-sdk";-import {createElementsTree,- setInstanceChildrenMutable,-} from "~/shared/tree-utils";+} from "@webstudio-is/react-sdk";+import { setInstanceChildrenMutable } from "~/shared/tree-utils";import { useDragDropHandlers } from "./shared/use-drag-drop-handlers";import { useShortcuts } from "./shared/use-shortcuts";import {diff --git a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsxindex 169e79370a..7dc5571f4c 100644--- a/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx+++ b/apps/designer/app/canvas/features/wrapper-component/wrapper-component.tsx@@ -1,8 +1,8 @@import { useCallback, MouseEvent, FormEvent, useMemo } from "react";-import type { OnChangeChildren } from "~/shared/tree-utils";import {type Instance,type CSS,+ type OnChangeChildren,toCss,useUserProps,renderWrapperComponentChildren,diff --git a/apps/designer/app/shared/documents/canvas.tsx b/apps/designer/app/shared/documents/canvas.tsxindex 023a96310c..83fda3bf2a 100644--- a/apps/designer/app/shared/documents/canvas.tsx+++ b/apps/designer/app/shared/documents/canvas.tsx@@ -1,13 +1,13 @@import {Links,- LiveReload,Meta,Outlet as DefaultOutlet,Scripts,ScrollRestoration,} from "@remix-run/react";-import { CriticalCss } from "@webstudio-is/react-sdk";-import { Env } from "~/shared/env";+import { CriticalCss, components } from "@webstudio-is/react-sdk";++const Body = components.Body.Component;/*** We are using Outlet prop from index layout when user renders site from a subdomain.@@ -28,15 +28,11 @@ export const Canvas = ({<Links /><CriticalCss /></head>- <Outlet />- {- // @todo may need to figure out how to put in script tags inside the body- // body is rendered by outlet because its part of the user tree- }- <ScrollRestoration />- <Env />- <Scripts />- {process.env.NODE_ENV === "development" && <LiveReload />}+ <body>+ <Outlet />+ <ScrollRestoration />+ <Scripts />+ </body></html>);};diff --git a/apps/designer/app/shared/tree-utils/index.ts b/apps/designer/app/shared/tree-utils/index.tsindex e510e32304..4ace2d2a23 100644--- a/apps/designer/app/shared/tree-utils/index.ts+++ b/apps/designer/app/shared/tree-utils/index.ts@@ -3,10 +3,6 @@ export * from "./delete-instance";export * from "./insert-instance";export * from "./populate";export * from "./find-instance";-export {- createElementsTree,- type OnChangeChildren,-} from "@webstudio-is/react-sdk";export * from "./set-instance-style";export * from "./set-instance-children";export * from "./get-instance-path";diff --git a/packages/react-sdk/src/components/body.tsx b/packages/react-sdk/src/components/body.tsxindex fce7385390..a842fdac68 100644--- a/packages/react-sdk/src/components/body.tsx+++ b/packages/react-sdk/src/components/body.tsx@@ -3,6 +3,7 @@ import {forwardRef,type ElementRef,type ComponentProps,+ useEffect,} from "react";const defaultTag = "body";@@ -10,6 +11,11 @@ const defaultTag = "body";export const Body = forwardRef<ElementRef<typeof defaultTag>,ComponentProps<typeof defaultTag>->((props, ref) => createElement(defaultTag, { ...props, ref }));+>(({ children, className }, ref) => {+ useEffect(() => {+ document.body.className = className;+ }, []);+ return children;+});Body.displayName = "Body";diff --git a/packages/react-sdk/src/tree/create-elements-tree.tsx b/packages/react-sdk/src/tree/create-elements-tree.tsxindex 767ca47a28..270213a0c7 100644--- a/packages/react-sdk/src/tree/create-elements-tree.tsx+++ b/packages/react-sdk/src/tree/create-elements-tree.tsx@@ -48,6 +48,10 @@ export const createElementsTree = ({children.push(element);}+ //if (instance.component === "Body") {+ // return children;+ //}+const props = {instance,children,