mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-21 10:27:44 +08:00
Fix:修复导入md文件时存在加粗的标题文本会解析为undefined的问题
This commit is contained in:
parent
85171db778
commit
d93825dd57
@ -1,5 +1,15 @@
|
||||
import { fromMarkdown } from 'mdast-util-from-markdown'
|
||||
|
||||
const getNodeValue = node => {
|
||||
if (node.children[0]) {
|
||||
if (node.children[0].value !== undefined) {
|
||||
return node.children[0].value
|
||||
}
|
||||
return getNodeValue(node.children[0])
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
// 处理list的情况
|
||||
const handleList = node => {
|
||||
let list = []
|
||||
@ -9,7 +19,7 @@ const handleList = node => {
|
||||
let node = {}
|
||||
node.data = {
|
||||
// 节点内容
|
||||
text: cur.children[0].children[0].value
|
||||
text: getNodeValue(cur)
|
||||
}
|
||||
node.children = []
|
||||
newArr.push(node)
|
||||
@ -45,7 +55,7 @@ export const transformMarkdownTo = md => {
|
||||
let node = {}
|
||||
node.data = {
|
||||
// 节点内容
|
||||
text: cur.children[0].value
|
||||
text: getNodeValue(cur)
|
||||
}
|
||||
node.children = []
|
||||
// 如果当前的层级大于上一个节点的层级,那么是其子节点
|
||||
|
||||
@ -4,6 +4,8 @@
|
||||
* @returns {string} 过滤后的文本
|
||||
*/
|
||||
export function defenseXSS(text) {
|
||||
text = String(text)
|
||||
|
||||
// 初始化结果变量
|
||||
let result = text;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user