mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 13:01:59 +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) {
|
private async _copyHandler(e: ClipboardEvent) {
|
||||||
if (!this._utils.shouldHandlerContinue(e)) {
|
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._editor.getHooks().onCopy(e);
|
this._editor.getHooks().onCopy(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _cutHandler(e: ClipboardEvent) {
|
private async _cutHandler(e: ClipboardEvent) {
|
||||||
if (!this._utils.shouldHandlerContinue(e)) {
|
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._editor.getHooks().onCut(e);
|
this._editor.getHooks().onCut(e);
|
||||||
}
|
}
|
||||||
private _pasteHandler(e: ClipboardEvent) {
|
private async _pasteHandler(e: ClipboardEvent) {
|
||||||
if (!this._utils.shouldHandlerContinue(e)) {
|
if (!(await this._utils.shouldHandlerContinue(e))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export class ClipboardUtils {
|
|||||||
this._editor = editor;
|
this._editor = editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldHandlerContinue(event: ClipboardEvent) {
|
async shouldHandlerContinue(event: ClipboardEvent) {
|
||||||
const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
|
const filterNodes = ['INPUT', 'SELECT', 'TEXTAREA'];
|
||||||
|
|
||||||
if (event.defaultPrevented) {
|
if (event.defaultPrevented) {
|
||||||
@ -20,8 +20,12 @@ export class ClipboardUtils {
|
|||||||
if (filterNodes.includes((event.target as HTMLElement)?.tagName)) {
|
if (filterNodes.includes((event.target as HTMLElement)?.tagName)) {
|
||||||
return false;
|
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) {
|
async getClipInfoOfBlockById(blockId: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user