From 02a4b8e48ce6a47bf74391bdc1f891d8d89cad3e Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Sat, 2 Mar 2024 07:32:37 +0000 Subject: [PATCH 01/41] feat(nc-gui): rich text setup in form field --- packages/nc-gui/assets/nc-icons/link.svg | 10 +- packages/nc-gui/components/cell/RichText.vue | 35 ++- .../cell/RichText/SelectedBubbleMenu.vue | 236 +++++++++--------- .../nc-gui/components/smartsheet/Form.vue | 28 ++- packages/nc-gui/utils/iconUtils.ts | 1 + 5 files changed, 182 insertions(+), 128 deletions(-) diff --git a/packages/nc-gui/assets/nc-icons/link.svg b/packages/nc-gui/assets/nc-icons/link.svg index 1207f4b97f..383121b0eb 100644 --- a/packages/nc-gui/assets/nc-icons/link.svg +++ b/packages/nc-gui/assets/nc-icons/link.svg @@ -1,4 +1,8 @@ - - - + + + \ No newline at end of file diff --git a/packages/nc-gui/components/cell/RichText.vue b/packages/nc-gui/components/cell/RichText.vue index b263004f00..097d43189e 100644 --- a/packages/nc-gui/components/cell/RichText.vue +++ b/packages/nc-gui/components/cell/RichText.vue @@ -16,6 +16,7 @@ const props = defineProps<{ syncValueChange?: boolean showMenu?: boolean fullMode?: boolean + isFormField?: boolean }>() const emits = defineEmits(['update:value']) @@ -126,6 +127,24 @@ const editor = useEditor({ editable: !props.readOnly, }) +watch(props, () => { + console.log('readonly node') + if (props.isFormField) { + if (props.readOnly) { + editor.value?.setEditable(false) + } else { + editor.value?.setEditable(true) + setTimeout(() => { + editor.value?.chain().focus().run() + }, 50) + } + } +}) + +watchEffect(() => { + console.log('read only ', props.readOnly) +}) + const setEditorContent = (contentMd: any, focusEndOfDoc?: boolean) => { if (!editor.value) return @@ -177,21 +196,22 @@ watch(editorDom, () => { 'flex flex-col flex-grow nc-rich-text-full': fullMode, 'nc-rich-text-embed flex flex-col pl-1 w-full': !fullMode, 'readonly': readOnly, + 'nc-form-rich-text-field !p-0': isFormField, }" :tabindex="readOnlyCell ? -1 : 0" >
- +
- + { !fullMode && readOnly && rowHeight && !isExpandedFormOpen && !isForm, }" /> +
+ +
@@ -223,7 +246,11 @@ watch(editorDom, () => { .nc-rich-text-embed { .ProseMirror { @apply !border-transparent max-h-full; - min-height: 8rem; + } + &:not(.nc-form-rich-text-field) { + .ProseMirror { + min-height: 8rem; + } } &.readonly { .nc-textarea-rich-editor { diff --git a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue index 51b939b264..b2f001b033 100644 --- a/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue +++ b/packages/nc-gui/components/cell/RichText/SelectedBubbleMenu.vue @@ -14,6 +14,7 @@ import MsFormatQuote from '~icons/material-symbols/format-quote' interface Props { editor: Editor embedMode?: boolean + isFormField?: boolean } const props = defineProps() @@ -83,9 +84,10 @@ const onToggleLink = () => { :class="{ 'embed-mode': embedMode, 'full-mode': !embedMode, + 'form-field-mode': isFormField, }" > - +