TypeCellOS / BlockNote

A React Rich Text Editor that's block-based (Notion style) and extensible. Built on top of Prosemirror and Tiptap.
https://www.blocknotejs.org/
Mozilla Public License 2.0
6.79k stars 476 forks source link

fix: Various multi-column bugs #1240

Closed matthewlipski closed 2 weeks ago

matthewlipski commented 2 weeks ago

This PR fixes 4 bugs to do with multi-column blocks:

  1. Dragging a block from one column to another in the same column list now works properly. Previously, it would copy the dragged block instead of moving it.
  2. Fixed bug where creating a new column list above an existing one would merge them. This was due to incorrect positions being used in removeBlocksWithCallback.
  3. Fixed bug where dropping a block inside a new column in a column list would sometimes throw an error, as nodeDOM would return null due to the cursor position being outdated. I've managed to reproduce this consistently using the document setup below, and dragging the "bbbbb" block between the "c" and "d" blocks.
  4. Fixed error being thrown after live reload due to event listeners not getting cleaned up in the column resize extension.

Document to reproduce issue 3:

[
  {
    type: "columnList",
    children: [
      {
        type: "column",
        children: [
          {
            type: "paragraph",
            content: "a",
          },
        ],
      },
      {
        type: "column",
        children: [
          {
            type: "paragraph",
            content: "bbbbb",
          },
        ],
      },
    ],
  },
  {
    type: "columnList",
    children: [
      {
        type: "column",
        children: [
          {
            type: "paragraph",
            content: "c",
          },
        ],
      },
      {
        type: "column",
        children: [
          {
            type: "paragraph",
            content: "d",
          },
        ],
      },
    ],
  },
  {
    type: "paragraph",
  },
],
vercel[bot] commented 2 weeks ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Nov 14, 2024 0:40am
blocknote-website ✅ Ready (Inspect) Visit Preview Nov 14, 2024 0:40am
tommerty commented 2 weeks ago

Can I ask that if the resizing/dragging of columns be disabled if editable is false? 🙏🏻 https://github.com/TypeCellOS/BlockNote/issues/1244

matthewlipski commented 2 weeks ago

Can I ask that if the resizing/dragging of columns be disabled if editable is false? 🙏🏻 #1244

Will fix shortly! But in a separate PR