Fix:修复节点富文本编辑时清除样式后文字样式丢失并且切换主题也不会恢复的问题
This commit is contained in:
parent
ecc15ea572
commit
cd7936a50b
@ -486,9 +486,9 @@ class RichText {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 格式化当前选中的文本
|
// 格式化当前选中的文本
|
||||||
formatText(config = {}, clear = false) {
|
formatText(config = {}, clear = false, pure = false) {
|
||||||
if (!this.range && !this.lastRange) return
|
if (!this.range && !this.lastRange) return
|
||||||
this.syncFormatToNodeConfig(config, clear)
|
if(!pure) this.syncFormatToNodeConfig(config, clear)
|
||||||
let rangeLost = !this.range
|
let rangeLost = !this.range
|
||||||
let range = rangeLost ? this.lastRange : this.range
|
let range = rangeLost ? this.lastRange : this.range
|
||||||
clear
|
clear
|
||||||
@ -501,7 +501,24 @@ class RichText {
|
|||||||
|
|
||||||
// 清除当前选中文本的样式
|
// 清除当前选中文本的样式
|
||||||
removeFormat() {
|
removeFormat() {
|
||||||
|
// 先移除全部样式
|
||||||
this.formatText({}, true)
|
this.formatText({}, true)
|
||||||
|
// 再将样式恢复为当前主题改节点的默认样式
|
||||||
|
const style = {}
|
||||||
|
if (this.node) {
|
||||||
|
;[
|
||||||
|
'fontFamily',
|
||||||
|
'fontSize',
|
||||||
|
'fontWeight',
|
||||||
|
'fontStyle',
|
||||||
|
'textDecoration',
|
||||||
|
'color'
|
||||||
|
].forEach(key => {
|
||||||
|
style[key] = this.node.style.merge(key)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const config = this.normalStyleToRichTextStyle(style)
|
||||||
|
this.formatText(config, false, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化指定范围的文本
|
// 格式化指定范围的文本
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user