mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
parent
a174119877
commit
9db2502cd0
3 changed files with 14 additions and 13 deletions
|
@ -123,9 +123,9 @@ constexpr auto kLinkProtocols = {
|
|||
void EditLinkBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
const QString &startText,
|
||||
const TextWithTags &startText,
|
||||
const QString &startLink,
|
||||
Fn<void(QString, QString)> callback,
|
||||
Fn<void(TextWithTags, QString)> callback,
|
||||
const style::InputField *fieldStyle,
|
||||
Fn<QString(QString)> validate) {
|
||||
Expects(callback != nullptr);
|
||||
|
@ -137,6 +137,7 @@ void EditLinkBox(
|
|||
object_ptr<Ui::InputField>(
|
||||
content,
|
||||
fieldSt,
|
||||
Ui::InputField::Mode::SingleLine,
|
||||
tr::lng_formatting_link_text(),
|
||||
startText),
|
||||
st::markdownLinkFieldPadding);
|
||||
|
@ -181,9 +182,9 @@ void EditLinkBox(
|
|||
url->move(placeholder->pos());
|
||||
|
||||
const auto submit = [=] {
|
||||
const auto linkText = text->getLastText();
|
||||
const auto linkText = text->getTextWithTags();
|
||||
const auto linkUrl = validate(url->getLastText());
|
||||
if (linkText.isEmpty()) {
|
||||
if (linkText.text.isEmpty()) {
|
||||
text->showError();
|
||||
return;
|
||||
} else if (linkUrl.isEmpty()) {
|
||||
|
@ -222,7 +223,7 @@ void EditLinkBox(
|
|||
box->setWidth(st::boxWidth);
|
||||
|
||||
box->setFocusCallback([=] {
|
||||
if (startText.isEmpty()) {
|
||||
if (startText.text.isEmpty()) {
|
||||
text->setFocusFast();
|
||||
} else {
|
||||
if (!url->empty()) {
|
||||
|
@ -383,7 +384,7 @@ bool EditTextChanged(
|
|||
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
TextWithTags text,
|
||||
QString link,
|
||||
EditLinkAction action)> DefaultEditLinkCallback(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
|
@ -392,14 +393,14 @@ Fn<bool(
|
|||
const auto weak = Ui::MakeWeak(field);
|
||||
return [=](
|
||||
EditLinkSelection selection,
|
||||
QString text,
|
||||
TextWithTags text,
|
||||
QString link,
|
||||
EditLinkAction action) {
|
||||
if (action == EditLinkAction::Check) {
|
||||
return Ui::InputField::IsValidMarkdownLink(link)
|
||||
&& !TextUtilities::IsMentionLink(link);
|
||||
}
|
||||
auto callback = [=](const QString &text, const QString &link) {
|
||||
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||
}
|
||||
|
@ -470,7 +471,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
|||
|
||||
[[nodiscard]] Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
TextWithTags text,
|
||||
QString link,
|
||||
EditLinkAction action)> FactcheckEditLinkCallback(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
|
@ -478,7 +479,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
|||
const auto weak = Ui::MakeWeak(field);
|
||||
return [=](
|
||||
EditLinkSelection selection,
|
||||
QString text,
|
||||
TextWithTags text,
|
||||
QString link,
|
||||
EditLinkAction action) {
|
||||
const auto validate = [=](QString url) {
|
||||
|
@ -493,7 +494,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
|||
if (action == EditLinkAction::Check) {
|
||||
return IsGoodFactcheckUrl(link);
|
||||
}
|
||||
auto callback = [=](const QString &text, const QString &link) {
|
||||
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||
if (const auto strong = weak.data()) {
|
||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class Show;
|
|||
|
||||
Fn<bool(
|
||||
Ui::InputField::EditLinkSelection selection,
|
||||
QString text,
|
||||
TextWithTags text,
|
||||
QString link,
|
||||
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
|
||||
std::shared_ptr<Main::SessionShow> show,
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e052a8bff00c24d19c12e61b0adeb5fdf18770f0
|
||||
Subproject commit 5fbb38cf872f2132b1ad0a564083c498e6cc6f14
|
Loading…
Add table
Reference in a new issue