refactor(editor): generic layout type support for turbo renderer (#10766)

This PR refactored the turbo renderer architecture to support multiple block layout types.

- New base class `BlockLayoutPainter` and `BlockLayoutProvider` are introduced for writing extendable per-block layout querying and painting logic.
- Paragraph-specific lines are all moved into dedicated classes (`ParagraphLayoutProvider` and `ParagraphLayoutPainter`) under the `/variants/paragraph` dir.
- The `renderer-utils.ts` doesn't contain paragraph-specific logic now.
- The `text-utils.ts` is also now scoped for paragraph only.
- Worker messages are now strongly typed.

Upcoming PR should further implement the block registration system using extension API. The `variants` dir could still exist, since there will be similar rendering logic that can be reused among block types (i.e., between paragraph block and list block).
This commit is contained in:
doodlewind
2025-03-13 05:18:11 +00:00
parent c1c750d782
commit c023b724d0
18 changed files with 578 additions and 252 deletions

View File

@@ -2593,6 +2593,7 @@ __metadata:
resolution: "@blocksuite/affine-block-paragraph@workspace:blocksuite/affine/blocks/block-paragraph"
dependencies:
"@blocksuite/affine-components": "workspace:*"
"@blocksuite/affine-gfx-turbo-renderer": "workspace:*"
"@blocksuite/affine-model": "workspace:*"
"@blocksuite/affine-rich-text": "workspace:*"
"@blocksuite/affine-shared": "workspace:*"
@@ -2900,6 +2901,7 @@ __metadata:
dependencies:
"@blocksuite/block-std": "workspace:*"
"@blocksuite/global": "workspace:*"
"@blocksuite/store": "workspace:*"
"@types/lodash-es": "npm:^4.17.12"
lodash-es: "npm:^4.17.21"
rxjs: "npm:^7.8.1"