From 6075611c0f51ae52bee0e0b3e4742e15c2e5cc87 Mon Sep 17 00:00:00 2001 From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com> Date: Wed, 24 Apr 2024 09:57:11 +0530 Subject: [PATCH] Nc fix: Form view bug fixes (#8322) * fix(nc-gui): form view rich text link option issue * chore(nc-gui): lint * fix(nc-gui): pw test fail issue * fix(nc-gui): add checkbox required form validation rule --- packages/nc-gui/components/cell/RichText.vue | 44 +++++++++++++++++-- .../components/cell/RichText/LinkOptions.vue | 13 +++++- .../nc-gui/components/smartsheet/Form.vue | 1 + .../composables/useSharedFormViewStore.ts | 8 ++-- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui/components/cell/RichText.vue b/packages/nc-gui/components/cell/RichText.vue index 82985aa48e..e350a6611f 100644 --- a/packages/nc-gui/components/cell/RichText.vue +++ b/packages/nc-gui/components/cell/RichText.vue @@ -59,6 +59,10 @@ const isFocused = ref(false) const keys = useMagicKeys() +const shouldShowLinkOption = computed(() => { + return isFormField.value ? isFocused.value : true +}) + const turndownService = new TurndownService({}) turndownService.addRule('lineBreak', { @@ -133,6 +137,8 @@ marked.use({ extensions: [checkListItem] }) const editorDom = ref(null) +const richTextLinkOptionRef = ref(null) + const vModel = useVModel(props, 'value', emits, { defaultValue: '' }) const tiptapExtensions = [ @@ -167,7 +173,7 @@ const editor = useEditor({ emits('focus') }, onBlur: (e) => { - if (!(e?.event?.relatedTarget as HTMLElement)?.closest('.bubble-menu, .nc-textarea-rich-editor')) { + if (!(e?.event?.relatedTarget as HTMLElement)?.closest('.bubble-menu, .nc-textarea-rich-editor, .nc-rich-text')) { isFocused.value = false emits('blur') } @@ -239,13 +245,37 @@ useEventListener( 'focusout', (e: FocusEvent) => { const targetEl = e?.relatedTarget as HTMLElement - if (targetEl?.classList?.contains('tiptap') || !targetEl?.closest('.bubble-menu, .nc-textarea-rich-editor')) { + if (targetEl?.classList?.contains('tiptap') || !targetEl?.closest('.bubble-menu, .tippy-content, .nc-textarea-rich-editor')) { + isFocused.value = false + emits('blur') + } + }, + true, +) +useEventListener( + richTextLinkOptionRef, + 'focusout', + (e: FocusEvent) => { + const targetEl = e?.relatedTarget as HTMLElement + if (!targetEl && (e.target as HTMLElement)?.closest('.bubble-menu, .tippy-content, .nc-textarea-rich-editor')) return + + if (!targetEl?.closest('.bubble-menu, .tippy-content, .nc-textarea-rich-editor')) { isFocused.value = false emits('blur') } }, true, ) +onClickOutside(editorDom, (e) => { + if (!isFocused.value) return + + const targetEl = e?.target as HTMLElement + + if (!targetEl?.closest('.bubble-menu,.tippy-content, .nc-textarea-rich-editor')) { + isFocused.value = false + emits('blur') + } +})