Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#4479 - Macro: quick double paste operation from clipboard leads to invalid entities on canvas #4629

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { ketcherProvider } from 'application/utils';
import { DrawingEntitiesManager } from 'domain/entities/DrawingEntitiesManager';

export abstract class BaseMode {
private _pasteIsInProgress = false;

protected constructor(
public modeName: LayoutMode,
public previousMode: LayoutMode = 'flex-layout-mode',
Expand Down Expand Up @@ -139,8 +141,12 @@ export abstract class BaseMode {
async onPaste(event: ClipboardEvent) {
if (!this.checkIfTargetIsInput(event)) {
if (isClipboardAPIAvailable()) {
if (this._pasteIsInProgress) return;
this._pasteIsInProgress = true;
const clipboardData = await navigator.clipboard.read();
this.pasteFromClipboard(clipboardData);
this.pasteFromClipboard(clipboardData).finally(() => {
this._pasteIsInProgress = false;
});
} else {
const clipboardData = legacyPaste(event.clipboardData, ['text/plain']);
this.pasteFromClipboard(clipboardData);
Expand Down
Loading