mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-19 02:51:47 +08:00
fix(editor): edgeless selected block is missing in the return of getSelectedBlockCommand (#11813)
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import type { BlockSelection, Command, TextSelection } from '@blocksuite/std';
|
||||
import type {
|
||||
BlockSelection,
|
||||
Command,
|
||||
SurfaceSelection,
|
||||
TextSelection,
|
||||
} from '@blocksuite/std';
|
||||
import { BlockComponent } from '@blocksuite/std';
|
||||
import type { RoleType } from '@blocksuite/store';
|
||||
|
||||
@@ -9,11 +14,13 @@ export const getSelectedBlocksCommand: Command<
|
||||
currentTextSelection?: TextSelection;
|
||||
currentBlockSelections?: BlockSelection[];
|
||||
currentImageSelections?: ImageSelection[];
|
||||
currentSurfaceSelection?: SurfaceSelection;
|
||||
textSelection?: TextSelection;
|
||||
blockSelections?: BlockSelection[];
|
||||
imageSelections?: ImageSelection[];
|
||||
surfaceSelection?: SurfaceSelection;
|
||||
filter?: (el: BlockComponent) => boolean;
|
||||
types?: Array<'image' | 'text' | 'block'>;
|
||||
types?: Array<'image' | 'text' | 'block' | 'surface'>;
|
||||
roles?: RoleType[];
|
||||
mode?: 'all' | 'flat' | 'highest';
|
||||
},
|
||||
@@ -22,7 +29,7 @@ export const getSelectedBlocksCommand: Command<
|
||||
}
|
||||
> = (ctx, next) => {
|
||||
const {
|
||||
types = ['block', 'text', 'image'],
|
||||
types = ['block', 'text', 'image', 'surface'],
|
||||
roles = ['content'],
|
||||
mode = 'flat',
|
||||
} = ctx;
|
||||
@@ -109,6 +116,15 @@ export const getSelectedBlocksCommand: Command<
|
||||
dirtyResult.push(...selectedBlocks);
|
||||
}
|
||||
|
||||
const surfaceSelection = ctx.surfaceSelection ?? ctx.currentSurfaceSelection;
|
||||
if (types.includes('surface') && surfaceSelection) {
|
||||
const viewStore = ctx.std.view;
|
||||
const selectedBlocks = surfaceSelection.elements
|
||||
.map(id => viewStore.getBlock(id))
|
||||
.filter(block => !!block);
|
||||
dirtyResult.push(...selectedBlocks);
|
||||
}
|
||||
|
||||
if (ctx.filter) {
|
||||
dirtyResult = dirtyResult.filter(ctx.filter);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user