Skip to content

Commit

Permalink
feat: Add paste functionality to the input component
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberDex committed Dec 2, 2024
1 parent 07f1e64 commit 7daeccc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
});
}
}

0 comments on commit 7daeccc

Please sign in to comment.