diff --git a/.changeset/eight-chicken-rush.md b/.changeset/eight-chicken-rush.md new file mode 100644 index 000000000..ef87949ff --- /dev/null +++ b/.changeset/eight-chicken-rush.md @@ -0,0 +1,6 @@ +--- +"@wangeditor-next/basic-modules": patch +"@wangeditor-next/editor": patch +--- + +fix: add more font style diff --git a/packages/basic-modules/src/modules/font-size-family/menu/FontFamilyMenu.ts b/packages/basic-modules/src/modules/font-size-family/menu/FontFamilyMenu.ts index 48369cdb2..5ddec8e4b 100644 --- a/packages/basic-modules/src/modules/font-size-family/menu/FontFamilyMenu.ts +++ b/packages/basic-modules/src/modules/font-size-family/menu/FontFamilyMenu.ts @@ -48,14 +48,23 @@ class FontFamilyMenu extends BaseMenu { // 设置 selected const curValue = this.getValue(editor) + let flag = false options.forEach(opt => { if (opt.value === curValue) { + flag = true opt.selected = true } else { - delete opt.selected + opt.selected = undefined } }) + if (!flag && typeof curValue === 'string') { + options.push({ + text: curValue, + value: curValue, + selected: true, + }) + } return options } diff --git a/packages/basic-modules/src/modules/font-size-family/menu/FontSizeMenu.ts b/packages/basic-modules/src/modules/font-size-family/menu/FontSizeMenu.ts index 23e66e648..b3a204968 100644 --- a/packages/basic-modules/src/modules/font-size-family/menu/FontSizeMenu.ts +++ b/packages/basic-modules/src/modules/font-size-family/menu/FontSizeMenu.ts @@ -44,14 +44,24 @@ class FontSizeMenu extends BaseMenu { // 设置 selected const curValue = this.getValue(editor) + let flag = false options.forEach(opt => { if (opt.value === curValue) { + flag = true opt.selected = true } else { - delete opt.selected + opt.selected = undefined } }) + // @ts-ignore + if (!flag && typeof curValue === 'string') { + options.push({ + text: curValue, + value: curValue, + selected: true, + }) + } return options } diff --git a/packages/basic-modules/src/modules/header/menu/HeaderSelectMenu.ts b/packages/basic-modules/src/modules/header/menu/HeaderSelectMenu.ts index 19f547846..dc0add9fb 100644 --- a/packages/basic-modules/src/modules/header/menu/HeaderSelectMenu.ts +++ b/packages/basic-modules/src/modules/header/menu/HeaderSelectMenu.ts @@ -63,7 +63,7 @@ class HeaderSelectMenu implements ISelectMenu { if (opt.value === curValue) { opt.selected = true } else { - delete opt.selected + opt.selected = undefined } }) diff --git a/packages/basic-modules/src/modules/line-height/menu/LineHeightMenu.ts b/packages/basic-modules/src/modules/line-height/menu/LineHeightMenu.ts index 58874ce93..e8a61dfc9 100644 --- a/packages/basic-modules/src/modules/line-height/menu/LineHeightMenu.ts +++ b/packages/basic-modules/src/modules/line-height/menu/LineHeightMenu.ts @@ -47,7 +47,7 @@ class LineHeightMenu implements ISelectMenu { if (opt.value === curValue) { opt.selected = true } else { - delete opt.selected + opt.selected = undefined } }) diff --git a/packages/code-highlight/src/module/menu/SelectLangMenu.ts b/packages/code-highlight/src/module/menu/SelectLangMenu.ts index 9f0550dfc..8e352bfd6 100644 --- a/packages/code-highlight/src/module/menu/SelectLangMenu.ts +++ b/packages/code-highlight/src/module/menu/SelectLangMenu.ts @@ -52,7 +52,7 @@ class SelectLangMenu implements ISelectMenu { if (opt.value === curValue) { opt.selected = true } else { - delete opt.selected + opt.selected = undefined } })