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

feat: import default markdown content #558

Merged
merged 1 commit into from
Mar 8, 2025
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
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