|
|
@ -1,6 +1,8 @@ |
|
|
<script setup lang="ts"> |
|
|
<script setup lang="ts"> |
|
|
|
|
|
import type MarkdownIt from 'markdown-it' |
|
|
import { MdEditor } from 'md-editor-v3' |
|
|
import { MdEditor } from 'md-editor-v3' |
|
|
import 'md-editor-v3/lib/style.css' |
|
|
import 'md-editor-v3/lib/style.css' |
|
|
|
|
|
import { attachMarkdownItStripFrontMatter } from '../utils/markdown-front-matter' |
|
|
|
|
|
|
|
|
const props = defineProps<{ |
|
|
const props = defineProps<{ |
|
|
modelValue: string |
|
|
modelValue: string |
|
|
@ -13,6 +15,11 @@ const emit = defineEmits<{ |
|
|
const { fetchData } = useClientApi() |
|
|
const { fetchData } = useClientApi() |
|
|
const toast = useToast() |
|
|
const toast = useToast() |
|
|
const editorId = `post-body-md-${useId()}` |
|
|
const editorId = `post-body-md-${useId()}` |
|
|
|
|
|
const previewFmRule = `strip_fm_${useId().replace(/[^a-zA-Z0-9_]/g, '_')}` |
|
|
|
|
|
|
|
|
|
|
|
function markdownItConfig(md: MarkdownIt) { |
|
|
|
|
|
attachMarkdownItStripFrontMatter(md, previewFmRule) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const local = computed({ |
|
|
const local = computed({ |
|
|
get: () => props.modelValue, |
|
|
get: () => props.modelValue, |
|
|
@ -46,6 +53,7 @@ async function onUploadImg(files: File[], callback: (urls: string[]) => void) { |
|
|
:preview="true" |
|
|
:preview="true" |
|
|
preview-theme="github" |
|
|
preview-theme="github" |
|
|
theme="light" |
|
|
theme="light" |
|
|
|
|
|
:markdown-it-config="markdownItConfig" |
|
|
:on-upload-img="onUploadImg" |
|
|
:on-upload-img="onUploadImg" |
|
|
:style="{ height: 'min(72vh, 720px)' }" |
|
|
:style="{ height: 'min(72vh, 720px)' }" |
|
|
class="w-full rounded-lg overflow-hidden ring ring-default" |
|
|
class="w-full rounded-lg overflow-hidden ring ring-default" |
|
|
|