修复表格节点空白问题和列表文本对齐问题

- 修复表格节点出现大量空白的问题
- 添加表格检测逻辑,避免对表格内容进行列表处理
- 保持列表节点的多行文本左对齐修复
- 确保表格和列表都能正常显示
This commit is contained in:
lixinran 2025-10-11 13:10:53 +08:00
parent 4bb72ba6a4
commit df89a448a4
9 changed files with 53 additions and 16 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -23,8 +23,8 @@
flex-direction: column;
}
</style>
<script type="module" crossorigin src="/assets/index-a5a78393.js"></script>
<link rel="stylesheet" href="/assets/index-2e253ee6.css">
<script type="module" crossorigin src="/assets/index-fc166542.js"></script>
<link rel="stylesheet" href="/assets/index-bafd0b52.css">
</head>
<body>
<div id="app"></div>

View File

@ -250,13 +250,25 @@
ul, ol {
text-align: left !important;
padding-left: 20px !important;
list-style-position: outside !important;
padding-left: 0 !important;
list-style: none !important;
margin: 0 !important;
}
li {
text-align: left !important;
list-style-position: outside !important;
margin-left: 0 !important;
padding-left: 0 !important;
margin-bottom: 0.3em !important;
position: relative !important;
&::before {
content: "•" !important;
position: absolute !important;
left: -1em !important;
color: inherit !important;
font-weight: normal !important;
}
}
p, span, div, strong, em {

View File

@ -30,13 +30,38 @@ export const shapeTpc = function (this: MindElixirInstance, tpc: Topic, nodeObj:
// 清理HTML内容移除重复的格式
let cleanedHTML = nodeObj.dangerouslySetInnerHTML
// 移除• 【这种重复格式
cleanedHTML = cleanedHTML.replace(/•\s*【/g, '【')
cleanedHTML = cleanedHTML.replace(/•\s*\[/g, '[')
// 检查是否包含表格,如果包含表格则不进行列表处理
const hasTable = cleanedHTML.includes('<table') || cleanedHTML.includes('<td>') || cleanedHTML.includes('<th>')
// 移除其他可能的重复格式
cleanedHTML = cleanedHTML.replace(/•\s*/g, '')
cleanedHTML = cleanedHTML.replace(/•\s*\(/g, '(')
if (!hasTable) {
// 移除• 【这种重复格式
cleanedHTML = cleanedHTML.replace(/•\s*【/g, '【')
cleanedHTML = cleanedHTML.replace(/•\s*\[/g, '[')
// 移除其他可能的重复格式
cleanedHTML = cleanedHTML.replace(/•\s*/g, '')
cleanedHTML = cleanedHTML.replace(/•\s*\(/g, '(')
// 处理换行符和列表格式
// 将换行符转换为<br>标签,但保持列表结构
cleanedHTML = cleanedHTML
// 处理列表项:将每个•开头的行转换为<li>
.replace(/^(\s*)•\s*(.+)$/gm, '<li>$2</li>')
// 将连续的<li>标签包装在<ul>中
.replace(/(<li>.*<\/li>)/gs, (match) => {
// 如果已经被<ul>包装,不重复包装
if (cleanedHTML.includes('<ul>')) return match
return `<ul>${match}</ul>`
})
// 将剩余的换行符转换为<br>
.replace(/\n/g, '<br>')
} else {
// 对于表格内容,只移除重复格式,不进行列表处理
cleanedHTML = cleanedHTML.replace(/•\s*【/g, '【')
cleanedHTML = cleanedHTML.replace(/•\s*\[/g, '[')
cleanedHTML = cleanedHTML.replace(/•\s*/g, '')
cleanedHTML = cleanedHTML.replace(/•\s*\(/g, '(')
}
tpc.innerHTML = cleanedHTML