Skip to content

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.

fix(editor): missing dependencies (#9436)

Saul-Mironea9f890017ed8
diff --git a/blocksuite/affine/block-attachment/src/attachment-service.ts b/blocksuite/affine/block-attachment/src/attachment-service.ts
index c81c9c559c..71c806dc8e 100644
--- a/blocksuite/affine/block-attachment/src/attachment-service.ts
+++ b/blocksuite/affine/block-attachment/src/attachment-service.ts
@@ -29,10 +29,7 @@ export const AttachmentDropOption = FileDropConfigExtension({
if (!attachmentFiles.length) return false;
- if (
- targetModel &&
- !matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
- ) {
+ if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
addSiblingAttachmentBlocks(
std.host,
attachmentFiles,
diff --git a/blocksuite/affine/block-attachment/src/index.ts b/blocksuite/affine/block-attachment/src/index.ts
index 4298e7a67f..ad03de0d56 100644
--- a/blocksuite/affine/block-attachment/src/index.ts
+++ b/blocksuite/affine/block-attachment/src/index.ts
@@ -1,3 +1,7 @@
+import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';
+
+declare type _GLOBAL_ = typeof SurfaceEffects;
+
export * from './adapters/notion-html';
export * from './attachment-block';
export * from './attachment-service';
diff --git a/blocksuite/affine/block-database/package.json b/blocksuite/affine/block-database/package.json
index 8f31531c22..9e1d20766b 100644
--- a/blocksuite/affine/block-database/package.json
+++ b/blocksuite/affine/block-database/package.json
@@ -16,6 +16,7 @@
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
+ "@blocksuite/affine-widget-drag-handle": "workspace:*",
"@blocksuite/block-std": "workspace:*",
"@blocksuite/data-view": "workspace:*",
"@blocksuite/global": "workspace:*",
diff --git a/blocksuite/affine/block-database/src/effects.ts b/blocksuite/affine/block-database/src/effects.ts
index 6b719f2917..7660927530 100644
--- a/blocksuite/affine/block-database/src/effects.ts
+++ b/blocksuite/affine/block-database/src/effects.ts
@@ -1,5 +1,3 @@
-import type { DatabaseBlockModel } from '@blocksuite/affine-model';
-
import type { insertDatabaseBlockCommand } from './commands';
import { CenterPeek } from './components/layout';
import { DatabaseTitle } from './components/title';
@@ -44,10 +42,6 @@ export function effects() {
declare global {
namespace BlockSuite {
- interface BlockModels {
- 'affine:database': DatabaseBlockModel;
- }
-
interface BlockConfigs {
'affine:database': Partial<DatabaseOptionsConfig>;
}
diff --git a/blocksuite/affine/block-database/src/index.ts b/blocksuite/affine/block-database/src/index.ts
index 6765ee94cf..9c9eab562e 100644
--- a/blocksuite/affine/block-database/src/index.ts
+++ b/blocksuite/affine/block-database/src/index.ts
@@ -1,4 +1,6 @@
-import type { DatabaseBlockModel } from '@blocksuite/affine-model';
+import type * as CommandType from '@blocksuite/affine-shared/commands';
+
+declare type _GLOBAL_ = typeof CommandType;
export * from './adapters';
export type { DatabaseOptionsConfig } from './config';
@@ -12,11 +14,3 @@ export * from './properties';
export * from './properties/rich-text/cell-renderer';
export * from './properties/utils';
export * from './utils/block-utils';
-
-declare global {
- namespace BlockSuite {
- interface BlockModels {
- 'affine:database': DatabaseBlockModel;
- }
- }
-}
diff --git a/blocksuite/affine/block-database/tsconfig.json b/blocksuite/affine/block-database/tsconfig.json
index 69950602cc..419ea8f164 100644
--- a/blocksuite/affine/block-database/tsconfig.json
+++ b/blocksuite/affine/block-database/tsconfig.json
@@ -32,16 +32,7 @@
"path": "../data-view"
},
{
- "path": "../block-embed"
- },
- {
- "path": "../block-paragraph"
- },
- {
- "path": "../block-note"
- },
- {
- "path": "../block-list"
+ "path": "../widget-drag-handle"
}
]
}
diff --git a/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts b/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts
index b5e4e97f04..5eeb322310 100644
--- a/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts
+++ b/blocksuite/affine/block-edgeless-text/src/edgeless-text-block.ts
@@ -87,34 +87,32 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
this.updateComplete
.then(() => {
const command = this.std.command;
- const blockSelections = this.model.children.map(
- child =>
- this.std.selection.create('block', {
- blockId: child.id,
- })
- // FIXME: BS-2216
- ) as never;
+ const blockSelections = this.model.children.map(child =>
+ this.std.selection.create('block', {
+ blockId: child.id,
+ })
+ );
if (key === 'fontStyle') {
command.exec('formatBlock', {
blockSelections,
styles: {
italic: null,
- } as never,
+ },
});
} else if (key === 'color') {
command.exec('formatBlock', {
blockSelections,
styles: {
color: null,
- } as never,
+ },
});
} else if (key === 'fontWeight') {
command.exec('formatBlock', {
blockSelections,
styles: {
bold: null,
- } as never,
+ },
});
}
})
diff --git a/blocksuite/affine/block-edgeless-text/src/index.ts b/blocksuite/affine/block-edgeless-text/src/index.ts
index 8a2d31ee97..4198826e9e 100644
--- a/blocksuite/affine/block-edgeless-text/src/index.ts
+++ b/blocksuite/affine/block-edgeless-text/src/index.ts
@@ -1,2 +1,6 @@
+import type * as CommandType from '@blocksuite/affine-shared/commands';
+
+declare type _GLOBAL_ = typeof CommandType;
+
export * from './edgeless-text-block.js';
export * from './edgeless-text-spec.js';
diff --git a/blocksuite/affine/block-image/src/image-service.ts b/blocksuite/affine/block-image/src/image-service.ts
index a3946ebbf8..92531de7e4 100644
--- a/blocksuite/affine/block-image/src/image-service.ts
+++ b/blocksuite/affine/block-image/src/image-service.ts
@@ -28,10 +28,7 @@ export const ImageDropOption = FileDropConfigExtension({
const imageFiles = files.filter(file => file.type.startsWith('image/'));
if (!imageFiles.length) return false;
- if (
- targetModel &&
- !matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
- ) {
+ if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
addSiblingImageBlock(
std.host,
imageFiles,
diff --git a/blocksuite/affine/block-image/src/index.ts b/blocksuite/affine/block-image/src/index.ts
index c844dcc910..eb321e4640 100644
--- a/blocksuite/affine/block-image/src/index.ts
+++ b/blocksuite/affine/block-image/src/index.ts
@@ -1,3 +1,7 @@
+import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';
+
+declare type _GLOBAL_ = typeof SurfaceEffects;
+
export * from './adapters';
export * from './image-block';
export * from './image-edgeless-block';
diff --git a/blocksuite/affine/block-image/src/utils.ts b/blocksuite/affine/block-image/src/utils.ts
index 96a2c0d289..702bc0ecfb 100644
--- a/blocksuite/affine/block-image/src/utils.ts
+++ b/blocksuite/affine/block-image/src/utils.ts
@@ -523,7 +523,6 @@ export async function addImages(
editing: false,
});
if (isMultipleFiles) {
- // @ts-expect-error FIXME(command): BS-2216
std.command.exec('autoResizeElements');
}
return blockIds;
diff --git a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts b/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
index 05c904e118..8534546dcf 100644
--- a/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
+++ b/blocksuite/affine/block-paragraph/src/utils/forward-delete.ts
@@ -21,7 +21,6 @@ export function forwardDelete(std: BlockStdScope) {
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
'affine:attachment',
'affine:bookmark',
- // @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
'affine:database',
'affine:code',
'affine:image',
diff --git a/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts b/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts
index cb46ce8928..c5d66115d4 100644
--- a/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts
+++ b/blocksuite/affine/block-paragraph/src/utils/merge-with-prev.ts
@@ -86,7 +86,6 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
return true;
}
- // @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
if (matchFlavours(parent, ['affine:database'])) {
doc.deleteBlock(model);
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);
diff --git a/blocksuite/affine/components/src/rich-text/dom.ts b/blocksuite/affine/components/src/rich-text/dom.ts
index 053d622b08..29ae4b1a19 100644
--- a/blocksuite/affine/components/src/rich-text/dom.ts
+++ b/blocksuite/affine/components/src/rich-text/dom.ts
@@ -37,7 +37,6 @@ export function getInlineEditorByModel(
typeof model === 'string'
? editorHost.std.doc.getBlock(model)?.model
: model;
- // @ts-expect-error TODO: migrate database model to `@blocksuite/affine-model`
if (!blockModel || matchFlavours(blockModel, ['affine:database'])) {
// 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.
diff --git a/blocksuite/affine/model/src/blocks/database/database-model.ts b/blocksuite/affine/model/src/blocks/database/database-model.ts
index eda9934652..9488050e4f 100644
--- a/blocksuite/affine/model/src/blocks/database/database-model.ts
+++ b/blocksuite/affine/model/src/blocks/database/database-model.ts
@@ -28,3 +28,11 @@ export const DatabaseBlockSchema = defineBlockSchema({
},
toModel: () => new DatabaseBlockModel(),
});
+
+declare global {
+ namespace BlockSuite {
+ interface BlockModels {
+ 'affine:database': DatabaseBlockModel;
+ }
+ }
+}
diff --git a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts
index cdc36511ca..07e2bcf397 100644
--- a/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts
+++ b/blocksuite/affine/shared/src/utils/dnd/calc-drop-target.ts
@@ -43,9 +43,7 @@ export function calcDropTarget(
*/
allowSublist: boolean = true
): DropResult | null {
- const schema = model.doc.getSchemaByFlavour(
- 'affine:database' as BlockSuite.Flavour
- );
+ const schema = model.doc.getSchemaByFlavour('affine:database');
const children = schema?.model.children ?? [];
let shouldAppendToDatabase = true;
@@ -56,10 +54,7 @@ export function calcDropTarget(
.every(m => children.includes(m.flavour));
}
- if (
- !shouldAppendToDatabase &&
- !matchFlavours(model, ['affine:database' as BlockSuite.Flavour])
- ) {
+ if (!shouldAppendToDatabase && !matchFlavours(model, ['affine:database'])) {
const databaseBlockComponent =
element.closest<BlockComponent>('affine-database');
if (databaseBlockComponent) {
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.ts
index bc3cddf89c..567057bf47 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
@@ -24,9 +24,7 @@ export function getDropRectByPoint(
flag: DropFlags.Normal,
};
- const isDatabase = matchFlavours(model, [
- 'affine:database' as BlockSuite.Flavour,
- ]);
+ const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) {
const table = getDatabaseBlockTableElement(element);
diff --git a/blocksuite/affine/widget-drag-handle/src/drag-handle.ts b/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
index 97b10bcfc1..f34af2fd69 100644
--- a/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
+++ b/blocksuite/affine/widget-drag-handle/src/drag-handle.ts
@@ -75,9 +75,7 @@ export class AffineDragHandleWidget extends WidgetComponent<RootBlockModel> {
const blockId = closestBlock.model.id;
const model = closestBlock.model;
- const isDatabase = matchFlavours(model, [
- 'affine:database' as BlockSuite.Flavour,
- ]);
+ const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) return null;
// note block can only be dropped into another note block
diff --git a/blocksuite/affine/widget-drag-handle/src/utils.ts b/blocksuite/affine/widget-drag-handle/src/utils.ts
index d3e20f6625..16988a00ac 100644
--- a/blocksuite/affine/widget-drag-handle/src/utils.ts
+++ b/blocksuite/affine/widget-drag-handle/src/utils.ts
@@ -188,9 +188,7 @@ export const getDropResult = (
const model = closestBlock.model;
- const isDatabase = matchFlavours(model, [
- 'affine:database' as BlockSuite.Flavour,
- ]);
+ const isDatabase = matchFlavours(model, ['affine:database']);
if (isDatabase) {
return dropIndicator;
}
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.ts
index 8068a0decd..ae4d2cfc0c 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
@@ -61,7 +61,6 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
return (
matchFlavours(block, [
'affine:code',
- // @ts-expect-error FIXME: fix after database model moved to affine-model
'affine:database',
'affine:image',
'affine:attachment',
diff --git a/tools/utils/src/workspace.gen.ts b/tools/utils/src/workspace.gen.ts
index b858f81d0e..de136e5f1a 100644
--- a/tools/utils/src/workspace.gen.ts
+++ b/tools/utils/src/workspace.gen.ts
@@ -62,6 +62,7 @@ export const PackageList = [
'blocksuite/affine/components',
'blocksuite/affine/model',
'blocksuite/affine/shared',
+ 'blocksuite/affine/widget-drag-handle',
'blocksuite/framework/block-std',
'blocksuite/affine/data-view',
'blocksuite/framework/global',
diff --git a/yarn.lock b/yarn.lock
index 073aacfdd1..2efa2bca56 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3338,6 +3338,7 @@ __metadata:
"@blocksuite/affine-components": "workspace:*"
"@blocksuite/affine-model": "workspace:*"
"@blocksuite/affine-shared": "workspace:*"
+ "@blocksuite/affine-widget-drag-handle": "workspace:*"
"@blocksuite/block-std": "workspace:*"
"@blocksuite/data-view": "workspace:*"
"@blocksuite/global": "workspace:*"