| The block handle (the drag handle shown in the left margin when hovering a block) is not vertically centered on the first line of the block in two cases:
- the block is empty, e.g. an empty paragraph showing the "Enter text or type '/' for commands" placeholder;
- the block starts with an inline macro, e.g. a mention.
Steps to reproduce
- Make BlockNote the default WYSIWYG editor.
- Edit a page and add a paragraph starting with an inline macro (e.g. a mention), a heading starting with an inline macro, and an empty paragraph.
- Hover each block.
Actual Measured offsets between the center of the handle and the center of the first line:
| Block |
Offset |
| Paragraph with text |
about 1px |
| Paragraph starting with a mention |
4.6px lower |
| Heading starting with a mention |
5px higher |
| Empty paragraph |
4.5px lower |
See the attached handle-alignment.png (from top to bottom: a paragraph with text, a paragraph starting with a mention, a heading starting with a mention, an empty paragraph). Expected The handle is centered on the first line, as it is for a block starting with text. Cause centerOnFirstLine (blocknote-react/src/components/SideMenu/centerOnFirstLine.ts) centers the handle on the first node that renders something: a non-empty text node or a replaced element (img, svg, video, canvas, iframe). When that node is missing or has no height, it falls back to the box of the block's first child, which includes the block padding and the heading margins, so the handle is centered on the whole block instead of its first line.
- An empty block has no such node.
- ProseMirror inserts an <img class="ProseMirror-separator"> before an inline node view that starts a line. It matches the replaced elements but is 0px tall, so the fallback is used.
|