mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
fix(editor): peekable conditions for edgeless note block (#12969)
fix AF-2704 #### PR Dependency Tree * **PR #12969** 👈 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 * **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. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user