refactor(editor): 优化富文本编辑器内容格式转换逻辑

- 改进 HTML 到 Markdown 的转换规则,处理块级元素和行内元素的嵌套关系
- 优化图片和视频标签的解析逻辑,确保附件正确提取
- 修复换行符处理问题,避免产生多余空行
- 增强居中文本和标题的格式转换准确性
- 清理调试日志和冗余代码
This commit is contained in:
A1300399510
2025-11-30 23:54:41 +08:00
parent 1b5cf79300
commit 57bf0ed3eb
5 changed files with 182 additions and 80 deletions

View File

@@ -36,6 +36,7 @@
.content {
flex-direction: column;
.name {
font-size: 14px;
color: #333333;
@@ -55,6 +56,7 @@
.operate {
position: relative;
.view {
.icon {
width: 13px;
@@ -185,15 +187,25 @@
line-height: 26px;
margin-bottom: 66px;
* {
background: transparent !important;
color: #555555 !important;
}
a {
text-decoration: underline;
color: #04b0d5;
color: #04b0d5 !important;
* {
color: #04b0d5 !important;
}
}
.blue {
font-size: 15px;
line-height: 26px;
color: #026277;
color: #026277 !important;
margin: 0 4px;
text-decoration: none;
}
@@ -204,21 +216,20 @@
}
video {
margin: 0 auto;
margin: 0 auto 5px;
height: 300px;
display: block;
}
h1 {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
color: #000000;
color: #000000 !important;
font-size: 18px;
line-height: 30px;
}
tr,
td {
background: transparent;
}
}
.last-time {
@@ -244,6 +255,7 @@
height: 20px;
margin-right: 6px;
}
font-size: 14px;
color: #333333;
cursor: pointer;
@@ -254,6 +266,7 @@
&.share {
position: relative;
&:hover {
.share-box {
display: flex;
@@ -353,6 +366,7 @@
padding-top: 20px;
padding-bottom: 12px;
border-bottom: 1px solid #ebebeb;
.text {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
@@ -494,6 +508,7 @@
.author-info {
color: #7f7f7f;
font-size: 13px;
.amount {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
@@ -508,6 +523,7 @@
width: calc(100% - 16px);
padding-bottom: 22px;
margin-left: 16px;
.medal-title {
font-size: 14px;
color: #7f7f7f;
@@ -551,6 +567,7 @@
&:hover {
color: #000000;
}
.dot {
width: 6px;
height: 6px;
@@ -608,6 +625,7 @@
font-weight: 400;
color: #7f7f7f;
font-size: 14px;
.sum {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
@@ -682,6 +700,7 @@
.coins-total {
color: #7f7f7f;
font-size: 14px;
.sum {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
@@ -713,6 +732,7 @@
.user {
color: #555555;
font-size: 13px;
.avatar {
width: 32px;
height: 32px;
@@ -724,6 +744,7 @@
.amount {
color: #000000;
font-size: 16px;
.text {
font-size: 13px;
margin-left: 2px;
@@ -883,8 +904,7 @@
cursor: pointer;
}
.answer-discuss .input-box .bottom .operate .item {
}
.answer-discuss .input-box .bottom .operate .item {}
.answer-discuss .input-box .bottom .operate .item .emoji-box {
width: 582px;
@@ -1421,29 +1441,35 @@
background-color: rgba(0, 0, 0, 0.5);
z-index: 12;
}
.answer-discuss .edit-comment .box {
width: 650px;
border-radius: 10px;
background: #fff;
padding: 20px 15px;
}
.answer-discuss .edit-comment .box .text {
font-size: 18px;
font-weight: 650;
margin-bottom: 15px;
color: #000;
}
.answer-discuss .edit-comment .box .input-box {
margin-right: 0;
padding-top: 10px;
}
.answer-discuss .edit-comment .box .input-box .bottom {
// border-top: 1px solid #ebebeb;
}
.answer-discuss .edit-comment .box .btn-list {
padding: 15px 0;
justify-content: flex-end;
}
.answer-discuss .edit-comment .box .btn-list .btn {
font-size: 14px;
color: #333;
@@ -1457,6 +1483,7 @@
border: 1px solid #ebebeb;
margin-left: 20px;
}
.answer-discuss .edit-comment .box .btn-list .btn.send {
background-color: #fddf6d;
border: 1px solid #fddf6d;
@@ -1469,6 +1496,7 @@
width: 100vw;
height: 100vh;
}
.answer-discuss .emoji-box-mask {
position: fixed;
top: 0;
@@ -1483,6 +1511,7 @@
@media screen and (max-width: 850px) {
#details {
padding: 10px 10px 0;
.head-top {
display: none;
}
@@ -1494,6 +1523,7 @@
.matter {
.matter-left {
margin-right: 0 !important;
.action-bar {
margin-right: 0 !important;
justify-content: space-around;
@@ -1508,10 +1538,13 @@
.related-head {
padding-left: 14px;
}
.list {
padding: 14px;
.item {
width: 100% !important;
&:not(:last-child) {
margin-bottom: 7px;
}
@@ -1523,10 +1556,12 @@
}
}
}
.sidebar-box {
display: none;
}
}
.answer-discuss {
padding: 15px;
@@ -1594,6 +1629,7 @@
.comments-item {
.comments-header {
font-size: 12px;
.comments-title {
height: 14px !important;
}
@@ -1610,6 +1646,7 @@
.comments-box {
.comments-item {
.comments-header {
.comment-icon,
.like-box {
margin-left: 15px;
@@ -1619,4 +1656,4 @@
}
}
}
}
}