2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="dialogVisible">
|
2022-01-07 13:02:21 -08:00
|
|
|
<el-dialog
|
2023-12-28 00:49:58 -08:00
|
|
|
:model-value="dialogVisible"
|
2022-01-07 13:02:21 -08:00
|
|
|
append-to-body
|
|
|
|
width="80%"
|
|
|
|
:title="`${$locale.baseText('textEdit.edit')} ${$locale
|
|
|
|
.nodeText()
|
|
|
|
.inputLabelDisplayName(parameter, path)}`"
|
|
|
|
:before-close="closeDialog"
|
|
|
|
>
|
2021-10-27 12:55:37 -07:00
|
|
|
<div class="ignore-key-press">
|
2022-01-07 13:02:21 -08:00
|
|
|
<n8n-input-label :label="$locale.nodeText().inputLabelDisplayName(parameter, path)">
|
2022-04-14 00:30:31 -07:00
|
|
|
<div @keydown.stop @keydown.esc="onKeyDownEsc()">
|
2022-10-24 11:17:25 -07:00
|
|
|
<n8n-input
|
2023-12-28 00:49:58 -08:00
|
|
|
ref="inputField"
|
2022-10-24 11:17:25 -07:00
|
|
|
v-model="tempValue"
|
|
|
|
type="textarea"
|
|
|
|
:placeholder="$locale.nodeText().placeholder(parameter, path)"
|
2023-12-28 00:49:58 -08:00
|
|
|
:read-only="isReadOnly"
|
2022-10-24 11:17:25 -07:00
|
|
|
:rows="15"
|
2024-03-26 06:22:57 -07:00
|
|
|
@update:model-value="valueChanged"
|
2022-10-24 11:17:25 -07:00
|
|
|
/>
|
2021-10-27 12:55:37 -07:00
|
|
|
</div>
|
|
|
|
</n8n-input-label>
|
2019-06-23 03:35:23 -07:00
|
|
|
</div>
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2023-04-21 08:51:08 -07:00
|
|
|
import { nextTick, defineComponent } from 'vue';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
2023-04-21 08:51:08 -07:00
|
|
|
export default defineComponent({
|
2019-06-23 03:35:23 -07:00
|
|
|
name: 'TextEdit',
|
2023-07-28 00:51:07 -07:00
|
|
|
props: ['dialogVisible', 'parameter', 'path', 'modelValue', 'isReadOnly'],
|
2019-06-23 03:35:23 -07:00
|
|
|
data() {
|
|
|
|
return {
|
2020-01-03 19:48:55 -08:00
|
|
|
tempValue: '', // el-input does not seem to work without v-model so add one
|
2019-06-23 03:35:23 -07:00
|
|
|
};
|
|
|
|
},
|
2023-12-28 00:49:58 -08:00
|
|
|
watch: {
|
|
|
|
async dialogVisible() {
|
|
|
|
if (this.dialogVisible === true) {
|
|
|
|
await nextTick();
|
|
|
|
(this.$refs.inputField as HTMLInputElement).focus();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
modelValue(value: string) {
|
|
|
|
this.tempValue = value;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.tempValue = this.modelValue as string;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
methods: {
|
|
|
|
valueChanged(value: string) {
|
2023-07-28 00:51:07 -07:00
|
|
|
this.$emit('update:modelValue', value);
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
|
2022-04-14 00:30:31 -07:00
|
|
|
onKeyDownEsc() {
|
|
|
|
// Resetting input value when closing the dialog, required when closing it using the `Esc` key
|
2023-07-28 00:51:07 -07:00
|
|
|
this.tempValue = this.modelValue;
|
2022-04-14 00:30:31 -07:00
|
|
|
|
|
|
|
this.closeDialog();
|
|
|
|
},
|
|
|
|
|
2019-06-23 03:35:23 -07:00
|
|
|
closeDialog() {
|
|
|
|
// Handle the close externally as the visible parameter is an external prop
|
|
|
|
// and is so not allowed to be changed here.
|
|
|
|
this.$emit('closeDialog');
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|