From 03aeb44dc95e3b0cf73c00e4810d8fdb8735591e Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Mon, 30 Jun 2025 15:13:02 +0800 Subject: [PATCH] fix(editor): peekable conditions for edgeless note block (#12969) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix AF-2704 #### PR Dependency Tree * **PR #12969** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **Bug Fixes** * Improved peek behavior to allow peeking inside note blocks, even when the hit target differs from the current model, as long as the current model is contained within the note block. This enhances usability when interacting with nested note blocks. --- .../affine/components/src/peek/peekable.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/blocksuite/affine/components/src/peek/peekable.ts b/blocksuite/affine/components/src/peek/peekable.ts index f4db6a765..c82adf618 100644 --- a/blocksuite/affine/components/src/peek/peekable.ts +++ b/blocksuite/affine/components/src/peek/peekable.ts @@ -1,7 +1,14 @@ +import { NoteBlockModel } from '@blocksuite/affine-model'; import { DocModeProvider } from '@blocksuite/affine-shared/services'; -import { isInsideEdgelessEditor } from '@blocksuite/affine-shared/utils'; +import { + isInsideEdgelessEditor, + matchModels, +} from '@blocksuite/affine-shared/utils'; import type { Constructor } from '@blocksuite/global/utils'; -import { GfxControllerIdentifier } from '@blocksuite/std/gfx'; +import { + GfxBlockElementModel, + GfxControllerIdentifier, +} from '@blocksuite/std/gfx'; import type { BlockModel } from '@blocksuite/store'; import type { LitElement, TemplateResult } from 'lit'; @@ -72,6 +79,20 @@ export const Peekable = ); if (hitTarget && hitTarget !== model) { + // Check if hitTarget is a GfxBlockElementModel (which extends BlockModel) + // and if it's a NoteBlockModel, then check if current model is inside it + if ( + hitTarget instanceof GfxBlockElementModel && + matchModels(hitTarget, [NoteBlockModel]) + ) { + let curModel: BlockModel | null = model; + while (curModel) { + if (curModel === hitTarget) { + return true; // Model is inside the NoteBlockModel, allow peek + } + curModel = curModel.parent; + } + } return false; }