Browse Source

fix: Fixed rich cell value sync when rich modal is open and show scrollbar in rich cell only when on hover

pull/7046/head
Muhammed Mustafa 10 months ago
parent
commit
9379dfab0f
  1. 20
      packages/nc-gui/components/cell/RichText.vue
  2. 13
      packages/nc-gui/components/cell/TextArea.vue

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

@ -12,6 +12,7 @@ import { Link } from '@/helpers/dbTiptapExtensions/links'
const props = defineProps<{ const props = defineProps<{
value?: string | null value?: string | null
readonly?: boolean readonly?: boolean
syncValueChange?: boolean
}>() }>()
const emits = defineEmits(['update:value']) const emits = defineEmits(['update:value'])
@ -54,6 +55,12 @@ const setEditorContent = (contentMd: any) => {
editor.value.chain().setContent(content).setTextSelection(selection.to).run() editor.value.chain().setContent(content).setTextSelection(selection.to).run()
} }
if (props.syncValueChange) {
watch(vModel, () => {
setEditorContent(vModel.value)
})
}
onMounted(() => { onMounted(() => {
setTimeout(() => { setTimeout(() => {
setEditorContent(vModel.value) setEditorContent(vModel.value)
@ -65,11 +72,22 @@ onMounted(() => {
<div class="h-full"> <div class="h-full">
<CellRichTextSelectedBubbleMenu v-if="editor" :editor="editor" /> <CellRichTextSelectedBubbleMenu v-if="editor" :editor="editor" />
<CellRichTextLinkOptions v-if="editor" :editor="editor" /> <CellRichTextLinkOptions v-if="editor" :editor="editor" />
<EditorContent :editor="editor" class="nc-textarea-rich w-full h-full nc-scrollbar-md" /> <EditorContent :editor="editor" class="nc-textarea-rich w-full h-full nc-text-rich-scroll nc-scrollbar-md" />
</div> </div>
</template> </template>
<style lang="scss"> <style lang="scss">
.nc-text-rich-scroll {
&::-webkit-scrollbar-thumb {
@apply bg-transparent;
}
}
.nc-text-rich-scroll:hover {
&::-webkit-scrollbar-thumb {
@apply bg-gray-200;
}
}
.nc-textarea-rich { .nc-textarea-rich {
.ProseMirror-focused { .ProseMirror-focused {
// remove all border // remove all border

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

@ -109,7 +109,7 @@ watch(editEnabled, () => {
maxHeight: `${height}px !important`, maxHeight: `${height}px !important`,
}" }"
> >
<CellRichText v-model:value="vModel" read-only /> <CellRichText v-model:value="vModel" sync-value-change readonly />
</div> </div>
<textarea <textarea
v-else-if="editEnabled && !isVisible" v-else-if="editEnabled && !isVisible"
@ -194,13 +194,20 @@ watch(editEnabled, () => {
@keydown.escape="isVisible = false" @keydown.escape="isVisible = false"
/> />
<CellRichText v-else v-model:value="vModel" class="ml-2 mt-2 max-h-70vh nc-scrollbar-md" /> <CellRichText
v-else
v-model:value="vModel"
class="ml-2 mt-2 nc-scrollbar-md"
:style="{
'max-height': 'calc(min(60vh, 100rem))',
}"
/>
</div> </div>
</template> </template>
</NcDropdown> </NcDropdown>
</template> </template>
<style> <style lang="scss">
textarea:focus { textarea:focus {
box-shadow: none; box-shadow: none;
} }

Loading…
Cancel
Save