Skip to content

Commit 0aabdfc

Browse files
committed
Hide block menu when placeholder is visible
1 parent 809ab4a commit 0aabdfc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/zui/ZUIEditor/EditorOverlays/index.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
usePositioner,
66
} from '@remirror/react';
77
import { FC, useCallback, useEffect, useState } from 'react';
8+
import { ProsemirrorNode } from '@remirror/pm/suggest';
89
import { Box } from '@mui/material';
910

1011
import BlockToolbar from './BlockToolbar';
@@ -18,6 +19,7 @@ export type BlockDividerData = {
1819
};
1920

2021
type BlockData = {
22+
node: ProsemirrorNode;
2123
rect: DOMRect;
2224
type: string;
2325
};
@@ -54,6 +56,7 @@ const EditorOverlays: FC<Props> = ({ blocks, enableVariable }) => {
5456
const x = nodeRect.x - editorRect.x;
5557
const y = nodeRect.y - editorRect.y;
5658
setCurrentBlock({
59+
node,
5760
rect: {
5861
...nodeRect.toJSON(),
5962
left: x,
@@ -129,7 +132,11 @@ const EditorOverlays: FC<Props> = ({ blocks, enableVariable }) => {
129132
}
130133
});
131134

132-
const showBlockToolbar = !showBlockMenu && !!currentBlock && !typing;
135+
const isEmptyParagraph =
136+
currentBlock?.type == 'paragraph' && currentBlock?.node.textContent == '';
137+
138+
const showBlockToolbar =
139+
!showBlockMenu && !!currentBlock && !typing && !isEmptyParagraph;
133140

134141
const showBlockInsert = !showBlockMenu && !typing;
135142

0 commit comments

Comments
 (0)