mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 18:09:58 +08:00
refactor(editor): remove global types in model (#10082)
Closes: [BS-2249](https://linear.app/affine-design/issue/BS-2249/remove-global-types-in-model) ```ts // before matchFlavours(model, ['affine:page']); // after matchFlavours(model, [PageBlockModel]); ```
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { RootBlockModel } from '@blocksuite/affine-model';
|
||||
import {
|
||||
type BlockStdScope,
|
||||
type EditorHost,
|
||||
@@ -19,7 +20,7 @@ const handlePoint = (
|
||||
model: DraftModel
|
||||
) => {
|
||||
const { index, length } = point;
|
||||
if (matchFlavours(model, ['affine:page'])) {
|
||||
if (matchFlavours(model, [RootBlockModel])) {
|
||||
if (length === 0) return;
|
||||
(snapshot.props.title as Record<string, unknown>).delta =
|
||||
model.title.sliceToDelta(index, length + index);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import {
|
||||
CodeBlockModel,
|
||||
type DocMode,
|
||||
DocModes,
|
||||
ImageBlockModel,
|
||||
type ParagraphBlockModel,
|
||||
type ReferenceInfo,
|
||||
} from '@blocksuite/affine-model';
|
||||
@@ -291,7 +293,7 @@ class PasteTr {
|
||||
return;
|
||||
}
|
||||
if (!cursorModel.text) {
|
||||
if (matchFlavours(cursorModel, ['affine:image'])) {
|
||||
if (matchFlavours(cursorModel, [ImageBlockModel])) {
|
||||
const selection = this.std.selection.create(ImageSelection, {
|
||||
blockId: target.blockId,
|
||||
});
|
||||
@@ -356,7 +358,7 @@ class PasteTr {
|
||||
if (
|
||||
this.firstSnapshot !== this.lastSnapshot &&
|
||||
this.lastSnapshot.props.text &&
|
||||
!matchFlavours(this.pointState.model, ['affine:code'])
|
||||
!matchFlavours(this.pointState.model, [CodeBlockModel])
|
||||
) {
|
||||
const text = fromJSON(this.lastSnapshot.props.text) as Text;
|
||||
const doc = new Y.Doc();
|
||||
|
||||
Reference in New Issue
Block a user