mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-09 21:25:45 +08:00
fix(core): editor blur unexpectedly when clicking blank area (#10501)
### Before https://github.com/user-attachments/assets/3c4b20e1-6d89-4dc7-a51f-04b6e9a89486 ### After https://github.com/user-attachments/assets/86b93403-597e-4dbb-ab65-90908342c230
This commit is contained in:
@@ -4,14 +4,23 @@ import {
|
||||
TextSelection,
|
||||
} from '@blocksuite/block-std';
|
||||
|
||||
/**
|
||||
* Focus the end of the block
|
||||
* @param focusBlock - The block to focus
|
||||
* @param force - If set to true, the selection will be cleared.
|
||||
* It is useful when the selection is same.
|
||||
*/
|
||||
export const focusBlockEnd: Command<{
|
||||
focusBlock?: BlockComponent;
|
||||
force?: boolean;
|
||||
}> = (ctx, next) => {
|
||||
const { focusBlock, std } = ctx;
|
||||
const { focusBlock, force, std } = ctx;
|
||||
if (!focusBlock || !focusBlock.model.text) return;
|
||||
|
||||
const { selection } = std;
|
||||
|
||||
if (force) selection.clear();
|
||||
|
||||
selection.setGroup('note', [
|
||||
selection.create(TextSelection, {
|
||||
from: {
|
||||
|
||||
Reference in New Issue
Block a user