Fix:修复导入Markdown文件时对于加粗、代码等语法识别错误的问题

This commit is contained in:
街角小林 2025-03-12 16:39:31 +08:00
parent 0f6f714303
commit 70cc88efbd
4 changed files with 13 additions and 15 deletions

View File

@ -1,19 +1,17 @@
import { fromMarkdown } from 'mdast-util-from-markdown' import { fromMarkdown } from 'mdast-util-from-markdown'
const getNodeText = node => { const getNodeText = node => {
// 优先找出其中的text类型的子节点 let textStr = ''
let textChild = (node.children || []).find(item => {
return item.type === 'text' ;(node.children || []).forEach(item => {
}) if (['inlineCode', 'text'].includes(item.type)) {
// 没有找到,那么直接使用第一个子节点 textStr += item.value || ''
textChild = textChild || node.children[0] } else {
if (textChild) { textStr += getNodeText(item)
if (textChild.value !== undefined) {
return textChild.value
} }
return getNodeText(textChild) })
}
return '' return textStr
} }
// 处理list的情况 // 处理list的情况

View File

@ -359,7 +359,7 @@ export default {
'Current: Left click to box select nodes, right click to drag the canvas' 'Current: Left click to box select nodes, right click to drag the canvas'
}, },
search: { search: {
searchPlaceholder: 'Please enter the search content', searchPlaceholder: 'Enter the search content and press Enter',
replacePlaceholder: 'Please enter replacement content', replacePlaceholder: 'Please enter replacement content',
replace: 'Replace', replace: 'Replace',
replaceAll: 'Replace all', replaceAll: 'Replace all',

View File

@ -347,7 +347,7 @@ export default {
tip2: '当前:左键框选节点,右键拖动画布' tip2: '当前:左键框选节点,右键拖动画布'
}, },
search: { search: {
searchPlaceholder: '输入查找内容', searchPlaceholder: '输入查找内容后按回车键',
replacePlaceholder: '请输入替换内容', replacePlaceholder: '请输入替换内容',
replace: '替换', replace: '替换',
replaceAll: '全部替换', replaceAll: '全部替换',

View File

@ -346,7 +346,7 @@ export default {
tip2: '目前:左鍵框選節點,右鍵拖曳畫布' tip2: '目前:左鍵框選節點,右鍵拖曳畫布'
}, },
search: { search: {
searchPlaceholder: '請輸入搜尋內容', searchPlaceholder: '輸入查找內容後按回車鍵',
replacePlaceholder: '請輸入取代內容', replacePlaceholder: '請輸入取代內容',
replace: '取代', replace: '取代',
replaceAll: '全部取代', replaceAll: '全部取代',