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 @@
+
<\/p>/g, '
'))
.replaceAll(/\n\n
\n\n/g, '
\n\n')
- vModel.value = markdown
+ vModel.value = props.isFormField && markdown === '
' ? '' : markdown
},
editable: !props.readOnly,
+ autofocus: props.autofocus,
+ onFocus: () => {
+ isFocused.value = true
+ },
+ onBlur: () => {
+ if (props.isTabPressed) {
+ isFocused.value = false
+ }
+ },
})
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
@@ -182,11 +187,20 @@ watch(editorDom, () => {
setEditorContent(vModel.value, true)
+ if (props.isFormField) return
// Focus editor after editor is mounted
setTimeout(() => {
editor.value?.chain().focus().run()
}, 50)
})
+
+onClickOutside(editorDom, (e) => {
+ if ((e.target as HTMLElement)?.closest('.bubble-menu')) {
+ return
+ }
+
+ isFocused.value = false
+})
@@ -198,7 +212,7 @@ watch(editorDom, () => {
'readonly': readOnly,
'nc-form-rich-text-field !p-0': isFormField,
}"
- :tabindex="readOnlyCell ? -1 : 0"
+ :tabindex="readOnlyCell || isFormField ? -1 : 0"
>