fix(editor): missing dependencies (#9436)

This commit is contained in:
Saul-Mirone
2024-12-30 14:10:37 +00:00
parent c28f918527
commit a9f890017e
22 changed files with 42 additions and 64 deletions
@@ -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,
@@ -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';
@@ -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:*",
@@ -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>;
}
@@ -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;
}
}
}
+1 -10
View File
@@ -32,16 +32,7 @@
"path": "../data-view"
},
{
"path": "../block-embed"
},
{
"path": "../block-paragraph"
},
{
"path": "../block-note"
},
{
"path": "../block-list"
"path": "../widget-drag-handle"
}
]
}
@@ -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,
},
});
}
})
@@ -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';
@@ -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,
@@ -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';
@@ -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;
@@ -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',
@@ -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);
@@ -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.
@@ -28,3 +28,11 @@ export const DatabaseBlockSchema = defineBlockSchema({
},
toModel: () => new DatabaseBlockModel(),
});
declare global {
namespace BlockSuite {
interface BlockModels {
'affine:database': DatabaseBlockModel;
}
}
}
@@ -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) {
@@ -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);
@@ -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
@@ -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;
}
@@ -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',
+1
View File
@@ -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',
+1
View File
@@ -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:*"