From 1f303145c632427944f6cc24963c0c9a62eb0175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A1=97=E8=A7=92=E5=B0=8F=E6=9E=97?= <1013335014@qq.com> Date: Tue, 3 Sep 2024 17:20:49 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=8D=B3=E4=BD=BF?= =?UTF-8?q?=E6=9C=AA=E4=BF=AE=E6=94=B9=E6=96=87=E6=9C=AC=E4=B9=9F=E4=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/plugins/RichText.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/simple-mind-map/src/plugins/RichText.js b/simple-mind-map/src/plugins/RichText.js index 765d76cd..e32c96cc 100644 --- a/simple-mind-map/src/plugins/RichText.js +++ b/simple-mind-map/src/plugins/RichText.js @@ -359,6 +359,18 @@ class RichText { return html.replace(/
<\/p>$/, '')
}
+ // 给html字符串中的节点样式按样式名首字母排序
+ sortHtmlNodeStyles(html) {
+ return html.replace(/(<[^<>]+\s+style=")([^"]+)("\s*>)/g, (_, a, b, c) => {
+ let arr = b.match(/[^:]+:[^:]+;/g) || []
+ arr = arr.map(item => {
+ return item.trim()
+ })
+ arr.sort()
+ return a + arr.join('') + c
+ })
+ }
+
// 隐藏文本编辑控件,即完成编辑
hideEditText(nodes) {
if (!this.showTextEdit) {
@@ -369,6 +381,7 @@ class RichText {
beforeHideRichTextEdit(this)
}
let html = this.getEditText()
+ html = this.sortHtmlNodeStyles(html)
let list =
nodes && nodes.length > 0 ? nodes : this.mindMap.renderer.activeNodeList
list.forEach(node => {