mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +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:
@@ -1,23 +1,10 @@
|
||||
import { BlockSelection, type Command } from '@blocksuite/block-std';
|
||||
import { BlockSelection } from '@blocksuite/block-std';
|
||||
|
||||
export const getBlockSelectionsCommand: Command<
|
||||
never,
|
||||
'currentBlockSelections'
|
||||
> = (ctx, next) => {
|
||||
import type { GetSelectionCommand } from './types';
|
||||
|
||||
export const getBlockSelectionsCommand: GetSelectionCommand = (ctx, next) => {
|
||||
const currentBlockSelections = ctx.std.selection.filter(BlockSelection);
|
||||
if (currentBlockSelections.length === 0) return;
|
||||
|
||||
next({ currentBlockSelections });
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface CommandContext {
|
||||
currentBlockSelections?: BlockSelection[];
|
||||
}
|
||||
|
||||
interface Commands {
|
||||
getBlockSelections: typeof getBlockSelectionsCommand;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user