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.
37 lines
842 B
37 lines
842 B
3 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { VNodeRef } from '@vue/runtime-core'
|
||
2 years ago
|
import { computed, inject } from '#imports'
|
||
|
import { EditModeInj } from '~/context'
|
||
3 years ago
|
|
||
2 years ago
|
interface Props {
|
||
2 years ago
|
modelValue: string | null | undefined
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const { modelValue } = defineProps<Props>()
|
||
3 years ago
|
|
||
2 years ago
|
const emits = defineEmits(['update:modelValue'])
|
||
2 years ago
|
|
||
2 years ago
|
const editEnabled = inject(EditModeInj)
|
||
3 years ago
|
|
||
2 years ago
|
const vModel = computed({
|
||
|
get: () => modelValue ?? '',
|
||
|
set: (value) => emits('update:modelValue', value),
|
||
|
})
|
||
3 years ago
|
|
||
2 years ago
|
const focus: VNodeRef = (el) => (el as HTMLTextAreaElement)?.focus()
|
||
3 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<textarea
|
||
|
v-if="editEnabled"
|
||
|
:ref="focus"
|
||
|
v-model="vModel"
|
||
|
rows="4"
|
||
|
class="h-full w-full min-h-[60px] outline-none"
|
||
2 years ago
|
@blur="editEnabled = false"
|
||
2 years ago
|
@keydown.alt.enter.stop
|
||
|
@keydown.shift.enter.stop
|
||
|
/>
|
||
2 years ago
|
<span v-else>{{ vModel }}</span>
|
||
3 years ago
|
</template>
|