Skip to content

Commit

Permalink
Decide if element is bold by getComputedStyle (#2453) (#2579)
Browse files Browse the repository at this point in the history
* Decide if element is bold by getComputedStyle (#2453)

* Use getComputedStyle() for italics too (dae)
  • Loading branch information
mmjang authored Oct 2, 2024
1 parent 2ac2758 commit 9ced6be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ts/editor/editor-toolbar/BoldButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
return match.remove();
}
const fontWeight = element.style.fontWeight;
if (fontWeight === "bold" || Number(fontWeight) >= 700) {
const fontWeight = getComputedStyle(element).fontWeight;
const threshold = 700;
if (fontWeight && Number(fontWeight) >= threshold) {
return match.clear((): void => {
if (
removeStyleProperties(element, "font-weight") &&
Expand Down
3 changes: 2 additions & 1 deletion ts/editor/editor-toolbar/ItalicButton.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
return match.remove();
}
if (["italic", "oblique"].includes(element.style.fontStyle)) {
const fontStyle = getComputedStyle(element).fontStyle;
if (["italic", "oblique"].includes(fontStyle)) {
return match.clear((): void => {
if (
removeStyleProperties(element, "font-style") &&
Expand Down

0 comments on commit 9ced6be

Please sign in to comment.