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 {
if (this._clipboard.length === 0) {
$notify($msg('CLIPBOARD_IS_EMPTY'));
return;
// If the no selection has been made, update with the text on the clipboard.
if (this._clipboard.length !== 0) {
this._actionDispatcher.addTopics(this._clipboard, null);
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(),
);
});
}
}
this._actionDispatcher.addTopics(this._clipboard, null);
this._clipboard = [];
}
getModel(): DesignerModel {