Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions apps/builder/app/builder/features/marketplace/templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@webstudio-is/design-system";
import { ChevronLeftIcon, ExternalLinkIcon } from "@webstudio-is/icons";
import {
elementComponent,
ROOT_FOLDER_ID,
type Asset,
type Page,
Expand Down Expand Up @@ -50,9 +51,12 @@ const insertSection = ({
);
// remove body and use its children as root insrances
if (body) {
fragment.instances = fragment.instances.filter(
(instance) => instance.component !== "Body"
);
fragment.instances = fragment.instances.filter((instance) => {
const isBody =
instance.component === "Body" ||
(instance.component === elementComponent && instance.tag === "body");
return !isBody;
});
fragment.children = body.children;
}
const insertable = findClosestInsertable(fragment);
Expand Down
4 changes: 3 additions & 1 deletion apps/builder/app/builder/features/pages/page-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
isLiteralExpression,
documentTypes,
isRootFolder,
elementComponent,
} from "@webstudio-is/sdk";
import {
theme,
Expand Down Expand Up @@ -1307,7 +1308,8 @@ const createPage = (pageId: Page["id"], values: Values) => {
instances.set(rootInstanceId, {
type: "instance",
id: rootInstanceId,
component: "Body",
component: elementComponent,
tag: "body",
children: [],
});
registerFolderChildMutable(pages.folders, pageId, values.parentFolderId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ export const TagControl = ({ meta, prop }: ControlProps<"tag">) => {
const instanceTag = instance?.tag;
const defaultTag = meta.options[0];
const computedTag = instanceTag ?? propTag ?? defaultTag;
const satisfyingTags = useStore($satisfyingTags);
let satisfyingTags = useStore($satisfyingTags);
// forbid changing tag on body element
if (computedTag === "body") {
satisfyingTags = ["body"];
}
const options = meta.options.filter((tag) => satisfyingTags.includes(tag));
const [value, setValue] = useState<undefined | string>();
const updateTag = (value: string) => {
Expand Down
12 changes: 1 addition & 11 deletions apps/builder/app/canvas/canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ import { subscribeSelected } from "./instance-selected";
import { subscribeScrollNewInstanceIntoView } from "./shared/scroll-new-instance-into-view";
import { $selectedPage } from "~/shared/awareness";
import { createInstanceElement } from "./elements";
import { Body } from "./shared/body";
import { subscribeScrollbarSize } from "./scrollbar-width";
import { compareMedia } from "@webstudio-is/css-engine";
import { builderApi } from "~/shared/builder-api";
Expand Down Expand Up @@ -248,15 +247,6 @@ export const Canvas = () => {
hooks: baseComponentHooks,
templates: baseComponentTemplates,
});
registerComponentLibrary({
components: {
// override only canvas specific body component
// not related to sdk-components-react-remix anymore
Body,
},
metas: {},
templates: {},
});
registerComponentLibrary({
namespace: "@webstudio-is/sdk-components-react-radix",
components: radixComponents,
Expand Down Expand Up @@ -321,7 +311,7 @@ export const Canvas = () => {
}, []);

if (components.size === 0 || instances.size === 0) {
return <Body />;
return;
}

return (
Expand Down
14 changes: 0 additions & 14 deletions apps/builder/app/canvas/shared/body.tsx

This file was deleted.

15 changes: 12 additions & 3 deletions apps/builder/app/routes/_canvas.canvas.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { lazy } from "react";
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
import type { LoaderFunctionArgs } from "@remix-run/server-runtime";
import { Scripts, ScrollRestoration } from "@remix-run/react";
import { isCanvas } from "~/shared/router-utils";
import { ClientOnly } from "~/shared/client-only";
import { Body } from "~/canvas/shared/body";

export { ErrorBoundary } from "~/shared/error/error-boundary";

Expand All @@ -22,7 +22,16 @@ const Canvas = lazy(async () => {

const CanvasRoute = () => {
return (
<ClientOnly fallback={<Body />}>
// this setup remix scripts on canvas and after rendering a website
// scripts will continue to work even though removed from dom
<ClientOnly
fallback={
<body>
<Scripts />
<ScrollRestoration />
</body>
}
>
<Canvas />
</ClientOnly>
);
Expand Down
4 changes: 3 additions & 1 deletion packages/project-build/src/db/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
type StyleDecl,
Pages,
initialBreakpoints,
elementComponent,
} from "@webstudio-is/sdk";
import type { Build, CompactBuild } from "../types";
import { parseDeployment } from "./deployment";
Expand Down Expand Up @@ -229,7 +230,8 @@ const createNewPageInstances = (): Build["instances"] => {
{
type: "instance",
id: instanceId,
component: "Body",
component: elementComponent,
tag: "body",
children: [],
},
],
Expand Down