mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
24 lines
496 B
TypeScript
24 lines
496 B
TypeScript
import {
|
|
type BlockComponent,
|
|
type Command,
|
|
TextSelection,
|
|
} from '@blocksuite/block-std';
|
|
|
|
export const focusBlockStart: Command<{
|
|
focusBlock?: BlockComponent;
|
|
}> = (ctx, next) => {
|
|
const { focusBlock, std } = ctx;
|
|
if (!focusBlock || !focusBlock.model.text) return;
|
|
|
|
const { selection } = std;
|
|
|
|
selection.setGroup('note', [
|
|
selection.create(TextSelection, {
|
|
from: { blockId: focusBlock.blockId, index: 0, length: 0 },
|
|
to: null,
|
|
}),
|
|
]);
|
|
|
|
return next();
|
|
};
|