There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
feat(editor): is nothing selected command (#10721)
yoyoyohamapi04efca362e99
diff --git a/blocksuite/affine/shared/src/commands/selection/index.ts b/blocksuite/affine/shared/src/commands/selection/index.tsindex 4aaa0fd62c..99731e7959 100644--- a/blocksuite/affine/shared/src/commands/selection/index.ts+++ b/blocksuite/affine/shared/src/commands/selection/index.ts@@ -7,4 +7,5 @@ export {getSelectionRectsCommand,type SelectionRect,} from './get-selection-rects';-export { getTextSelectionCommand } from './get-text-selection';+export { getTextSelectionCommand } from './get-text-selection.js';+export { isNothingSelectedCommand } from './is-nothing-selected.js';diff --git a/blocksuite/affine/shared/src/commands/selection/is-nothing-selected.ts b/blocksuite/affine/shared/src/commands/selection/is-nothing-selected.tsnew file mode 100644index 0000000000..0c31c9da24--- /dev/null+++ b/blocksuite/affine/shared/src/commands/selection/is-nothing-selected.ts@@ -0,0 +1,28 @@+import {+ BlockSelection,+ type Command,+ TextSelection,+} from '@blocksuite/block-std';++import { ImageSelection } from '../../selection';++export const isNothingSelectedCommand: Command<+ {+ currentTextSelection?: TextSelection;+ currentImageSelections?: ImageSelection[];+ currentBlockSelections?: BlockSelection[];+ },+ { isNothingSelected: boolean }+> = (ctx, next) => {+ const textSelection =+ ctx.currentTextSelection || ctx.std.selection.find(TextSelection);+ const imageSelections =+ ctx.currentImageSelections || ctx.std.selection.filter(ImageSelection);+ const blockSelections =+ ctx.currentBlockSelections || ctx.std.selection.filter(BlockSelection);+ const isNothingSelected =+ !textSelection &&+ imageSelections.length === 0 &&+ blockSelections.length === 0;+ next({ isNothingSelected });+};