mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 05:14:54 +00:00
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:
@@ -8,7 +8,11 @@ import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||
import { useI18n } from '@affine/i18n';
|
||||
import { track } from '@affine/track';
|
||||
import { GfxControllerIdentifier } from '@blocksuite/affine/block-std/gfx';
|
||||
import { matchFlavours, type NoteBlockModel } from '@blocksuite/affine/blocks';
|
||||
import {
|
||||
matchFlavours,
|
||||
type NoteBlockModel,
|
||||
NoteDisplayMode,
|
||||
} from '@blocksuite/affine/blocks';
|
||||
import { Bound } from '@blocksuite/affine/global/utils';
|
||||
import {
|
||||
ExpandFullIcon,
|
||||
@@ -160,12 +164,14 @@ export const EdgelessNoteHeader = ({ note }: { note: NoteBlockModel }) => {
|
||||
|
||||
if (!flags.enable_page_block_header) return null;
|
||||
|
||||
const isFirstNote =
|
||||
note.parent?.children.find(child =>
|
||||
matchFlavours(child, ['affine:note'])
|
||||
const isFirstVisibleNote =
|
||||
note.parent?.children.find(
|
||||
child =>
|
||||
matchFlavours(child, ['affine:note']) &&
|
||||
child.displayMode === NoteDisplayMode.DocAndEdgeless
|
||||
) === note;
|
||||
|
||||
if (!isFirstNote) return null;
|
||||
if (!isFirstVisibleNote) return null;
|
||||
|
||||
return (
|
||||
<div className={styles.header} data-testid="edgeless-page-block-header">
|
||||
|
||||
Reference in New Issue
Block a user