refactor(editor): remove block models global type (#10086)

This commit is contained in:
Saul-Mirone
2025-02-11 11:00:57 +00:00
parent a725df6ebe
commit 39eb8625d6
157 changed files with 402 additions and 621 deletions
@@ -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);
@@ -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 mode
if (!titleEditor) {
if (
matchFlavours(parent, [EdgelessTextBlockModel]) ||
matchModels(parent, [EdgelessTextBlockModel]) ||
model.children.length > 0
) {
doc.deleteBlock(model, {