mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
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:
@@ -1,4 +1,9 @@
|
||||
import {
|
||||
ParagraphLayoutHandlerExtension,
|
||||
ParagraphPaintConfigExtension,
|
||||
} from '@blocksuite/affine/blocks/paragraph';
|
||||
import {
|
||||
TurboRendererConfigFactory,
|
||||
ViewportTurboRendererExtension,
|
||||
ViewportTurboRendererIdentifier,
|
||||
} from '@blocksuite/affine/gfx/turbo-renderer';
|
||||
@@ -7,7 +12,17 @@ import { addSampleNotes } from './doc-generator.js';
|
||||
import { setupEditor } from './setup.js';
|
||||
|
||||
async function init() {
|
||||
setupEditor('edgeless', [ViewportTurboRendererExtension]);
|
||||
setupEditor('edgeless', [
|
||||
ParagraphLayoutHandlerExtension,
|
||||
ParagraphPaintConfigExtension,
|
||||
TurboRendererConfigFactory({
|
||||
options: {
|
||||
zoomThreshold: 1,
|
||||
debounceTime: 1000,
|
||||
},
|
||||
}),
|
||||
ViewportTurboRendererExtension,
|
||||
]);
|
||||
addSampleNotes(doc, 100);
|
||||
doc.load();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user