-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(markdown-viewer): add new component
新增MarkdownViewer组件用于显示Markdown格式的富文本 close: #1181
- Loading branch information
Showing
6 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import { withInstall } from '/@/utils'; | ||
import markDown from './src/Markdown.vue'; | ||
import markDownViewer from './src/MarkdownViewer.vue'; | ||
|
||
export const MarkDown = withInstall(markDown); | ||
export const MarkdownViewer = withInstall(markDownViewer); | ||
export * from './src/typing'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<template> | ||
<div v-html="getHtmlData" :class="$props.class" class="markdown-viewer"></div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed } from 'vue'; | ||
import showdown from 'showdown'; | ||
const converter = new showdown.Converter(); | ||
converter.setOption('tables', true); | ||
const props = defineProps({ | ||
value: { type: String }, | ||
class: { type: String }, | ||
}); | ||
const getHtmlData = computed(() => converter.makeHtml(props.value || '')); | ||
</script> | ||
|
||
<style scoped> | ||
.markdown-viewer { | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters