mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.4 KiB
82 lines
1.4 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { computed } from '@vue/reactivity'
|
||
2 years ago
|
import { inject, onMounted } from 'vue'
|
||
2 years ago
|
|
||
2 years ago
|
const { modelValue: value } = defineProps<{ modelValue: any }>()
|
||
2 years ago
|
|
||
2 years ago
|
const emit = defineEmits(['update:modelValue'])
|
||
2 years ago
|
const editEnabled = inject<boolean>('editEnabled')
|
||
2 years ago
|
|
||
2 years ago
|
const root = ref<HTMLInputElement>()
|
||
2 years ago
|
|
||
|
const localState = computed({
|
||
|
get() {
|
||
2 years ago
|
return value
|
||
|
},
|
||
|
set(val) {
|
||
|
emit('update:modelValue', val)
|
||
|
},
|
||
|
})
|
||
2 years ago
|
|
||
|
onMounted(() => {
|
||
|
root.value?.focus()
|
||
2 years ago
|
})
|
||
|
/* export default {
|
||
2 years ago
|
name: 'TextAreaCell',
|
||
|
props: {
|
||
|
value: String,
|
||
|
},
|
||
|
computed: {
|
||
|
localState: {
|
||
|
get() {
|
||
|
return this.value
|
||
|
},
|
||
|
set(val) {
|
||
|
this.$emit('input', val)
|
||
|
},
|
||
|
},
|
||
|
parentListeners() {
|
||
|
const $listeners = {}
|
||
|
|
||
|
if (this.$listeners.blur) {
|
||
|
$listeners.blur = this.$listeners.blur
|
||
|
}
|
||
|
if (this.$listeners.focus) {
|
||
|
$listeners.focus = this.$listeners.focus
|
||
|
}
|
||
|
|
||
|
return $listeners
|
||
|
},
|
||
|
},
|
||
|
created() {
|
||
|
this.localState = this.value
|
||
|
},
|
||
|
mounted() {
|
||
|
this.$refs.textarea && this.$refs.textarea.focus()
|
||
|
},
|
||
2 years ago
|
} */
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<textarea
|
||
|
v-if="editEnabled"
|
||
|
ref="root"
|
||
|
v-model="localState"
|
||
|
rows="4"
|
||
|
v-on="parentListeners"
|
||
|
@keydown.alt.enter.stop
|
||
|
@keydown.shift.enter.stop
|
||
|
/>
|
||
|
<span v-else>{{ localState }}</span>
|
||
2 years ago
|
</template>
|
||
|
|
||
|
<style scoped>
|
||
|
input,
|
||
|
textarea {
|
||
|
width: 100%;
|
||
|
min-height: 60px;
|
||
|
height: 100%;
|
||
|
color: var(--v-textColor-base);
|
||
|
}
|
||
|
</style>
|