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

View File

@@ -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);

View File

@@ -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();