refactor(editor): remove dependency of command global types (#9903)

Closes: [BS-2216](https://linear.app/affine-design/issue/BS-2216/remove-global-types-in-command)
This commit is contained in:
Saul-Mirone
2025-01-27 12:28:46 +00:00
parent 4b549e0484
commit 17bf75e843
170 changed files with 1461 additions and 2124 deletions

View File

@@ -12,10 +12,6 @@ import { EmbedHtmlBlockComponent } from './embed-html-block';
import { EmbedHtmlFullscreenToolbar } from './embed-html-block/components/fullscreen-toolbar';
import { EmbedEdgelessHtmlBlockComponent } from './embed-html-block/embed-edgeless-html-block';
import { EmbedLinkedDocBlockComponent } from './embed-linked-doc-block';
import type {
InsertedLinkType,
insertEmbedLinkedDocCommand,
} from './embed-linked-doc-block/commands/insert-embed-linked-doc';
import { EmbedEdgelessLinkedDocBlockComponent } from './embed-linked-doc-block/embed-edgeless-linked-doc-block';
import {
EmbedLoomBlockComponent,
@@ -119,12 +115,5 @@ declare global {
'affine:embed-loom': EmbedLoomBlockService;
'affine:embed-youtube': EmbedYoutubeBlockService;
}
interface CommandContext {
insertedLinkType?: Promise<InsertedLinkType>;
}
interface Commands {
insertEmbedLinkedDoc: typeof insertEmbedLinkedDocCommand;
}
}
}

View File

@@ -1,9 +1 @@
import type { BlockCommands } from '@blocksuite/block-std';
import { insertEmbedLinkedDocCommand } from './insert-embed-linked-doc.js';
export const commands: BlockCommands = {
insertEmbedLinkedDoc: insertEmbedLinkedDocCommand,
};
export type { InsertedLinkType } from './insert-embed-linked-doc';
export * from './insert-embed-linked-doc';

View File

@@ -7,14 +7,10 @@ export type InsertedLinkType = {
flavour?: 'affine:bookmark' | 'affine:embed-linked-doc';
} | null;
export const insertEmbedLinkedDocCommand: Command<
never,
'insertedLinkType',
{
docId: string;
params?: ReferenceParams;
}
> = (ctx, next) => {
export const insertEmbedLinkedDocCommand: Command<{
docId: string;
params?: ReferenceParams;
}> = (ctx, next) => {
const { docId, params, std } = ctx;
const flavour = 'affine:embed-linked-doc';
const targetStyle: EmbedCardStyle = 'vertical';

View File

@@ -1,4 +1,7 @@
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
import {
EdgelessCRUDIdentifier,
reassociateConnectorsCommand,
} from '@blocksuite/affine-block-surface';
import {
EMBED_CARD_HEIGHT,
EMBED_CARD_WIDTH,
@@ -51,7 +54,7 @@ export class EmbedEdgelessLinkedDocBlockComponent extends toEdgelessEmbedBlock(
surface
);
this.std.command.exec('reassociateConnectors', {
this.std.command.exec(reassociateConnectorsCommand, {
oldId: id,
newId,
});

View File

@@ -1,12 +1,10 @@
import { BlockViewExtension, CommandExtension } from '@blocksuite/block-std';
import { BlockViewExtension } from '@blocksuite/block-std';
import type { ExtensionType } from '@blocksuite/store';
import { literal } from 'lit/static-html.js';
import { EmbedLinkedDocBlockAdapterExtensions } from './adapters/extension.js';
import { commands } from './commands/index.js';
export const EmbedLinkedDocBlockSpec: ExtensionType[] = [
CommandExtension(commands),
BlockViewExtension('affine:embed-linked-doc', model => {
return model.parent?.flavour === 'affine:surface'
? literal`affine-embed-edgeless-linked-doc-block`

View File

@@ -1,4 +1,4 @@
export * from './adapters';
export type { InsertedLinkType } from './commands';
export * from './commands';
export * from './embed-linked-doc-block';
export * from './embed-linked-doc-spec';

View File

@@ -1,4 +1,7 @@
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
import {
EdgelessCRUDIdentifier,
reassociateConnectorsCommand,
} from '@blocksuite/affine-block-surface';
import type { AliasInfo } from '@blocksuite/affine-model';
import {
EMBED_CARD_HEIGHT,
@@ -144,7 +147,7 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(
surface
);
this.std.command.exec('reassociateConnectors', {
this.std.command.exec(reassociateConnectorsCommand, {
oldId: id,
newId,
});