toeverything / blocksuite

🧩 Content editing tech stack for the web - BlockSuite is a toolkit for building editors and collaborative applications.
https://blocksuite.io
Mozilla Public License 2.0
4.24k stars 378 forks source link

Surface block's children's view position is mismatched with their position in block tree #5624

Closed Saul-Mirone closed 4 months ago

Saul-Mirone commented 8 months ago

For now, surface's children like image block is rendered by portal. The portal will render the block in EdgelessPageBlock, it will be something like:

<EdgelessPageBlock>
  <SurfaceBlock />
  <Image Portal>
    <Image Block />
  </Image Portal>
</EdgelessPageBlock>

The view module will calculate the block's position in dom tree and get the path for it. So the path will be pageBlock -> imageBlock.

However, in the block tree in Yjs, the structure will be something like:

const blockTree = {
  pageBlock: {
    surfaceBlock: {
      imageBlock: {}
    }
  }
}

There'll be a mismatch between model and view.

doouding commented 8 months ago

Technically, this is not a bug and may not be resolved in the short term. In order to satisfy the product requirements, the image block can only be placed outside the surface for now. We will discuss possible solutions in the next iteration, though we might stick to the current approach.