feat!: 将QuestionList的内容渲染由Markdown改为HTML
All checks were successful
deploy to server / build-and-deploy (push) Successful in 6m51s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 6m51s
- 后端CMS字段由Markdown改为WYSIWYG因此前端做出对应修改
This commit is contained in:
30
app/utils/htmlDefaultMap.ts
Normal file
30
app/utils/htmlDefaultMap.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import type { HtmlRenderMap } from '@/composables/useHtmlRenderer';
|
||||
import { h } from 'vue';
|
||||
import MarkdownTable from '@/components/shared/MarkdownTable.vue';
|
||||
|
||||
export const defaultHtmlRenderMap: HtmlRenderMap = {
|
||||
h1: (_, children) => h('h1', {}, children),
|
||||
|
||||
h2: (_, children) => h('h2', {}, children),
|
||||
|
||||
p: (_, children) => h('p', {}, children),
|
||||
|
||||
// table: (_, children) => h('div', {}, [h('table', {}, children)]),
|
||||
table: (node) => {
|
||||
const { headers, rows } = parseHtmlTable(node);
|
||||
|
||||
return h(
|
||||
'div',
|
||||
{},
|
||||
h(MarkdownTable, {
|
||||
headers,
|
||||
rows,
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
img: (node) =>
|
||||
h('img', {
|
||||
src: node.attribs?.src,
|
||||
}),
|
||||
};
|
||||
Reference in New Issue
Block a user