Skip to content

Commit

Permalink
fix: add more font style (#382)
Browse files Browse the repository at this point in the history
* fix: add more font style

* Create eight-chicken-rush.md

* perf: replate delete to undefined
  • Loading branch information
cycleccc authored Nov 23, 2024
1 parent 4ea62bc commit 5bbff78
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changeset/eight-chicken-rush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@wangeditor-next/basic-modules": patch
"@wangeditor-next/editor": patch
---

fix: add more font style
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class HeaderSelectMenu implements ISelectMenu {
if (opt.value === curValue) {
opt.selected = true
} else {
delete opt.selected
opt.selected = undefined
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class LineHeightMenu implements ISelectMenu {
if (opt.value === curValue) {
opt.selected = true
} else {
delete opt.selected
opt.selected = undefined
}
})

Expand Down
2 changes: 1 addition & 1 deletion packages/code-highlight/src/module/menu/SelectLangMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class SelectLangMenu implements ISelectMenu {
if (opt.value === curValue) {
opt.selected = true
} else {
delete opt.selected
opt.selected = undefined
}
})

Expand Down

0 comments on commit 5bbff78

Please sign in to comment.