mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-11 22:18:54 +08:00
fix(editor): adjust highlght style of comment and comment editor flickering (#13040)
### Before https://github.com/user-attachments/assets/6b98946b-d53c-42fb-b341-e09ba5204523 ### After https://github.com/user-attachments/assets/274341de-33c4-4fd3-b01b-a8f7c25bf2fe #### PR Dependency Tree * **PR #13040** 👈 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** * Improved comment highlighting: Clicking now cycles through and highlights individual comments one at a time instead of highlighting all at once. * Highlighting behavior is now more flexible, allowing highlighting to be toggled on or off in certain scenarios. * **Bug Fixes** * Prevented flickering in the comment editor when focusing on comments. * **Refactor** * Enhanced selection and anchoring logic to support the new highlight flag and updated types for improved clarity and control. <!-- end of auto-generated comment: release notes by coderabbit.ai --> #### PR Dependency Tree * **PR #13040** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal)
This commit is contained in:
@@ -12,6 +12,7 @@ import { styleMap } from 'lit/directives/style-map.js';
|
||||
type Anchor = {
|
||||
id: string;
|
||||
mode: DocMode;
|
||||
highlight: boolean;
|
||||
};
|
||||
|
||||
export const AFFINE_SCROLL_ANCHORING_WIDGET = 'affine-scroll-anchoring-widget';
|
||||
@@ -221,6 +222,7 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
|
||||
mode,
|
||||
blockIds: [bid],
|
||||
elementIds: [eid],
|
||||
highlight,
|
||||
} = highlighted;
|
||||
const id = mode === 'page' ? bid : eid || bid;
|
||||
if (!id) return;
|
||||
@@ -228,7 +230,7 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
|
||||
// Consumes highlight selection
|
||||
this.std.selection.clear(['highlight']);
|
||||
|
||||
this.anchor$.value = { mode, id };
|
||||
this.anchor$.value = { mode, id, highlight };
|
||||
this.#listened = true;
|
||||
})
|
||||
);
|
||||
@@ -241,7 +243,7 @@ export class AffineScrollAnchoringWidget extends WidgetComponent {
|
||||
|
||||
override render() {
|
||||
const anchor = this.anchor$.value;
|
||||
if (!anchor) return nothing;
|
||||
if (!anchor || !anchor.highlight) return nothing;
|
||||
|
||||
const { mode, id } = anchor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user