Add a separate Semibold entity type.
This commit is contained in:
parent
cc9b7e2c2f
commit
555a9d203c
5 changed files with 30 additions and 11 deletions
|
|
@ -83,6 +83,7 @@ TextWithEntities PrepareRichFromRich(
|
||||||
(type == EntityType::Cashtag && !parseHashtags) ||
|
(type == EntityType::Cashtag && !parseHashtags) ||
|
||||||
(type == EntityType::BotCommand && !parseBotCommands) || // #TODO entities
|
(type == EntityType::BotCommand && !parseBotCommands) || // #TODO entities
|
||||||
(!parseMarkdown && (type == EntityType::Bold
|
(!parseMarkdown && (type == EntityType::Bold
|
||||||
|
|| type == EntityType::Semibold
|
||||||
|| type == EntityType::Italic
|
|| type == EntityType::Italic
|
||||||
|| type == EntityType::Underline
|
|| type == EntityType::Underline
|
||||||
|| type == EntityType::StrikeOut
|
|| type == EntityType::StrikeOut
|
||||||
|
|
@ -542,6 +543,8 @@ bool Parser::checkEntities() {
|
||||||
const auto entityEnd = entityBegin + entityLength;
|
const auto entityEnd = entityBegin + entityLength;
|
||||||
if (entityType == EntityType::Bold) {
|
if (entityType == EntityType::Bold) {
|
||||||
flags = TextBlockFBold;
|
flags = TextBlockFBold;
|
||||||
|
} else if (entityType == EntityType::Semibold) {
|
||||||
|
flags = TextBlockFSemibold;
|
||||||
} else if (entityType == EntityType::Italic) {
|
} else if (entityType == EntityType::Italic) {
|
||||||
flags = TextBlockFItalic;
|
flags = TextBlockFItalic;
|
||||||
} else if (entityType == EntityType::Underline) {
|
} else if (entityType == EntityType::Underline) {
|
||||||
|
|
@ -3244,6 +3247,7 @@ TextForMimeData String::toText(
|
||||||
? std::vector<MarkdownTagTracker>{
|
? std::vector<MarkdownTagTracker>{
|
||||||
{ TextBlockFItalic, EntityType::Italic },
|
{ TextBlockFItalic, EntityType::Italic },
|
||||||
{ TextBlockFBold, EntityType::Bold },
|
{ TextBlockFBold, EntityType::Bold },
|
||||||
|
{ TextBlockFSemibold, EntityType::Semibold },
|
||||||
{ TextBlockFUnderline, EntityType::Underline },
|
{ TextBlockFUnderline, EntityType::Underline },
|
||||||
{ TextBlockFStrikeOut, EntityType::StrikeOut },
|
{ TextBlockFStrikeOut, EntityType::StrikeOut },
|
||||||
{ TextBlockFCode, EntityType::Code }, // #TODO entities
|
{ TextBlockFCode, EntityType::Code }, // #TODO entities
|
||||||
|
|
|
||||||
|
|
@ -2011,6 +2011,8 @@ EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags) {
|
||||||
}
|
}
|
||||||
} else if (tag.id == Ui::InputField::kTagBold) {
|
} else if (tag.id == Ui::InputField::kTagBold) {
|
||||||
push(EntityType::Bold);
|
push(EntityType::Bold);
|
||||||
|
//} else if (tag.id == Ui::InputField::kTagSemibold) {
|
||||||
|
// push(EntityType::Semibold); // Semibold is for UI parts only.
|
||||||
} else if (tag.id == Ui::InputField::kTagItalic) {
|
} else if (tag.id == Ui::InputField::kTagItalic) {
|
||||||
push(EntityType::Italic);
|
push(EntityType::Italic);
|
||||||
} else if (tag.id == Ui::InputField::kTagUnderline) {
|
} else if (tag.id == Ui::InputField::kTagUnderline) {
|
||||||
|
|
@ -2054,6 +2056,9 @@ TextWithTags::Tags ConvertEntitiesToTextTags(const EntitiesInText &entities) {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case EntityType::Bold: push(Ui::InputField::kTagBold); break;
|
case EntityType::Bold: push(Ui::InputField::kTagBold); break;
|
||||||
|
//case EntityType::Semibold: // Semibold is for UI parts only.
|
||||||
|
// push(Ui::InputField::kTagSemibold);
|
||||||
|
// break;
|
||||||
case EntityType::Italic: push(Ui::InputField::kTagItalic); break;
|
case EntityType::Italic: push(Ui::InputField::kTagItalic); break;
|
||||||
case EntityType::Underline:
|
case EntityType::Underline:
|
||||||
push(Ui::InputField::kTagUnderline);
|
push(Ui::InputField::kTagUnderline);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ enum class EntityType {
|
||||||
BotCommand,
|
BotCommand,
|
||||||
|
|
||||||
Bold,
|
Bold,
|
||||||
|
Semibold,
|
||||||
Italic,
|
Italic,
|
||||||
Underline,
|
Underline,
|
||||||
StrikeOut,
|
StrikeOut,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,10 @@ TextWithEntities Bold(const QString &text) {
|
||||||
return WithSingleEntity(text, EntityType::Bold);
|
return WithSingleEntity(text, EntityType::Bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextWithEntities Semibold(const QString &text) {
|
||||||
|
return WithSingleEntity(text, EntityType::Semibold);
|
||||||
|
}
|
||||||
|
|
||||||
TextWithEntities Italic(const QString &text) {
|
TextWithEntities Italic(const QString &text) {
|
||||||
return WithSingleEntity(text, EntityType::Italic);
|
return WithSingleEntity(text, EntityType::Italic);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,39 +24,44 @@ struct ToUpperType {
|
||||||
} // namespace details
|
} // namespace details
|
||||||
|
|
||||||
inline constexpr auto Upper = details::ToUpperType{};
|
inline constexpr auto Upper = details::ToUpperType{};
|
||||||
TextWithEntities Bold(const QString &text);
|
[[nodiscard]] TextWithEntities Bold(const QString &text);
|
||||||
TextWithEntities Italic(const QString &text);
|
[[nodiscard]] TextWithEntities Semibold(const QString &text);
|
||||||
TextWithEntities Link(
|
[[nodiscard]] TextWithEntities Italic(const QString &text);
|
||||||
|
[[nodiscard]] TextWithEntities Link(
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const QString &url = "internal:action");
|
const QString &url = "internal:action");
|
||||||
TextWithEntities RichLangValue(const QString &text);
|
[[nodiscard]] TextWithEntities RichLangValue(const QString &text);
|
||||||
inline TextWithEntities WithEntities(const QString &text) {
|
[[nodiscard]] inline TextWithEntities WithEntities(const QString &text) {
|
||||||
return { text };
|
return { text };
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToUpper() {
|
[[nodiscard]] inline auto ToUpper() {
|
||||||
return rpl::map(Upper);
|
return rpl::map(Upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToBold() {
|
[[nodiscard]] inline auto ToBold() {
|
||||||
return rpl::map(Bold);
|
return rpl::map(Bold);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToItalic() {
|
[[nodiscard]] inline auto ToSemibold() {
|
||||||
|
return rpl::map(Semibold);
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] inline auto ToItalic() {
|
||||||
return rpl::map(Italic);
|
return rpl::map(Italic);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToLink(const QString &url = "internal:action") {
|
[[nodiscard]] inline auto ToLink(const QString &url = "internal:action") {
|
||||||
return rpl::map([=](const QString &text) {
|
return rpl::map([=](const QString &text) {
|
||||||
return Link(text, url);
|
return Link(text, url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToRichLangValue() {
|
[[nodiscard]] inline auto ToRichLangValue() {
|
||||||
return rpl::map(RichLangValue);
|
return rpl::map(RichLangValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto ToWithEntities() {
|
[[nodiscard]] inline auto ToWithEntities() {
|
||||||
return rpl::map(WithEntities);
|
return rpl::map(WithEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue