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

@@ -1,15 +1,18 @@
import { getSurfaceBlock } from '@blocksuite/affine-block-surface';
import type { SurfaceRefProps } from '@blocksuite/affine-model';
import { matchFlavours } from '@blocksuite/affine-shared/utils';
import type { BlockCommands, Command } from '@blocksuite/block-std';
import type { Command } from '@blocksuite/block-std';
import type { BlockModel } from '@blocksuite/store';
export const insertSurfaceRefBlockCommand: Command<
'selectedModels',
'insertedSurfaceRefBlockId',
{
reference: string;
place: 'after' | 'before';
removeEmptyLine?: boolean;
selectedModels?: BlockModel[];
},
{
insertedSurfaceRefBlockId: string;
}
> = (ctx, next) => {
const { selectedModels, reference, place, removeEmptyLine, std } = ctx;
@@ -57,7 +60,3 @@ export const insertSurfaceRefBlockCommand: Command<
insertedSurfaceRefBlockId: result[0],
});
};
export const commands: BlockCommands = {
insertSurfaceRefBlock: insertSurfaceRefBlockCommand,
};

View File

@@ -1,4 +1,3 @@
import type { insertSurfaceRefBlockCommand } from './commands.js';
import { SurfaceRefGenericBlockPortal } from './portal/generic-block.js';
import { SurfaceRefNotePortal } from './portal/note.js';
import { SurfaceRefBlockComponent } from './surface-ref-block.js';
@@ -16,22 +15,3 @@ export function effects() {
);
customElements.define('surface-ref-note-portal', SurfaceRefNotePortal);
}
declare global {
namespace BlockSuite {
interface CommandContext {
insertedSurfaceRefBlockId?: string;
}
interface Commands {
/**
* insert a SurfaceRef block after or before the current block selection
* @param reference the reference block id. The block should be group or frame
* @param place where to insert the LaTeX block
* @param removeEmptyLine remove the current block if it is empty
* @returns the id of the inserted SurfaceRef block
*/
insertSurfaceRefBlock: typeof insertSurfaceRefBlockCommand;
}
}
}

View File

@@ -1,5 +1,4 @@
import '@blocksuite/affine-shared/commands';
export * from './commands.js';
export * from './surface-ref-block.js';
export * from './surface-ref-block-edgeless.js';
export {

View File

@@ -1,17 +1,13 @@
import {
BlockViewExtension,
CommandExtension,
FlavourExtension,
WidgetViewMapExtension,
} from '@blocksuite/block-std';
import type { ExtensionType } from '@blocksuite/store';
import { literal } from 'lit/static-html.js';
import { commands } from './commands.js';
export const PageSurfaceRefBlockSpec: ExtensionType[] = [
FlavourExtension('affine:surface-ref'),
CommandExtension(commands),
BlockViewExtension('affine:surface-ref', literal`affine-surface-ref`),
WidgetViewMapExtension('affine:surface-ref', {
surfaceToolbar: literal`affine-surface-ref-toolbar`,