Browse Source

Merge pull request #7266 from nocodb/nc-fix/rich-text

fix: rich text first char issue
pull/7269/head
Raju Udava 11 months ago committed by GitHub
parent
commit
084d818a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      packages/nc-gui/components/cell/RichText.vue
  2. 10
      packages/nc-gui/composables/useMultiSelect/index.ts

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

@ -108,7 +108,7 @@ const editor = useEditor({
editable: !props.readonly,
})
const setEditorContent = (contentMd: any) => {
const setEditorContent = (contentMd: any, focusEndOfDoc?: boolean) => {
if (!editor.value) return
const selection = editor.value.view.state.selection
@ -120,6 +120,15 @@ const setEditorContent = (contentMd: any) => {
editor.value.chain().setContent(content).setTextSelection(selection.to).run()
setTimeout(() => {
if (focusEndOfDoc) {
const docSize = editor.value!.state.doc.nodeSize
editor.value
?.chain()
.setTextSelection(docSize - 1)
.run()
}
;(editor.value!.state as any).history$.prevRanges = null
;(editor.value!.state as any).history$.done.eventCount = 0
}, 100)
@ -134,7 +143,7 @@ if (props.syncValueChange) {
watch(editorDom, () => {
if (!editorDom.value) return
setEditorContent(vModel.value)
setEditorContent(vModel.value, true)
// Focus editor after editor is mounted
setTimeout(() => {

10
packages/nc-gui/composables/useMultiSelect/index.ts

@ -718,7 +718,15 @@ export function useMultiSelect(
return message.info(t('msg.info.updateNotAllowedWithoutPK'))
}
if (isTypableInputColumn(columnObj) && makeEditable(rowObj, columnObj) && columnObj.title) {
rowObj.row[columnObj.title] = ''
if (columnObj.uidt === UITypes.LongText) {
if (rowObj.row[columnObj.title] === '<br />') {
rowObj.row[columnObj.title] = e.key
} else {
rowObj.row[columnObj.title] = rowObj.row[columnObj.title] ? rowObj.row[columnObj.title] + e.key : e.key
}
} else {
rowObj.row[columnObj.title] = ''
}
}
// editEnabled = true
}

Loading…
Cancel
Save