Skip to content

Commit c0439ef

Browse files
committed
feat: handle root with Fragment only
1 parent 07fe0ac commit c0439ef

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

packages/react/src/editor/Droppable/Droppable.module.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@
3030
background-color: var(--composify-palette-primary);
3131
opacity: 0.8;
3232
}
33+
34+
.Droppable--fullScreen {
35+
display: block !important;
36+
position: fixed !important;
37+
width: auto !important;
38+
height: auto !important;
39+
left: 0;
40+
right: 0;
41+
top: 0;
42+
bottom: 0;
43+
}

packages/react/src/editor/Droppable/Droppable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import styles from './Droppable.module.css';
1010
type Props = PropsWithChildren<{
1111
item: Node;
1212
index: number;
13+
replace?: boolean;
1314
onDrop?: (item: Node) => void;
1415
}>;
1516

1617
const getClassName = getClassNameFactory('Droppable', styles);
1718

18-
export const Droppable: FC<Props> = ({ item, index, onDrop, ...props }) => {
19+
export const Droppable: FC<Props> = ({ item, index, replace, onDrop, ...props }) => {
1920
const { isDragging, focusedBlock, relocateFocusedBlock, insertBlock } = useEditing();
2021

2122
const [{ isOver }, dropRef] = useDrop<Node, unknown, { isOver: boolean }>({
@@ -55,6 +56,7 @@ export const Droppable: FC<Props> = ({ item, index, onDrop, ...props }) => {
5556
className={getClassName({
5657
active: isDragging,
5758
over: isOver,
59+
fullScreen: !!replace,
5860
})}
5961
{...props}
6062
/>

packages/react/src/editor/Preview/Preview.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,9 @@ const pragma: Pragma = {
5757
export const Preview = () => {
5858
const { root } = useEditing();
5959

60+
if (root.type === 'Fragment' && root.children.length === 0) {
61+
return <Droppable item={root} index={0} replace={true} />;
62+
}
63+
6064
return <Renderer source={root} pragma={pragma} />;
6165
};

0 commit comments

Comments
 (0)