mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
@@ -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`
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user