Skip to content

Commit

Permalink
Add paste event to AddressInput to intercept request links
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed May 29, 2020
1 parent 4ae0e0a commit 7ac7ec4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/AddressInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ export default class AddressInput extends Vue {
}
private _onPaste(e: ClipboardEvent) {
const clipboardData = e.clipboardData;
const pastedData = clipboardData ? clipboardData.getData('text/plain') : '';
this.$emit('paste', e, pastedData);
inputFormatOnPaste(e, this.$refs.textarea, AddressInput._parse, AddressInput._format, this._afterChange);
}
Expand Down
6 changes: 5 additions & 1 deletion src/stories/index.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,12 @@ storiesOf('Components', module)
lastValidAddress: null,
};
},
methods: {
input: action('input'),
paste: action('paste'),
},
template: `<div>
<AddressInput v-model="address" @address="lastValidAddress = $event" />
<AddressInput v-model="address" @input="input" @address="lastValidAddress = $event" @paste="paste" />
<div>Current address: {{ address }}</div>
<div>valid?: {{ address === lastValidAddress }}</div>
</div>`,
Expand Down

0 comments on commit 7ac7ec4

Please sign in to comment.