mirror of
https://github.com/doocs/md.git
synced 2024-11-24 19:10:34 +08:00
fix: error of insert action (#339)
This commit is contained in:
parent
1a7eeab9ff
commit
b94750384a
@ -1,11 +1,11 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref } from 'vue'
|
import { ref, toRaw } from 'vue'
|
||||||
import { useStore } from '@/stores'
|
import { useStore } from '@/stores'
|
||||||
import { createTable } from '@/utils'
|
import { createTable } from '@/utils'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const { formatContent, toggleShowInsertFormDialog } = store
|
const { toggleShowInsertFormDialog } = store
|
||||||
|
|
||||||
const rowNum = ref(3)
|
const rowNum = ref(3)
|
||||||
const colNum = ref(3)
|
const colNum = ref(3)
|
||||||
@ -24,12 +24,8 @@ function insertTable() {
|
|||||||
cols: colNum.value,
|
cols: colNum.value,
|
||||||
data: tableData.value,
|
data: tableData.value,
|
||||||
})
|
})
|
||||||
store.editor.operation(() => {
|
toRaw(store.editor).replaceSelection(`\n${table}\n`, `end`)
|
||||||
store.editor.replaceSelection(`\n${table}\n`, `end`)
|
|
||||||
})
|
|
||||||
store.editorRefresh()
|
|
||||||
resetVal()
|
resetVal()
|
||||||
formatContent()
|
|
||||||
toggleShowInsertFormDialog()
|
toggleShowInsertFormDialog()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref, toRaw } from 'vue'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import CodeMirror from 'codemirror'
|
import CodeMirror from 'codemirror'
|
||||||
@ -180,10 +180,10 @@ function uploaded(imageUrl) {
|
|||||||
const cursor = editor.value.getCursor()
|
const cursor = editor.value.getCursor()
|
||||||
const markdownImage = `![](${imageUrl})`
|
const markdownImage = `![](${imageUrl})`
|
||||||
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
// 将 Markdown 形式的 URL 插入编辑框光标所在位置
|
||||||
editor.value.replaceSelection(`\n${markdownImage}\n`, cursor)
|
toRaw(store.editor).replaceSelection(`\n${markdownImage}\n`, cursor)
|
||||||
ElMessage.success(`图片上传成功`)
|
ElMessage.success(`图片上传成功`)
|
||||||
formatContent()
|
// formatContent()
|
||||||
onEditorRefresh()
|
// onEditorRefresh()
|
||||||
}
|
}
|
||||||
function uploadImage(file, cb) {
|
function uploadImage(file, cb) {
|
||||||
isImgLoading.value = true
|
isImgLoading.value = true
|
||||||
|
Loading…
Reference in New Issue
Block a user