mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
fc863e484c
Closes: [BS-2217](https://linear.app/affine-design/issue/BS-2217/remove-global-types-in-selection)
24 lines
535 B
TypeScript
24 lines
535 B
TypeScript
import { type Command, TextSelection } from '@blocksuite/block-std';
|
|
|
|
export const getTextSelectionCommand: Command<never, 'currentTextSelection'> = (
|
|
ctx,
|
|
next
|
|
) => {
|
|
const currentTextSelection = ctx.std.selection.find(TextSelection);
|
|
if (!currentTextSelection) return;
|
|
|
|
next({ currentTextSelection });
|
|
};
|
|
|
|
declare global {
|
|
namespace BlockSuite {
|
|
interface CommandContext {
|
|
currentTextSelection?: TextSelection;
|
|
}
|
|
|
|
interface Commands {
|
|
getTextSelection: typeof getTextSelectionCommand;
|
|
}
|
|
}
|
|
}
|