From 49dfa2c2aa1806c780a4ed94480b3553626fd54e Mon Sep 17 00:00:00 2001 From: artoscinote <85488244+artoscinote@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:44:35 +0200 Subject: [PATCH] Fix multiline paste on windows [SCI-6960] (#4267) --- app/javascript/vue/shared/inline_edit.vue | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/javascript/vue/shared/inline_edit.vue b/app/javascript/vue/shared/inline_edit.vue index 20fda3ea7..057e1c2d4 100644 --- a/app/javascript/vue/shared/inline_edit.vue +++ b/app/javascript/vue/shared/inline_edit.vue @@ -125,13 +125,13 @@ }, handlePaste(e) { if (!this.multilinePaste) return; - e.clipboardData.items[0].getAsString((data) => { - let lines = data.split(/[\n\r]/); - if (lines.length > 1) { - this.newValue = lines[0]; - this.$emit('multilinePaste', lines); - } - }) + let lines = (e.originalEvent || e).clipboardData.getData('text/plain').split(/[\n\r]/); + lines = lines.filter((l) => l).map((l) => l.trim()); + + if (lines.length > 1) { + this.newValue = lines[0]; + this.$emit('multilinePaste', lines); + } }, handleInput() { this.newValue = this.newValue.replace(/^[\n\r]+|[\n\r]+$/g, ''); @@ -148,6 +148,8 @@ } }, resize() { + if (!this.$refs.input) return; + this.$refs.input.style.height = "auto"; this.$refs.input.style.height = (this.$refs.input.scrollHeight) + "px"; },