diff --git a/backend/mindmap.db b/backend/mindmap.db index b66b61d..eecb48a 100644 Binary files a/backend/mindmap.db and b/backend/mindmap.db differ diff --git a/frontend/src/components/MindMap.vue b/frontend/src/components/MindMap.vue index 804a2b0..aaf4ad1 100644 --- a/frontend/src/components/MindMap.vue +++ b/frontend/src/components/MindMap.vue @@ -445,6 +445,100 @@ const closeImagePreview = () => { imagePreviewError.value = ''; }; +// HTML转Markdown函数 +const convertHTMLToMarkdown = (html) => { + if (!html || typeof html !== 'string') { + return ''; + } + + try { + console.log('🔄 开始转换HTML到Markdown:', html.substring(0, 100) + '...'); + + // 使用Vditor的html2md功能(如果可用) + if (typeof Vditor?.html2md === 'function') { + const markdown = Vditor.html2md(html); + console.log('✅ 使用Vditor.html2md转换成功:', markdown.substring(0, 100) + '...'); + return markdown; + } + + // 回退到简单转换逻辑 + console.log('⚠️ Vditor.html2md不可用,使用简单转换逻辑'); + let markdown = html + // 处理表格 - 保持表格结构 + .replace(/
| ]*>/gi, '| ') + .replace(/<\/th>/gi, ' ') + .replace(/ | ]*>/gi, '| ')
+ .replace(/<\/td>/gi, ' ')
+ // 图片处理
+ .replace(/ /gi, '\n') + .replace(/<\/p>/gi, '\n\n') + .replace(/ ]*>/gi, '')
+ // 加粗与斜体
+ .replace(/(.*?)<\/strong>/gi, '**$1**')
+ .replace(/(.*?)<\/b>/gi, '**$1**')
+ .replace(/(.*?)<\/em>/gi, '*$1*')
+ .replace(/(.*?)<\/i>/gi, '*$1*')
+ // 列表
+ .replace(/ |
|---|