Skip to content

Commit

Permalink
feat: reuse previous font color when change font size (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Oct 18, 2023
1 parent 9762c53 commit abd01e2
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ChangeDetectionStrategy, Component, Inject} from '@angular/core';
import {tuiAssert, tuiPx} from '@taiga-ui/cdk';
import {TuiLanguageEditor} from '@taiga-ui/i18n';
import {AbstractTuiEditor} from '@tinkoff/tui-editor/abstract';
import {EDITOR_BLANK_COLOR} from '@tinkoff/tui-editor/constants';
import {TuiTiptapEditorService} from '@tinkoff/tui-editor/directives';
import {TuiEditorFontOption} from '@tinkoff/tui-editor/interfaces';
import {
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 abd01e2

Please sign in to comment.