Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25813

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 18.9.0
    • BlockNote
    • None
    • Unknown

    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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mleduc Manuel Leduc
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: