UnisKB/ui/src/components/markdown/MdPreview.vue

42 lines
1017 B
Vue
Raw Normal View History

2025-06-06 08:32:03 +00:00
<template>
2025-07-15 08:31:26 +00:00
<MdPreview :language="language" noIconfont noPrettier :codeFoldable="false" v-bind="$attrs" @click.stop="handleClick"/>
2025-06-06 08:32:03 +00:00
</template>
<script setup lang="ts">
import { computed } from 'vue'
import { MdPreview, config } from 'md-editor-v3'
import { getBrowserLang } from '@/locales/index'
import useStore from '@/stores'
// 引入公共库中的语言配置
import ZH_TW from '@vavt/cm-extension/dist/locale/zh-TW'
defineOptions({ name: 'MdPreview' })
2025-07-15 08:31:26 +00:00
const emit = defineEmits(['clickPreview'])
2025-06-06 08:32:03 +00:00
const { user } = useStore()
const language = computed(() => user.getLanguage() || getBrowserLang() || '')
config({
editorConfig: {
languageUserDefined: {
'zh-Hant': ZH_TW
}
}
})
2025-07-15 08:31:26 +00:00
function handleClick(e: MouseEvent) {
if ((e.target as HTMLElement).closest('a') || (e.target as HTMLElement).closest('.md-editor-copy-button')) {
e.stopPropagation()
} else {
emit('clickPreview')
}
}
2025-06-06 08:32:03 +00:00
</script>
<style lang="scss" scoped>
:deep(audio) {
width: 300px;
height: 43px;
}
</style>