From 7daeccca468314eacf54900bba0e4dc3ef21f2b2 Mon Sep 17 00:00:00 2001 From: Dmytro Soldatov Date: Mon, 2 Dec 2024 15:25:13 +0200 Subject: [PATCH] feat: Add paste functionality to the input component --- src/Input.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Input.ts b/src/Input.ts index 9f54733..615088b 100644 --- a/src/Input.ts +++ b/src/Input.ts @@ -169,7 +169,11 @@ export class Input extends Container { const key = e.key; - if (key === 'Backspace') + if (key === 'v' && (e.ctrlKey || e.metaKey)) + { + this.pasteContent(); + + } else if (key === 'Backspace') { this._delete(); } @@ -730,4 +734,11 @@ export class Input extends Container this.inputMask.position.set(this.paddingLeft, this.paddingTop); } + + protected pasteContent() { + navigator.clipboard.readText().then((text) => { + this.value = text; + this.onChange.emit(this.value); + }); + } }