Files
AFFiNE-Mirror/blocksuite/affine/shared/src/commands/selection/get-text-selection.ts
T

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;
}
}
}