Fix multiline paste on windows [SCI-6960] (#4267)

This commit is contained in:
artoscinote 2022-07-19 16:44:35 +02:00 committed by GitHub
parent fd4c6aa682
commit 49dfa2c2aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -125,13 +125,13 @@
}, },
handlePaste(e) { handlePaste(e) {
if (!this.multilinePaste) return; if (!this.multilinePaste) return;
e.clipboardData.items[0].getAsString((data) => { let lines = (e.originalEvent || e).clipboardData.getData('text/plain').split(/[\n\r]/);
let lines = data.split(/[\n\r]/); lines = lines.filter((l) => l).map((l) => l.trim());
if (lines.length > 1) {
this.newValue = lines[0]; if (lines.length > 1) {
this.$emit('multilinePaste', lines); this.newValue = lines[0];
} this.$emit('multilinePaste', lines);
}) }
}, },
handleInput() { handleInput() {
this.newValue = this.newValue.replace(/^[\n\r]+|[\n\r]+$/g, ''); this.newValue = this.newValue.replace(/^[\n\r]+|[\n\r]+$/g, '');
@ -148,6 +148,8 @@
} }
}, },
resize() { resize() {
if (!this.$refs.input) return;
this.$refs.input.style.height = "auto"; this.$refs.input.style.height = "auto";
this.$refs.input.style.height = (this.$refs.input.scrollHeight) + "px"; this.$refs.input.style.height = (this.$refs.input.scrollHeight) + "px";
}, },