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
take area/edge into account & minor fixes
Roman Pominovc80cb02b98b1
diff --git a/apps/designer/app/shared/design-system/components/primitives/dnd/canvas.stories.tsx b/apps/designer/app/shared/design-system/components/primitives/dnd/canvas.stories.tsxindex b745e252e0..ad753fe30c 100644--- a/apps/designer/app/shared/design-system/components/primitives/dnd/canvas.stories.tsx+++ b/apps/designer/app/shared/design-system/components/primitives/dnd/canvas.stories.tsx@@ -154,6 +154,7 @@ export const Canvas = () => {};const dropTargetHandlers = useDropTarget({+ edgeDistanceThreshold: 10,isDropTarget(element: HTMLElement) {return elementToId(element) !== undefined;},@@ -166,16 +167,22 @@ export const Canvas = () => {}if (id !== ROOT_ID) {- const path = findItemPath(data, id) ?? [];+ let path = findItemPath(data, id) ?? [];++ // NOTE: not sure we should always do this.+ // Might depend on whether there's a parent with acceptsChildren, or something.+ if (event.area !== "center") {+ path = path.slice(1);+ }// to make sure we are not dropping on ourselfconst dragItemIndex = path.findIndex((item) => item.id === dragItemId);+ if (dragItemIndex !== -1) {+ path = path.slice(dragItemIndex + 1);+ }for (const item of path) {- if (- item.acceptsChildren &&- (dragItemIndex === -1 || path.indexOf(item) > dragItemIndex)- ) {+ if (item.acceptsChildren) {const element = idToElement(rootElement, item.id);if (element) {setDropTarget(item.id, element);@@ -274,7 +281,9 @@ export const Canvas = () => {width: 500,height: 500,overflow: "auto",- "[data-id]": { cursor: "grab" },+ "[data-id]": {+ cursor: dragItemId === undefined ? "grab" : "default",+ },}}ref={(element) => {dropTargetHandlers.rootRef(element);diff --git a/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx b/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsxindex 5b4ae82a9f..47823e1184 100644--- a/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx+++ b/apps/designer/app/shared/design-system/components/primitives/dnd/placement.tsx@@ -225,6 +225,7 @@ export const PlacementIndicator = ({ rect }: { rect?: Rect }) => {boxSizing: "content-box",position: "absolute",border: "1px solid $grass9",+ pointerEvents: "none",}}/>);diff --git a/apps/designer/app/shared/design-system/components/primitives/dnd/use-drop-target.ts b/apps/designer/app/shared/design-system/components/primitives/dnd/use-drop-target.tsindex c56b669978..f3c5ea501b 100644--- a/apps/designer/app/shared/design-system/components/primitives/dnd/use-drop-target.ts+++ b/apps/designer/app/shared/design-system/components/primitives/dnd/use-drop-target.ts@@ -97,7 +97,6 @@ export const useDropTarget = ({if (hasTargetChanged || hasAreaChanged || hasRectChanged) {onDropTargetChange({rect: nextRect,- // NOTE: might make more sense to pass the area to isDropTarget instead of herearea: nextArea,target: nextTarget,});