This issue has been created
There is 1 update.
 
 
XWiki Platform / cid:jira-generated-image-avatar-3f3fdfbb-7dc8-47cc-9c92-31743e13345a XWIKI-25813 Open

The BlockNote block handle is misaligned on empty blocks and blocks starting with an inline macro

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-2e3df8d2-4aa1-4e5d-bade-d7e740ea2f36 Manuel Leduc created this issue on 20/Nov/26 10:42
 
Summary: The BlockNote block handle is misaligned on empty blocks and blocks starting with an inline macro
Issue Type: cid:jira-generated-image-avatar-3f3fdfbb-7dc8-47cc-9c92-31743e13345a Bug
Affects Versions: 18.9.0
Assignee: Unassigned
Components: BlockNote
Created: 20/Nov/26 10:42
Priority: cid:jira-generated-image-static-major-7d5c9287-71d2-42b2-a38c-bfd13f363f8c Major
Reporter: Manuel Leduc
Description:

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

  1. Make BlockNote the default WYSIWYG editor.
  2. 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.
  3. 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.
 
 

1 update

 
cid:jira-generated-image-avatar-2e3df8d2-4aa1-4e5d-bade-d7e740ea2f36 Changes by Manuel Leduc on 20/Nov/26 10:42
 
Attachment: handle-alignment.png