fix(editor): block selection delete conflict with native selection (#9340)
Closes: [BS-2228](https://linear.app/affine-design/issue/BS-2228/[bug]-选区删除拖拽失灵)
This commit is contained in:
@@ -5,12 +5,17 @@ import {
|
|||||||
promptDocTitle,
|
promptDocTitle,
|
||||||
} from '@blocksuite/affine-block-embed';
|
} from '@blocksuite/affine-block-embed';
|
||||||
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
import { matchFlavours } from '@blocksuite/affine-shared/utils';
|
||||||
import type { BlockComponent, BlockSelection } from '@blocksuite/block-std';
|
import type {
|
||||||
|
BlockComponent,
|
||||||
|
BlockSelection,
|
||||||
|
UIEventHandler,
|
||||||
|
} from '@blocksuite/block-std';
|
||||||
import { IS_MAC, IS_WINDOWS } from '@blocksuite/global/env';
|
import { IS_MAC, IS_WINDOWS } from '@blocksuite/global/env';
|
||||||
import { assertExists } from '@blocksuite/global/utils';
|
import { assertExists } from '@blocksuite/global/utils';
|
||||||
|
|
||||||
export class PageKeyboardManager {
|
export class PageKeyboardManager {
|
||||||
private readonly _handleDelete = () => {
|
private readonly _handleDelete: UIEventHandler = ctx => {
|
||||||
|
const event = ctx.get('keyboardState').raw;
|
||||||
const blockSelections = this._currentSelection.filter(sel =>
|
const blockSelections = this._currentSelection.filter(sel =>
|
||||||
sel.is('block')
|
sel.is('block')
|
||||||
);
|
);
|
||||||
@@ -18,6 +23,7 @@ export class PageKeyboardManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
this._doc.transact(() => {
|
this._doc.transact(() => {
|
||||||
const selection = this._replaceBlocksBySelection(
|
const selection = this._replaceBlocksBySelection(
|
||||||
blockSelections,
|
blockSelections,
|
||||||
@@ -79,9 +85,9 @@ export class PageKeyboardManager {
|
|||||||
'Mod-Backspace': () => true,
|
'Mod-Backspace': () => true,
|
||||||
Backspace: this._handleDelete,
|
Backspace: this._handleDelete,
|
||||||
Delete: this._handleDelete,
|
Delete: this._handleDelete,
|
||||||
'Control-d': () => {
|
'Control-d': ctx => {
|
||||||
if (!IS_MAC) return;
|
if (!IS_MAC) return;
|
||||||
this._handleDelete();
|
this._handleDelete(ctx);
|
||||||
},
|
},
|
||||||
'Mod-Shift-l': () => {
|
'Mod-Shift-l': () => {
|
||||||
this._createEmbedBlock();
|
this._createEmbedBlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user