fix(editor): focus comment editor after click its bottom area (#13060)
#### PR Dependency Tree * **PR #13060** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved the comment editor's focus behavior to place the cursor at the end of the content when clicking inside the editor. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { LitDocEditor, type PageEditor } from '@affine/core/blocksuite/editors';
|
import { LitDocEditor, type PageEditor } from '@affine/core/blocksuite/editors';
|
||||||
import { SnapshotHelper } from '@affine/core/modules/comment/services/snapshot-helper';
|
import { SnapshotHelper } from '@affine/core/modules/comment/services/snapshot-helper';
|
||||||
import type { RichText } from '@blocksuite/affine/rich-text';
|
import { focusTextModel, type RichText } from '@blocksuite/affine/rich-text';
|
||||||
import { ViewportElementExtension } from '@blocksuite/affine/shared/services';
|
import { ViewportElementExtension } from '@blocksuite/affine/shared/services';
|
||||||
import { type DocSnapshot, Store } from '@blocksuite/affine/store';
|
import { type DocSnapshot, Store } from '@blocksuite/affine/store';
|
||||||
import { ArrowUpBigIcon } from '@blocksuite/icons/rc';
|
import { ArrowUpBigIcon } from '@blocksuite/icons/rc';
|
||||||
@@ -175,7 +175,10 @@ export const CommentEditor = forwardRef<CommentEditorRef, CommentEditorProps>(
|
|||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (editorRef.current) {
|
if (editorRef.current) {
|
||||||
editorRef.current.focus();
|
const lastChild = editorRef.current.std.store.root?.lastChild();
|
||||||
|
if (lastChild) {
|
||||||
|
focusTextModel(editorRef.current.std, lastChild.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[editorRef]
|
[editorRef]
|
||||||
|
|||||||
Reference in New Issue
Block a user