There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
refactor(editor): remove block models global type (#10086)
Saul-Mirone39eb8625d6f7
diff --git a/blocksuite/affine/block-attachment/src/attachment-service.ts b/blocksuite/affine/block-attachment/src/attachment-service.tsindex 10e80ecdbb..3337b446f7 100644--- a/blocksuite/affine/block-attachment/src/attachment-service.ts+++ b/blocksuite/affine/block-attachment/src/attachment-service.ts@@ -7,7 +7,7 @@ import {} from '@blocksuite/affine-shared/services';import {isInsideEdgelessEditor,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';@@ -24,7 +24,7 @@ export const AttachmentDropOption = FileDropConfigExtension({const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;- if (targetModel && !matchFlavours(targetModel, [SurfaceBlockModel])) {+ if (targetModel && !matchModels(targetModel, [SurfaceBlockModel])) {addSiblingAttachmentBlocks(std.host,attachmentFiles,diff --git a/blocksuite/affine/block-data-view/src/effects.ts b/blocksuite/affine/block-data-view/src/effects.tsindex ba2a0106e4..0c4abb892b 100644--- a/blocksuite/affine/block-data-view/src/effects.ts+++ b/blocksuite/affine/block-data-view/src/effects.ts@@ -1,14 +1,5 @@import { DataViewBlockComponent } from './data-view-block';-import type { DataViewBlockModel } from './data-view-model';export function effects() {customElements.define('affine-data-view', DataViewBlockComponent);}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:data-view': DataViewBlockModel;- }- }-}diff --git a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts b/blocksuite/affine/block-database/src/detail-panel/note-renderer.tsindex 826c1faae4..c132370863 100644--- a/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts+++ b/blocksuite/affine/block-database/src/detail-panel/note-renderer.ts@@ -8,10 +8,7 @@ import {import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';import { TelemetryProvider } from '@blocksuite/affine-shared/services';import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';-import {- createDefaultDoc,- matchFlavours,-} from '@blocksuite/affine-shared/utils';+import { createDefaultDoc, matchModels } from '@blocksuite/affine-shared/utils';import { type EditorHost, ShadowlessElement } from '@blocksuite/block-std';import type { DetailSlotProps, SingleView } from '@blocksuite/data-view';import { SignalWatcher, WithDisposable } from '@blocksuite/global/utils';@@ -75,7 +72,7 @@ export class NoteRenderernote.root.children.find(child => child.flavour === 'affine:note')?.children.find(block =>- matchFlavours(block, [+ matchModels(block, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,diff --git a/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts b/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.tsindex db615f4b57..eb75d02ef8 100644--- a/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts+++ b/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts@@ -6,7 +6,7 @@ import {ParagraphBlockModel,} from '@blocksuite/affine-model';import { ThemeProvider } from '@blocksuite/affine-shared/services';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockComponent } from '@blocksuite/block-std';import {BlockSelection,@@ -162,7 +162,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBlconst firstChild = this.model.firstChild();if (!firstChild ||- !matchFlavours(firstChild, [ListBlockModel, ParagraphBlockModel])+ !matchModels(firstChild, [ListBlockModel, ParagraphBlockModel])) {newParagraphId = this.doc.addBlock('affine:paragraph',@@ -175,7 +175,7 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBlconst lastChild = this.model.lastChild();if (!lastChild ||- !matchFlavours(lastChild, [ListBlockModel, ParagraphBlockModel])+ !matchModels(lastChild, [ListBlockModel, ParagraphBlockModel])) {newParagraphId = this.doc.addBlock('affine:paragraph',diff --git a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts b/blocksuite/affine/block-embed/src/common/render-linked-doc.tsindex 997dd75e7a..4711228545 100644--- a/blocksuite/affine/block-embed/src/common/render-linked-doc.ts+++ b/blocksuite/affine/block-embed/src/common/render-linked-doc.ts@@ -9,7 +9,7 @@ import {} from '@blocksuite/affine-model';import { EMBED_CARD_HEIGHT } from '@blocksuite/affine-shared/consts';import { NotificationProvider } from '@blocksuite/affine-shared/services';-import { matchFlavours, SpecProvider } from '@blocksuite/affine-shared/utils';+import { matchModels, SpecProvider } from '@blocksuite/affine-shared/utils';import { BlockStdScope } from '@blocksuite/block-std';import { assertExists } from '@blocksuite/global/utils';import {@@ -71,7 +71,7 @@ async function renderPageAsBanner(card: EmbedSyncedDocCard) {}const target = notes.flatMap(note =>- note.children.filter(child => matchFlavours(child, [ImageBlockModel]))+ note.children.filter(child => matchModels(child, [ImageBlockModel])))[0];if (target) {@@ -142,7 +142,7 @@ async function renderNoteContent(const noteChildren = notes.flatMap(note =>note.children.filter(model => {- if (matchFlavours(model, allowFlavours)) {+ if (matchModels(model, allowFlavours)) {return true;}return filterTextModel(model);@@ -215,7 +215,7 @@ async function renderNoteContent(}function filterTextModel(model: BlockModel) {- if (matchFlavours(model, [ParagraphBlockModel, ListBlockModel])) {+ if (matchModels(model, [ParagraphBlockModel, ListBlockModel])) {return !!model.text?.toString().length;}return false;@@ -224,7 +224,7 @@ function filterTextModel(model: BlockModel) {export function getNotesFromDoc(doc: Store) {const notes = doc.root?.children.filter(child =>- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode !== NoteDisplayMode.EdgelessOnly);@@ -305,7 +305,7 @@ export function getDocContentWithMaxLength(doc: Store, maxlength = 500) {export function getTitleFromSelectedModels(selectedModels: DraftModel[]) {const firstBlock = selectedModels[0];if (- matchFlavours(firstBlock, [ParagraphBlockModel]) &&+ matchModels(firstBlock, [ParagraphBlockModel]) &&firstBlock.type.startsWith('h')) {return firstBlock.text.toString();diff --git a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.tsindex 041f2b287f..06be046690 100644--- a/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts+++ b/blocksuite/affine/block-embed/src/embed-linked-doc-block/embed-linked-doc-block.ts@@ -24,7 +24,7 @@ import {cloneReferenceInfoWithoutAliases,isNewTabTrigger,isNewViewTrigger,- matchFlavours,+ matchModels,referenceToNode,} from '@blocksuite/affine-shared/utils';import { BlockSelection } from '@blocksuite/block-std';@@ -374,7 +374,7 @@ export class EmbedLinkedDocBlockComponent extends EmbedBlockComponent<EmbedLinkeconst isLoading = this._loading;const isError = this.isError;const isEmpty = this._isDocEmpty() && this.isBannerEmpty;- const inCanvas = matchFlavours(this.model.parent, [SurfaceBlockModel]);+ const inCanvas = matchModels(this.model.parent, [SurfaceBlockModel]);const cardClassMap = classMap({loading: isLoading,diff --git a/blocksuite/affine/block-image/src/image-service.ts b/blocksuite/affine/block-image/src/image-service.tsindex abaea50137..4d63cd7684 100644--- a/blocksuite/affine/block-image/src/image-service.ts+++ b/blocksuite/affine/block-image/src/image-service.ts@@ -7,7 +7,7 @@ import {} from '@blocksuite/affine-shared/services';import {isInsideEdgelessEditor,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { BlockService } from '@blocksuite/block-std';import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';@@ -26,7 +26,7 @@ export const ImageDropOption = FileDropConfigExtension({const maxFileSize = std.store.get(FileSizeLimitService).maxFileSize;- if (targetModel && !matchFlavours(targetModel, [SurfaceBlockModel])) {+ if (targetModel && !matchModels(targetModel, [SurfaceBlockModel])) {addSiblingImageBlock(std.host,imageFiles,diff --git a/blocksuite/affine/block-list/src/commands/dedent-list.ts b/blocksuite/affine/block-list/src/commands/dedent-list.tsindex beb5190c7a..016de4210a 100644--- a/blocksuite/affine/block-list/src/commands/dedent-list.ts+++ b/blocksuite/affine/block-list/src/commands/dedent-list.ts@@ -1,6 +1,6 @@import { ListBlockModel } from '@blocksuite/affine-model';import type { IndentContext } from '@blocksuite/affine-shared/types';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';import { correctNumberedListsOrderToPrev } from './utils.js';@@ -54,7 +54,7 @@ export const canDedentListCommand: Command<* ccc*/const model = store.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ListBlockModel])) {+ if (!model || !matchModels(model, [ListBlockModel])) {return;}/**diff --git a/blocksuite/affine/block-list/src/commands/indent-list.ts b/blocksuite/affine/block-list/src/commands/indent-list.tsindex de8bfbd8b3..b956e0ced3 100644--- a/blocksuite/affine/block-list/src/commands/indent-list.ts+++ b/blocksuite/affine/block-list/src/commands/indent-list.ts@@ -2,7 +2,7 @@ import { ListBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';import type { IndentContext } from '@blocksuite/affine-shared/types';import {getNearestHeadingBefore,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';@@ -55,7 +55,7 @@ export const canIndentListCommand: Command<* ccc*/const model = store.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ListBlockModel])) {+ if (!model || !matchModels(model, [ListBlockModel])) {return;}const schema = std.store.schema;@@ -126,7 +126,7 @@ export const indentListCommand: Command<{const nearestHeading = getNearestHeadingBefore(model);if (nearestHeading &&- matchFlavours(nearestHeading, [ParagraphBlockModel]) &&+ matchModels(nearestHeading, [ParagraphBlockModel]) &&nearestHeading.collapsed) {store.updateBlock(nearestHeading, {diff --git a/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts b/blocksuite/affine/block-list/src/commands/list-to-paragraph.tsindex c16e94cc71..e93ba33f06 100644--- a/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts+++ b/blocksuite/affine/block-list/src/commands/list-to-paragraph.ts@@ -1,6 +1,6 @@import { focusTextModel } from '@blocksuite/affine-components/rich-text';import { ListBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';export const listToParagraphCommand: Command<@@ -17,7 +17,7 @@ export const listToParagraphCommand: Command<const doc = std.store;const model = doc.getBlock(id)?.model;- if (!model || !matchFlavours(model, [ListBlockModel])) return false;+ if (!model || !matchModels(model, [ListBlockModel])) return false;const parent = doc.getParent(model);if (!parent) return false;diff --git a/blocksuite/affine/block-list/src/commands/split-list.ts b/blocksuite/affine/block-list/src/commands/split-list.tsindex 50836d8405..799d2d1ab0 100644--- a/blocksuite/affine/block-list/src/commands/split-list.ts+++ b/blocksuite/affine/block-list/src/commands/split-list.ts@@ -2,7 +2,7 @@ import { focusTextModel } from '@blocksuite/affine-components/rich-text';import { ListBlockModel } from '@blocksuite/affine-model';import {getNextContinuousNumberedLists,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { Command, EditorHost } from '@blocksuite/block-std';@@ -18,7 +18,7 @@ export const splitListCommand: Command<{const doc = host.doc;const model = doc.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ListBlockModel])) {+ if (!model || !matchModels(model, [ListBlockModel])) {console.error(`block ${blockId} is not a list block`);return;}diff --git a/blocksuite/affine/block-list/src/commands/utils.ts b/blocksuite/affine/block-list/src/commands/utils.tsindex 129bc5ae73..1dcb2f2a3b 100644--- a/blocksuite/affine/block-list/src/commands/utils.ts+++ b/blocksuite/affine/block-list/src/commands/utils.ts@@ -1,7 +1,7 @@import { ListBlockModel } from '@blocksuite/affine-model';import {getNextContinuousNumberedLists,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { BlockModel, Store } from '@blocksuite/store';@@ -22,7 +22,7 @@ export function correctNumberedListsOrderToPrev(if (!model) return;if (- !matchFlavours(model, [ListBlockModel]) ||+ !matchModels(model, [ListBlockModel]) ||model.type$.value !== 'numbered') {return;@@ -33,7 +33,7 @@ export function correctNumberedListsOrderToPrev(const previousSibling = doc.getPrev(model);if (previousSibling &&- matchFlavours(previousSibling, [ListBlockModel]) &&+ matchModels(previousSibling, [ListBlockModel]) &&previousSibling.type === 'numbered') {if (!previousSibling.order) previousSibling.order = 1;diff --git a/blocksuite/affine/block-list/src/utils/forward-delete.ts b/blocksuite/affine/block-list/src/utils/forward-delete.tsindex c51d0db7dc..15bcc733c5 100644--- a/blocksuite/affine/block-list/src/utils/forward-delete.ts+++ b/blocksuite/affine/block-list/src/utils/forward-delete.ts@@ -1,7 +1,7 @@import { ListBlockModel } from '@blocksuite/affine-model';import {getNextContentBlock,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';import type { Text } from '@blocksuite/store';@@ -26,7 +26,7 @@ export function forwardDelete(std: BlockStdScope): true | undefined {const isCollapsed = text.isCollapsed();const doc = std.store;const model = doc.getBlock(text.from.blockId)?.model;- if (!model || !matchFlavours(model, [ListBlockModel])) return;+ if (!model || !matchModels(model, [ListBlockModel])) return;const isEnd = isCollapsed && text.from.index === model.text.length;if (!isEnd) return;// Has children in listdiff --git a/blocksuite/affine/block-note/src/commands/block-type.ts b/blocksuite/affine/block-note/src/commands/block-type.tsindex 6f4cdafdfa..a8f34e91df 100644--- a/blocksuite/affine/block-note/src/commands/block-type.ts+++ b/blocksuite/affine/block-note/src/commands/block-type.ts@@ -14,7 +14,7 @@ import {getTextSelectionCommand,} from '@blocksuite/affine-shared/commands';import {- matchFlavours,+ matchModels,mergeToCodeModel,transformModel,} from '@blocksuite/affine-shared/utils';@@ -27,7 +27,7 @@ import {import type { BlockModel } from '@blocksuite/store';type UpdateBlockConfig = {- flavour: BlockSuite.Flavour;+ flavour: string;props?: Record<string, unknown>;};@@ -200,7 +200,7 @@ export const updateBlockType: Command<const newModels: BlockModel[] = [];blockModels.forEach(model => {if (- !matchFlavours(model, [+ !matchModels(model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,diff --git a/blocksuite/affine/block-note/src/commands/change-note-display-mode.ts b/blocksuite/affine/block-note/src/commands/change-note-display-mode.tsindex 6ecfbf5190..ab052bfef9 100644--- a/blocksuite/affine/block-note/src/commands/change-note-display-mode.ts+++ b/blocksuite/affine/block-note/src/commands/change-note-display-mode.ts@@ -1,5 +1,5 @@import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';export const changeNoteDisplayMode: Command<{@@ -10,8 +10,7 @@ export const changeNoteDisplayMode: Command<{const { std, noteId, mode, stopCapture } = ctx;const noteBlockModel = std.store.getBlock(noteId)?.model;- if (!noteBlockModel || !matchFlavours(noteBlockModel, [NoteBlockModel]))- return;+ if (!noteBlockModel || !matchModels(noteBlockModel, [NoteBlockModel])) return;const currentMode = noteBlockModel.displayMode;if (currentMode === mode) return;@@ -27,7 +26,7 @@ export const changeNoteDisplayMode: Command<{const parent = std.store.getParent(noteBlockModel);if (parent) {const notes = parent.children.filter(child =>- matchFlavours(child, [NoteBlockModel])+ matchModels(child, [NoteBlockModel]));const firstEdgelessOnlyNote = notes.find(note => note.displayMode === NoteDisplayMode.EdgelessOnlydiff --git a/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts b/blocksuite/affine/block-note/src/commands/dedent-block-to-root.tsindex 3d17e560e6..da34bd7d3d 100644--- a/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts+++ b/blocksuite/affine/block-note/src/commands/dedent-block-to-root.ts@@ -1,5 +1,5 @@import { NoteBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';import { dedentBlock } from './dedent-block';@@ -21,7 +21,7 @@ export const dedentBlockToRoot: Command<{let parent = store.getParent(model);let changed = false;- while (parent && !matchFlavours(parent, [NoteBlockModel])) {+ while (parent && !matchModels(parent, [NoteBlockModel])) {if (!changed) {if (stopCapture) store.captureSync();changed = true;diff --git a/blocksuite/affine/block-note/src/commands/dedent-block.ts b/blocksuite/affine/block-note/src/commands/dedent-block.tsindex e33dd8fd1e..b1a279424b 100644--- a/blocksuite/affine/block-note/src/commands/dedent-block.ts+++ b/blocksuite/affine/block-note/src/commands/dedent-block.ts@@ -1,7 +1,7 @@import { ParagraphBlockModel } from '@blocksuite/affine-model';import {calculateCollapsedSiblings,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';@@ -46,7 +46,7 @@ export const dedentBlock: Command<{if (stopCapture) store.captureSync();if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {diff --git a/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts b/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.tsindex 4396c0a249..fc9f81ed92 100644--- a/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts+++ b/blocksuite/affine/block-note/src/commands/dedent-blocks-to-root.ts@@ -1,5 +1,5 @@import { NoteBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';import { dedentBlockToRoot } from './dedent-block-to-root';@@ -31,7 +31,7 @@ export const dedentBlocksToRoot: Command<{for (let i = blockIds.length - 1; i >= 0; i--) {const model = blockIds[i];const parent = store.getParent(model);- if (parent && !matchFlavours(parent, [NoteBlockModel])) {+ if (parent && !matchModels(parent, [NoteBlockModel])) {std.command.exec(dedentBlockToRoot, {blockId: model,stopCapture: false,diff --git a/blocksuite/affine/block-note/src/commands/dedent-blocks.ts b/blocksuite/affine/block-note/src/commands/dedent-blocks.tsindex 9fb04980bb..21012b6c39 100644--- a/blocksuite/affine/block-note/src/commands/dedent-blocks.ts+++ b/blocksuite/affine/block-note/src/commands/dedent-blocks.ts@@ -1,7 +1,7 @@import { ParagraphBlockModel } from '@blocksuite/affine-model';import {calculateCollapsedSiblings,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';@@ -58,7 +58,7 @@ export const dedentBlocks: Command<{const model = store.getBlock(id)?.model;if (!model) return;if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {diff --git a/blocksuite/affine/block-note/src/commands/indent-block.ts b/blocksuite/affine/block-note/src/commands/indent-block.tsindex f9d22acfa5..a8bdc51794 100644--- a/blocksuite/affine/block-note/src/commands/indent-block.ts+++ b/blocksuite/affine/block-note/src/commands/indent-block.ts@@ -1,7 +1,7 @@import { ListBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';import {calculateCollapsedSiblings,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';@@ -50,7 +50,7 @@ export const indentBlock: Command<{if (stopCapture) store.captureSync();if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {@@ -62,7 +62,7 @@ export const indentBlock: Command<{// update collapsed state of affine listif (- matchFlavours(previousSibling, [ListBlockModel]) &&+ matchModels(previousSibling, [ListBlockModel]) &&previousSibling.collapsed) {store.updateBlock(previousSibling, {diff --git a/blocksuite/affine/block-note/src/commands/indent-blocks.ts b/blocksuite/affine/block-note/src/commands/indent-blocks.tsindex 5793f02dce..8a6e137fd4 100644--- a/blocksuite/affine/block-note/src/commands/indent-blocks.ts+++ b/blocksuite/affine/block-note/src/commands/indent-blocks.ts@@ -2,7 +2,7 @@ import { ParagraphBlockModel } from '@blocksuite/affine-model';import {calculateCollapsedSiblings,getNearestHeadingBefore,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';@@ -59,7 +59,7 @@ export const indentBlocks: Command<{const model = store.getBlock(id)?.model;if (!model) return;if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {@@ -84,7 +84,7 @@ export const indentBlocks: Command<{const nearestHeading = getNearestHeadingBefore(firstModel);if (nearestHeading &&- matchFlavours(nearestHeading, [ParagraphBlockModel]) &&+ matchModels(nearestHeading, [ParagraphBlockModel]) &&nearestHeading.collapsed) {store.updateBlock(nearestHeading, { collapsed: false });@@ -105,7 +105,7 @@ export const indentBlocks: Command<{const nearestHeading = getNearestHeadingBefore(firstModel);if (nearestHeading &&- matchFlavours(nearestHeading, [ParagraphBlockModel]) &&+ matchModels(nearestHeading, [ParagraphBlockModel]) &&nearestHeading.collapsed) {store.updateBlock(nearestHeading, { collapsed: false });diff --git a/blocksuite/affine/block-note/src/components/edgeless-note-background.ts b/blocksuite/affine/block-note/src/components/edgeless-note-background.tsindex 47d6166753..bef130ace4 100644--- a/blocksuite/affine/block-note/src/components/edgeless-note-background.ts+++ b/blocksuite/affine/block-note/src/components/edgeless-note-background.ts@@ -9,7 +9,7 @@ import { ThemeProvider } from '@blocksuite/affine-shared/services';import {getClosestBlockComponentByPoint,handleNativeRangeAtPoint,- matchFlavours,+ matchModels,stopPropagation,} from '@blocksuite/affine-shared/utils';import {@@ -100,10 +100,10 @@ export class EdgelessNoteBackground extends SignalWatcher(if ((!nearestModel.text ||- !matchFlavours(nearestModel, [ParagraphBlockModel, ListBlockModel])) &&+ !matchModels(nearestModel, [ParagraphBlockModel, ListBlockModel])) &&(!siblingModel ||!siblingModel.text ||- !matchFlavours(siblingModel, [ParagraphBlockModel, ListBlockModel]))+ !matchModels(siblingModel, [ParagraphBlockModel, ListBlockModel]))) {const [pId] = this.doc.addSiblingBlocks(nearestModel,diff --git a/blocksuite/affine/block-note/src/note-service.ts b/blocksuite/affine/block-note/src/note-service.tsindex 02cde50227..f4417050bb 100644--- a/blocksuite/affine/block-note/src/note-service.ts+++ b/blocksuite/affine/block-note/src/note-service.ts@@ -12,7 +12,7 @@ import {getPrevBlockCommand,getTextSelectionCommand,} from '@blocksuite/affine-shared/commands';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {type BlockComponent,BlockSelection,@@ -155,7 +155,7 @@ export class NoteBlockService extends BlockService {const doc = this._std.store;let parent = doc.getBlock(blockId)?.model ?? null;while (parent) {- if (matchFlavours(parent, [NoteBlockModel])) {+ if (matchModels(parent, [NoteBlockModel])) {return parent;}parent = doc.getParent(parent);@@ -194,7 +194,7 @@ export class NoteBlockService extends BlockService {}if (- !matchFlavours(nextBlock.model, [+ !matchModels(nextBlock.model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,@@ -230,7 +230,7 @@ export class NoteBlockService extends BlockService {event.preventDefault();if (- matchFlavours(nextBlock.model, [+ matchModels(nextBlock.model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,@@ -284,7 +284,7 @@ export class NoteBlockService extends BlockService {}if (- !matchFlavours(prevBlock.model, [+ !matchModels(prevBlock.model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,@@ -318,7 +318,7 @@ export class NoteBlockService extends BlockService {}if (- matchFlavours(prevBlock.model, [+ matchModels(prevBlock.model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,diff --git a/blocksuite/affine/block-note/src/utils.ts b/blocksuite/affine/block-note/src/utils.tsindex ec41758034..194d60253b 100644--- a/blocksuite/affine/block-note/src/utils.ts+++ b/blocksuite/affine/block-note/src/utils.ts@@ -1,6 +1,6 @@import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';import { FeatureFlagService } from '@blocksuite/affine-shared/services';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';/**@@ -11,7 +11,7 @@ export function isPageBlock(std: BlockStdScope, note: NoteBlockModel) {std.get(FeatureFlagService).getFlag('enable_page_block') &¬e.parent?.children.find(child =>- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode !== NoteDisplayMode.EdgelessOnly) === note);diff --git a/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.tsindex 72bc407490..1ba7e54dc3 100644--- a/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts+++ b/blocksuite/affine/block-paragraph/src/commands/dedent-paragraph.ts@@ -2,7 +2,7 @@ import { ParagraphBlockModel } from '@blocksuite/affine-model';import type { IndentContext } from '@blocksuite/affine-shared/types';import {calculateCollapsedSiblings,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';@@ -35,7 +35,7 @@ export const canDedentParagraphCommand: Command<}const model = store.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) {+ if (!model || !matchModels(model, [ParagraphBlockModel])) {return;}@@ -89,7 +89,7 @@ export const dedentParagraphCommand: Command<{store.captureSync();if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {diff --git a/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.tsindex 5051922d1d..70eed55879 100644--- a/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts+++ b/blocksuite/affine/block-paragraph/src/commands/indent-paragraph.ts@@ -3,7 +3,7 @@ import type { IndentContext } from '@blocksuite/affine-shared/types';import {calculateCollapsedSiblings,getNearestHeadingBefore,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';@@ -37,7 +37,7 @@ export const canIndentParagraphCommand: Command<}const model = std.store.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) {+ if (!model || !matchModels(model, [ParagraphBlockModel])) {return;}@@ -95,7 +95,7 @@ export const indentParagraphCommand: Command<{const nearestHeading = getNearestHeadingBefore(model);if (nearestHeading &&- matchFlavours(nearestHeading, [ParagraphBlockModel]) &&+ matchModels(nearestHeading, [ParagraphBlockModel]) &&nearestHeading.collapsed) {store.updateBlock(nearestHeading, {@@ -105,7 +105,7 @@ export const indentParagraphCommand: Command<{}if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {@@ -124,7 +124,7 @@ export const indentParagraphCommand: Command<{const nearestHeading = getNearestHeadingBefore(model);if (nearestHeading &&- matchFlavours(nearestHeading, [ParagraphBlockModel]) &&+ matchModels(nearestHeading, [ParagraphBlockModel]) &&nearestHeading.collapsed) {store.updateBlock(nearestHeading, {@@ -135,7 +135,7 @@ export const indentParagraphCommand: Command<{// update collapsed state of affine listif (- matchFlavours(previousSibling, [ListBlockModel]) &&+ matchModels(previousSibling, [ListBlockModel]) &&previousSibling.collapsed) {store.updateBlock(previousSibling, {diff --git a/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts b/blocksuite/affine/block-paragraph/src/commands/split-paragraph.tsindex 8ae4614444..26852a0356 100644--- a/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts+++ b/blocksuite/affine/block-paragraph/src/commands/split-paragraph.ts@@ -3,7 +3,7 @@ import {getInlineEditorByModel,} from '@blocksuite/affine-components/rich-text';import { ParagraphBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';export const splitParagraphCommand: Command<@@ -24,7 +24,7 @@ export const splitParagraphCommand: Command<if (!blockId) return;const model = store.getBlock(blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;+ if (!model || !matchModels(model, [ParagraphBlockModel])) return;const inlineEditor = getInlineEditorByModel(host, model);const range = inlineEditor?.getInlineRange();@@ -43,7 +43,7 @@ export const splitParagraphCommand: Command<store.captureSync();const right = model.text.split(splitIndex, splitLength);const id = store.addBlock(- model.flavour as BlockSuite.Flavour,+ model.flavour,{text: right,type: model.type,@@ -62,7 +62,7 @@ export const splitParagraphCommand: Command<store.captureSync();const right = model.text.split(splitIndex, splitLength);const id = store.addBlock(- model.flavour as BlockSuite.Flavour,+ model.flavour,{text: right,type: model.type,diff --git a/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts b/blocksuite/affine/block-paragraph/src/paragraph-keymap.tsindex 539aa26bba..dbdb6e9f9e 100644--- a/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts+++ b/blocksuite/affine/block-paragraph/src/paragraph-keymap.ts@@ -10,7 +10,7 @@ import {} from '@blocksuite/affine-model';import {calculateCollapsedSiblings,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { KeymapExtension, TextSelection } from '@blocksuite/block-std';import { IS_MAC } from '@blocksuite/global/env';@@ -40,7 +40,7 @@ export const ParagraphKeymapExtension = KeymapExtension(const { store } = std;const model = store.getBlock(text.from.blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;+ if (!model || !matchModels(model, [ParagraphBlockModel])) return;const event = ctx.get('keyboardState').raw;event.preventDefault();@@ -71,7 +71,7 @@ export const ParagraphKeymapExtension = KeymapExtension(const text = std.selection.find(TextSelection);if (!text) return;const model = store.getBlock(text.from.blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;+ if (!model || !matchModels(model, [ParagraphBlockModel])) return;const inlineEditor = getInlineEditorByModel(std.host,text.from.blockId@@ -98,7 +98,7 @@ export const ParagraphKeymapExtension = KeymapExtension(const text = std.selection.find(TextSelection);if (!text) return;const model = store.getBlock(text.from.blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;+ if (!model || !matchModels(model, [ParagraphBlockModel])) return;const inlineEditor = getInlineEditorByModel(std.host,text.from.blockId@@ -151,7 +151,7 @@ export const ParagraphKeymapExtension = KeymapExtension(const rightText = model.text.split(range.index);const newId = store.addBlock(- model.flavour as BlockSuite.Flavour,+ model.flavour,{ type: model.type, text: rightText },parent,index + collapsedSiblings.length + 1diff --git a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts b/blocksuite/affine/block-paragraph/src/utils/forward-delete.tsindex 3e2130a0c4..ff136fe522 100644--- a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts+++ b/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts@@ -11,7 +11,7 @@ import {import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';import {getNextContentBlock,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {BlockSelection,@@ -25,7 +25,7 @@ export function forwardDelete(std: BlockStdScope) {if (!text) return;const isCollapsed = text.isCollapsed();const model = store.getBlock(text.from.blockId)?.model;- if (!model || !matchFlavours(model, [ParagraphBlockModel])) return;+ if (!model || !matchModels(model, [ParagraphBlockModel])) return;const isEnd = isCollapsed && text.from.index === model.text.length;if (!isEnd) return;const parent = store.getParent(model);@@ -34,7 +34,7 @@ export function forwardDelete(std: BlockStdScope) {const nextSibling = store.getNext(model);if (- matchFlavours(nextSibling, [+ matchModels(nextSibling, [AttachmentBlockModel,BookmarkBlockModel,DatabaseBlockModel,@@ -50,7 +50,7 @@ export function forwardDelete(std: BlockStdScope) {return true;}- if (matchFlavours(nextSibling, [ParagraphBlockModel, ListBlockModel])) {+ if (matchModels(nextSibling, [ParagraphBlockModel, ListBlockModel])) {model.text.join(nextSibling.text);if (nextSibling.children) {const parent = store.getParent(nextSibling);diff --git a/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts b/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.tsindex a2a12cd8a3..f7d88ded96 100644--- a/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts+++ b/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts@@ -20,7 +20,7 @@ import {focusTitle,getDocTitleInlineEditor,getPrevContentBlock,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import { BlockSelection, type EditorHost } from '@blocksuite/block-std';import type { BlockModel, Text } from '@blocksuite/store';@@ -44,7 +44,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {const parent = doc.getParent(model);if (!parent) return false;- if (matchFlavours(parent, [EdgelessTextBlockModel])) {+ if (matchModels(parent, [EdgelessTextBlockModel])) {return true;}@@ -53,7 +53,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {return handleNoPreviousSibling(editorHost, model);}- if (matchFlavours(prevBlock, [ParagraphBlockModel, ListBlockModel])) {+ if (matchModels(prevBlock, [ParagraphBlockModel, ListBlockModel])) {const modelIndex = parent.children.indexOf(model);if ((modelIndex === -1 || modelIndex === parent.children.length - 1) &&@@ -74,7 +74,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {}if (- matchFlavours(prevBlock, [+ matchModels(prevBlock, [AttachmentBlockModel,BookmarkBlockModel,CodeBlockModel,@@ -97,7 +97,7 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {return true;}- if (matchFlavours(parent, [DatabaseBlockModel])) {+ if (matchModels(parent, [DatabaseBlockModel])) {doc.deleteBlock(model);focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);return true;@@ -115,7 +115,7 @@ function handleNoPreviousSibling(editorHost: EditorHost, model: ExtendedModel) {// Probably no title, e.g. in edgeless modeif (!titleEditor) {if (- matchFlavours(parent, [EdgelessTextBlockModel]) ||+ matchModels(parent, [EdgelessTextBlockModel]) ||model.children.length > 0) {doc.deleteBlock(model, {diff --git a/blocksuite/affine/block-surface-ref/src/commands.ts b/blocksuite/affine/block-surface-ref/src/commands.tsindex 588b8795f2..bbce831d42 100644--- a/blocksuite/affine/block-surface-ref/src/commands.ts+++ b/blocksuite/affine/block-surface-ref/src/commands.ts@@ -3,7 +3,7 @@ import {FrameBlockModel,type SurfaceRefProps,} from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { Command } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';@@ -41,7 +41,7 @@ export const insertSurfaceRefBlockCommand: Command<if (element?.type === 'group') {surfaceRefProps.refFlavour = 'group';- } else if (matchFlavours(blockModel, [FrameBlockModel])) {+ } else if (matchModels(blockModel, [FrameBlockModel])) {surfaceRefProps.refFlavour = 'frame';} else {console.error(`reference not found ${reference}`);diff --git a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts b/blocksuite/affine/block-surface-ref/src/surface-ref-block.tsindex 5c4edfbf4b..6e2c3ba612 100644--- a/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts+++ b/blocksuite/affine/block-surface-ref/src/surface-ref-block.ts@@ -41,6 +41,7 @@ import {GfxBlockElementModel,GfxControllerIdentifier,GfxExtension,+ type GfxModel,} from '@blocksuite/block-std/gfx';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import {@@ -249,7 +250,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModeprivate readonly _previewSpec =SpecProvider.getInstance().getSpec('edgeless:preview');- private _referencedModel: BlockSuite.EdgelessModel | null = null;+ private _referencedModel: GfxModel | null = null;private _referenceXYWH: SerializedXYWH | null = null;@@ -321,10 +322,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModeconst surfaceModel = getSurfaceBlock(this.doc);this._surfaceModel = surfaceModel;- const findReferencedModel = (): [- BlockSuite.EdgelessModel | null,- string,- ] => {+ const findReferencedModel = (): [GfxModel | null, string] => {if (!this.model.reference) return [null, this.doc.id];if (this.doc.getBlock(this.model.reference)) {@@ -541,10 +539,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModeviewport.setViewportByBound(Bound.deserialize(this._referenceXYWH));}- private _renderMask(- referencedModel: BlockSuite.EdgelessModel,- flavourOrType: string- ) {+ private _renderMask(referencedModel: GfxModel, flavourOrType: string) {const title = 'title' in referencedModel ? referencedModel.title : '';return html`@@ -561,7 +556,7 @@ export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockMode`;}- private _renderRefContent(referencedModel: BlockSuite.EdgelessModel) {+ private _renderRefContent(referencedModel: GfxModel) {const [, , w, h] = deserializeXYWH(referencedModel.xywh);const flavourOrType ='flavour' in referencedModeldiff --git a/blocksuite/affine/block-surface/src/effects.ts b/blocksuite/affine/block-surface/src/effects.tsindex a9ee0b6e35..7bb01e35c7 100644--- a/blocksuite/affine/block-surface/src/effects.ts+++ b/blocksuite/affine/block-surface/src/effects.ts@@ -1,6 +1,5 @@import { SurfaceBlockComponent } from './surface-block.js';import { SurfaceBlockVoidComponent } from './surface-block-void.js';-import type { SurfaceBlockModel } from './surface-model.js';import type { SurfaceBlockService } from './surface-service.js';export function effects() {@@ -13,8 +12,5 @@ declare global {interface BlockServices {'affine:surface': SurfaceBlockService;}- interface BlockModels {- 'affine:surface': SurfaceBlockModel;- }}}diff --git a/blocksuite/affine/block-surface/src/extensions/crud-extension.ts b/blocksuite/affine/block-surface/src/extensions/crud-extension.tsindex cbccf37cdc..9788beaccc 100644--- a/blocksuite/affine/block-surface/src/extensions/crud-extension.ts+++ b/blocksuite/affine/block-surface/src/extensions/crud-extension.ts@@ -1,6 +1,9 @@import { EditPropsStore } from '@blocksuite/affine-shared/services';import { type BlockStdScope, StdIdentifier } from '@blocksuite/block-std';-import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';+import {+ GfxControllerIdentifier,+ type GfxModel,+} from '@blocksuite/block-std/gfx';import { type Container, createIdentifier } from '@blocksuite/global/di';import { type BlockModel, Extension } from '@blocksuite/store';@@ -30,7 +33,7 @@ export class EdgelessCRUDExtension extends Extension {return this._gfx.surface as SurfaceBlockModel | null;}- deleteElements = (elements: BlockSuite.EdgelessModel[]) => {+ deleteElements = (elements: GfxModel[]) => {const surface = this._surface;if (!surface) {console.error('surface is not initialized');@@ -134,7 +137,7 @@ export class EdgelessCRUDExtension extends Extension {}};- getElementById(id: string): BlockSuite.EdgelessModel | null {+ getElementById(id: string): GfxModel | null {const surface = this._surface;if (!surface) {return null;diff --git a/blocksuite/affine/block-surface/src/extensions/query.ts b/blocksuite/affine/block-surface/src/extensions/query.tsindex 38ba97d295..957f8a8a83 100644--- a/blocksuite/affine/block-surface/src/extensions/query.ts+++ b/blocksuite/affine/block-surface/src/extensions/query.ts@@ -1,16 +1,17 @@import type { NoteBlockModel } from '@blocksuite/affine-model';+import type { GfxModel } from '@blocksuite/block-std/gfx';import type { BlockModel } from '@blocksuite/store';import type { Connectable } from '../managers/connector-manager';export function isConnectable(- element: BlockSuite.EdgelessModel | null+ element: GfxModel | null): element is Connectable {return !!element && element.connectable;}export function isNoteBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is NoteBlockModel {return !!element && 'flavour' in element && element.flavour === 'affine:note';}diff --git a/blocksuite/affine/block-surface/src/managers/connector-manager.ts b/blocksuite/affine/block-surface/src/managers/connector-manager.tsindex f9e4ddbaac..4569ba1b99 100644--- a/blocksuite/affine/block-surface/src/managers/connector-manager.ts+++ b/blocksuite/affine/block-surface/src/managers/connector-manager.ts@@ -37,7 +37,7 @@ import { Overlay } from '../renderer/overlay.js';import { AStarRunner } from '../utils/a-star.js';export type Connectable = Exclude<- BlockSuite.EdgelessModel,+ GfxModel,ConnectorElementModel | BrushElementModel | GroupElementModel>;diff --git a/blocksuite/affine/block-surface/src/utils/add-note.ts b/blocksuite/affine/block-surface/src/utils/add-note.tsindex 97b7c15435..42833a878a 100644--- a/blocksuite/affine/block-surface/src/utils/add-note.ts+++ b/blocksuite/affine/block-surface/src/utils/add-note.ts@@ -96,7 +96,7 @@ export function addNote(const doc = std.store;const blockId = doc.addBlock(- options.childFlavour as BlockSuite.Flavour,+ options.childFlavour,{ type: options.childType },noteId);diff --git a/blocksuite/affine/components/src/doc-title/doc-title.ts b/blocksuite/affine/components/src/doc-title/doc-title.tsindex e17faa3f40..8b29e5982a 100644--- a/blocksuite/affine/components/src/doc-title/doc-title.ts+++ b/blocksuite/affine/components/src/doc-title/doc-title.ts@@ -6,7 +6,7 @@ import {ParagraphBlockModel,type RootBlockModel,} from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { ShadowlessElement } from '@blocksuite/block-std';import { WithDisposable } from '@blocksuite/global/utils';import type { Store } from '@blocksuite/store';@@ -72,7 +72,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {private _getOrCreateFirstPageVisibleNote() {const note = this._rootModel.children.find((child): child is NoteBlockModel =>- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode !== NoteDisplayMode.EdgelessOnly);if (note) return note;@@ -105,7 +105,7 @@ export class DocTitle extends WithDisposable(ShadowlessElement) {const note = this._getOrCreateFirstPageVisibleNote();const firstText = note?.children.find(block =>- matchFlavours(block, [+ matchModels(block, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,diff --git a/blocksuite/affine/components/src/drop-indicator/file-drop-manager.ts b/blocksuite/affine/components/src/drop-indicator/file-drop-manager.tsindex c63f33a5d6..e8f27eee12 100644--- a/blocksuite/affine/components/src/drop-indicator/file-drop-manager.ts+++ b/blocksuite/affine/components/src/drop-indicator/file-drop-manager.ts@@ -4,7 +4,7 @@ import {type DropTarget,getClosestBlockComponentByPoint,isInsidePageEditor,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {type BlockComponent,@@ -59,7 +59,7 @@ export class FileDropExtension extends LifeCycleWatcher {const model = element.model;const parent = this.std.store.getParent(model);- if (!matchFlavours(parent, [SurfaceBlockModel])) {+ if (!matchModels(parent, [SurfaceBlockModel])) {const point = this.point$.value;target = point && calcDropTarget(point, model, element);}@@ -75,7 +75,7 @@ export class FileDropExtension extends LifeCycleWatcher {if (!rootModel) return null;let lastNote = rootModel.children[rootModel.children.length - 1];- if (!lastNote || !matchFlavours(lastNote, [NoteBlockModel])) {+ if (!lastNote || !matchModels(lastNote, [NoteBlockModel])) {const newNoteId = this.doc.addBlock('affine:note', {}, rootModel.id);const newNote = this.doc.getBlock(newNoteId)?.model;if (!newNote) return null;diff --git a/blocksuite/affine/components/src/rich-text/conversion.ts b/blocksuite/affine/components/src/rich-text/conversion.tsindex bde5f01c91..d0fb841f78 100644--- a/blocksuite/affine/components/src/rich-text/conversion.ts+++ b/blocksuite/affine/components/src/rich-text/conversion.ts@@ -21,7 +21,7 @@ import {* which are also used for registering hotkeys for converting block flavours.*/export interface TextConversionConfig {- flavour: BlockSuite.Flavour;+ flavour: string;type?: string;name: string;description?: string;diff --git a/blocksuite/affine/components/src/rich-text/dom.ts b/blocksuite/affine/components/src/rich-text/dom.tsindex e73e3ddadf..699c734095 100644--- a/blocksuite/affine/components/src/rich-text/dom.ts+++ b/blocksuite/affine/components/src/rich-text/dom.ts@@ -2,7 +2,7 @@ import { DatabaseBlockModel } from '@blocksuite/affine-model';import {asyncGetBlockComponent,getCurrentNativeRange,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {type BlockStdScope,@@ -42,7 +42,7 @@ export function getInlineEditorByModel(typeof model === 'string'? editorHost.std.store.getBlock(model)?.model: model;- if (!blockModel || matchFlavours(blockModel, [DatabaseBlockModel])) {+ if (!blockModel || matchModels(blockModel, [DatabaseBlockModel])) {// Not support database model since it's may be have multiple inline editor instances.// Support to enter the editing state through the Enter key in the database.return null;diff --git a/blocksuite/affine/components/src/rich-text/format/delete-text.ts b/blocksuite/affine/components/src/rich-text/format/delete-text.tsindex c224e61bb2..6e29390e6b 100644--- a/blocksuite/affine/components/src/rich-text/format/delete-text.ts+++ b/blocksuite/affine/components/src/rich-text/format/delete-text.ts@@ -1,5 +1,5 @@import { RootBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { type Command, TextSelection } from '@blocksuite/block-std';import type { Text } from '@blocksuite/store';@@ -25,7 +25,7 @@ export const deleteTextCommand: Command<{if (!fromElement) return;let fromText: Text | undefined;- if (matchFlavours(fromElement.model, [RootBlockModel])) {+ if (matchModels(fromElement.model, [RootBlockModel])) {fromText = fromElement.model.title;} else {fromText = fromElement.model.text;diff --git a/blocksuite/affine/components/src/rich-text/format/format-block.ts b/blocksuite/affine/components/src/rich-text/format/format-block.tsindex 468ea77a42..d7f1a97381 100644--- a/blocksuite/affine/components/src/rich-text/format/format-block.ts+++ b/blocksuite/affine/components/src/rich-text/format/format-block.ts@@ -28,10 +28,7 @@ export const formatBlockCommand: Command<{.chain().pipe(getSelectedBlocksCommand, {blockSelections,- filter: el =>- FORMAT_BLOCK_SUPPORT_FLAVOURS.includes(- el.model.flavour as BlockSuite.Flavour- ),+ filter: el => FORMAT_BLOCK_SUPPORT_FLAVOURS.includes(el.model.flavour),types: ['block'],}).pipe((ctx, next) => {diff --git a/blocksuite/affine/components/src/rich-text/format/format-native.ts b/blocksuite/affine/components/src/rich-text/format/format-native.tsindex 9afe4d6fe1..808ccebe87 100644--- a/blocksuite/affine/components/src/rich-text/format/format-native.ts+++ b/blocksuite/affine/components/src/rich-text/format/format-native.ts@@ -31,9 +31,7 @@ export const formatNativeCommand: Command<{.filter(el => {const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);if (block) {- return FORMAT_NATIVE_SUPPORT_FLAVOURS.includes(- block.model.flavour as BlockSuite.Flavour- );+ return FORMAT_NATIVE_SUPPORT_FLAVOURS.includes(block.model.flavour);}return false;})diff --git a/blocksuite/affine/components/src/rich-text/format/format-text.ts b/blocksuite/affine/components/src/rich-text/format/format-text.tsindex 1f37cd45e2..ef280cb549 100644--- a/blocksuite/affine/components/src/rich-text/format/format-text.ts+++ b/blocksuite/affine/components/src/rich-text/format/format-text.ts@@ -22,10 +22,7 @@ export const formatTextCommand: Command<{.chain().pipe(getSelectedBlocksCommand, {textSelection,- filter: el =>- FORMAT_TEXT_SUPPORT_FLAVOURS.includes(- el.model.flavour as BlockSuite.Flavour- ),+ filter: el => FORMAT_TEXT_SUPPORT_FLAVOURS.includes(el.model.flavour),types: ['text'],}).pipe((ctx, next) => {diff --git a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts b/blocksuite/affine/components/src/rich-text/keymap/bracket.tsindex 61bfc2b707..0b49356894 100644--- a/blocksuite/affine/components/src/rich-text/keymap/bracket.ts+++ b/blocksuite/affine/components/src/rich-text/keymap/bracket.ts@@ -1,9 +1,6 @@import { CodeBlockModel } from '@blocksuite/affine-model';import { BRACKET_PAIRS } from '@blocksuite/affine-shared/consts';-import {- createDefaultDoc,- matchFlavours,-} from '@blocksuite/affine-shared/utils';+import { createDefaultDoc, matchModels } from '@blocksuite/affine-shared/utils';import {type BlockStdScope,TextSelection,@@ -29,7 +26,7 @@ export const bracketKeymap = (if (!textSelection) return;const model = doc.getBlock(textSelection.from.blockId)?.model;if (!model) return;- if (!matchFlavours(model, [CodeBlockModel])) return;+ if (!matchModels(model, [CodeBlockModel])) return;const inlineEditor = getInlineEditorByModel(std.host,textSelection.from.blockId@@ -56,7 +53,7 @@ export const bracketKeymap = (const model = doc.getBlock(textSelection.from.blockId)?.model;if (!model) return;- const isCodeBlock = matchFlavours(model, [CodeBlockModel]);+ const isCodeBlock = matchModels(model, [CodeBlockModel]);// When selection is collapsed, only trigger auto complete in code blockif (textSelection.isCollapsed() && !isCodeBlock) return;if (!textSelection.isInSameBlock()) return;diff --git a/blocksuite/affine/components/src/rich-text/markdown/divider.ts b/blocksuite/affine/components/src/rich-text/markdown/divider.tsindex 063d0f57ee..1c1ad817a3 100644--- a/blocksuite/affine/components/src/rich-text/markdown/divider.ts+++ b/blocksuite/affine/components/src/rich-text/markdown/divider.ts@@ -2,7 +2,7 @@ import {DividerBlockModel,ParagraphBlockModel,} from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';@@ -16,8 +16,8 @@ export function toDivider() {const { store: doc } = std;if (- matchFlavours(model, [DividerBlockModel]) ||- (matchFlavours(model, [ParagraphBlockModel]) && model.type === 'quote')+ matchModels(model, [DividerBlockModel]) ||+ (matchModels(model, [ParagraphBlockModel]) && model.type === 'quote')) {return;}diff --git a/blocksuite/affine/components/src/rich-text/markdown/list.ts b/blocksuite/affine/components/src/rich-text/markdown/list.tsindex f7263de4bc..25069518c5 100644--- a/blocksuite/affine/components/src/rich-text/markdown/list.ts+++ b/blocksuite/affine/components/src/rich-text/markdown/list.ts@@ -3,7 +3,7 @@ import {type ListType,ParagraphBlockModel,} from '@blocksuite/affine-model';-import { matchFlavours, toNumberedList } from '@blocksuite/affine-shared/utils';+import { matchModels, toNumberedList } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';@@ -17,7 +17,7 @@ export function toList(prefix: string,otherProperties?: Partial<ListProps>) {- if (!matchFlavours(model, [ParagraphBlockModel])) {+ if (!matchModels(model, [ParagraphBlockModel])) {return;}const { store: doc } = std;diff --git a/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts b/blocksuite/affine/components/src/rich-text/markdown/markdown-input.tsindex 489959ae0d..e08ec62d60 100644--- a/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts+++ b/blocksuite/affine/components/src/rich-text/markdown/markdown-input.ts@@ -1,8 +1,5 @@import { CodeBlockModel, ParagraphBlockModel } from '@blocksuite/affine-model';-import {- isMarkdownPrefix,- matchFlavours,-} from '@blocksuite/affine-shared/utils';+import { isMarkdownPrefix, matchModels } from '@blocksuite/affine-shared/utils';import { type BlockStdScope, TextSelection } from '@blocksuite/block-std';import { getInlineEditorByModel } from '../dom.js';@@ -32,10 +29,10 @@ export function markdownInput(const prefixText = getPrefixText(inline);if (!isMarkdownPrefix(prefixText)) return;- const isParagraph = matchFlavours(model, [ParagraphBlockModel]);+ const isParagraph = matchModels(model, [ParagraphBlockModel]);const isHeading = isParagraph && model.type.startsWith('h');const isParagraphQuoteBlock = isParagraph && model.type === 'quote';- const isCodeBlock = matchFlavours(model, [CodeBlockModel]);+ const isCodeBlock = matchModels(model, [CodeBlockModel]);if (isHeading || isParagraphQuoteBlock || isCodeBlock) return;const lineInfo = inline.getLine(range.index);diff --git a/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts b/blocksuite/affine/components/src/rich-text/markdown/paragraph.tsindex 287bcb4378..f9fe82c07a 100644--- a/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts+++ b/blocksuite/affine/components/src/rich-text/markdown/paragraph.ts@@ -2,7 +2,7 @@ import {ParagraphBlockModel,type ParagraphType,} from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';@@ -16,7 +16,7 @@ export function toParagraph(prefix: string) {const { store: doc } = std;- if (!matchFlavours(model, [ParagraphBlockModel])) {+ if (!matchModels(model, [ParagraphBlockModel])) {const parent = doc.getParent(model);if (!parent) return;@@ -36,7 +36,7 @@ export function toParagraph(return id;}- if (matchFlavours(model, [ParagraphBlockModel]) && model.type !== type) {+ if (matchModels(model, [ParagraphBlockModel]) && model.type !== type) {beforeConvert(std, model, prefix.length);doc.updateBlock(model, { type });diff --git a/blocksuite/affine/components/src/rich-text/markdown/to-code.ts b/blocksuite/affine/components/src/rich-text/markdown/to-code.tsindex c147237e67..f187feeb26 100644--- a/blocksuite/affine/components/src/rich-text/markdown/to-code.ts+++ b/blocksuite/affine/components/src/rich-text/markdown/to-code.ts@@ -1,5 +1,5 @@import { ParagraphBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';@@ -11,7 +11,7 @@ export function toCode(prefixText: string,language: string | null) {- if (matchFlavours(model, [ParagraphBlockModel]) && model.type === 'quote') {+ if (matchModels(model, [ParagraphBlockModel]) && model.type === 'quote') {return;}diff --git a/blocksuite/affine/model/src/blocks/attachment/attachment-model.ts b/blocksuite/affine/model/src/blocks/attachment/attachment-model.tsindex f80c52805f..fcdac29658 100644--- a/blocksuite/affine/model/src/blocks/attachment/attachment-model.ts+++ b/blocksuite/affine/model/src/blocks/attachment/attachment-model.ts@@ -94,8 +94,5 @@ declare global {interface EdgelessBlockModelMap {'affine:attachment': AttachmentBlockModel;}- interface BlockModels {- 'affine:attachment': AttachmentBlockModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/bookmark/bookmark-model.ts b/blocksuite/affine/model/src/blocks/bookmark/bookmark-model.tsindex 243dabaa6d..ed13c426df 100644--- a/blocksuite/affine/model/src/blocks/bookmark/bookmark-model.ts+++ b/blocksuite/affine/model/src/blocks/bookmark/bookmark-model.ts@@ -63,8 +63,5 @@ declare global {interface EdgelessBlockModelMap {'affine:bookmark': BookmarkBlockModel;}- interface BlockModels {- 'affine:bookmark': BookmarkBlockModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/code/code-model.ts b/blocksuite/affine/model/src/blocks/code/code-model.tsindex 36bd0a6520..f93e94323d 100644--- a/blocksuite/affine/model/src/blocks/code/code-model.ts+++ b/blocksuite/affine/model/src/blocks/code/code-model.ts@@ -33,11 +33,3 @@ export const CodeBlockSchema = defineBlockSchema({export class CodeBlockModel extends BlockModel<CodeBlockProps> {override text!: Text;}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:code': CodeBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/database/database-model.ts b/blocksuite/affine/model/src/blocks/database/database-model.tsindex 9488050e4f..eda9934652 100644--- a/blocksuite/affine/model/src/blocks/database/database-model.ts+++ b/blocksuite/affine/model/src/blocks/database/database-model.ts@@ -28,11 +28,3 @@ export const DatabaseBlockSchema = defineBlockSchema({},toModel: () => new DatabaseBlockModel(),});--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:database': DatabaseBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/divider/divider-model.ts b/blocksuite/affine/model/src/blocks/divider/divider-model.tsindex 06456298b8..ef5bd6a1f9 100644--- a/blocksuite/affine/model/src/blocks/divider/divider-model.ts+++ b/blocksuite/affine/model/src/blocks/divider/divider-model.ts@@ -15,11 +15,3 @@ type Props = {};export class DividerBlockModel extends BlockModel<Props> {}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:divider': DividerBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/edgeless-text/edgeless-text-model.ts b/blocksuite/affine/model/src/blocks/edgeless-text/edgeless-text-model.tsindex ea36b21df5..88a6a4d3af 100644--- a/blocksuite/affine/model/src/blocks/edgeless-text/edgeless-text-model.ts+++ b/blocksuite/affine/model/src/blocks/edgeless-text/edgeless-text-model.ts@@ -82,10 +82,6 @@ export class EdgelessTextBlockModeldeclare global {namespace BlockSuite {- interface BlockModels {- 'affine:edgeless-text': EdgelessTextBlockModel;- }-interface EdgelessBlockModelMap {'affine:edgeless-text': EdgelessTextBlockModel;}diff --git a/blocksuite/affine/model/src/blocks/embed/figma/figma-model.ts b/blocksuite/affine/model/src/blocks/embed/figma/figma-model.tsindex 77e74fb084..1097804b66 100644--- a/blocksuite/affine/model/src/blocks/embed/figma/figma-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/figma/figma-model.ts@@ -25,8 +25,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-figma': EmbedFigmaModel;}- interface BlockModels {- 'affine:embed-figma': EmbedFigmaModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/github/github-model.ts b/blocksuite/affine/model/src/blocks/embed/github/github-model.tsindex 2644aa1ef5..fafc7930ea 100644--- a/blocksuite/affine/model/src/blocks/embed/github/github-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/github/github-model.ts@@ -39,8 +39,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-github': EmbedGithubModel;}- interface BlockModels {- 'affine:embed-github': EmbedGithubModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/html/html-model.ts b/blocksuite/affine/model/src/blocks/embed/html/html-model.tsindex e518927de8..a153a4cff7 100644--- a/blocksuite/affine/model/src/blocks/embed/html/html-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/html/html-model.ts@@ -21,8 +21,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-html': EmbedHtmlModel;}- interface BlockModels {- 'affine:embed-html': EmbedHtmlModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/linked-doc/linked-doc-model.ts b/blocksuite/affine/model/src/blocks/embed/linked-doc/linked-doc-model.tsindex 2cff7fdabd..93c82d226b 100644--- a/blocksuite/affine/model/src/blocks/embed/linked-doc/linked-doc-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/linked-doc/linked-doc-model.ts@@ -26,8 +26,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-linked-doc': EmbedLinkedDocModel;}- interface BlockModels {- 'affine:embed-linked-doc': EmbedLinkedDocModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/loom/loom-model.ts b/blocksuite/affine/model/src/blocks/embed/loom/loom-model.tsindex e11cb30a81..8115bb7172 100644--- a/blocksuite/affine/model/src/blocks/embed/loom/loom-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/loom/loom-model.ts@@ -27,8 +27,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-loom': EmbedLoomModel;}- interface BlockModels {- 'affine:embed-loom': EmbedLoomModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/synced-doc/synced-doc-model.ts b/blocksuite/affine/model/src/blocks/embed/synced-doc/synced-doc-model.tsindex 0833c786bf..32a8fd098b 100644--- a/blocksuite/affine/model/src/blocks/embed/synced-doc/synced-doc-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/synced-doc/synced-doc-model.ts@@ -21,8 +21,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-synced-doc': EmbedSyncedDocModel;}- interface BlockModels {- 'affine:embed-synced-doc': EmbedSyncedDocModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/embed/youtube/youtube-model.ts b/blocksuite/affine/model/src/blocks/embed/youtube/youtube-model.tsindex c208a1e330..a2084b3719 100644--- a/blocksuite/affine/model/src/blocks/embed/youtube/youtube-model.ts+++ b/blocksuite/affine/model/src/blocks/embed/youtube/youtube-model.ts@@ -30,8 +30,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-youtube': EmbedYoutubeModel;}- interface BlockModels {- 'affine:embed-youtube': EmbedYoutubeModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/frame/frame-model.ts b/blocksuite/affine/model/src/blocks/frame/frame-model.tsindex 80fc928cea..2eec73509b 100644--- a/blocksuite/affine/model/src/blocks/frame/frame-model.ts+++ b/blocksuite/affine/model/src/blocks/frame/frame-model.ts@@ -150,8 +150,5 @@ declare global {interface EdgelessBlockModelMap {'affine:frame': FrameBlockModel;}- interface BlockModels {- 'affine:frame': FrameBlockModel;- }}}diff --git a/blocksuite/affine/model/src/blocks/image/image-model.ts b/blocksuite/affine/model/src/blocks/image/image-model.tsindex 6bcd97898f..b3002d9c07 100644--- a/blocksuite/affine/model/src/blocks/image/image-model.ts+++ b/blocksuite/affine/model/src/blocks/image/image-model.ts@@ -45,9 +45,6 @@ export class ImageBlockModeldeclare global {namespace BlockSuite {- interface BlockModels {- 'affine:image': ImageBlockModel;- }interface EdgelessBlockModelMap {'affine:image': ImageBlockModel;}diff --git a/blocksuite/affine/model/src/blocks/latex/latex-model.ts b/blocksuite/affine/model/src/blocks/latex/latex-model.tsindex 31f1a6b23d..5253ac89fc 100644--- a/blocksuite/affine/model/src/blocks/latex/latex-model.ts+++ b/blocksuite/affine/model/src/blocks/latex/latex-model.ts@@ -40,10 +40,6 @@ export class LatexBlockModeldeclare global {namespace BlockSuite {- interface BlockModels {- 'affine:latex': LatexBlockModel;- }-interface EdgelessBlockModelMap {'affine:latex': LatexBlockModel;}diff --git a/blocksuite/affine/model/src/blocks/list/list-model.ts b/blocksuite/affine/model/src/blocks/list/list-model.tsindex 235ded40a4..2ea461e029 100644--- a/blocksuite/affine/model/src/blocks/list/list-model.ts+++ b/blocksuite/affine/model/src/blocks/list/list-model.ts@@ -41,11 +41,3 @@ export const ListBlockSchema = defineBlockSchema({export class ListBlockModel extends BlockModel<ListProps> {override text!: Text;}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:list': ListBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/note/note-model.ts b/blocksuite/affine/model/src/blocks/note/note-model.tsindex a3f4116092..561d3d282f 100644--- a/blocksuite/affine/model/src/blocks/note/note-model.ts+++ b/blocksuite/affine/model/src/blocks/note/note-model.ts@@ -158,9 +158,6 @@ export class NoteBlockModeldeclare global {namespace BlockSuite {- interface BlockModels {- 'affine:note': NoteBlockModel;- }interface EdgelessBlockModelMap {'affine:note': NoteBlockModel;}diff --git a/blocksuite/affine/model/src/blocks/paragraph/paragraph-model.ts b/blocksuite/affine/model/src/blocks/paragraph/paragraph-model.tsindex b42155c221..a51e51c569 100644--- a/blocksuite/affine/model/src/blocks/paragraph/paragraph-model.ts+++ b/blocksuite/affine/model/src/blocks/paragraph/paragraph-model.ts@@ -44,11 +44,3 @@ export class ParagraphBlockModel extends BlockModel<ParagraphProps> {return this.text$.value.length === 0 && this.children.length === 0;}}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:paragraph': ParagraphBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/root/root-block-model.ts b/blocksuite/affine/model/src/blocks/root/root-block-model.tsindex 2cf068a9fa..afb22d5f42 100644--- a/blocksuite/affine/model/src/blocks/root/root-block-model.ts+++ b/blocksuite/affine/model/src/blocks/root/root-block-model.ts@@ -51,11 +51,3 @@ export const RootBlockSchema = defineBlockSchema({},toModel: () => new RootBlockModel(),});--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:page': RootBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/surface-ref/surface-ref-model.ts b/blocksuite/affine/model/src/blocks/surface-ref/surface-ref-model.tsindex c2997e87a1..f6a7306e48 100644--- a/blocksuite/affine/model/src/blocks/surface-ref/surface-ref-model.ts+++ b/blocksuite/affine/model/src/blocks/surface-ref/surface-ref-model.ts@@ -22,11 +22,3 @@ export const SurfaceRefBlockSchema = defineBlockSchema({});export class SurfaceRefBlockModel extends BlockModel<SurfaceRefProps> {}--declare global {- namespace BlockSuite {- interface BlockModels {- 'affine:surface-ref': SurfaceRefBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/blocks/table/table-model.ts b/blocksuite/affine/model/src/blocks/table/table-model.tsindex 0de6645fdf..a13dd79105 100644--- a/blocksuite/affine/model/src/blocks/table/table-model.ts+++ b/blocksuite/affine/model/src/blocks/table/table-model.ts@@ -56,11 +56,3 @@ export const TableBlockSchema = defineBlockSchema({},toModel: () => new TableBlockModel(),});--declare global {- namespace BlockSuite {- interface BlockModels {- [TableModelFlavour]: TableBlockModel;- }- }-}diff --git a/blocksuite/affine/model/src/utils/global.ts b/blocksuite/affine/model/src/utils/global.tsindex 0f332fb613..7c44631a75 100644--- a/blocksuite/affine/model/src/utils/global.ts+++ b/blocksuite/affine/model/src/utils/global.ts@@ -2,7 +2,6 @@ import type {GfxBlockElementModel,GfxGroupLikeElementModel,GfxLocalElementModel,- GfxModel,GfxPrimitiveElementModel,} from '@blocksuite/block-std/gfx';@@ -14,8 +13,6 @@ declare global {| EdgelessBlockModelMap[EdgelessBlockModelKeyType]| GfxBlockElementModel;- type EdgelessModel = GfxModel;-interface EdgelessTextModelMap {}type EdgelessTextModelKeyType = keyof EdgelessTextModelMap;type EdgelessTextModelType = EdgelessTextModelMap[EdgelessTextModelKeyType];diff --git a/blocksuite/affine/shared/src/adapters/middlewares/copy.ts b/blocksuite/affine/shared/src/adapters/middlewares/copy.tsindex 4bd4e35311..242ed27e57 100644--- a/blocksuite/affine/shared/src/adapters/middlewares/copy.ts+++ b/blocksuite/affine/shared/src/adapters/middlewares/copy.ts@@ -12,7 +12,7 @@ import type {TransformerSlots,} from '@blocksuite/store';-import { matchFlavours } from '../../utils';+import { matchModels } from '../../utils';const handlePoint = (point: TextRangePoint,@@ -20,7 +20,7 @@ const handlePoint = (model: DraftModel) => {const { index, length } = point;- if (matchFlavours(model, [RootBlockModel])) {+ if (matchModels(model, [RootBlockModel])) {if (length === 0) return;(snapshot.props.title as Record<string, unknown>).delta =model.title.sliceToDelta(index, length + index);diff --git a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts b/blocksuite/affine/shared/src/adapters/middlewares/paste.tsindex d10af873a2..038e1a4a9f 100644--- a/blocksuite/affine/shared/src/adapters/middlewares/paste.ts+++ b/blocksuite/affine/shared/src/adapters/middlewares/paste.ts@@ -35,7 +35,7 @@ import {TelemetryProvider,} from '../../services';import type { AffineTextAttributes } from '../../types';-import { matchFlavours, referenceToNode } from '../../utils';+import { matchModels, referenceToNode } from '../../utils';function findLastMatchingNode(root: BlockSnapshot[],@@ -293,7 +293,7 @@ class PasteTr {return;}if (!cursorModel.text) {- if (matchFlavours(cursorModel, [ImageBlockModel])) {+ if (matchModels(cursorModel, [ImageBlockModel])) {const selection = this.std.selection.create(ImageSelection, {blockId: target.blockId,});@@ -358,7 +358,7 @@ class PasteTr {if (this.firstSnapshot !== this.lastSnapshot &&this.lastSnapshot.props.text &&- !matchFlavours(this.pointState.model, [CodeBlockModel])+ !matchModels(this.pointState.model, [CodeBlockModel])) {const text = fromJSON(this.lastSnapshot.props.text) as Text;const doc = new Y.Doc();diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts b/blocksuite/affine/shared/src/commands/block-crud/get-next-block.tsindex e71bd38ad8..40803bcda4 100644--- a/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts+++ b/blocksuite/affine/shared/src/commands/block-crud/get-next-block.ts@@ -1,8 +1,12 @@-import type { BlockComponent, Command } from '@blocksuite/block-std';+import type {+ BlockComponent,+ BlockStdScope,+ Command,+} from '@blocksuite/block-std';import { getNextContentBlock } from '../../utils/index.js';-function getNextBlock(std: BlockSuite.Std, path: string) {+function getNextBlock(std: BlockStdScope, path: string) {const view = std.view;const model = std.store.getBlock(path)?.model;if (!model) return null;diff --git a/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts b/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.tsindex fcc14b5223..0220f5a7a2 100644--- a/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts+++ b/blocksuite/affine/shared/src/commands/block-crud/get-prev-block.ts@@ -1,8 +1,12 @@-import type { BlockComponent, Command } from '@blocksuite/block-std';+import type {+ BlockComponent,+ BlockStdScope,+ Command,+} from '@blocksuite/block-std';import { getPrevContentBlock } from '../../utils/index.js';-function getPrevBlock(std: BlockSuite.Std, path: string) {+function getPrevBlock(std: BlockStdScope, path: string) {const view = std.view;const model = std.store.getBlock(path)?.model;diff --git a/blocksuite/affine/shared/src/types/index.ts b/blocksuite/affine/shared/src/types/index.tsindex 3f69765626..531a19a2f6 100644--- a/blocksuite/affine/shared/src/types/index.ts+++ b/blocksuite/affine/shared/src/types/index.ts@@ -52,10 +52,7 @@ export type EmbedOptions = {export type IndentContext = {blockId: string;inlineIndex: number;- flavour: Extract<- keyof BlockSuite.BlockModels,- 'affine:paragraph' | 'affine:list'- >;+ flavour: string;type: 'indent' | 'dedent';};diff --git a/blocksuite/affine/shared/src/utils/collapsed/paragraph.ts b/blocksuite/affine/shared/src/utils/collapsed/paragraph.tsindex 42b4cdf929..69948af48e 100644--- a/blocksuite/affine/shared/src/utils/collapsed/paragraph.ts+++ b/blocksuite/affine/shared/src/utils/collapsed/paragraph.ts@@ -1,7 +1,7 @@import { ParagraphBlockModel } from '@blocksuite/affine-model';import type { BlockModel } from '@blocksuite/store';-import { matchFlavours } from '../model/checker.js';+import { matchModels } from '../model/checker.js';export function calculateCollapsedSiblings(model: ParagraphBlockModel@@ -15,7 +15,7 @@ export function calculateCollapsedSiblings(const collapsedEdgeIndex = children.findIndex((child, i) => {if (i > index &&- matchFlavours(child, [ParagraphBlockModel]) &&+ matchModels(child, [ParagraphBlockModel]) &&child.type.startsWith('h')) {const modelLevel = parseInt(model.type.slice(1));@@ -46,7 +46,7 @@ export function getNearestHeadingBefore(for (let i = index - 1; i >= 0; i--) {const sibling = parent.children[i];if (- matchFlavours(sibling, [ParagraphBlockModel]) &&+ matchModels(sibling, [ParagraphBlockModel]) &&sibling.type.startsWith('h')) {return sibling;diff --git a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.tsindex 23db1c9fb7..11142f915e 100644--- a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts+++ b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts@@ -8,7 +8,7 @@ import {getClosestBlockComponentByElement,getRectByBlockComponent,} from '../dom/index.js';-import { matchFlavours } from '../model/index.js';+import { matchModels } from '../model/index.js';import { getDropRectByPoint } from './get-drop-rect-by-point.js';import { DropFlags, type DropPlacement, type DropTarget } from './types.js';@@ -56,7 +56,7 @@ export function calcDropTarget(.every(m => children.includes(m.flavour));}- if (!shouldAppendToDatabase && !matchFlavours(model, [DatabaseBlockModel])) {+ if (!shouldAppendToDatabase && !matchModels(model, [DatabaseBlockModel])) {const databaseBlockComponent =element.closest<BlockComponent>('affine-database');if (databaseBlockComponent) {@@ -150,7 +150,7 @@ export function calcDropTarget(const hasChild = (element as BlockComponent).childBlocks.length;if (allowSublist &&- matchFlavours(model, [ListBlockModel]) &&+ matchModels(model, [ListBlockModel]) &&!hasChild &&point.x > domRect.x + BLOCK_CHILDREN_CONTAINER_PADDING_LEFT) {diff --git a/blocksuite/affine/shared/src/utils/dnd/get-drop-rect-by-point.ts b/blocksuite/affine/shared/src/utils/dnd/get-drop-rect-by-point.tsindex a3e68a4f2f..e8280a38cc 100644--- a/blocksuite/affine/shared/src/utils/dnd/get-drop-rect-by-point.ts+++ b/blocksuite/affine/shared/src/utils/dnd/get-drop-rect-by-point.ts@@ -4,7 +4,7 @@ import type { Point } from '@blocksuite/global/utils';import type { BlockModel } from '@blocksuite/store';import { getRectByBlockComponent } from '../dom/index.js';-import { matchFlavours } from '../model/index.js';+import { matchModels } from '../model/index.js';import { DropFlags } from './types.js';const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;@@ -25,7 +25,7 @@ export function getDropRectByPoint(flag: DropFlags.Normal,};- const isDatabase = matchFlavours(model, [DatabaseBlockModel]);+ const isDatabase = matchModels(model, [DatabaseBlockModel]);if (isDatabase) {const table = getDatabaseBlockTableElement(element);diff --git a/blocksuite/affine/shared/src/utils/dom/point-to-block.ts b/blocksuite/affine/shared/src/utils/dom/point-to-block.tsindex aa05de567a..87dd09efc7 100644--- a/blocksuite/affine/shared/src/utils/dom/point-to-block.ts+++ b/blocksuite/affine/shared/src/utils/dom/point-to-block.ts@@ -6,7 +6,7 @@ import type { BlockModel } from '@blocksuite/store';import { BLOCK_CHILDREN_CONTAINER_PADDING_LEFT } from '../../consts/index.js';import { clamp } from '../math.js';-import { matchFlavours } from '../model/checker.js';+import { matchModels } from '../model/checker.js';const ATTR_SELECTOR = `[${BLOCK_ID_ATTR}]`;@@ -36,7 +36,7 @@ function hasBlockId(element: Element): element is BlockComponent {* Returns `true` if element is default/edgeless page or note.*/function isRootOrNoteOrSurface(element: BlockComponent) {- return matchFlavours(element.model, [+ return matchModels(element.model, [RootBlockModel,NoteBlockModel,SurfaceBlockModel,diff --git a/blocksuite/affine/shared/src/utils/edgeless.ts b/blocksuite/affine/shared/src/utils/edgeless.tsindex 3daf5775a5..ff8c4b6fac 100644--- a/blocksuite/affine/shared/src/utils/edgeless.ts+++ b/blocksuite/affine/shared/src/utils/edgeless.ts@@ -1,12 +1,12 @@import { FrameBlockModel, GroupElementModel } from '@blocksuite/affine-model';-import type { GfxBlockElementModel } from '@blocksuite/block-std/gfx';+import type { GfxBlockElementModel, GfxModel } from '@blocksuite/block-std/gfx';import {deserializeXYWH,getQuadBoundWithRotation,} from '@blocksuite/global/utils';import type { BlockModel } from '@blocksuite/store';-export function getSelectedRect(selected: BlockSuite.EdgelessModel[]): DOMRect {+export function getSelectedRect(selected: GfxModel[]): DOMRect {if (selected.length === 0) {return new DOMRect();}@@ -57,8 +57,8 @@ export function getSelectedRect(selected: BlockSuite.EdgelessModel[]): DOMRect {);}-export function getElementsWithoutGroup(elements: BlockSuite.EdgelessModel[]) {- const set = new Set<BlockSuite.EdgelessModel>();+export function getElementsWithoutGroup(elements: GfxModel[]) {+ const set = new Set<GfxModel>();elements.forEach(element => {if (element instanceof GroupElementModel) {@@ -73,7 +73,7 @@ export function getElementsWithoutGroup(elements: BlockSuite.EdgelessModel[]) {}export function isTopLevelBlock(- selectable: BlockModel | BlockSuite.EdgelessModel | null+ selectable: BlockModel | GfxModel | null): selectable is GfxBlockElementModel {return !!selectable && 'flavour' in selectable;}diff --git a/blocksuite/affine/shared/src/utils/model/checker.ts b/blocksuite/affine/shared/src/utils/model/checker.tsindex 9a2ba890c4..d10f034fb9 100644--- a/blocksuite/affine/shared/src/utils/model/checker.ts+++ b/blocksuite/affine/shared/src/utils/model/checker.ts@@ -8,7 +8,7 @@ type ModelList<T> =: never: never;-export function matchFlavours<+export function matchModels<const Model extends ConstructorType<BlockModel>[],U extends ModelList<Model>[number] = ModelList<Model>[number],>(model: unknown, expected: Model): model is U {diff --git a/blocksuite/affine/shared/src/utils/model/get-content-block.ts b/blocksuite/affine/shared/src/utils/model/get-content-block.tsindex ce83a10f14..b1a413dab0 100644--- a/blocksuite/affine/shared/src/utils/model/get-content-block.ts+++ b/blocksuite/affine/shared/src/utils/model/get-content-block.ts@@ -3,7 +3,7 @@ import type { EditorHost } from '@blocksuite/block-std';import type { BlockModel } from '@blocksuite/store';import { DocModeProvider } from '../../services/doc-mode-service.js';-import { matchFlavours } from './checker.js';+import { matchModels } from './checker.js';/***@@ -74,7 +74,7 @@ export function getPrevContentBlock(const prev = getPrev(model);if (prev) {- if (prev.role === 'content' && !matchFlavours(prev, [FrameBlockModel])) {+ if (prev.role === 'content' && !matchModels(prev, [FrameBlockModel])) {return prev;}diff --git a/blocksuite/affine/shared/src/utils/model/getter.ts b/blocksuite/affine/shared/src/utils/model/getter.tsindex 2ba8a5c579..0900a3eec9 100644--- a/blocksuite/affine/shared/src/utils/model/getter.ts+++ b/blocksuite/affine/shared/src/utils/model/getter.ts@@ -2,7 +2,7 @@ import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';import type { BlockComponent, EditorHost } from '@blocksuite/block-std';import type { BlockModel, Store } from '@blocksuite/store';-import { matchFlavours } from './checker.js';+import { matchModels } from './checker.js';export function findAncestorModel(model: BlockModel,@@ -37,7 +37,7 @@ export async function asyncGetBlockComponent(export function findNoteBlockModel(model: BlockModel) {return findAncestorModel(model, m =>- matchFlavours(m, [NoteBlockModel])+ matchModels(m, [NoteBlockModel])) as NoteBlockModel | null;}@@ -48,7 +48,7 @@ export function getLastNoteBlock(doc: Store) {for (let i = children.length - 1; i >= 0; i--) {const child = children[i];if (- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode !== NoteDisplayMode.EdgelessOnly) {note = child as NoteBlockModel;diff --git a/blocksuite/affine/shared/src/utils/model/list.ts b/blocksuite/affine/shared/src/utils/model/list.tsindex f45b2c2652..71b23b89bd 100644--- a/blocksuite/affine/shared/src/utils/model/list.ts+++ b/blocksuite/affine/shared/src/utils/model/list.ts@@ -2,7 +2,7 @@ import { ListBlockModel } from '@blocksuite/affine-model';import type { BlockStdScope } from '@blocksuite/block-std';import type { BlockModel, Store } from '@blocksuite/store';-import { matchFlavours } from './checker.js';+import { matchModels } from './checker.js';/*** Pass in a list model, and this function will look forward to find continuous sibling numbered lists,@@ -23,7 +23,7 @@ export function getNextContinuousNumberedLists(const firstNotNumberedListIndex = parent.children.findIndex((model, i) =>i > modelIndex &&- (!matchFlavours(model, [ListBlockModel]) || model.type !== 'numbered')+ (!matchModels(model, [ListBlockModel]) || model.type !== 'numbered'));const newContinuousLists = parent.children.slice(modelIndex + 1,@@ -31,8 +31,7 @@ export function getNextContinuousNumberedLists();if (!newContinuousLists.every(- model =>- matchFlavours(model, [ListBlockModel]) && model.type === 'numbered'+ model => matchModels(model, [ListBlockModel]) && model.type === 'numbered'))return [];@@ -56,7 +55,7 @@ export function toNumberedList(// if there is a numbered list before, the order continues from the previous listif (prevSibling &&- matchFlavours(prevSibling, [ListBlockModel]) &&+ matchModels(prevSibling, [ListBlockModel]) &&prevSibling.type === 'numbered') {doc.transact(() => {diff --git a/blocksuite/affine/shared/src/utils/model/transform-model.ts b/blocksuite/affine/shared/src/utils/model/transform-model.tsindex 5f5d770e67..54aebb525b 100644--- a/blocksuite/affine/shared/src/utils/model/transform-model.ts+++ b/blocksuite/affine/shared/src/utils/model/transform-model.ts@@ -2,7 +2,7 @@ import type { BlockModel, Store, Text } from '@blocksuite/store';export function transformModel(model: BlockModel,- flavour: BlockSuite.Flavour,+ flavour: string,props?: Parameters<Store['addBlock']>[1]) {const doc = model.doc;diff --git a/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts b/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.tsindex abdeb200fb..4c69538b01 100644--- a/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts+++ b/blocksuite/affine/widget-drag-handle/src/middleware/reorder-list.ts@@ -1,6 +1,6 @@import { correctNumberedListsOrderToPrev } from '@blocksuite/affine-block-list';import { ListBlockModel } from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import type { BlockStdScope } from '@blocksuite/block-std';import type { TransformerMiddleware } from '@blocksuite/store';@@ -10,10 +10,7 @@ export const reorderList =slots.afterImport.on(payload => {if (payload.type === 'block') {const model = payload.model;- if (- matchFlavours(model, [ListBlockModel]) &&- model.type === 'numbered'- ) {+ if (matchModels(model, [ListBlockModel]) && model.type === 'numbered') {const next = std.store.getNext(model);correctNumberedListsOrderToPrev(std.store, model);if (next) {diff --git a/blocksuite/affine/widget-drag-handle/src/utils.ts b/blocksuite/affine/widget-drag-handle/src/utils.tsindex 4a60796682..8ad72ddeae 100644--- a/blocksuite/affine/widget-drag-handle/src/utils.ts+++ b/blocksuite/affine/widget-drag-handle/src/utils.ts@@ -15,7 +15,7 @@ import {findClosestBlockComponent,getBlockProps,getClosestBlockComponentByPoint,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { BlockComponent, EditorHost } from '@blocksuite/block-std';import { Point, Rect } from '@blocksuite/global/utils';@@ -220,7 +220,7 @@ export const getDropResult = (const model = closestBlock.model;- const isDatabase = matchFlavours(model, [DatabaseBlockModel]);+ const isDatabase = matchModels(model, [DatabaseBlockModel]);if (isDatabase) {return dropIndicator;}@@ -236,7 +236,7 @@ export const getDropResult = (export function getDragHandleLeftPadding(blocks: BlockComponent[]) {const hasToggleList = blocks.some(block =>- (matchFlavours(block.model, [ListBlockModel]) &&+ (matchModels(block.model, [ListBlockModel]) &&block.model.children.length > 0) ||(block instanceof ParagraphBlockComponent &&block.model.type.startsWith('h') &&diff --git a/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts b/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.tsindex ca4b502e36..4d9ce6e2dd 100644--- a/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts+++ b/blocksuite/affine/widget-drag-handle/src/watchers/drag-event-watcher.ts@@ -28,7 +28,7 @@ import {getBlockComponentsExcludeSubtrees,getRectByBlockComponent,getScrollContainer,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {type BlockComponent,@@ -161,17 +161,17 @@ export class DragEventWatcher {!snapshot ||snapshot.content.length === 0 ||!dragPayload?.from ||- matchFlavours(model, [DatabaseBlockModel])+ matchModels(model, [DatabaseBlockModel]))return null;- const isDropOnNoteBlock = matchFlavours(model, [NoteBlockModel]);+ const isDropOnNoteBlock = matchModels(model, [NoteBlockModel]);const edge = dropPayload.edge;const scale = this.widget.scale.peek();let result: DropResult;- if (edge === 'right' && matchFlavours(dropBlock.model, [ListBlockModel])) {+ if (edge === 'right' && matchModels(dropBlock.model, [ListBlockModel])) {const domRect = getRectByBlockComponent(dropBlock);const placement = 'in';const rect = Rect.fromLWTH(@@ -373,7 +373,7 @@ export class DragEventWatcher {result.placement === 'in' ? model : this.std.store.getParent(model);if (!parent) return;- if (matchFlavours(parent, [SurfaceBlockModel])) {+ if (matchModels(parent, [SurfaceBlockModel])) {return;}@@ -383,7 +383,7 @@ export class DragEventWatcher {: parent.children.indexOf(model) +(result.placement === 'before' ? 0 : 1);- if (matchFlavours(parent, [NoteBlockModel])) {+ if (matchModels(parent, [NoteBlockModel])) {const [first] = snapshot.content;if (first.flavour === 'affine:note') {if (parent.id !== first.id) {@@ -685,7 +685,7 @@ export class DragEventWatcher {}));- if (matchFlavours(view.model, [AttachmentBlockModel, BookmarkBlockModel])) {+ if (matchModels(view.model, [AttachmentBlockModel, BookmarkBlockModel])) {cleanups.push(this._makeDraggable(view));}diff --git a/blocksuite/affine/widget-edgeless-auto-connect/src/index.ts b/blocksuite/affine/widget-edgeless-auto-connect/src/index.tsindex c1095a299d..f4f80ad282 100644--- a/blocksuite/affine/widget-edgeless-auto-connect/src/index.ts+++ b/blocksuite/affine/widget-edgeless-auto-connect/src/index.ts@@ -17,10 +17,7 @@ import {SurfaceRefBlockModel,} from '@blocksuite/affine-model';import { FeatureFlagService } from '@blocksuite/affine-shared/services';-import {- matchFlavours,- stopPropagation,-} from '@blocksuite/affine-shared/utils';+import { matchModels, stopPropagation } from '@blocksuite/affine-shared/utils';import { WidgetComponent } from '@blocksuite/block-std';import {type GfxController,@@ -195,7 +192,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {const pageVisibleBlocks = new Map<AutoConnectElement, number>();const notes = service.doc.root?.children.filter(child =>- matchFlavours(child, [NoteBlockModel])+ matchModels(child, [NoteBlockModel]));const edgelessOnlyNotesSet = new Set<NoteBlockModel>();@@ -209,7 +206,7 @@ export class EdgelessAutoConnectWidget extends WidgetComponent<RootBlockModel> {}note.children.forEach(model => {- if (matchFlavours(model, [SurfaceRefBlockModel])) {+ if (matchModels(model, [SurfaceRefBlockModel])) {const reference = this._crud.getElementById(model.reference);if (!isAutoConnectElement(reference)) return;diff --git a/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts b/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.tsindex d23d61a7da..9017242d37 100644--- a/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts+++ b/blocksuite/affine/widget-remote-selection/src/doc/doc-remote-selection.ts@@ -8,7 +8,7 @@ import {} from '@blocksuite/affine-model';import { getSelectionRectsCommand } from '@blocksuite/affine-shared/commands';import { EMBED_BLOCK_MODEL_LIST } from '@blocksuite/affine-shared/consts';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {BlockSelection,TextSelection,@@ -76,7 +76,7 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {private get _config(): DocRemoteSelectionConfig {return {blockSelectionBackgroundTransparent: block => {- return matchFlavours(block, [+ return matchModels(block, [CodeBlockModel,DatabaseBlockModel,ImageBlockModel,diff --git a/blocksuite/affine/widget-remote-selection/src/edgeless/index.ts b/blocksuite/affine/widget-remote-selection/src/edgeless/index.tsindex b7b5620e64..1a544e7099 100644--- a/blocksuite/affine/widget-remote-selection/src/edgeless/index.ts+++ b/blocksuite/affine/widget-remote-selection/src/edgeless/index.ts@@ -7,7 +7,10 @@ import {requestThrottledConnectedFrame,} from '@blocksuite/affine-shared/utils';import { WidgetComponent } from '@blocksuite/block-std';-import { GfxControllerIdentifier } from '@blocksuite/block-std/gfx';+import {+ GfxControllerIdentifier,+ type GfxModel,+} from '@blocksuite/block-std/gfx';import { pickValues } from '@blocksuite/global/utils';import type { UserInfo } from '@blocksuite/store';import { css, html, nothing } from 'lit';@@ -118,7 +121,7 @@ export class EdgelessRemoteSelectionWidget extends WidgetComponent<RootBlockModeconst elements = selection.elements.map(id => this.crud.getElementById(id))- .filter(element => element) as BlockSuite.EdgelessModel[];+ .filter(element => element) as GfxModel[];const rect = getSelectedRect(elements);if (rect.width === 0 || rect.height === 0) return;diff --git a/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts b/blocksuite/blocks/src/__tests__/database/database.unit.spec.tsindex dbea86008c..c16d507b6b 100644--- a/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts+++ b/blocksuite/blocks/src/__tests__/database/database.unit.spec.ts@@ -76,7 +76,7 @@ describe('DatabaseManager', () => {noteBlockId = doc.addBlock('affine:note', {}, rootId);databaseBlockId = doc.addBlock(- 'affine:database' as BlockSuite.Flavour,+ 'affine:database',{columns: [],titleColumn: 'Title',diff --git a/blocksuite/blocks/src/_common/edgeless/mindmap/index.ts b/blocksuite/blocks/src/_common/edgeless/mindmap/index.tsindex 663c0c3e4a..4960cfd89d 100644--- a/blocksuite/blocks/src/_common/edgeless/mindmap/index.ts+++ b/blocksuite/blocks/src/_common/edgeless/mindmap/index.ts@@ -1,13 +1,13 @@import { MindmapElementModel } from '@blocksuite/affine-model';-import type { Viewport } from '@blocksuite/block-std/gfx';+import type { GfxModel, Viewport } from '@blocksuite/block-std/gfx';-export function isSingleMindMapNode(els: BlockSuite.EdgelessModel[]) {+export function isSingleMindMapNode(els: GfxModel[]) {return els.length === 1 && els[0].group instanceof MindmapElementModel;}export function isElementOutsideViewport(viewport: Viewport,- element: BlockSuite.EdgelessModel,+ element: GfxModel,padding: [number, number] = [0, 0]) {const elementBound = element.elementBound;@@ -25,7 +25,7 @@ export function isElementOutsideViewport(export function getNearestTranslation(viewport: Viewport,- element: BlockSuite.EdgelessModel,+ element: GfxModel,padding: [number, number] = [0, 0]) {const viewportBound = viewport.viewportBounds;diff --git a/blocksuite/blocks/src/_common/export-manager/export-manager.ts b/blocksuite/blocks/src/_common/export-manager/export-manager.tsindex 8652eb2989..8e5f2fba90 100644--- a/blocksuite/blocks/src/_common/export-manager/export-manager.ts+++ b/blocksuite/blocks/src/_common/export-manager/export-manager.ts@@ -15,7 +15,7 @@ import {} from '@blocksuite/affine-shared/consts';import {isInsidePageEditor,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {type BlockStdScope,@@ -458,7 +458,7 @@ export class ExportManager {edgeless?.service.gfx.getElementsByBound(bound, { type: 'block' }) ??[];for (const block of blocks) {- if (matchFlavours(block, [ImageBlockModel])) {+ if (matchModels(block, [ImageBlockModel])) {if (!block.sourceId) return;const blob = await block.doc.blobSync.get(block.sourceId);@@ -495,7 +495,7 @@ export class ExportManager {);}- if (matchFlavours(block, [FrameBlockModel])) {+ if (matchModels(block, [FrameBlockModel])) {// TODO(@L-Sun): use children of frame instead of boundconst blocksInsideFrame = getBlocksInFrameBound(this.doc, block, false);const frameBound = Bound.deserialize(block.xywh);diff --git a/blocksuite/blocks/src/_common/types.ts b/blocksuite/blocks/src/_common/types.tsindex e21ea42531..fc35e8f84c 100644--- a/blocksuite/blocks/src/_common/types.ts+++ b/blocksuite/blocks/src/_common/types.ts@@ -4,6 +4,7 @@ import type {DocMode,GroupElementModel,} from '@blocksuite/affine-model';+import type { GfxModel } from '@blocksuite/block-std/gfx';import type { Store } from '@blocksuite/store';export type AbstractEditor = {@@ -12,6 +13,6 @@ export type AbstractEditor = {} & HTMLElement;export type Connectable = Exclude<- BlockSuite.EdgelessModel,+ GfxModel,ConnectorElementModel | BrushElementModel | GroupElementModel>;diff --git a/blocksuite/blocks/src/index.ts b/blocksuite/blocks/src/index.tsindex 1c5ae2511c..8b92b20256 100644--- a/blocksuite/blocks/src/index.ts+++ b/blocksuite/blocks/src/index.ts@@ -1,6 +1,6 @@/* oxlint-disable @typescript-eslint/triple-slash-reference *//// <reference path="./effects.ts" />-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { deserializeXYWH, Point } from '@blocksuite/global/utils';import { splitElements } from './root-block/edgeless/utils/clipboard-utils.js';@@ -142,7 +142,7 @@ export {getLastNoteBlock,isInsideEdgelessEditor,isInsidePageEditor,- matchFlavours,+ matchModels,on,once,openFileOrFiles,@@ -155,7 +155,7 @@ export type { DragBlockPayload } from '@blocksuite/affine-widget-drag-handle';export const BlocksUtils = {splitElements,- matchFlavours,+ matchModels,deserializeXYWH,isCanvasElement,Point,diff --git a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.tsindex fcf7ef438d..9dd5e7054d 100644--- a/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts+++ b/blocksuite/blocks/src/root-block/edgeless/clipboard/clipboard.ts@@ -29,7 +29,7 @@ import {isInsidePageEditor,isTopLevelBlock,isUrlInClipboard,- matchFlavours,+ matchModels,referenceToNode,} from '@blocksuite/affine-shared/utils';import type {@@ -41,6 +41,7 @@ import type {import {compareLayer,type GfxCompatibleProps,+ type GfxModel,type SerializedElement,SortOrder,} from '@blocksuite/block-std/gfx';@@ -995,7 +996,7 @@ export class EdgelessClipboardController extends PageClipboard {for (const nodeElement of nodeElements) {await _drawTopLevelBlock(nodeElement);- if (matchFlavours(nodeElement, [FrameBlockModel])) {+ if (matchModels(nodeElement, [FrameBlockModel])) {const blocksInsideFrame: BlockSuite.EdgelessBlockModelType[] = [];this.edgeless.service.frame.getElementsInFrameBound(nodeElement, false)@@ -1153,21 +1154,21 @@ export class EdgelessClipboardController extends PageClipboard {}private _updatePastedElementsIndex(- elements: BlockSuite.EdgelessModel[],+ elements: GfxModel[],originalIndexes: Map<string, string>) {- function compare(a: BlockSuite.EdgelessModel, b: BlockSuite.EdgelessModel) {+ function compare(a: GfxModel, b: GfxModel) {if (a instanceof SurfaceGroupLikeModel && a.hasDescendant(b)) {return SortOrder.BEFORE;} else if (b instanceof SurfaceGroupLikeModel && b.hasDescendant(a)) {return SortOrder.AFTER;} else {- const aGroups = a.groups as BlockSuite.SurfaceGroupLikeModel[];- const bGroups = b.groups as BlockSuite.SurfaceGroupLikeModel[];+ const aGroups = a.groups as SurfaceGroupLikeModel[];+ const bGroups = b.groups as SurfaceGroupLikeModel[];let i = 1;- let aGroup: BlockSuite.EdgelessModel | undefined = nToLast(aGroups, i);- let bGroup: BlockSuite.EdgelessModel | undefined = nToLast(bGroups, i);+ let aGroup: GfxModel | undefined = nToLast(aGroups, i);+ let bGroup: GfxModel | undefined = nToLast(bGroups, i);while (aGroup === bGroup && aGroup) {++i;@@ -1246,7 +1247,7 @@ export class EdgelessClipboardController extends PageClipboard {const blockModels: BlockSuite.EdgelessBlockModelType[] = [];const canvasElements: BlockSuite.SurfaceModel[] = [];- const allElements: BlockSuite.EdgelessModel[] = [];+ const allElements: GfxModel[] = [];for (const data of elementsRawData) {const { data: blockSnapshot } = BlockSnapshotSchema.safeParse(data);@@ -1371,7 +1372,7 @@ export class EdgelessClipboardController extends PageClipboard {}export async function prepareClipboardData(- selectedAll: BlockSuite.EdgelessModel[],+ selectedAll: GfxModel[],std: BlockStdScope) {const job = new Transformer({diff --git a/blocksuite/blocks/src/root-block/edgeless/components/rects/edgeless-selected-rect.ts b/blocksuite/blocks/src/root-block/edgeless/components/rects/edgeless-selected-rect.tsindex f181f0825c..64f3244edf 100644--- a/blocksuite/blocks/src/root-block/edgeless/components/rects/edgeless-selected-rect.ts+++ b/blocksuite/blocks/src/root-block/edgeless/components/rects/edgeless-selected-rect.ts@@ -958,11 +958,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<* Related issue: https://linear.app/affine-design/issue/BS-1009/* @deprecated*/- #adjustAIChat(- element: BlockSuite.EdgelessModel,- bound: Bound,- direction: HandleDirection- ) {+ #adjustAIChat(element: GfxModel, bound: Bound, direction: HandleDirection) {const curBound = Bound.deserialize(element.xywh);let scale = 1;@@ -1165,7 +1161,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<}#adjustProportional(- element: BlockSuite.EdgelessModel,+ element: GfxModel,bound: Bound,direction: HandleDirection) {@@ -1263,7 +1259,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<}#adjustUseFallback(- element: BlockSuite.EdgelessModel,+ element: GfxModel,bound: Bound,_direction: HandleDirection) {@@ -1293,7 +1289,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<);}- private _isProportionalElement(element: BlockSuite.EdgelessModel) {+ private _isProportionalElement(element: GfxModel) {return (isAttachmentBlock(element) ||isImageBlock(element) ||@@ -1306,7 +1302,7 @@ export class EdgelessSelectedRectWidget extends WidgetComponent<);}- private _shouldRenderSelection(elements?: BlockSuite.EdgelessModel[]) {+ private _shouldRenderSelection(elements?: GfxModel[]) {elements = elements ?? this.selection.selectedElements;return elements.length > 0 && !this.selection.editing;}diff --git a/blocksuite/blocks/src/root-block/edgeless/edgeless-keyboard.ts b/blocksuite/blocks/src/root-block/edgeless/edgeless-keyboard.tsindex c977cb447c..ba4b1891e5 100644--- a/blocksuite/blocks/src/root-block/edgeless/edgeless-keyboard.ts+++ b/blocksuite/blocks/src/root-block/edgeless/edgeless-keyboard.ts@@ -19,7 +19,7 @@ import {TelemetryProvider,} from '@blocksuite/affine-shared/services';import { LassoMode } from '@blocksuite/affine-shared/types';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { SurfaceSelection, TextSelection } from '@blocksuite/block-std';import {GfxBlockElementModel,@@ -134,7 +134,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {if (selection.selectedElements.length === 1 &&selection.firstElement instanceof GfxBlockElementModel &&- matchFlavours(selection.firstElement as GfxBlockElementModel, [+ matchModels(selection.firstElement as GfxBlockElementModel, [NoteBlockModel,])) {@@ -260,7 +260,7 @@ export class EdgelessPageKeyboardManager extends PageKeyboardManager {block =>block.group === null &&!(- matchFlavours(block, [NoteBlockModel]) &&+ matchModels(block, [NoteBlockModel]) &&block.displayMode === NoteDisplayMode.DocOnly))diff --git a/blocksuite/blocks/src/root-block/edgeless/edgeless-root-block.ts b/blocksuite/blocks/src/root-block/edgeless/edgeless-root-block.tsindex 30b9ffbc00..50eb6017d8 100644--- a/blocksuite/blocks/src/root-block/edgeless/edgeless-root-block.ts+++ b/blocksuite/blocks/src/root-block/edgeless/edgeless-root-block.ts@@ -24,7 +24,7 @@ import {import type { Viewport } from '@blocksuite/affine-shared/types';import {isTouchPadPinchEvent,- matchFlavours,+ matchModels,requestConnectedFrame,requestThrottledConnectedFrame,} from '@blocksuite/affine-shared/utils';@@ -350,7 +350,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<const primaryMode = std.get(DocModeProvider).getPrimaryMode(this.doc.id);const note = this.model.children.find((child): child is NoteBlockModel =>- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode !== NoteDisplayMode.EdgelessOnly);diff --git a/blocksuite/blocks/src/root-block/edgeless/edgeless-root-service.ts b/blocksuite/blocks/src/root-block/edgeless/edgeless-root-service.tsindex 80e3dc2bdc..9ef50d5314 100644--- a/blocksuite/blocks/src/root-block/edgeless/edgeless-root-service.ts+++ b/blocksuite/blocks/src/root-block/edgeless/edgeless-root-service.ts@@ -169,7 +169,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {);}- createGroup(elements: BlockSuite.EdgelessModel[] | string[]) {+ createGroup(elements: GfxModel[] | string[]) {const groups = this.elements.filter(el => el.type === 'group') as GroupElementModel[];@@ -277,7 +277,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {return this.layer.generateIndex();}- getConnectors(element: BlockSuite.EdgelessModel | string) {+ getConnectors(element: GfxModel | string) {const id = typeof element === 'string' ? element : element.id;return this.surface.getConnectors(id) as ConnectorElementModel[];@@ -298,11 +298,11 @@ export class EdgelessRootService extends RootService implements SurfaceContext {x: number,y: number,options?: PointTestOptions- ): BlockSuite.EdgelessModel | null {+ ): GfxModel | null {return this.gfx.getElementInGroup(x, y, options);}- removeElement(id: string | BlockSuite.EdgelessModel) {+ removeElement(id: string | GfxModel) {id = typeof id === 'string' ? id : id.id;const el = this.crud.getElementById(id);@@ -323,10 +323,7 @@ export class EdgelessRootService extends RootService implements SurfaceContext {}}- reorderElement(- element: BlockSuite.EdgelessModel,- direction: ReorderingDirection- ) {+ reorderElement(element: GfxModel, direction: ReorderingDirection) {const index = this.layer.getReorderedIndex(element, direction);// block should be updated in transactiondiff --git a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts b/blocksuite/blocks/src/root-block/edgeless/frame-manager.tsindex 4e0858ee85..1fb42ba907 100644--- a/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts+++ b/blocksuite/blocks/src/root-block/edgeless/frame-manager.ts@@ -390,7 +390,7 @@ export class EdgelessFrameManager extends GfxExtension {.map(id => this.gfx.getElementById(id)).filter(element => element !== null);- return childElements as BlockSuite.EdgelessModel[];+ return childElements as GfxModel[];}/**diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/connector-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/connector-tool.tsindex f594e58e60..e5821ee29d 100644--- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/connector-tool.ts+++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/connector-tool.ts@@ -18,7 +18,7 @@ import {} from '@blocksuite/affine-model';import { TelemetryProvider } from '@blocksuite/affine-shared/services';import type { PointerEventState } from '@blocksuite/block-std';-import { BaseTool } from '@blocksuite/block-std/gfx';+import { BaseTool, type GfxModel } from '@blocksuite/block-std/gfx';import type { IBound, IVec } from '@blocksuite/global/utils';import { Bound } from '@blocksuite/global/utils';@@ -189,7 +189,7 @@ export class ConnectorTool extends BaseTool<ConnectorToolOptions> {this._overlay?.clear();}- quickConnect(point: IVec, element: BlockSuite.EdgelessModel) {+ quickConnect(point: IVec, element: GfxModel) {this._startPoint = this.gfx.viewport.toModelCoord(point[0], point[1]);this._mode = ConnectorToolMode.Quick;this._sourceBounds = Bound.deserialize(element.xywh);diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/copilot-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/copilot-tool.tsindex b0e691081b..5be4ecdcbf 100644--- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/copilot-tool.ts+++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/copilot-tool.ts@@ -1,6 +1,10 @@/* oxlint-disable @typescript-eslint/no-non-null-assertion */import type { PointerEventState } from '@blocksuite/block-std';-import { BaseTool, MouseButton } from '@blocksuite/block-std/gfx';+import {+ BaseTool,+ type GfxModel,+ MouseButton,+} from '@blocksuite/block-std/gfx';import { IS_MAC } from '@blocksuite/global/env';import {Bound,@@ -141,10 +145,7 @@ export class CopilotTool extends BaseTool {this.gfx.tool.setTool('default');}- updateDragPointsWith(- selectedElements: BlockSuite.EdgelessModel[],- padding = 0- ) {+ updateDragPointsWith(selectedElements: GfxModel[], padding = 0) {const bounds = getCommonBoundWithRotation(selectedElements).expand(padding / this.gfx.viewport.zoom);@@ -153,10 +154,7 @@ export class CopilotTool extends BaseTool {this.dragLastPoint = bounds.br as [number, number];}- updateSelectionWith(- selectedElements: BlockSuite.EdgelessModel[],- padding = 0- ) {+ updateSelectionWith(selectedElements: GfxModel[], padding = 0) {const { selection } = this.gfx;selection.clear();diff --git a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/eraser-tool.ts b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/eraser-tool.tsindex 07ca2951f4..f0432aa4c3 100644--- a/blocksuite/blocks/src/root-block/edgeless/gfx-tool/eraser-tool.ts+++ b/blocksuite/blocks/src/root-block/edgeless/gfx-tool/eraser-tool.ts@@ -5,7 +5,7 @@ import {} from '@blocksuite/affine-block-surface';import { isTopLevelBlock } from '@blocksuite/affine-shared/utils';import type { PointerEventState } from '@blocksuite/block-std';-import { BaseTool } from '@blocksuite/block-std/gfx';+import { BaseTool, type GfxModel } from '@blocksuite/block-std/gfx';import {Bound,getStroke,@@ -28,11 +28,11 @@ class EraserOverlay extends Overlay {export class EraserTool extends BaseTool {static override toolName = 'eraser';- private _erasable = new Set<BlockSuite.EdgelessModel>();+ private _erasable = new Set<GfxModel>();private _eraserPoints: IVec[] = [];- private readonly _eraseTargets = new Set<BlockSuite.EdgelessModel>();+ private readonly _eraseTargets = new Set<GfxModel>();private readonly _loop = () => {const now = Date.now();diff --git a/blocksuite/blocks/src/root-block/edgeless/services/template.ts b/blocksuite/blocks/src/root-block/edgeless/services/template.tsindex 58ac7693ec..0e2858acc3 100644--- a/blocksuite/blocks/src/root-block/edgeless/services/template.ts+++ b/blocksuite/blocks/src/root-block/edgeless/services/template.ts@@ -211,7 +211,7 @@ export class TemplateJob {assertExists(modelData);doc.addBlock(- modelData.flavour as BlockSuite.Flavour,+ modelData.flavour,{...modelData.props,id: modelData.id,diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/clipboard-utils.ts b/blocksuite/blocks/src/root-block/edgeless/utils/clipboard-utils.tsindex 67131dfa6b..e55eff4012 100644--- a/blocksuite/blocks/src/root-block/edgeless/utils/clipboard-utils.ts+++ b/blocksuite/blocks/src/root-block/edgeless/utils/clipboard-utils.ts@@ -10,6 +10,7 @@ import type {import { getElementsWithoutGroup } from '@blocksuite/affine-shared/utils';import {generateKeyBetweenV2,+ type GfxModel,type SerializedElement,} from '@blocksuite/block-std/gfx';import { getCommonBoundWithRotation, groupBy } from '@blocksuite/global/utils';@@ -28,7 +29,7 @@ import {const offset = 10;export async function duplicate(edgeless: EdgelessRootBlockComponent,- elements: BlockSuite.EdgelessModel[],+ elements: GfxModel[],select = true) {const { clipboardController } = edgeless;@@ -54,7 +55,7 @@ export async function duplicate(});}}-export const splitElements = (elements: BlockSuite.EdgelessModel[]) => {+export const splitElements = (elements: GfxModel[]) => {const { notes, frames, shapes, images, edgelessTexts, embedSyncedDocs } =groupBy(getElementsWithoutGroup(elements), element => {if (isNoteBlock(element)) {diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/crud.ts b/blocksuite/blocks/src/root-block/edgeless/utils/crud.tsindex 6b179bccf4..fa50419323 100644--- a/blocksuite/blocks/src/root-block/edgeless/utils/crud.ts+++ b/blocksuite/blocks/src/root-block/edgeless/utils/crud.ts@@ -1,4 +1,5 @@import { isNoteBlock } from '@blocksuite/affine-block-surface';+import type { GfxModel } from '@blocksuite/block-std/gfx';import type { Connectable } from '../../../_common/utils/index.js';import type { EdgelessRootBlockComponent } from '../index.js';@@ -10,7 +11,7 @@ import { isConnectable } from './query.js';*/export function deleteElements(edgeless: EdgelessRootBlockComponent,- elements: BlockSuite.EdgelessModel[]+ elements: GfxModel[]) {const set = new Set(elements);const { service } = edgeless;diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/query.ts b/blocksuite/blocks/src/root-block/edgeless/utils/query.tsindex d4c6f18087..34f30b8fd5 100644--- a/blocksuite/blocks/src/root-block/edgeless/utils/query.ts+++ b/blocksuite/blocks/src/root-block/edgeless/utils/query.ts@@ -39,14 +39,12 @@ import type { BlockModel } from '@blocksuite/store';import type { Connectable } from '../../../_common/utils/index.js';-export function isMindmapNode(- element: GfxBlockElementModel | BlockSuite.EdgelessModel | null-) {+export function isMindmapNode(element: GfxBlockElementModel | GfxModel | null) {return element?.group instanceof MindmapElementModel;}export function isEdgelessTextBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EdgelessTextBlockModel {return (!!element &&@@ -60,7 +58,7 @@ export function isFrameBlock(element: unknown): element is FrameBlockModel {}export function isImageBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is ImageBlockModel {return (!!element && 'flavour' in element && element.flavour === 'affine:image'@@ -68,7 +66,7 @@ export function isImageBlock(}export function isAttachmentBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is AttachmentBlockModel {return (!!element && 'flavour' in element && element.flavour === 'affine:attachment'@@ -76,7 +74,7 @@ export function isAttachmentBlock(}export function isBookmarkBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is BookmarkBlockModel {return (!!element && 'flavour' in element && element.flavour === 'affine:bookmark'@@ -84,7 +82,7 @@ export function isBookmarkBlock(}export function isEmbeddedBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedBlockModel {return (!!element && 'flavour' in element && /affine:embed-*/.test(element.flavour)@@ -98,9 +96,7 @@ export function isEmbeddedBlock(* Related issue: https://linear.app/affine-design/issue/BS-1009/* @deprecated*/-export function isAIChatBlock(- element: BlockModel | BlockSuite.EdgelessModel | null-) {+export function isAIChatBlock(element: BlockModel | GfxModel | null) {return (!!element &&'flavour' in element &&@@ -108,9 +104,7 @@ export function isAIChatBlock();}-export function isEmbeddedLinkBlock(- element: BlockModel | BlockSuite.EdgelessModel | null-) {+export function isEmbeddedLinkBlock(element: BlockModel | GfxModel | null) {return (isEmbeddedBlock(element) &&!isEmbedSyncedDocBlock(element) &&@@ -119,7 +113,7 @@ export function isEmbeddedLinkBlock(}export function isEmbedGithubBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedGithubModel {return (!!element &&@@ -129,7 +123,7 @@ export function isEmbedGithubBlock(}export function isEmbedYoutubeBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedYoutubeModel {return (!!element &&@@ -139,7 +133,7 @@ export function isEmbedYoutubeBlock(}export function isEmbedLoomBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedLoomModel {return (!!element && 'flavour' in element && element.flavour === 'affine:embed-loom'@@ -147,7 +141,7 @@ export function isEmbedLoomBlock(}export function isEmbedFigmaBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedFigmaModel {return (!!element &&@@ -157,7 +151,7 @@ export function isEmbedFigmaBlock(}export function isEmbedLinkedDocBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedLinkedDocModel {return (!!element &&@@ -167,7 +161,7 @@ export function isEmbedLinkedDocBlock(}export function isEmbedSyncedDocBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedSyncedDocModel {return (!!element &&@@ -177,7 +171,7 @@ export function isEmbedSyncedDocBlock(}export function isEmbedHtmlBlock(- element: BlockModel | BlockSuite.EdgelessModel | null+ element: BlockModel | GfxModel | null): element is EmbedHtmlModel {return (!!element && 'flavour' in element && element.flavour === 'affine:embed-html'@@ -191,7 +185,7 @@ export function isCanvasElement(}export function isCanvasElementWithText(- element: BlockSuite.EdgelessModel+ element: GfxModel): element is CanvasElementWithText {return (element instanceof TextElementModel || element instanceof ShapeElementModel@@ -199,7 +193,7 @@ export function isCanvasElementWithText(}export function isConnectable(- element: BlockSuite.EdgelessModel | null+ element: GfxModel | null): element is Connectable {return !!element && element.connectable;}@@ -253,7 +247,7 @@ export type SelectableProps = {};export function getSelectableBounds(- selected: BlockSuite.EdgelessModel[]+ selected: GfxModel[]): Map<string, SelectableProps> {const bounds = new Map();getElementsWithoutGroup(selected).forEach(ele => {diff --git a/blocksuite/blocks/src/root-block/edgeless/utils/snap-manager.ts b/blocksuite/blocks/src/root-block/edgeless/utils/snap-manager.tsindex 8254243531..dc1f6d91c8 100644--- a/blocksuite/blocks/src/root-block/edgeless/utils/snap-manager.ts+++ b/blocksuite/blocks/src/root-block/edgeless/utils/snap-manager.ts@@ -4,7 +4,7 @@ import type {} from '@blocksuite/affine-block-surface';import { getSurfaceBlock, Overlay } from '@blocksuite/affine-block-surface';import type { ConnectorElementModel } from '@blocksuite/affine-model';-import type { GfxController } from '@blocksuite/block-std/gfx';+import type { GfxController, GfxModel } from '@blocksuite/block-std/gfx';import { BlockSuiteError, ErrorCode } from '@blocksuite/global/exceptions';import { Bound, Point } from '@blocksuite/global/utils';@@ -413,10 +413,7 @@ export class EdgelessSnapManager extends Overlay {});}- setupAlignables(- alignables: BlockSuite.EdgelessModel[],- exclude: BlockSuite.EdgelessModel[] = []- ): Bound {+ setupAlignables(alignables: GfxModel[], exclude: GfxModel[] = []): Bound {if (alignables.length === 0) return new Bound();const connectors = alignables.filter(isConnectable).reduce((prev, el) => {@@ -437,20 +434,17 @@ export class EdgelessSnapManager extends Overlay {const canvasElements = this.gfx.layer.canvasElements;const excludes = new Set([...alignables, ...exclude, ...connectors]);this._alignableBounds = [];- (- [- ...this.gfx.layer.blocks,- ...canvasElements,- ] as BlockSuite.EdgelessModel[]- ).forEach(alignable => {- const bounds = alignable.elementBound;- if (- viewportBounds.isOverlapWithBound(bounds) &&- !excludes.has(alignable)- ) {- this._alignableBounds.push(bounds);+ ([...this.gfx.layer.blocks, ...canvasElements] as GfxModel[]).forEach(+ alignable => {+ const bounds = alignable.elementBound;+ if (+ viewportBounds.isOverlapWithBound(bounds) &&+ !excludes.has(alignable)+ ) {+ this._alignableBounds.push(bounds);+ }}- });+ );return alignables.reduce((prev, element) => {const bounds = element.elementBound;diff --git a/blocksuite/blocks/src/root-block/keyboard/keyboard-manager.ts b/blocksuite/blocks/src/root-block/keyboard/keyboard-manager.tsindex cf8f57c2b9..417699e33b 100644--- a/blocksuite/blocks/src/root-block/keyboard/keyboard-manager.ts+++ b/blocksuite/blocks/src/root-block/keyboard/keyboard-manager.ts@@ -10,7 +10,7 @@ import {draftSelectedModelsCommand,getSelectedModelsCommand,} from '@blocksuite/affine-shared/commands';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {type BlockComponent,BlockSelection,@@ -38,7 +38,7 @@ export class PageKeyboardManager {const model = block.model;if (- matchFlavours(model, [ParagraphBlockModel]) &&+ matchModels(model, [ParagraphBlockModel]) &&model.type.startsWith('h') &&model.collapsed) {@@ -134,7 +134,7 @@ export class PageKeyboardManager {const selectedModels = ctx.selectedModels?.filter(block =>!block.flavour.startsWith('affine:embed-') &&- matchFlavours(doc.getParent(block), [NoteBlockModel])+ matchModels(doc.getParent(block), [NoteBlockModel]));const draftedModels = ctx.draftedModels;diff --git a/blocksuite/blocks/src/root-block/page/page-root-block.ts b/blocksuite/blocks/src/root-block/page/page-root-block.tsindex 1c747949ea..5a29f664c2 100644--- a/blocksuite/blocks/src/root-block/page/page-root-block.ts+++ b/blocksuite/blocks/src/root-block/page/page-root-block.ts@@ -14,7 +14,7 @@ import {getClosestBlockComponentByPoint,getDocTitleInlineEditor,getScrollContainer,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import type { PointerEventState } from '@blocksuite/block-std';import {@@ -128,11 +128,7 @@ export class PageRootBlockComponent extends BlockComponent<focusFirstParagraph = (): { id: string; created: boolean } => {const defaultNote = this._getDefaultNoteBlock();const firstText = defaultNote?.children.find(block =>- matchFlavours(block, [- ParagraphBlockModel,- ListBlockModel,- CodeBlockModel,- ])+ matchModels(block, [ParagraphBlockModel, ListBlockModel, CodeBlockModel]));if (firstText) {focusTextModel(this.std, firstText.id);@@ -248,7 +244,7 @@ export class PageRootBlockComponent extends BlockComponent<'Mod-a': () => {const blocks = this.model.children.filter(model => {- if (matchFlavours(model, [NoteBlockModel])) {+ if (matchModels(model, [NoteBlockModel])) {if (model.displayMode === NoteDisplayMode.EdgelessOnly)return false;@@ -394,7 +390,7 @@ export class PageRootBlockComponent extends BlockComponent<.slice().reverse().find(child => {- const isNote = matchFlavours(child, [NoteBlockModel]);+ const isNote = matchModels(child, [NoteBlockModel]);if (!isNote) return false;const displayOnDoc =!!child.displayMode &&@@ -410,9 +406,7 @@ export class PageRootBlockComponent extends BlockComponent<const last = lastNote.children.at(-1);if (!last ||- !(- matchFlavours(last, [ParagraphBlockModel]) && last.text.length === 0- )+ !(matchModels(last, [ParagraphBlockModel]) && last.text.length === 0)) {if (readonly) return;const paragraphId = this.doc.addBlock(@@ -452,7 +446,7 @@ export class PageRootBlockComponent extends BlockComponent<override firstUpdated() {this._initViewportResizeEffect();const noteModels = this.model.children.filter(model =>- matchFlavours(model, [NoteBlockModel])+ matchModels(model, [NoteBlockModel]));noteModels.forEach(note => {this.disposables.add(@@ -473,7 +467,7 @@ export class PageRootBlockComponent extends BlockComponent<)}`;const children = this.renderChildren(this.model, child => {- const isNote = matchFlavours(child, [NoteBlockModel]);+ const isNote = matchModels(child, [NoteBlockModel]);const note = child as NoteBlockModel;const displayOnEdgeless =!!note.displayMode && note.displayMode === NoteDisplayMode.EdgelessOnly;diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-frame-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-frame-button.tsindex e0f583c2d7..6d53da7183 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-frame-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-frame-button.ts@@ -1,6 +1,7 @@import { FrameIcon } from '@blocksuite/affine-components/icons';import { MindmapElementModel } from '@blocksuite/affine-model';import { TelemetryProvider } from '@blocksuite/affine-shared/services';+import type { GfxModel } from '@blocksuite/block-std/gfx';import { Bound, WithDisposable } from '@blocksuite/global/utils';import { css, html, LitElement, nothing } from 'lit';import { property } from 'lit/decorators.js';@@ -48,7 +49,7 @@ export class EdgelessAddFrameButton extends WithDisposable(LitElement) {export function renderAddFrameButton(edgeless: EdgelessRootBlockComponent,- elements: BlockSuite.EdgelessModel[]+ elements: GfxModel[]) {if (elements.length < 2) return nothing;if (elements.some(e => e.group instanceof MindmapElementModel))diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-group-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-group-button.tsindex 61fb223481..6fc9c8970c 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-group-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/add-group-button.ts@@ -3,6 +3,7 @@ import {GroupElementModel,MindmapElementModel,} from '@blocksuite/affine-model';+import type { GfxModel } from '@blocksuite/block-std/gfx';import { WithDisposable } from '@blocksuite/global/utils';import { css, html, LitElement, nothing } from 'lit';import { property } from 'lit/decorators.js';@@ -39,7 +40,7 @@ export class EdgelessAddGroupButton extends WithDisposable(LitElement) {export function renderAddGroupButton(edgeless: EdgelessRootBlockComponent,- elements: BlockSuite.EdgelessModel[]+ elements: GfxModel[]) {if (elements.length < 2) return nothing;if (elements[0] instanceof GroupElementModel) return nothing;diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/align-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/align-button.tsindex 068b25944a..02a7d7385c 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/align-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/align-button.ts@@ -16,6 +16,7 @@ import {SmallArrowDownIcon,} from '@blocksuite/affine-components/icons';import { MindmapElementModel } from '@blocksuite/affine-model';+import type { GfxModel } from '@blocksuite/block-std/gfx';import { Bound, WithDisposable } from '@blocksuite/global/utils';import { AutoTidyUpIcon, ResizeTidyUpIcon } from '@blocksuite/icons/lit';import { css, html, LitElement, nothing, type TemplateResult } from 'lit';@@ -271,7 +272,7 @@ export class EdgelessAlignButton extends WithDisposable(LitElement) {});}- private _updateXYWH(ele: BlockSuite.EdgelessModel, bound: Bound) {+ private _updateXYWH(ele: GfxModel, bound: Bound) {const { updateElement } = this.edgeless.std.get(EdgelessCRUDIdentifier);const { updateBlock } = this.edgeless.doc;updateXYWH(ele, bound, updateElement, updateBlock);@@ -333,7 +334,7 @@ export class EdgelessAlignButton extends WithDisposable(LitElement) {export function renderAlignButton(edgeless: EdgelessRootBlockComponent,- elements: BlockSuite.EdgelessModel[]+ elements: GfxModel[]) {if (elements.length < 2) return nothing;if (elements.some(e => e.group instanceof MindmapElementModel))diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-frame-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-frame-button.tsindex 08d724263b..df0b775795 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-frame-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-frame-button.ts@@ -25,7 +25,7 @@ import {} from '@blocksuite/affine-model';import { FeatureFlagService } from '@blocksuite/affine-shared/services';import type { ColorEvent } from '@blocksuite/affine-shared/utils';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import { GfxExtensionIdentifier } from '@blocksuite/block-std/gfx';import {countBy,@@ -93,7 +93,7 @@ export class EdgelessChangeFrameButton extends WithDisposable(LitElement) {const rootModel = this.edgeless.doc.root;const notes = rootModel.children.filter(model =>- matchFlavours(model, [NoteBlockModel]) &&+ matchModels(model, [NoteBlockModel]) &&model.displayMode !== NoteDisplayMode.EdgelessOnly);const lastNote = notes[notes.length - 1];diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-group-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-group-button.tsindex cdf7210734..06b7fe3fcc 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-group-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-group-button.ts@@ -11,7 +11,7 @@ import {NoteBlockModel,NoteDisplayMode,} from '@blocksuite/affine-model';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {deserializeXYWH,serializeXYWH,@@ -31,7 +31,7 @@ export class EdgelessChangeGroupButton extends WithDisposable(LitElement) {const rootModel = this.edgeless.doc.root;const notes = rootModel.children.filter(model =>- matchFlavours(model, [NoteBlockModel]) &&+ matchModels(model, [NoteBlockModel]) &&model.displayMode !== NoteDisplayMode.EdgelessOnly);const lastNote = notes[notes.length - 1];diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-note-button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-note-button.tsindex e42f11bd05..2742e3afc6 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-note-button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/change-note-button.ts@@ -35,7 +35,7 @@ import {SidebarExtensionIdentifier,ThemeProvider,} from '@blocksuite/affine-shared/services';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {Bound,countBy,@@ -158,7 +158,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {this._pageBlockEnabled &&this.notes.length === 1 &&this.notes[0].parent?.children.find(child =>- matchFlavours(child, [NoteBlockModel])+ matchModels(child, [NoteBlockModel])) === this.notes[0]);}@@ -340,7 +340,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {const isFirstNote =onlyOne &¬e.parent?.children.find(child =>- matchFlavours(child, [NoteBlockModel])+ matchModels(child, [NoteBlockModel])) === note;const theme = this.edgeless.std.get(ThemeProvider).theme;const buttons = [diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/index.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/index.tsindex 97182d4d2f..e233feafbd 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/index.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/index.ts@@ -29,6 +29,7 @@ import {import { ThemeProvider } from '@blocksuite/affine-shared/services';import { requestConnectedFrame } from '@blocksuite/affine-shared/utils';import { WidgetComponent } from '@blocksuite/block-std';+import type { GfxModel } from '@blocksuite/block-std/gfx';import {atLeastNMatches,clamp,@@ -85,7 +86,7 @@ type CategorizedElements = {type CustomEntry = {render: (edgeless: EdgelessRootBlockComponent) => TemplateResult | null;- when: (model: BlockSuite.EdgelessModel[]) => boolean;+ when: (model: GfxModel[]) => boolean;};export const EDGELESS_ELEMENT_TOOLBAR_WIDGET =@@ -461,7 +462,7 @@ export class EdgelessElementToolbarWidget extends WidgetComponent<@state()private accessor _registeredEntries: {render: (edgeless: EdgelessRootBlockComponent) => TemplateResult | null;- when: (model: BlockSuite.EdgelessModel[]) => boolean;+ when: (model: GfxModel[]) => boolean;}[] = [];@property({ attribute: false })diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/button.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/button.tsindex 91bee6c3d3..2243330bf8 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/button.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/button.ts@@ -1,5 +1,6 @@import type { MenuItemGroup } from '@blocksuite/affine-components/toolbar';import { renderGroups } from '@blocksuite/affine-components/toolbar';+import type { GfxModel } from '@blocksuite/block-std/gfx';import { WithDisposable } from '@blocksuite/global/utils';import { MoreHorizontalIcon, MoreVerticalIcon } from '@blocksuite/icons/lit';import { html, LitElement } from 'lit';@@ -39,7 +40,7 @@ export class EdgelessMoreButton extends WithDisposable(LitElement) {accessor edgeless!: EdgelessRootBlockComponent;@property({ attribute: false })- accessor elements: BlockSuite.EdgelessModel[] = [];+ accessor elements: GfxModel[] = [];@property({ attribute: false })accessor groups!: MenuItemGroup<ElementToolbarMoreMenuContext>[];diff --git a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.tsindex a1c51af913..f0a85c626a 100644--- a/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts+++ b/blocksuite/blocks/src/root-block/widgets/element-toolbar/more-menu/render-linked-doc.ts@@ -4,7 +4,7 @@ import { NoteDisplayMode } from '@blocksuite/affine-model';import { DocModeProvider } from '@blocksuite/affine-shared/services';import { getBlockProps } from '@blocksuite/affine-shared/utils';import type { EditorHost } from '@blocksuite/block-std';-import { GfxBlockElementModel } from '@blocksuite/block-std/gfx';+import { GfxBlockElementModel, type GfxModel } from '@blocksuite/block-std/gfx';import { type BlockModel, type Store, Text } from '@blocksuite/store';import {@@ -17,11 +17,7 @@ import { isFrameBlock } from '../../../edgeless/utils/query.js';function addBlocksToDoc(targetDoc: Store, model: BlockModel, parentId: string) {// Add current block to linked docconst blockProps = getBlockProps(model);- const newModelId = targetDoc.addBlock(- model.flavour as BlockSuite.Flavour,- blockProps,- parentId- );+ const newModelId = targetDoc.addBlock(model.flavour, blockProps, parentId);// Add children to linked doc, parent is the new modelconst children = model.children;if (children.length > 0) {@@ -64,7 +60,7 @@ export function createLinkedDocFromNote(export function createLinkedDocFromEdgelessElements(host: EditorHost,- elements: BlockSuite.EdgelessModel[],+ elements: GfxModel[],docTitle?: string) {const linkedDoc = host.doc.workspace.createDoc({});@@ -93,11 +89,7 @@ export function createLinkedDocFromEdgelessElements(mapFrameIds(blockProps as unknown as FrameBlockModel, ids);}- newId = linkedDoc.addBlock(- model.flavour as BlockSuite.Flavour,- blockProps,- surfaceId- );+ newId = linkedDoc.addBlock(model.flavour, blockProps, surfaceId);}} else {const props = getElementProps(model, ids);diff --git a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/config.ts b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/config.tsindex d0098fa237..942399e541 100644--- a/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/config.ts+++ b/blocksuite/blocks/src/root-block/widgets/embed-card-toolbar/config.ts@@ -52,12 +52,7 @@ export const BUILT_IN_GROUPS: MenuItemGroup<EmbedCardToolbarContext>[] = [const parent = doc.getParent(model);const index = parent?.children.indexOf(model);- doc.addBlock(- model.flavour as BlockSuite.Flavour,- duplicateProps,- parent,- index- );+ doc.addBlock(model.flavour, duplicateProps, parent, index);close();},},diff --git a/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts b/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.tsindex 637e60d764..d217e35f3c 100644--- a/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts+++ b/blocksuite/blocks/src/root-block/widgets/format-bar/format-bar.ts@@ -21,7 +21,7 @@ import {getTextSelectionCommand,} from '@blocksuite/affine-shared/commands';import type { AffineTextAttributes } from '@blocksuite/affine-shared/types';-import { matchFlavours } from '@blocksuite/affine-shared/utils';+import { matchModels } from '@blocksuite/affine-shared/utils';import {type BlockComponent,BlockSelection,@@ -360,7 +360,7 @@ export class AffineFormatBarWidget extends WidgetComponent {if (this.displayType === 'block' && this._selectedBlocks.length === 1) {const selectedBlock = this._selectedBlocks[0];if (- !matchFlavours(selectedBlock.model, [+ !matchModels(selectedBlock.model, [ParagraphBlockModel,ListBlockModel,CodeBlockModel,@@ -421,7 +421,7 @@ export class AffineFormatBarWidget extends WidgetComponent {}addBlockTypeSwitch(config: {- flavour: BlockSuite.Flavour;+ flavour: string;icon: ParagraphActionConfigItem['icon'];type?: string;name?: string;diff --git a/blocksuite/blocks/src/root-block/widgets/image-toolbar/utils.ts b/blocksuite/blocks/src/root-block/widgets/image-toolbar/utils.tsindex 4893f47571..0ce65d5778 100644--- a/blocksuite/blocks/src/root-block/widgets/image-toolbar/utils.ts+++ b/blocksuite/blocks/src/root-block/widgets/image-toolbar/utils.ts@@ -27,7 +27,7 @@ export function duplicate(const index = parent?.children.indexOf(model);const duplicateId = doc.addBlock(- model.flavour as BlockSuite.Flavour,+ model.flavour,duplicateProps,parent,index + 1diff --git a/blocksuite/blocks/src/root-block/widgets/linked-doc/index.ts b/blocksuite/blocks/src/root-block/widgets/linked-doc/index.tsindex 7d77b04436..92fcf3febb 100644--- a/blocksuite/blocks/src/root-block/widgets/linked-doc/index.ts+++ b/blocksuite/blocks/src/root-block/widgets/linked-doc/index.ts@@ -120,12 +120,7 @@ export class AffineLinkedDocWidget extends WidgetComponent<const block = containerElement.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);- if (- !block ||- this.config.ignoreBlockTypes.includes(- block.flavour as keyof BlockSuite.BlockModels- )- )+ if (!block || this.config.ignoreBlockTypes.includes(block.flavour))return;const inlineRoot = containerElement.closest<InlineRootElement>(diff --git a/blocksuite/blocks/src/root-block/widgets/page-dragging-area/page-dragging-area.ts b/blocksuite/blocks/src/root-block/widgets/page-dragging-area/page-dragging-area.tsindex 1577c5e9fc..5a68c08e58 100644--- a/blocksuite/blocks/src/root-block/widgets/page-dragging-area/page-dragging-area.ts+++ b/blocksuite/blocks/src/root-block/widgets/page-dragging-area/page-dragging-area.ts@@ -2,7 +2,7 @@ import { NoteBlockModel, RootBlockModel } from '@blocksuite/affine-model';import {autoScroll,getScrollContainer,- matchFlavours,+ matchModels,} from '@blocksuite/affine-shared/utils';import {BLOCK_ID_ATTR,@@ -445,7 +445,7 @@ function isDragArea(e: PointerEventState) {const el = e.raw.target;assertInstanceOf(el, Element);const block = el.closest<BlockComponent>(`[${BLOCK_ID_ATTR}]`);- return block && matchFlavours(block.model, [RootBlockModel, NoteBlockModel]);+ return block && matchModels(block.model, [RootBlockModel, NoteBlockModel]);}declare global {diff --git a/blocksuite/blocks/src/root-block/widgets/surface-ref-toolbar/utils.ts b/blocksuite/blocks/src/root-block/widgets/surface-ref-toolbar/utils.tsindex b081a1feee..826170144d 100644--- a/blocksuite/blocks/src/root-block/widgets/surface-ref-toolbar/utils.ts+++ b/blocksuite/blocks/src/root-block/widgets/surface-ref-toolbar/utils.ts@@ -2,6 +2,7 @@ import type { CanvasRenderer } from '@blocksuite/affine-block-surface';import type { SurfaceRefBlockComponent } from '@blocksuite/affine-block-surface-ref';import { isTopLevelBlock } from '@blocksuite/affine-shared/utils';import type { EditorHost } from '@blocksuite/block-std';+import type { GfxModel } from '@blocksuite/block-std/gfx';import { assertExists, Bound } from '@blocksuite/global/utils';import { ExportManager } from '../../../_common/export-manager/export-manager.js';@@ -11,7 +12,7 @@ export const edgelessToBlob = async (options: {surfaceRefBlock: SurfaceRefBlockComponent;surfaceRenderer: CanvasRenderer;- edgelessElement: BlockSuite.EdgelessModel;+ edgelessElement: GfxModel;}): Promise<Blob> => {const { edgelessElement } = options;diff --git a/blocksuite/framework/block-std/src/__tests__/command.unit.spec.ts b/blocksuite/framework/block-std/src/__tests__/command.unit.spec.tsindex b296c1c02b..992979445a 100644--- a/blocksuite/framework/block-std/src/__tests__/command.unit.spec.ts+++ b/blocksuite/framework/block-std/src/__tests__/command.unit.spec.ts@@ -2,6 +2,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';import type { Command } from '../command/index.js';import { CommandManager } from '../command/index.js';+import type { BlockStdScope } from '../scope/block-std-scope.js';type Command1 = Command<{@@ -15,7 +16,7 @@ type Command1 = Command<type Command2 = Command<{ commandData1: string }, { commandData2: string }>;describe('CommandManager', () => {- let std: BlockSuite.Std;+ let std: BlockStdScope;let commandManager: CommandManager;beforeEach(() => {diff --git a/blocksuite/framework/block-std/src/command/manager.ts b/blocksuite/framework/block-std/src/command/manager.tsindex 5f026220ed..8521c22441 100644--- a/blocksuite/framework/block-std/src/command/manager.ts+++ b/blocksuite/framework/block-std/src/command/manager.ts@@ -8,7 +8,7 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* Commands are functions that take a context and a next function as arguments** ```ts- * const myCommand: Command<'count', 'count'> = (ctx, next) => {+ * const myCommand: Command<input, output> = (ctx, next) => {* const count = ctx.count || 0;** const success = someOperation();@@ -19,40 +19,17 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* return;* ```*- * You should always add the command to the global interface `BlockSuite.Commands`- * ```ts- * declare global {- * namespace BlockSuite {- * interface Commands {- * 'myCommand': typeof myCommand- * }- * }- * }- * ```- ** Command input and output data can be defined in the `Command` type** ```ts* // input: ctx.firstName, ctx.lastName* // output: ctx.fullName- * const myCommand: Command<'firstName' | 'lastName', 'fullName'> = (ctx, next) => {+ * const myCommand: Command<{ firstName: string; lastName: string }, { fullName: string }> = (ctx, next) => {* const { firstName, lastName } = ctx;* const fullName = `${firstName} ${lastName}`;* return next({ fullName });* }*- * declare global {- * namespace BlockSuite {- * interface CommandContext {- * // All command input and output data should be defined here- * // The keys should be optional- * firstName?: string;- * lastName?: string;- * fullName?: string;- * }- * }- * }- ** ```**@@ -63,7 +40,7 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* 1. Using `exec` method* `exec` is used to run a single command* ```ts- * const { success, ...data } = commandManager.exec('myCommand', payload);+ * const [result, data] = commandManager.exec(myCommand, payload);* ```** 2. Using `chain` method@@ -71,8 +48,8 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* ```ts* const chain = commandManager.chain();* const [result, data] = chain- * .myCommand1()- * .myCommand2(payload)+ * .pipe(myCommand1)+ * .pipe(myCommand2, payload)* .run();* ```*@@ -83,8 +60,8 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* ```ts* const chain = commandManager.chain();* const [result, data] = chain- * .myCommand1() <-- if this fail- * .myCommand2(payload) <- this won't run+ * .chain(myCommand1) <-- if this fail+ * .chain(myCommand2, payload) <- this won't run* .run();** result <- result will be `false`@@ -95,9 +72,9 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* const chain = commandManager.chain();* const [result, data] = chain* .try(chain => [- * chain.myCommand1(), <- if this fail- * chain.myCommand2(), <- this will run, if this success- * chain.myCommand3(), <- this won't run+ * chain.pipe(myCommand1), <- if this fail+ * chain.pipe(myCommand2, payload), <- this will run, if this success+ * chain.pipe(myCommand3), <- this won't run* ])* .run();* ```@@ -107,9 +84,9 @@ import type { Chain, Command, InitCommandCtx } from './types.js';* const chain = commandManager.chain();* const [result, data] = chain* .try(chain => [- * chain.myCommand1(), <- if this success- * chain.myCommand2(), <- this will also run- * chain.myCommand3(), <- so will this+ * chain.pipe(myCommand1), <- if this success+ * chain.pipe(myCommand2), <- this will also run+ * chain.pipe(myCommand3), <- so will this* ])* .run();* ```diff --git a/blocksuite/framework/block-std/src/event/dispatcher.ts b/blocksuite/framework/block-std/src/event/dispatcher.tsindex d435dc051e..886824d9f0 100644--- a/blocksuite/framework/block-std/src/event/dispatcher.ts+++ b/blocksuite/framework/block-std/src/event/dispatcher.ts@@ -3,6 +3,7 @@ import { DisposableGroup } from '@blocksuite/global/utils';import { LifeCycleWatcher } from '../extension/index.js';import { KeymapIdentifier } from '../identifier.js';+import type { BlockStdScope } from '../scope/index.js';import { type BlockComponent, EditorHost } from '../view/index.js';import {type UIEventHandler,@@ -111,7 +112,7 @@ export class UIEventDispatcher extends LifeCycleWatcher {return this.std.host;}- constructor(std: BlockSuite.Std) {+ constructor(std: BlockStdScope) {super(std);this._pointerControl = new PointerControl(this);this._keyboardControl = new KeyboardControl(this);diff --git a/blocksuite/framework/block-std/src/extension/block-view.ts b/blocksuite/framework/block-std/src/extension/block-view.tsindex 4397ea9aea..d714667824 100644--- a/blocksuite/framework/block-std/src/extension/block-view.ts+++ b/blocksuite/framework/block-std/src/extension/block-view.ts@@ -22,7 +22,7 @@ import type { BlockViewType } from '../spec/type.js';* ```*/export function BlockViewExtension(- flavour: BlockSuite.Flavour,+ flavour: string,view: BlockViewType): ExtensionType {return {diff --git a/blocksuite/framework/block-std/src/extension/config.ts b/blocksuite/framework/block-std/src/extension/config.tsindex b74f9498e9..de310041ea 100644--- a/blocksuite/framework/block-std/src/extension/config.ts+++ b/blocksuite/framework/block-std/src/extension/config.ts@@ -20,7 +20,7 @@ import { ConfigIdentifier } from '../identifier.js';* ```*/export function ConfigExtension(- flavor: BlockSuite.Flavour,+ flavor: string,config: Record<string, unknown>): ExtensionType {return {diff --git a/blocksuite/framework/block-std/src/extension/widget-view-map.ts b/blocksuite/framework/block-std/src/extension/widget-view-map.tsindex 1559e18aed..7574f95857 100644--- a/blocksuite/framework/block-std/src/extension/widget-view-map.ts+++ b/blocksuite/framework/block-std/src/extension/widget-view-map.ts@@ -21,7 +21,7 @@ import type { WidgetViewMapType } from '../spec/type.js';* });*/export function WidgetViewMapExtension(- flavour: BlockSuite.Flavour,+ flavour: string,widgetViewMap: WidgetViewMapType): ExtensionType {return {diff --git a/blocksuite/framework/block-std/src/scope/block-std-scope.ts b/blocksuite/framework/block-std/src/scope/block-std-scope.tsindex bb1d0d13bd..608c4802d1 100644--- a/blocksuite/framework/block-std/src/scope/block-std-scope.ts+++ b/blocksuite/framework/block-std/src/scope/block-std-scope.ts@@ -213,7 +213,5 @@ declare global {type ServiceKeys = string & keyof BlockServices;type ConfigKeys = string & keyof BlockConfigs;-- type Std = BlockStdScope;}}diff --git a/blocksuite/framework/block-std/src/view/element/lit-host.ts b/blocksuite/framework/block-std/src/view/element/lit-host.tsindex 4e5e4f46ab..5ac1518f69 100644--- a/blocksuite/framework/block-std/src/view/element/lit-host.ts+++ b/blocksuite/framework/block-std/src/view/element/lit-host.ts@@ -185,7 +185,7 @@ export class EditorHost extends SignalWatcher(@provide({ context: stdContext })@property({ attribute: false })- accessor std!: BlockSuite.Std;+ accessor std!: BlockStdScope;}declare global {diff --git a/blocksuite/framework/store/src/model/index.ts b/blocksuite/framework/store/src/model/index.tsindex ee38592c99..3ea243b2e3 100644--- a/blocksuite/framework/store/src/model/index.ts+++ b/blocksuite/framework/store/src/model/index.ts@@ -1,19 +1,5 @@-import type { BlockModel } from './block/block-model.js';-export * from './block/index.js';export * from './doc.js';export * from './store/index.js';export * from './workspace.js';export * from './workspace-meta.js';--declare global {- namespace BlockSuite {- interface BlockModels {}-- type Flavour = string & keyof BlockModels;-- type ModelProps<Model> = Partial<- Model extends BlockModel<infer U> ? U : never- >;- }-}diff --git a/blocksuite/framework/store/src/model/store/store.ts b/blocksuite/framework/store/src/model/store/store.tsindex 71668ff54d..eced871271 100644--- a/blocksuite/framework/store/src/model/store/store.ts+++ b/blocksuite/framework/store/src/model/store/store.ts@@ -658,7 +658,7 @@ export class Store {);}- getSchemaByFlavour(flavour: BlockSuite.Flavour) {+ getSchemaByFlavour(flavour: string) {return this._schema.flavourSchemaMap.get(flavour);}diff --git a/blocksuite/framework/store/src/transformer/transformer.ts b/blocksuite/framework/store/src/transformer/transformer.tsindex 12f1c95b03..91a7e1d0fc 100644--- a/blocksuite/framework/store/src/transformer/transformer.ts+++ b/blocksuite/framework/store/src/transformer/transformer.ts@@ -506,12 +506,7 @@ export class Transformer {const actualIndex =startIndex !== undefined ? startIndex + index : undefined;- doc.addBlock(- flavour as BlockSuite.Flavour,- draft as object,- parentId,- actualIndex- );+ doc.addBlock(flavour, draft as object, parentId, actualIndex);const model = doc.getBlock(id)?.model;if (!model) {diff --git a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.tsindex c9e367eb4c..21cbdafb91 100644--- a/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts+++ b/blocksuite/presets/src/fragments/outline/body/outline-panel-body.ts@@ -2,7 +2,7 @@ import { effects } from '@blocksuite/affine-block-note/effects';import { ShadowlessElement, SurfaceSelection } from '@blocksuite/block-std';import {changeNoteDisplayMode,- matchFlavours,+ matchModels,NoteBlockModel,NoteDisplayMode,} from '@blocksuite/blocks';@@ -155,7 +155,7 @@ export class OutlinePanelBody extends SignalWatcher(const noteIndex = new Map<NoteBlockModel, number>();children.forEach((block, index) => {- if (matchFlavours(block, [NoteBlockModel])) {+ if (matchModels(block, [NoteBlockModel])) {noteIndex.set(block, index);}});@@ -171,7 +171,7 @@ export class OutlinePanelBody extends SignalWatcher(if (targetIndex === null) return;const removeSelectedNoteFilter = (block: BlockModel) =>- !matchFlavours(block, [NoteBlockModel]) || !selected.includes(block);+ !matchModels(block, [NoteBlockModel]) || !selected.includes(block);const leftPart = children.slice(0, targetIndex)@@ -200,7 +200,7 @@ export class OutlinePanelBody extends SignalWatcher(private _selectNote(e: SelectEvent) {const { selected, id, multiselect } = e.detail;const note = this.doc.getBlock(id)?.model;- if (!note || !matchFlavours(note, [NoteBlockModel])) return;+ if (!note || !matchModels(note, [NoteBlockModel])) return;let selectedNotes = this._selectedNotes$.peek();@@ -231,7 +231,7 @@ export class OutlinePanelBody extends SignalWatcher(.filter(SurfaceSelection).map(({ blockId }) => doc.getBlock(blockId)?.model).filter(model => {- return !!model && matchFlavours(model, [NoteBlockModel]);+ return !!model && matchModels(model, [NoteBlockModel]);});const preSelected = this._selectedNotes$.peek();diff --git a/blocksuite/presets/src/fragments/outline/mobile-outline-panel.ts b/blocksuite/presets/src/fragments/outline/mobile-outline-panel.tsindex 60b3da27e6..1a5284c824 100644--- a/blocksuite/presets/src/fragments/outline/mobile-outline-panel.ts+++ b/blocksuite/presets/src/fragments/outline/mobile-outline-panel.ts@@ -1,7 +1,7 @@import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';import { PropTypes, requiredProperties } from '@blocksuite/block-std';import {- matchFlavours,+ matchModels,NoteDisplayMode,ParagraphBlockModel,RootBlockModel,@@ -134,11 +134,11 @@ export class MobileOutlineMenu extends SignalWatcher(renderItem = (item: BlockModel) => {let className = '';let text = '';- if (matchFlavours(item, [RootBlockModel])) {+ if (matchModels(item, [RootBlockModel])) {className = 'title';text = item.title$.value.toString();} else if (- matchFlavours(item, [ParagraphBlockModel]) &&+ matchModels(item, [ParagraphBlockModel]) &&['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(item.type$.value)) {className = item.type$.value;diff --git a/blocksuite/presets/src/fragments/outline/utils/query.ts b/blocksuite/presets/src/fragments/outline/utils/query.tsindex 69a6a876f5..0ddc4f5878 100644--- a/blocksuite/presets/src/fragments/outline/utils/query.ts+++ b/blocksuite/presets/src/fragments/outline/utils/query.ts@@ -1,6 +1,6 @@import {BlocksUtils,- matchFlavours,+ matchModels,NoteBlockModel,NoteDisplayMode,ParagraphBlockModel,@@ -24,7 +24,7 @@ export function getNotesFromDoc(const notes: NoteBlockModel[] = [];rootModel.children.forEach(block => {- if (!matchFlavours(block, [NoteBlockModel])) return;+ if (!matchModels(block, [NoteBlockModel])) return;if (modes.includes(block.displayMode$.value)) {notes.push(block);@@ -35,14 +35,14 @@ export function getNotesFromDoc(}export function isRootBlock(block: BlockModel): block is RootBlockModel {- return BlocksUtils.matchFlavours(block, [RootBlockModel]);+ return BlocksUtils.matchModels(block, [RootBlockModel]);}export function isHeadingBlock(block: BlockModel): block is ParagraphBlockModel {return (- BlocksUtils.matchFlavours(block, [ParagraphBlockModel]) &&+ BlocksUtils.matchModels(block, [ParagraphBlockModel]) &&headingKeys.has(block.type$.value));}diff --git a/blocksuite/tests-legacy/utils/actions/block.ts b/blocksuite/tests-legacy/utils/actions/block.tsindex 8e1620eccd..f3f3b7f49d 100644--- a/blocksuite/tests-legacy/utils/actions/block.ts+++ b/blocksuite/tests-legacy/utils/actions/block.ts@@ -4,7 +4,7 @@ import { waitNextFrame } from './misc.js';export async function updateBlockType(page: Page,- flavour: BlockSuite.Flavour,+ flavour: string,type?: string) {await page.evaluate(@@ -16,7 +16,7 @@ export async function updateBlockType(},});},- [flavour, type] as [BlockSuite.Flavour, string?]+ [flavour, type] as [string, string?]);await waitNextFrame(page, 400);}diff --git a/blocksuite/tests-legacy/utils/asserts.ts b/blocksuite/tests-legacy/utils/asserts.tsindex 4431ff7148..981b9ea9a8 100644--- a/blocksuite/tests-legacy/utils/asserts.ts+++ b/blocksuite/tests-legacy/utils/asserts.ts@@ -556,7 +556,7 @@ export async function assertBlockType(export async function assertBlockFlavour(page: Page,id: string | number,- flavour: BlockSuite.Flavour+ flavour: string) {const actual = await page.evaluate(({ id }) => {diff --git a/packages/frontend/core/src/blocksuite/blocks/ai-chat-block/ai-chat-model.ts b/packages/frontend/core/src/blocksuite/blocks/ai-chat-block/ai-chat-model.tsindex 1f68dde46b..34af4a01b0 100644--- a/packages/frontend/core/src/blocksuite/blocks/ai-chat-block/ai-chat-model.ts+++ b/packages/frontend/core/src/blocksuite/blocks/ai-chat-block/ai-chat-model.ts@@ -41,8 +41,5 @@ declare global {interface EdgelessBlockModelMap {'affine:embed-ai-chat': AIChatBlockModel;}- interface BlockModels {- 'affine:embed-ai-chat': AIChatBlockModel;- }}}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.tsindex 9fe390bf99..16b5a2763b 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/chat-actions-handle.ts@@ -36,7 +36,7 @@ import { reportResponse } from '../utils/action-reporter';import { insertBelow, replace } from '../utils/editor-actions';import { BlockIcon, CreateIcon, InsertBelowIcon, ReplaceIcon } from './icons';-const { matchFlavours } = BlocksUtils;+const { matchModels } = BlocksUtils;type Selections = {text?: TextSelection;@@ -232,7 +232,7 @@ const REPLACE_SELECTION = {if (currentTextSelection) {const { doc } = host;const block = doc.getBlock(currentTextSelection.blockId);- if (matchFlavours(block?.model ?? null, [ParagraphBlockModel])) {+ if (matchModels(block?.model ?? null, [ParagraphBlockModel])) {block?.model.text?.replace(currentTextSelection.from.index,currentTextSelection.from.length,diff --git a/packages/frontend/core/src/blocksuite/presets/ai/_common/config.ts b/packages/frontend/core/src/blocksuite/presets/ai/_common/config.tsindex be7a63aec1..adb83c93e4 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/_common/config.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/_common/config.ts@@ -6,7 +6,7 @@ import {getSelectedModelsCommand,ImageBlockModel,ListBlockModel,- matchFlavours,+ matchModels,ParagraphBlockModel,} from '@blocksuite/affine/blocks';@@ -107,7 +107,7 @@ const textBlockShowWhen = (chain: Chain<InitCommandCtx>) => {if (!selectedModels || selectedModels.length === 0) return false;return selectedModels.some(model =>- matchFlavours(model, [ParagraphBlockModel, ListBlockModel])+ matchModels(model, [ParagraphBlockModel, ListBlockModel]));};@@ -121,7 +121,7 @@ const codeBlockShowWhen = (chain: Chain<InitCommandCtx>) => {if (!selectedModels || selectedModels.length > 1) return false;const model = selectedModels[0];- return matchFlavours(model, [CodeBlockModel]);+ return matchModels(model, [CodeBlockModel]);};const imageBlockShowWhen = (chain: Chain<InitCommandCtx>) => {@@ -134,7 +134,7 @@ const imageBlockShowWhen = (chain: Chain<InitCommandCtx>) => {if (!selectedModels || selectedModels.length > 1) return false;const model = selectedModels[0];- return matchFlavours(model, [ImageBlockModel]);+ return matchModels(model, [ImageBlockModel]);};const EditAIGroup: AIItemGroupConfig = {@@ -282,7 +282,7 @@ const GenerateWithAIGroup: AIItemGroupConfig = {return selectedModels.every(model =>- matchFlavours(model, [ParagraphBlockModel, ListBlockModel]) &&+ matchModels(model, [ParagraphBlockModel, ListBlockModel]) &&!model.type.startsWith('h'));},diff --git a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.tsindex e8eaae8b2a..fe3538f113 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/actions/edgeless-handler.ts@@ -1,5 +1,8 @@import type { EditorHost } from '@blocksuite/affine/block-std';-import { GfxControllerIdentifier } from '@blocksuite/affine/block-std/gfx';+import {+ GfxControllerIdentifier,+ type GfxModel,+} from '@blocksuite/affine/block-std/gfx';import type {AffineAIPanelWidget,AIError,@@ -72,7 +75,7 @@ async function getContentFromHubBlockModel(export async function getContentFromSelected(host: EditorHost,- selected: BlockSuite.EdgelessModel[]+ selected: GfxModel[]) {type RemoveUndefinedKey<T, K extends keyof T> = T & {[P in K]-?: Exclude<T[P], undefined>;@@ -486,7 +489,7 @@ export function noteWithCodeBlockShowWen(return (selected[0] instanceof NoteBlockModel &&selected[0].children.length === 1 &&- BlocksUtils.matchFlavours(selected[0].children[0], [CodeBlockModel])+ BlocksUtils.matchModels(selected[0].children[0], [CodeBlockModel]));}diff --git a/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.ts b/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.tsindex 332ba9f7bc..f6bea31092 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/ai-panel.ts@@ -6,7 +6,7 @@ import {type AIItemConfig,ImageBlockModel,isInsideEdgelessEditor,- matchFlavours,+ matchModels,NoteBlockModel,NoteDisplayMode,} from '@blocksuite/affine/blocks';@@ -116,7 +116,7 @@ function createNewNote(host: EditorHost): AIItemConfig {// set the viewport to show the new note block and original note blockconst newNote = doc.getBlock(noteBlockId)?.model;- if (!newNote || !matchFlavours(newNote, [NoteBlockModel])) return;+ if (!newNote || !matchModels(newNote, [NoteBlockModel])) return;const newNoteBound = Bound.deserialize(newNote.xywh);const bounds = [bound, newNoteBound];service.gfx.fitToScreen({diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/context.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/context.tsindex 3a5559dd32..553d11a474 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/context.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/context.ts@@ -1,10 +1,11 @@+import type { GfxModel } from '@blocksuite/affine/block-std/gfx';import type { MindmapStyle } from '@blocksuite/affine/blocks';import type { SerializedXYWH } from '@blocksuite/affine/global/utils';import type { TemplateImage } from '../slides/template';export interface ContextValue {- selectedElements?: BlockSuite.EdgelessModel[];+ selectedElements?: GfxModel[];content?: string;// make it realwidth?: number;diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.tsindex 4f0c3a242a..3ae09aba36 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/edgeless.ts@@ -1,9 +1,10 @@import type { BlockComponent, EditorHost } from '@blocksuite/affine/block-std';+import type { GfxModel } from '@blocksuite/affine/block-std/gfx';import {AFFINE_EDGELESS_COPILOT_WIDGET,type EdgelessCopilotWidget,type EdgelessRootService,- matchFlavours,+ matchModels,MindmapElementModel,NoteBlockModel,RootBlockModel,@@ -32,13 +33,13 @@ export function mindMapToMarkdown(mindmap: MindmapElementModel) {return markdownStr;}-export function isMindMapRoot(ele: BlockSuite.EdgelessModel) {+export function isMindMapRoot(ele: GfxModel) {const group = ele?.group;return group instanceof MindmapElementModel && group.tree.element === ele;}-export function isMindmapChild(ele: BlockSuite.EdgelessModel) {+export function isMindmapChild(ele: GfxModel) {return ele?.group instanceof MindmapElementModel && !isMindMapRoot(ele);}@@ -65,10 +66,10 @@ export function getEdgelessCopilotWidget(export function findNoteBlockModel(blockElement: BlockComponent) {let curBlock = blockElement;while (curBlock) {- if (matchFlavours(curBlock.model, [NoteBlockModel])) {+ if (matchModels(curBlock.model, [NoteBlockModel])) {return curBlock.model;}- if (matchFlavours(curBlock.model, [RootBlockModel, SurfaceBlockModel])) {+ if (matchModels(curBlock.model, [RootBlockModel, SurfaceBlockModel])) {return null;}if (!curBlock.parentComponent) {diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/extract.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/extract.tsindex 20edefc627..12b917ffc6 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/extract.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/extract.ts@@ -164,7 +164,7 @@ export async function extractMarkdownFromDoc(const blockModels = getNoteBlockModels(doc);const textModels = blockModels.filter(model =>- !BlocksUtils.matchFlavours(model, [ImageBlockModel, DatabaseBlockModel])+ !BlocksUtils.matchModels(model, [ImageBlockModel, DatabaseBlockModel]));const drafts = textModels.map(toDraftModel);const slice = Slice.fromModels(doc, drafts);diff --git a/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.tsindex a712bf2fd1..9aad9fadf2 100644--- a/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts+++ b/packages/frontend/core/src/blocksuite/presets/ai/utils/selection-utils.ts@@ -134,7 +134,7 @@ export async function getTextContentFromBlockModels(// Currently only filter out images and databasesconst selectedTextModels = models.filter(model =>- !BlocksUtils.matchFlavours(model, [ImageBlockModel, DatabaseBlockModel])+ !BlocksUtils.matchModels(model, [ImageBlockModel, DatabaseBlockModel]));const drafts = selectedTextModels.map(toDraftModel);drafts.forEach(draft => traverse(draft, drafts));@@ -286,9 +286,7 @@ export const getSelectedNoteAnchor = (host: EditorHost, id: string) => {return host.querySelector(`affine-edgeless-note[data-block-id="${id}"]`);};-export function getCopilotSelectedElems(- host: EditorHost-): BlockSuite.EdgelessModel[] {+export function getCopilotSelectedElems(host: EditorHost): GfxModel[] {const service = getService(host);const copilotWidget = getEdgelessCopilotWidget(host);diff --git a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/widgets/edgeless-note-header.tsx b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/widgets/edgeless-note-header.tsxindex d9c19b07ec..e23ee91170 100644--- a/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/widgets/edgeless-note-header.tsx+++ b/packages/frontend/core/src/components/blocksuite/block-suite-editor/specs/custom/widgets/edgeless-note-header.tsx@@ -10,7 +10,7 @@ import { useI18n } from '@affine/i18n';import { track } from '@affine/track';import { GfxControllerIdentifier } from '@blocksuite/affine/block-std/gfx';import {- matchFlavours,+ matchModels,NoteBlockModel,NoteDisplayMode,} from '@blocksuite/affine/blocks';@@ -176,7 +176,7 @@ export const EdgelessNoteHeader = ({ note }: { note: NoteBlockModel }) => {const isFirstVisibleNote =note.parent?.children.find(child =>- matchFlavours(child, [NoteBlockModel]) &&+ matchModels(child, [NoteBlockModel]) &&child.displayMode === NoteDisplayMode.DocAndEdgeless) === note;