2019-06-23 03:35:23 -07:00
|
|
|
<template>
|
|
|
|
<div v-if="dialogVisible">
|
2022-01-07 13:02:21 -08:00
|
|
|
<el-dialog :visible="dialogVisible" append-to-body width="80%" :title="`${$locale.baseText('textEdit.edit')} ${$locale.nodeText().inputLabelDisplayName(parameter, path)}`" :before-close="closeDialog">
|
2019-06-23 03:35:23 -07:00
|
|
|
|
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 v-model="tempValue" type="textarea" ref="inputField" :value="value" :placeholder="$locale.nodeText().placeholder(parameter, path)" :readOnly="isReadOnly" @change="valueChanged" :rows="15" />
|
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">
|
|
|
|
import Vue from 'vue';
|
|
|
|
|
2021-12-07 07:14:40 -08:00
|
|
|
export default Vue.extend({
|
2019-06-23 03:35:23 -07:00
|
|
|
name: 'TextEdit',
|
|
|
|
props: [
|
|
|
|
'dialogVisible',
|
|
|
|
'parameter',
|
2022-01-07 13:02:21 -08:00
|
|
|
'path',
|
2019-06-23 03:35:23 -07:00
|
|
|
'value',
|
2022-10-24 11:17:25 -07:00
|
|
|
'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
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
valueChanged (value: string) {
|
|
|
|
this.$emit('valueChanged', value);
|
|
|
|
},
|
|
|
|
|
2022-04-14 00:30:31 -07:00
|
|
|
onKeyDownEsc () {
|
|
|
|
// Resetting input value when closing the dialog, required when closing it using the `Esc` key
|
|
|
|
this.tempValue = this.value;
|
|
|
|
|
|
|
|
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;
|
|
|
|
},
|
|
|
|
},
|
2020-01-08 11:25:35 -08:00
|
|
|
mounted () {
|
|
|
|
this.tempValue = this.value as string;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
watch: {
|
|
|
|
dialogVisible () {
|
|
|
|
if (this.dialogVisible === true) {
|
|
|
|
Vue.nextTick(() => {
|
|
|
|
(this.$refs.inputField as HTMLInputElement).focus();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
2020-01-03 19:48:55 -08:00
|
|
|
value () {
|
|
|
|
this.tempValue = this.value as string;
|
|
|
|
},
|
2019-06-23 03:35:23 -07:00
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|