mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 08:53:27 +03:00
fix: can not copy text other than block
This commit is contained in:
parent
77e3513d6d
commit
6b6e70f02c
@ -72,21 +72,21 @@ export class ClipboardEventDispatcher {
|
||||
);
|
||||
}
|
||||
|
||||
private _copyHandler(e: ClipboardEvent) {
|
||||
if (!this._utils.shouldHandlerContinue(e)) {
|
||||
private async _copyHandler(e: ClipboardEvent) {
|
||||
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||
return;
|
||||
}
|
||||
this._editor.getHooks().onCopy(e);
|
||||
}
|
||||
|
||||
private _cutHandler(e: ClipboardEvent) {
|
||||
if (!this._utils.shouldHandlerContinue(e)) {
|
||||
private async _cutHandler(e: ClipboardEvent) {
|
||||
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||
return;
|
||||
}
|
||||
this._editor.getHooks().onCut(e);
|
||||
}
|
||||
private _pasteHandler(e: ClipboardEvent) {
|
||||
if (!this._utils.shouldHandlerContinue(e)) {
|
||||
private async _pasteHandler(e: ClipboardEvent) {
|
||||
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ export class ClipboardUtils {
|
||||
this._editor = editor;
|
||||
}
|
||||
|
||||
shouldHandlerContinue(event: ClipboardEvent) {
|
||||
async shouldHandlerContinue(event: ClipboardEvent) {
|
||||
const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
|
||||
|
||||
if (event.defaultPrevented) {
|
||||
@ -20,8 +20,12 @@ export class ClipboardUtils {
|
||||
if (filterNodes.includes((event.target as HTMLElement)?.tagName)) {
|
||||
return false;
|
||||
}
|
||||
const selectInfo = await this._editor.selectionManager.getSelectInfo();
|
||||
|
||||
return this._editor.selectionManager.currentSelectInfo.type !== 'None';
|
||||
return (
|
||||
selectInfo.blocks.length &&
|
||||
this._editor.selectionManager.currentSelectInfo.type !== 'None'
|
||||
);
|
||||
}
|
||||
|
||||
async getClipInfoOfBlockById(blockId: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user