fix(core): some ux issues related to comments (#13057)

fix AF-2713

#### PR Dependency Tree


* **PR #13057** 👈

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

* **New Features**
* Added support for submitting comments by pressing Enter (without
Shift) in the comment editor.

* **Improvements**
* Improved comment highlight handling with smoother updates and reduced
unnecessary scrolling in the comment sidebar.
* Enhanced editor focus behavior to support highlighting comments
directly when a comment ID is provided, with automatic comment panel
activation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Peng Xiao
2025-07-07 11:23:24 +08:00
committed by GitHub
parent 2df4a60c44
commit 0d2fbaf3ea
3 changed files with 38 additions and 5 deletions
@@ -17,6 +17,8 @@ import { Entity, LiveData } from '@toeverything/infra';
import { defaults, isEqual, omit } from 'lodash-es';
import { skip } from 'rxjs';
import { CommentPanelService } from '../../comment/services/comment-panel-service';
import { DocCommentManagerService } from '../../comment/services/doc-comment-manager';
import type { DocService } from '../../doc';
import { paramsParseOptions, preprocessParams } from '../../navigation/utils';
import type { WorkbenchView } from '../../workbench';
@@ -233,6 +235,18 @@ export class Editor extends Entity {
}
// Workaround: clear selection to avoid comment editor flickering
selection?.clear();
// highlight comment
setTimeout(() => {
const commentManager = this.framework.get(DocCommentManagerService);
const commentPanelService = this.framework.get(CommentPanelService);
const commentEntity = commentManager.get(this.doc.id);
commentPanelService.openCommentPanel();
commentEntity.obj.highlightComment(commentId);
commentEntity.release();
}, 0);
// do not highlight block
highlight = false;
}