Skip to content

Commit

Permalink
feat: reuse previous font color when change font size
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode committed Oct 18, 2023
1 parent bad6f30 commit 6b171e4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from '@tinkoff/tui-editor/tokens';
import {Observable} from 'rxjs';
import {map} from 'rxjs/operators';
import {EDITOR_BLANK_COLOR} from '@tinkoff/tui-editor/constants';

@Component({
selector: 'tui-font-size',
Expand Down Expand Up @@ -44,6 +45,8 @@ export class TuiFontSizeComponent {
}

setFontOption({headingLevel, px}: Partial<TuiEditorFontOption>): void {
const color = this.editor.getFontColor();

this.clearPreviousTextStyles();

if (headingLevel) {
Expand All @@ -57,6 +60,10 @@ export class TuiFontSizeComponent {
} else {
this.editor.setParagraph({fontSize: tuiPx(px || 0)});
}

if (color !== EDITOR_BLANK_COLOR) {
this.editor.setFontColor(color);
}
}

private clearPreviousTextStyles(): void {
Expand Down

0 comments on commit 6b171e4

Please sign in to comment.