Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: error of insert action #339

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/components/CodemirrorEditor/InsertFormDialog.vue
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions src/views/CodemirrorEditor.vue
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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
Expand Down
Loading