Skip to content

Commit 024b668

Browse files
committed
feat: replace fragment type root node on drop
1 parent c0439ef commit 024b668

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

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

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

1717
const getClassName = getClassNameFactory('Droppable', styles);
1818

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

2222
const [{ isOver }, dropRef] = useDrop<Node, unknown, { isOver: boolean }>({
@@ -56,7 +56,7 @@ export const Droppable: FC<Props> = ({ item, index, replace, onDrop, ...props })
5656
className={getClassName({
5757
active: isDragging,
5858
over: isOver,
59-
fullScreen: !!replace,
59+
fullScreen: !!fullScreen,
6060
})}
6161
{...props}
6262
/>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ const pragma: Pragma = {
5555
};
5656

5757
export const Preview = () => {
58-
const { root } = useEditing();
58+
const { root, replaceRoot } = useEditing();
5959

6060
if (root.type === 'Fragment' && root.children.length === 0) {
61-
return <Droppable item={root} index={0} replace={true} />;
61+
return <Droppable item={root} index={0} fullScreen={true} onDrop={replaceRoot} />;
6262
}
6363

6464
return <Renderer source={root} pragma={pragma} />;

0 commit comments

Comments
 (0)