Files
AFFiNE-Mirror/blocksuite/affine/block-note/src/commands/select-block.ts

23 lines
420 B
TypeScript

import {
type BlockComponent,
BlockSelection,
type Command,
} from '@blocksuite/block-std';
export const selectBlock: Command<{
focusBlock?: BlockComponent;
}> = (ctx, next) => {
const { focusBlock, std } = ctx;
if (!focusBlock) {
return;
}
const { selection } = std;
selection.setGroup('note', [
selection.create(BlockSelection, { blockId: focusBlock.blockId }),
]);
return next();
};