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

View File

@@ -29,10 +29,7 @@ export const AttachmentDropOption = FileDropConfigExtension({
if (!attachmentFiles.length) return false; if (!attachmentFiles.length) return false;
if ( if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
targetModel &&
!matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
) {
addSiblingAttachmentBlocks( addSiblingAttachmentBlocks(
std.host, std.host,
attachmentFiles, attachmentFiles,

View File

@@ -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 './adapters/notion-html';
export * from './attachment-block'; export * from './attachment-block';
export * from './attachment-service'; export * from './attachment-service';

View File

@@ -16,6 +16,7 @@
"@blocksuite/affine-components": "workspace:*", "@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*", "@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*", "@blocksuite/affine-shared": "workspace:*",
"@blocksuite/affine-widget-drag-handle": "workspace:*",
"@blocksuite/block-std": "workspace:*", "@blocksuite/block-std": "workspace:*",
"@blocksuite/data-view": "workspace:*", "@blocksuite/data-view": "workspace:*",
"@blocksuite/global": "workspace:*", "@blocksuite/global": "workspace:*",

View File

@@ -1,5 +1,3 @@
import type { DatabaseBlockModel } from '@blocksuite/affine-model';
import type { insertDatabaseBlockCommand } from './commands'; import type { insertDatabaseBlockCommand } from './commands';
import { CenterPeek } from './components/layout'; import { CenterPeek } from './components/layout';
import { DatabaseTitle } from './components/title'; import { DatabaseTitle } from './components/title';
@@ -44,10 +42,6 @@ export function effects() {
declare global { declare global {
namespace BlockSuite { namespace BlockSuite {
interface BlockModels {
'affine:database': DatabaseBlockModel;
}
interface BlockConfigs { interface BlockConfigs {
'affine:database': Partial<DatabaseOptionsConfig>; 'affine:database': Partial<DatabaseOptionsConfig>;
} }

View File

@@ -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 * from './adapters';
export type { DatabaseOptionsConfig } from './config'; export type { DatabaseOptionsConfig } from './config';
@@ -12,11 +14,3 @@ export * from './properties';
export * from './properties/rich-text/cell-renderer'; export * from './properties/rich-text/cell-renderer';
export * from './properties/utils'; export * from './properties/utils';
export * from './utils/block-utils'; export * from './utils/block-utils';
declare global {
namespace BlockSuite {
interface BlockModels {
'affine:database': DatabaseBlockModel;
}
}
}

View File

@@ -32,16 +32,7 @@
"path": "../data-view" "path": "../data-view"
}, },
{ {
"path": "../block-embed" "path": "../widget-drag-handle"
},
{
"path": "../block-paragraph"
},
{
"path": "../block-note"
},
{
"path": "../block-list"
} }
] ]
} }

View File

@@ -87,34 +87,32 @@ export class EdgelessTextBlockComponent extends GfxBlockComponent<EdgelessTextBl
this.updateComplete this.updateComplete
.then(() => { .then(() => {
const command = this.std.command; const command = this.std.command;
const blockSelections = this.model.children.map( const blockSelections = this.model.children.map(child =>
child => this.std.selection.create('block', {
this.std.selection.create('block', { blockId: child.id,
blockId: child.id, })
}) );
// FIXME: BS-2216
) as never;
if (key === 'fontStyle') { if (key === 'fontStyle') {
command.exec('formatBlock', { command.exec('formatBlock', {
blockSelections, blockSelections,
styles: { styles: {
italic: null, italic: null,
} as never, },
}); });
} else if (key === 'color') { } else if (key === 'color') {
command.exec('formatBlock', { command.exec('formatBlock', {
blockSelections, blockSelections,
styles: { styles: {
color: null, color: null,
} as never, },
}); });
} else if (key === 'fontWeight') { } else if (key === 'fontWeight') {
command.exec('formatBlock', { command.exec('formatBlock', {
blockSelections, blockSelections,
styles: { styles: {
bold: null, bold: null,
} as never, },
}); });
} }
}) })

View File

@@ -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-block.js';
export * from './edgeless-text-spec.js'; export * from './edgeless-text-spec.js';

View File

@@ -28,10 +28,7 @@ export const ImageDropOption = FileDropConfigExtension({
const imageFiles = files.filter(file => file.type.startsWith('image/')); const imageFiles = files.filter(file => file.type.startsWith('image/'));
if (!imageFiles.length) return false; if (!imageFiles.length) return false;
if ( if (targetModel && !matchFlavours(targetModel, ['affine:surface'])) {
targetModel &&
!matchFlavours(targetModel, ['affine:surface' as BlockSuite.Flavour])
) {
addSiblingImageBlock( addSiblingImageBlock(
std.host, std.host,
imageFiles, imageFiles,

View File

@@ -1,3 +1,7 @@
import type * as SurfaceEffects from '@blocksuite/affine-block-surface/effects';
declare type _GLOBAL_ = typeof SurfaceEffects;
export * from './adapters'; export * from './adapters';
export * from './image-block'; export * from './image-block';
export * from './image-edgeless-block'; export * from './image-edgeless-block';

View File

@@ -523,7 +523,6 @@ export async function addImages(
editing: false, editing: false,
}); });
if (isMultipleFiles) { if (isMultipleFiles) {
// @ts-expect-error FIXME(command): BS-2216
std.command.exec('autoResizeElements'); std.command.exec('autoResizeElements');
} }
return blockIds; return blockIds;

View File

@@ -21,7 +21,6 @@ export function forwardDelete(std: BlockStdScope) {
const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [ const ignoreForwardDeleteFlavourList: BlockSuite.Flavour[] = [
'affine:attachment', 'affine:attachment',
'affine:bookmark', 'affine:bookmark',
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
'affine:database', 'affine:database',
'affine:code', 'affine:code',
'affine:image', 'affine:image',

View File

@@ -86,7 +86,6 @@ export function mergeWithPrev(editorHost: EditorHost, model: BlockModel) {
return true; return true;
} }
// @ts-expect-error FIXME: should be fixed after database model is migrated to affine-models
if (matchFlavours(parent, ['affine:database'])) { if (matchFlavours(parent, ['affine:database'])) {
doc.deleteBlock(model); doc.deleteBlock(model);
focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length); focusTextModel(editorHost.std, prevBlock.id, prevBlock.text?.yText.length);

View File

@@ -37,7 +37,6 @@ export function getInlineEditorByModel(
typeof model === 'string' typeof model === 'string'
? editorHost.std.doc.getBlock(model)?.model ? editorHost.std.doc.getBlock(model)?.model
: model; : model;
// @ts-expect-error TODO: migrate database model to `@blocksuite/affine-model`
if (!blockModel || matchFlavours(blockModel, ['affine:database'])) { if (!blockModel || matchFlavours(blockModel, ['affine:database'])) {
// Not support database model since it's may be have multiple inline editor instances. // 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. // Support to enter the editing state through the Enter key in the database.

View File

@@ -28,3 +28,11 @@ export const DatabaseBlockSchema = defineBlockSchema({
}, },
toModel: () => new DatabaseBlockModel(), toModel: () => new DatabaseBlockModel(),
}); });
declare global {
namespace BlockSuite {
interface BlockModels {
'affine:database': DatabaseBlockModel;
}
}
}

View File

@@ -43,9 +43,7 @@ export function calcDropTarget(
*/ */
allowSublist: boolean = true allowSublist: boolean = true
): DropResult | null { ): DropResult | null {
const schema = model.doc.getSchemaByFlavour( const schema = model.doc.getSchemaByFlavour('affine:database');
'affine:database' as BlockSuite.Flavour
);
const children = schema?.model.children ?? []; const children = schema?.model.children ?? [];
let shouldAppendToDatabase = true; let shouldAppendToDatabase = true;
@@ -56,10 +54,7 @@ export function calcDropTarget(
.every(m => children.includes(m.flavour)); .every(m => children.includes(m.flavour));
} }
if ( if (!shouldAppendToDatabase && !matchFlavours(model, ['affine:database'])) {
!shouldAppendToDatabase &&
!matchFlavours(model, ['affine:database' as BlockSuite.Flavour])
) {
const databaseBlockComponent = const databaseBlockComponent =
element.closest<BlockComponent>('affine-database'); element.closest<BlockComponent>('affine-database');
if (databaseBlockComponent) { if (databaseBlockComponent) {

View File

@@ -24,9 +24,7 @@ export function getDropRectByPoint(
flag: DropFlags.Normal, flag: DropFlags.Normal,
}; };
const isDatabase = matchFlavours(model, [ const isDatabase = matchFlavours(model, ['affine:database']);
'affine:database' as BlockSuite.Flavour,
]);
if (isDatabase) { if (isDatabase) {
const table = getDatabaseBlockTableElement(element); const table = getDatabaseBlockTableElement(element);

View File

@@ -75,9 +75,7 @@ export class AffineDragHandleWidget extends WidgetComponent<RootBlockModel> {
const blockId = closestBlock.model.id; const blockId = closestBlock.model.id;
const model = closestBlock.model; const model = closestBlock.model;
const isDatabase = matchFlavours(model, [ const isDatabase = matchFlavours(model, ['affine:database']);
'affine:database' as BlockSuite.Flavour,
]);
if (isDatabase) return null; if (isDatabase) return null;
// note block can only be dropped into another note block // note block can only be dropped into another note block

View File

@@ -188,9 +188,7 @@ export const getDropResult = (
const model = closestBlock.model; const model = closestBlock.model;
const isDatabase = matchFlavours(model, [ const isDatabase = matchFlavours(model, ['affine:database']);
'affine:database' as BlockSuite.Flavour,
]);
if (isDatabase) { if (isDatabase) {
return dropIndicator; return dropIndicator;
} }

View File

@@ -61,7 +61,6 @@ export class AffineDocRemoteSelectionWidget extends WidgetComponent {
return ( return (
matchFlavours(block, [ matchFlavours(block, [
'affine:code', 'affine:code',
// @ts-expect-error FIXME: fix after database model moved to affine-model
'affine:database', 'affine:database',
'affine:image', 'affine:image',
'affine:attachment', 'affine:attachment',

View File

@@ -62,6 +62,7 @@ export const PackageList = [
'blocksuite/affine/components', 'blocksuite/affine/components',
'blocksuite/affine/model', 'blocksuite/affine/model',
'blocksuite/affine/shared', 'blocksuite/affine/shared',
'blocksuite/affine/widget-drag-handle',
'blocksuite/framework/block-std', 'blocksuite/framework/block-std',
'blocksuite/affine/data-view', 'blocksuite/affine/data-view',
'blocksuite/framework/global', 'blocksuite/framework/global',

View File

@@ -3338,6 +3338,7 @@ __metadata:
"@blocksuite/affine-components": "workspace:*" "@blocksuite/affine-components": "workspace:*"
"@blocksuite/affine-model": "workspace:*" "@blocksuite/affine-model": "workspace:*"
"@blocksuite/affine-shared": "workspace:*" "@blocksuite/affine-shared": "workspace:*"
"@blocksuite/affine-widget-drag-handle": "workspace:*"
"@blocksuite/block-std": "workspace:*" "@blocksuite/block-std": "workspace:*"
"@blocksuite/data-view": "workspace:*" "@blocksuite/data-view": "workspace:*"
"@blocksuite/global": "workspace:*" "@blocksuite/global": "workspace:*"