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
@@ -24,10 +24,7 @@ import { updateXYWH } from '../utils/update-xywh.js';
/**
* Automatically arrange elements according to fixed row and column rules
*/
export const autoArrangeElementsCommand: Command<never, never, {}> = (
ctx,
next
) => {
export const autoArrangeElementsCommand: Command = (ctx, next) => {
const { updateBlock } = ctx.std.store;
const gfx = ctx.std.get(GfxControllerIdentifier);
@@ -42,10 +39,7 @@ export const autoArrangeElementsCommand: Command<never, never, {}> = (
/**
* Adjust the height of the selected element to a fixed value and arrange the elements
*/
export const autoResizeElementsCommand: Command<never, never, {}> = (
ctx,
next
) => {
export const autoResizeElementsCommand: Command = (ctx, next) => {
const { updateBlock } = ctx.std.store;
const gfx = ctx.std.get(GfxControllerIdentifier);
@@ -1,13 +1,5 @@
import type { BlockCommands } from '@blocksuite/block-std';
import {
export {
autoArrangeElementsCommand,
autoResizeElementsCommand,
} from './auto-align.js';
import { reassociateConnectorsCommand } from './reassociate-connectors.js';
export const commands: BlockCommands = {
reassociateConnectors: reassociateConnectorsCommand,
autoArrangeElements: autoArrangeElementsCommand,
autoResizeElements: autoResizeElementsCommand,
};
export { reassociateConnectorsCommand } from './reassociate-connectors.js';
@@ -6,11 +6,10 @@ import type { Command } from '@blocksuite/block-std';
* @param oldId - the old block id
* @param newId - the new block id
*/
export const reassociateConnectorsCommand: Command<
never,
never,
{ oldId: string; newId: string }
> = (ctx, next) => {
export const reassociateConnectorsCommand: Command<{
oldId: string;
newId: string;
}> = (ctx, next) => {
const { oldId, newId } = ctx;
const service = ctx.std.getService('affine:surface');
if (!oldId || !newId || !service) {