fix: error of insert action (#339)

This commit is contained in:
YangFong 2024-08-22 08:47:40 +08:00 committed by GitHub
parent 1a7eeab9ff
commit b94750384a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 11 deletions

View File

@ -1,11 +1,11 @@
<script setup>
import { ref } from 'vue'
import { ref, toRaw } from 'vue'
import { useStore } from '@/stores'
import { createTable } from '@/utils'
const store = useStore()
const { formatContent, toggleShowInsertFormDialog } = store
const { toggleShowInsertFormDialog } = store
const rowNum = ref(3)
const colNum = ref(3)
@ -24,12 +24,8 @@ function insertTable() {
cols: colNum.value,
data: tableData.value,
})
store.editor.operation(() => {
store.editor.replaceSelection(`\n${table}\n`, `end`)
})
store.editorRefresh()
toRaw(store.editor).replaceSelection(`\n${table}\n`, `end`)
resetVal()
formatContent()
toggleShowInsertFormDialog()
}
</script>

View File

@ -1,5 +1,5 @@
<script setup>
import { onMounted, ref } from 'vue'
import { onMounted, ref, toRaw } from 'vue'
import { storeToRefs } from 'pinia'
import { ElMessage } from 'element-plus'
import CodeMirror from 'codemirror'
@ -180,10 +180,10 @@ function uploaded(imageUrl) {
const cursor = editor.value.getCursor()
const markdownImage = `![](${imageUrl})`
// Markdown URL
editor.value.replaceSelection(`\n${markdownImage}\n`, cursor)
toRaw(store.editor).replaceSelection(`\n${markdownImage}\n`, cursor)
ElMessage.success(`图片上传成功`)
formatContent()
onEditorRefresh()
// formatContent()
// onEditorRefresh()
}
function uploadImage(file, cb) {
isImgLoading.value = true