Add support for text copy and paste.

This commit is contained in:
Paulo Gustavo Veiga 2023-01-13 23:49:53 -08:00
parent ad30a9dd94
commit 2f6b681016

View File

@ -404,12 +404,21 @@ class Designer extends Events {
} }
pasteClipboard(): void { pasteClipboard(): void {
if (this._clipboard.length === 0) { // If the no selection has been made, update with the text on the clipboard.
$notify($msg('CLIPBOARD_IS_EMPTY')); if (this._clipboard.length !== 0) {
return;
}
this._actionDispatcher.addTopics(this._clipboard, null); this._actionDispatcher.addTopics(this._clipboard, null);
this._clipboard = []; this._clipboard = [];
} else {
const topics = this.getModel().filterSelectedTopics();
if (topics.length > 0) {
navigator.clipboard.readText().then((text) => {
this._actionDispatcher.changeTextToTopic(
topics.map((t) => t.getId()),
text.trim(),
);
});
}
}
} }
getModel(): DesignerModel { getModel(): DesignerModel {