diff --git a/Telegram/SourceFiles/iv/editor/iv_editor_widget.cpp b/Telegram/SourceFiles/iv/editor/iv_editor_widget.cpp index ef554ab391..ce732b5690 100644 --- a/Telegram/SourceFiles/iv/editor/iv_editor_widget.cpp +++ b/Telegram/SourceFiles/iv/editor/iv_editor_widget.cpp @@ -1669,23 +1669,31 @@ void EditMathBox( host->resize(cardWidth, desiredHeight); }, host->lifetime()); preview->setSource(startSource); - const auto interacted = box->lifetime().make_state(false); - if (startSource.isEmpty()) { + const auto applyRandomSample = [=] { const auto &sample = kFormulaSamples[ base::RandomIndex(int(kFormulaSamples.size()))]; source->setPlaceholder(rpl::single(sample)); preview->setColor(st::windowSubTextFg); preview->setSource(sample); + }; + const auto wasEmpty = box->lifetime().make_state( + startSource.isEmpty()); + if (startSource.isEmpty()) { + applyRandomSample(); } source->changes( ) | rpl::on_next([=] { - if (!*interacted) { - *interacted = true; + const auto text = source->getLastText(); + if (text.isEmpty()) { + if (!*wasEmpty) { + *wasEmpty = true; + applyRandomSample(); + } + } else { + *wasEmpty = false; preview->setColor(st::ivFormulaPreviewFg); - source->setPlaceholder( - tr::lng_formatting_math_source_placeholder()); + preview->setSource(text); } - preview->setSource(source->getLastText()); }, source->lifetime()); box->setTitle(editingExisting diff --git a/Telegram/SourceFiles/iv/iv.style b/Telegram/SourceFiles/iv/iv.style index a049a4b7a7..9639fbb13e 100644 --- a/Telegram/SourceFiles/iv/iv.style +++ b/Telegram/SourceFiles/iv/iv.style @@ -577,9 +577,13 @@ ivFormulaPreviewRadius: 8px; ivFormulaPreviewBg: windowBgOver; ivFormulaPreviewFg: windowFg; ivFormulaSourceField: InputField(defaultInputField) { + textMargins: margins(0px, 6px, 0px, 4px); + placeholderFg: placeholderFg; + placeholderFgActive: placeholderFgActive; placeholderScale: 0.; placeholderFont: normalFont; placeholderShift: -50px; + heightMin: 33px; } defaultMarkdownTable: MarkdownTable { cellPadding: margins(8px, 10px, 8px, 10px);