refactor(editor): move focus block commands to blocksuite/shared (#10671)

This commit is contained in:
L-Sun
2025-03-07 03:07:49 +00:00
parent 43ce609cba
commit 98d44d5be5
8 changed files with 13 additions and 10 deletions
@@ -0,0 +1,23 @@
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();
};