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

@@ -160,14 +160,21 @@
line-height: 26px;
margin-bottom: 66px;
}
#details .matter .matter-left .html * {
background: transparent !important;
color: #555555 !important;
}
#details .matter .matter-left .html a {
text-decoration: underline;
color: #04b0d5;
color: #04b0d5 !important;
}
#details .matter .matter-left .html a * {
color: #04b0d5 !important;
}
#details .matter .matter-left .html .blue {
font-size: 15px;
line-height: 26px;
color: #026277;
color: #026277 !important;
margin: 0 4px;
text-decoration: none;
}
@@ -176,19 +183,17 @@
display: inline-block;
}
#details .matter .matter-left .html video {
margin: 0 auto;
margin: 0 auto 5px;
height: 300px;
display: block;
}
#details .matter .matter-left .html 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;
}
#details .matter .matter-left .html tr,
#details .matter .matter-left .html td {
background: transparent;
}
#details .matter .matter-left .last-time {
color: #aaaaaa;
font-size: 13px;

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 @@
}
}
}
}
}

View File

@@ -398,12 +398,16 @@
}
#appIndex .header-content-box .header-content-right .offer-box {
width: 240px;
height: 214px;
background-color: #fff;
border: 1px solid #e9eef2;
border-radius: 10px;
padding: 17px 10px;
overflow: hidden;
height: 64px;
padding: 15px 10px;
}
#appIndex .header-content-box .header-content-right .offer-box.big {
height: 214px;
padding: 17px 10px;
}
#appIndex .header-content-box .header-content-right .offer-box.small {
height: 64px;

View File

@@ -18,9 +18,11 @@
&:not(:last-child) {
margin-right: 12px;
}
a {
display: block;
}
img {
width: 468px;
height: 60px;
@@ -37,6 +39,7 @@
border-radius: 20px 20px 20px 0;
margin-top: 0;
margin-bottom: 10px;
.icon {
width: 15px;
height: 12px;
@@ -91,6 +94,7 @@
.people {
position: relative;
justify-content: space-between;
&::after {
content: "";
position: absolute;
@@ -119,6 +123,7 @@
width: 26px;
height: 26px;
border-radius: 50%;
.img {
width: 26px;
height: 26px;
@@ -128,12 +133,15 @@
&:nth-child(4) {
margin-right: -9px;
}
&:nth-child(3) {
margin-right: -9px;
}
&:nth-child(2) {
margin-right: -7px;
}
&:nth-child(2) {
margin-right: -5px;
}
@@ -145,6 +153,7 @@
.topic-list {
.item {
cursor: pointer;
&:not(:last-child) {
margin-bottom: 1px;
}
@@ -222,8 +231,10 @@
border-radius: 10px;
padding-left: 12px;
margin-top: 12px;
.adv {
margin-right: 26px;
.adv-icon {
width: 295px;
height: 118px;
@@ -279,6 +290,7 @@
.header-content-right {
width: 240px;
.post-entrance {
background-color: #fff;
border: 1px solid #e9eef2;
@@ -357,9 +369,11 @@
height: 140px;
margin-bottom: 10px;
display: block;
a {
display: block;
}
img {
width: 240px;
height: 140px;
@@ -394,12 +408,15 @@
&:nth-child(1) {
border-top-left-radius: 8px;
}
&:nth-child(2) {
border-top-right-radius: 8px;
}
&:nth-child(3) {
border-bottom-left-radius: 8px;
}
&:nth-child(4) {
border-bottom-right-radius: 8px;
}
@@ -429,6 +446,7 @@
line-height: 22px;
position: relative;
.title {
font-family: "PingFangSC-Semibold", "PingFang SC Semibold", "PingFang SC", sans-serif;
font-weight: 650;
@@ -455,6 +473,7 @@
padding: 20px;
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.168627450980392);
flex-direction: column;
.QRcode {
width: 100px;
height: 100px;
@@ -472,13 +491,21 @@
.offer-box {
width: 240px;
height: 214px;
// height: 214px;
background-color: #fff;
border: 1px solid #e9eef2;
border-radius: 10px;
padding: 17px 10px;
// padding: 17px 10px;
overflow: hidden;
height: 64px;
padding: 15px 10px;
&.big {
height: 214px;
padding: 17px 10px;
}
&.small {
height: 64px;
padding: 15px 10px;
@@ -521,6 +548,7 @@
.admission {
margin-bottom: 30px;
.admission-header {
margin-bottom: 24px;
display: inline-flex;
@@ -543,6 +571,7 @@
.admission-list {
flex-wrap: wrap;
.admission-item {
width: 291px;
height: 103px;
@@ -602,6 +631,7 @@
&:not(:last-child) {
margin-bottom: 10px;
}
.item {
font-family: "PingFangSC-Regular", "PingFang SC", sans-serif;
font-weight: 400;
@@ -622,6 +652,7 @@
}
}
}
.item-box {
margin-bottom: 12px;
}
@@ -641,6 +672,7 @@
height: 220px;
margin-bottom: 12px;
cursor: pointer;
img {
width: 291px;
height: 220px;
@@ -669,4 +701,4 @@
}
}
}
}
}