Skip to content

Commit a1defc9

Browse files
Merge pull request #5075 from wangeditor-team/fix-set-family
fix(font family menu): 处理 setHtml 的时候字体样式回显失败的问题
2 parents 9fa9915 + b941bab commit a1defc9

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/basic-modules/src/modules/font-size-family/parse-style-html.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export function parseStyleHtml(text: DOMElement, node: Descendant, editor: IDomE
2828

2929
// -------- 处理 font-family --------
3030
const { fontFamilyList = [] } = editor.getMenuConfig('fontFamily')
31-
const fontFamily = getStyleValue($text, 'font-family')
31+
// 这里需要替换掉 ", css 设置 font-family,会将有空格的字体使用 " 包裹
32+
const fontFamily = getStyleValue($text, 'font-family').replace(/"/g, '')
3233

3334
// getFontFamilyConfig 配置支持对象形式
3435
const includesFamily =

packages/core/src/to-html/text2html.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { Text } from 'slate'
77
import { IDomEditor } from '../editor/interface'
88
import { DomEditor } from '../editor/dom-editor'
99
import { STYLE_TO_HTML_FN_LIST } from './index'
10-
import { deReplaceHtmlSpecialSymbols, replaceHtmlSpecialSymbols } from '../utils/util'
10+
import { replaceHtmlSpecialSymbols } from '../utils/util'
1111

1212
function textToHtml(textNode: Text, editor: IDomEditor): string {
1313
const { text } = textNode
@@ -45,9 +45,6 @@ function textToHtml(textNode: Text, editor: IDomEditor): string {
4545
// 增加文本样式,如 color bgColor
4646
STYLE_TO_HTML_FN_LIST.forEach(fn => (textHtml = fn(textNode, textHtml)))
4747

48-
// 反转义 html 特殊字符
49-
textHtml = deReplaceHtmlSpecialSymbols(textHtml)
50-
5148
return textHtml
5249
}
5350

0 commit comments

Comments
 (0)