Browse Source

fix(nc-gui): long text field alignment in grid cell

pull/7824/head
Ramesh Mane 9 months ago
parent
commit
20b2aaf49a
  1. 10
      packages/nc-gui/components/cell/RichText.vue
  2. 20
      packages/nc-gui/components/cell/TextArea.vue
  3. 9
      packages/nc-gui/components/nc/ErrorBoundary.vue

10
packages/nc-gui/components/cell/RichText.vue

@ -9,7 +9,7 @@ import Underline from '@tiptap/extension-underline'
import Placeholder from '@tiptap/extension-placeholder' import Placeholder from '@tiptap/extension-placeholder'
import { TaskItem } from '@/helpers/dbTiptapExtensions/task-item' import { TaskItem } from '@/helpers/dbTiptapExtensions/task-item'
import { Link } from '@/helpers/dbTiptapExtensions/links' import { Link } from '@/helpers/dbTiptapExtensions/links'
import { IsExpandedFormOpenInj, IsFormInj, ReadonlyInj, RowHeightInj } from '#imports' import { IsExpandedFormOpenInj, IsFormInj, IsGridInj, ReadonlyInj, RowHeightInj } from '#imports'
const props = defineProps<{ const props = defineProps<{
value?: string | null value?: string | null
@ -33,6 +33,8 @@ const readOnlyCell = inject(ReadonlyInj, ref(false))
const isForm = inject(IsFormInj, ref(false)) const isForm = inject(IsFormInj, ref(false))
const isGrid = inject(IsGridInj, ref(false))
const isFocused = ref(false) const isFocused = ref(false)
const turndownService = new TurndownService({}) const turndownService = new TurndownService({})
@ -222,6 +224,7 @@ useEventListener(
'nc-rich-text-embed flex flex-col pl-1 w-full': !fullMode, 'nc-rich-text-embed flex flex-col pl-1 w-full': !fullMode,
'readonly': readOnly, 'readonly': readOnly,
'nc-form-rich-text-field !p-0': isFormField, 'nc-form-rich-text-field !p-0': isFormField,
'nc-rich-text-grid': isGrid,
}" }"
:tabindex="readOnlyCell || isFormField ? -1 : 0" :tabindex="readOnlyCell || isFormField ? -1 : 0"
> >
@ -285,11 +288,12 @@ useEventListener(
.ProseMirror { .ProseMirror {
@apply !border-transparent max-h-full; @apply !border-transparent max-h-full;
} }
&:not(.nc-form-rich-text-field) { &:not(.nc-form-rich-text-field):not(.nc-rich-text-grid) {
.ProseMirror { .ProseMirror {
min-height: 8rem; min-height: 8rem;
} }
} }
&.nc-form-rich-text-field { &.nc-form-rich-text-field {
.ProseMirror { .ProseMirror {
padding: 0; padding: 0;
@ -346,7 +350,7 @@ useEventListener(
pointer-events: none; pointer-events: none;
} }
.ProseMirror { .ProseMirror {
@apply flex-grow pt-1 border-1 border-gray-200 rounded-lg; @apply flex-grow pt-1.5 border-1 border-gray-200 rounded-lg;
> * { > * {
@apply ml-1; @apply ml-1;

20
packages/nc-gui/components/cell/TextArea.vue

@ -203,7 +203,7 @@ watch(inputWrapperRef, () => {
<template> <template>
<div> <div>
<div <div
class="flex flex-row pt-0.5 w-full long-text-wrapper" class="flex flex-row w-full long-text-wrapper"
:class="{ :class="{
'min-h-10': rowHeight !== 1 || isExpandedFormOpen, 'min-h-10': rowHeight !== 1 || isExpandedFormOpen,
'min-h-9': rowHeight === 1 && !isExpandedFormOpen, 'min-h-9': rowHeight === 1 && !isExpandedFormOpen,
@ -213,6 +213,10 @@ watch(inputWrapperRef, () => {
<div <div
v-if="isRichMode" v-if="isRichMode"
class="w-full cursor-pointer nc-readonly-rich-text-wrapper" class="w-full cursor-pointer nc-readonly-rich-text-wrapper"
:class="{
'nc-readonly-rich-text-grid ': !isExpandedFormOpen && !isForm,
'nc-readonly-rich-text-sort-height': rowHeight === 1 && !isExpandedFormOpen && !isForm,
}"
:style="{ :style="{
maxHeight: isForm ? undefined : isExpandedFormOpen ? `${height}px` : `${25 * (rowHeight || 1)}px`, maxHeight: isForm ? undefined : isExpandedFormOpen ? `${height}px` : `${25 * (rowHeight || 1)}px`,
minHeight: isForm ? undefined : isExpandedFormOpen ? `${height}px` : `${25 * (rowHeight || 1)}px`, minHeight: isForm ? undefined : isExpandedFormOpen ? `${height}px` : `${25 * (rowHeight || 1)}px`,
@ -256,10 +260,9 @@ watch(inputWrapperRef, () => {
v-else-if="rowHeight" v-else-if="rowHeight"
:value="vModel" :value="vModel"
:lines="rowHeight" :lines="rowHeight"
class="mr-7 nc-text-area-clamped-text" class="nc-text-area-clamped-text my-auto"
:style="{ :style="{
'word-break': 'break-word', 'word-break': 'break-word',
'white-space': 'pre-line',
'max-height': `${25 * (rowHeight || 1)}px`, 'max-height': `${25 * (rowHeight || 1)}px`,
}" }"
@click="onTextClick" @click="onTextClick"
@ -350,6 +353,17 @@ textarea:focus {
.nc-longtext-scrollbar { .nc-longtext-scrollbar {
@apply scrollbar-thin scrollbar-thumb-gray-200 hover:scrollbar-thumb-gray-300 scrollbar-track-transparent; @apply scrollbar-thin scrollbar-thumb-gray-200 hover:scrollbar-thumb-gray-300 scrollbar-track-transparent;
} }
.nc-readonly-rich-text-wrapper {
&.nc-readonly-rich-text-grid {
:deep(.ProseMirror) {
@apply !pt-0;
}
&.nc-readonly-rich-text-sort-height {
@apply mt-2;
}
}
}
</style> </style>
<style lang="scss"> <style lang="scss">

9
packages/nc-gui/components/nc/ErrorBoundary.vue

@ -66,7 +66,14 @@ export default {
<template> <template>
<slot :key="key"></slot> <slot :key="key"></slot>
<slot name="error"> <slot name="error">
<NcModal v-if="error" v-model:visible="errModal" :class="{ active: errModal }" :centered="true" :closable="false" :footer="null"> <NcModal
v-if="error"
v-model:visible="errModal"
:class="{ active: errModal }"
:centered="true"
:closable="false"
:footer="null"
>
<div class="w-full flex flex-col gap-1"> <div class="w-full flex flex-col gap-1">
<h2 class="text-xl font-semibold">Oops! Something unexpected happened :/</h2> <h2 class="text-xl font-semibold">Oops! Something unexpected happened :/</h2>

Loading…
Cancel
Save