|
7 | 7 | } from "@webstudio-is/react-sdk"; |
8 | 8 | import type { Project } from "@webstudio-is/project"; |
9 | 9 | import { createDefaultPages } from "@webstudio-is/project-build"; |
10 | | -import { $, renderJsx } from "@webstudio-is/sdk/testing"; |
| 10 | +import { $, ws, renderJsx } from "@webstudio-is/sdk/testing"; |
11 | 11 | import { parseCss } from "@webstudio-is/css-data"; |
12 | 12 | import * as defaultMetas from "@webstudio-is/sdk-components-react/metas"; |
13 | 13 | import type { |
@@ -589,6 +589,27 @@ describe("find closest droppable target", () => { |
589 | 589 | ) |
590 | 590 | ).toEqual(undefined); |
591 | 591 | }); |
| 592 | + |
| 593 | + test("allow inserting into collection item", () => { |
| 594 | + const { instances } = renderJsx( |
| 595 | + <$.Body ws:id="bodyId"> |
| 596 | + <ws.collection ws:id="collectionId"> |
| 597 | + <$.Box ws:id="boxId"></$.Box> |
| 598 | + </ws.collection> |
| 599 | + </$.Body> |
| 600 | + ); |
| 601 | + expect( |
| 602 | + findClosestDroppableTarget( |
| 603 | + defaultMetasMap, |
| 604 | + instances, |
| 605 | + ["collectionId[1]", "collectionId", "bodyId"], |
| 606 | + emptyInsertConstraints |
| 607 | + ) |
| 608 | + ).toEqual({ |
| 609 | + parentSelector: ["collectionId", "bodyId"], |
| 610 | + position: "end", |
| 611 | + }); |
| 612 | + }); |
592 | 613 | }); |
593 | 614 |
|
594 | 615 | describe("insert instance children", () => { |
@@ -3185,7 +3206,12 @@ describe("copy paste", () => { |
3185 | 3206 | const styleSources: StyleSources = new Map(); |
3186 | 3207 | const styles: Styles = new Map(); |
3187 | 3208 | const parsed = mapGroupBy( |
3188 | | - parseCss(cssString), |
| 3209 | + parseCss(cssString).map((styleDecl) => ({ |
| 3210 | + ...styleDecl, |
| 3211 | + selector: styleDecl.selector.startsWith("__") |
| 3212 | + ? styleDecl.selector.slice(2) |
| 3213 | + : styleDecl.selector, |
| 3214 | + })), |
3189 | 3215 | (parsedStyleDecl) => parsedStyleDecl.selector |
3190 | 3216 | ); |
3191 | 3217 | for (const [selector, parsedStyles] of parsed) { |
@@ -3298,7 +3324,8 @@ describe("copy paste", () => { |
3298 | 3324 | boxId__boxlocalid { |
3299 | 3325 | color: red; |
3300 | 3326 | } |
3301 | | - ${newBoxId}__${newBoxLocalId} { |
| 3327 | + /* escape potential leading digit */ |
| 3328 | + __${newBoxId}__${newBoxLocalId} { |
3302 | 3329 | color: red; |
3303 | 3330 | } |
3304 | 3331 | `); |
|
0 commit comments