@@ -13,6 +13,7 @@ import {
13
13
import { ChevronLeftIcon , ExternalLinkIcon } from "@webstudio-is/icons" ;
14
14
import {
15
15
elementComponent ,
16
+ Instance ,
16
17
ROOT_FOLDER_ID ,
17
18
type Asset ,
18
19
type Page ,
@@ -33,6 +34,10 @@ import { Card } from "./card";
33
34
import type { MarketplaceOverviewItem } from "~/shared/marketplace/types" ;
34
35
import { selectPage } from "~/shared/awareness" ;
35
36
37
+ const isBody = ( instance : Instance ) =>
38
+ instance . component === "Body" ||
39
+ ( instance . component === elementComponent && instance . tag === "body" ) ;
40
+
36
41
/**
37
42
* Insert page as a template.
38
43
* - Currently only supports inserting everything from the body
@@ -46,17 +51,12 @@ const insertSection = ({
46
51
instanceId : string ;
47
52
} ) => {
48
53
const fragment = extractWebstudioFragment ( data , instanceId ) ;
49
- const body = fragment . instances . find (
50
- ( instance ) => instance . component === "Body"
51
- ) ;
54
+ const body = fragment . instances . find ( isBody ) ;
52
55
// remove body and use its children as root insrances
53
56
if ( body ) {
54
- fragment . instances = fragment . instances . filter ( ( instance ) => {
55
- const isBody =
56
- instance . component === "Body" ||
57
- ( instance . component === elementComponent && instance . tag === "body" ) ;
58
- return ! isBody ;
59
- } ) ;
57
+ fragment . instances = fragment . instances . filter (
58
+ ( instance ) => ! isBody ( instance )
59
+ ) ;
60
60
fragment . children = body . children ;
61
61
}
62
62
const insertable = findClosestInsertable ( fragment ) ;
0 commit comments