fix: disable multiline on EnvInput
This commit is contained in:
@@ -1,8 +1,3 @@
|
|||||||
<!--
|
|
||||||
This code is a complete adaptation of the work done here
|
|
||||||
https://github.com/SyedWasiHaider/vue-highlightable-input
|
|
||||||
-->
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="flex flex-1 items-center flex-shrink-0 whitespace-nowrap overflow-auto hide-scrollbar"
|
class="flex flex-1 items-center flex-shrink-0 whitespace-nowrap overflow-auto hide-scrollbar"
|
||||||
@@ -66,15 +61,17 @@ const editor = ref<any | null>(null)
|
|||||||
watch(
|
watch(
|
||||||
() => props.value,
|
() => props.value,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (cachedValue.value !== newVal) {
|
const singleLinedText = newVal.replaceAll("\n", "")
|
||||||
cachedValue.value = newVal
|
|
||||||
|
if (cachedValue.value !== singleLinedText) {
|
||||||
|
cachedValue.value = singleLinedText
|
||||||
|
|
||||||
view.value?.dispatch({
|
view.value?.dispatch({
|
||||||
filter: false,
|
filter: false,
|
||||||
changes: {
|
changes: {
|
||||||
from: 0,
|
from: 0,
|
||||||
to: view.value.state.doc.length,
|
to: view.value.state.doc.length,
|
||||||
insert: newVal,
|
insert: singleLinedText,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -107,7 +104,10 @@ const initView = (el: any) => {
|
|||||||
.toJSON()
|
.toJSON()
|
||||||
.join(update.state.lineBreak)
|
.join(update.state.lineBreak)
|
||||||
|
|
||||||
const value = clone(cachedValue.value)
|
// We do not update the cache directly in this case (to trigger value watcher to dispatch)
|
||||||
|
// So, we desync cachedValue a bit so we can trigger updates
|
||||||
|
const value = clone(cachedValue.value).replaceAll("\n", "")
|
||||||
|
|
||||||
emit("input", value)
|
emit("input", value)
|
||||||
emit("change", value)
|
emit("change", value)
|
||||||
if (pasted) {
|
if (pasted) {
|
||||||
|
|||||||
Reference in New Issue
Block a user