Support blockquote / pre in caption / ai tools.

This commit is contained in:
John Preston
2026-03-30 16:34:47 +07:00
parent f8efc992ef
commit 50cd572754
15 changed files with 167 additions and 28 deletions
@@ -1807,3 +1807,27 @@ aiComposeSendButton: SendButton(historySend) {
}
sendIconFg: windowFgActive;
}
aiComposeBodyLabel: FlatLabel(defaultFlatLabel) {
minWidth: 300px;
align: align(topleft);
style: TextStyle(defaultTextStyle) {
lineHeight: 22px;
blockquote: QuoteStyle(historyQuoteStyle) {
padding: margins(10px, 2px, 20px, 2px);
icon: icon{{ "chat/mini_quote", windowFg }};
iconPosition: point(4px, 4px);
expand: icon{{ "intro_country_dropdown", windowFg }};
expandPosition: point(6px, 4px);
collapse: icon{{ "intro_country_dropdown-flip_vertical", windowFg }};
collapsePosition: point(6px, 4px);
}
pre: QuoteStyle(historyQuoteStyle) {
header: 20px;
headerPosition: point(10px, 2px);
scrollable: true;
icon: icon{{ "chat/mini_copy", windowFg }};
iconPosition: point(4px, 2px);
}
}
}
@@ -498,7 +498,8 @@ Fn<void(QString now, Fn<void(QString)> save)> DefaultEditLanguageCallback(
};
}
void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
auto InitMessageFieldHandlers(MessageFieldHandlersArgs &&args)
-> std::shared_ptr<Ui::ChatStyle> {
const auto paused = [passed = args.customEmojiPaused] {
return passed && passed();
};
@@ -526,7 +527,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
field->setEditLanguageCallback(DefaultEditLanguageCallback(show));
InitSpellchecker(show, field, args.fieldStyle != nullptr);
}
const auto style = field->lifetime().make_state<Ui::ChatStyle>(
const auto style = std::make_shared<Ui::ChatStyle>(
session->colorIndicesValue());
field->setPreCache([=] {
return style->messageStyle(false, false).preCache.get();
@@ -535,6 +536,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
const auto colorIndex = session->user()->colorIndex();
return style->coloredQuoteCache(false, colorIndex).get();
});
return style;
}
[[nodiscard]] bool IsGoodFactcheckUrl(QStringView url) {
@@ -646,11 +648,11 @@ void InitMessageFieldGeometry(not_null<Ui::InputField*> field) {
field->setAdditionalMargin(style::ConvertScale(4) - 4);
}
void InitMessageField(
std::shared_ptr<Ui::ChatStyle> InitMessageField(
std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
InitMessageFieldHandlers({
const auto style = InitMessageFieldHandlers({
.session = &show->session(),
.show = show,
.field = field,
@@ -660,9 +662,10 @@ void InitMessageField(
.allowPremiumEmoji = std::move(allowPremiumEmoji),
});
InitMessageFieldGeometry(field);
return style;
}
void InitMessageField(
std::shared_ptr<Ui::ChatStyle> InitMessageField(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji) {
@@ -42,6 +42,7 @@ struct WriteRestriction;
} // namespace HistoryView::Controls
namespace Ui {
class ChatStyle;
class GenericBox;
class PopupMenu;
class Show;
@@ -73,18 +74,19 @@ struct MessageFieldHandlersArgs {
const style::InputField *fieldStyle = nullptr;
base::flat_set<QString> allowMarkdownTags;
};
void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args);
auto InitMessageFieldHandlers(MessageFieldHandlersArgs &&args)
-> std::shared_ptr<Ui::ChatStyle>;
void InitMessageFieldHandlers(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
ChatHelpers::PauseReason pauseReasonLevel,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji = nullptr);
void InitMessageField(
std::shared_ptr<Ui::ChatStyle> InitMessageField(
std::shared_ptr<ChatHelpers::Show> show,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji);
void InitMessageField(
std::shared_ptr<Ui::ChatStyle> InitMessageField(
not_null<Window::SessionController*> controller,
not_null<Ui::InputField*> field,
Fn<bool(not_null<DocumentData*>)> allowPremiumEmoji);