refactor(editor): highlight selected cards of TOC based on signal (#9807)

Close [BS-2314](https://linear.app/affine-design/issue/BS-2314/添加打开toc时,将note-block-高亮), [BS-1868](https://linear.app/affine-design/issue/BS-1868/toc-里面-note之间顺序可拖动性,在page和edgeless里面是不同的,这个是设计的行为么?)

This PR refactor the highlight logic of note cards of TOC panel:
- notes block selected in edgeless note
- notes block covered by text or block selection in page mode
- note cards selected in TOC for dragging

Other changes:
- remove not used codes
- add tests for highlight note cards
This commit is contained in:
L-Sun
2025-01-21 07:50:57 +00:00
parent 6470d83248
commit 7400cf225f
9 changed files with 218 additions and 162 deletions
@@ -245,10 +245,12 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
}
}
private _isFirstNote() {
private _isFirstVisibleNote() {
return (
this.model.parent?.children.find(child =>
matchFlavours(child, ['affine:note'])
this.model.parent?.children.find(
child =>
matchFlavours(child, ['affine:note']) &&
child.displayMode !== NoteDisplayMode.EdgelessOnly
) === this.model
);
}
@@ -509,7 +511,8 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
.editing=${this._editing}
></edgeless-note-mask>
${isCollapsable && (!this._isFirstNote() || !this._enablePageHeader)
${isCollapsable &&
(!this._isFirstVisibleNote() || !this._enablePageHeader)
? html`<div
class="${classMap({
'edgeless-note-collapse-button': true,