Skip to content

Commit

Permalink
feat: import default markdown content
Browse files Browse the repository at this point in the history
  • Loading branch information
yanglbme committed Mar 8, 2025
1 parent 389519b commit 89fd314
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/stores/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ export const useStore = defineStore(`store`, () => {
downloadMD(editor.value!.getValue())
}

// 导入默认文档
const importDefaultContent = () => {
editor.value!.setValue(DEFAULT_CONTENT)
toast.success(`文档已重置为默认文档`)
}

// 导入 Markdown 文档
const importMarkdownContent = () => {
const body = document.body
Expand Down Expand Up @@ -476,6 +482,7 @@ export const useStore = defineStore(`store`, () => {
exportEditorContent2MD,

importMarkdownContent,
importDefaultContent,

isOpenConfirmDialog,
resetStyleConfirm,
Expand Down
4 changes: 4 additions & 0 deletions src/views/CodemirrorEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const {
exportEditorContent2MD,
formatContent,
importMarkdownContent,
importDefaultContent,
resetStyleConfirm,
} = store
Expand Down Expand Up @@ -397,6 +398,9 @@ onMounted(() => {
<ContextMenuItem inset @click="resetStyleConfirm()">
恢复默认样式
</ContextMenuItem>
<ContextMenuItem inset @click="importDefaultContent()">
导入默认文档
</ContextMenuItem>
<ContextMenuSeparator />
<ContextMenuItem inset @click="importMarkdownContent()">
导入 .md 文档
Expand Down

0 comments on commit 89fd314

Please sign in to comment.