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::BotCommand && !parseBotCommands) || // #TODO entities
|
||||
(!parseMarkdown && (type == EntityType::Bold
|
||||
|| type == EntityType::Semibold
|
||||
|| type == EntityType::Italic
|
||||
|| type == EntityType::Underline
|
||||
|| type == EntityType::StrikeOut
|
||||
|
|
@ -542,6 +543,8 @@ bool Parser::checkEntities() {
|
|||
const auto entityEnd = entityBegin + entityLength;
|
||||
if (entityType == EntityType::Bold) {
|
||||
flags = TextBlockFBold;
|
||||
} else if (entityType == EntityType::Semibold) {
|
||||
flags = TextBlockFSemibold;
|
||||
} else if (entityType == EntityType::Italic) {
|
||||
flags = TextBlockFItalic;
|
||||
} else if (entityType == EntityType::Underline) {
|
||||
|
|
@ -3244,6 +3247,7 @@ TextForMimeData String::toText(
|
|||
? std::vector<MarkdownTagTracker>{
|
||||
{ TextBlockFItalic, EntityType::Italic },
|
||||
{ TextBlockFBold, EntityType::Bold },
|
||||
{ TextBlockFSemibold, EntityType::Semibold },
|
||||
{ TextBlockFUnderline, EntityType::Underline },
|
||||
{ TextBlockFStrikeOut, EntityType::StrikeOut },
|
||||
{ TextBlockFCode, EntityType::Code }, // #TODO entities
|
||||
|
|
|
|||
|
|
@ -2011,6 +2011,8 @@ EntitiesInText ConvertTextTagsToEntities(const TextWithTags::Tags &tags) {
|
|||
}
|
||||
} else if (tag.id == Ui::InputField::kTagBold) {
|
||||
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) {
|
||||
push(EntityType::Italic);
|
||||
} else if (tag.id == Ui::InputField::kTagUnderline) {
|
||||
|
|
@ -2054,6 +2056,9 @@ TextWithTags::Tags ConvertEntitiesToTextTags(const EntitiesInText &entities) {
|
|||
}
|
||||
} 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::Underline:
|
||||
push(Ui::InputField::kTagUnderline);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ enum class EntityType {
|
|||
BotCommand,
|
||||
|
||||
Bold,
|
||||
Semibold,
|
||||
Italic,
|
||||
Underline,
|
||||
StrikeOut,
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ TextWithEntities Bold(const QString &text) {
|
|||
return WithSingleEntity(text, EntityType::Bold);
|
||||
}
|
||||
|
||||
TextWithEntities Semibold(const QString &text) {
|
||||
return WithSingleEntity(text, EntityType::Semibold);
|
||||
}
|
||||
|
||||
TextWithEntities Italic(const QString &text) {
|
||||
return WithSingleEntity(text, EntityType::Italic);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,39 +24,44 @@ struct ToUpperType {
|
|||
} // namespace details
|
||||
|
||||
inline constexpr auto Upper = details::ToUpperType{};
|
||||
TextWithEntities Bold(const QString &text);
|
||||
TextWithEntities Italic(const QString &text);
|
||||
TextWithEntities Link(
|
||||
[[nodiscard]] TextWithEntities Bold(const QString &text);
|
||||
[[nodiscard]] TextWithEntities Semibold(const QString &text);
|
||||
[[nodiscard]] TextWithEntities Italic(const QString &text);
|
||||
[[nodiscard]] TextWithEntities Link(
|
||||
const QString &text,
|
||||
const QString &url = "internal:action");
|
||||
TextWithEntities RichLangValue(const QString &text);
|
||||
inline TextWithEntities WithEntities(const QString &text) {
|
||||
[[nodiscard]] TextWithEntities RichLangValue(const QString &text);
|
||||
[[nodiscard]] inline TextWithEntities WithEntities(const QString &text) {
|
||||
return { text };
|
||||
}
|
||||
|
||||
inline auto ToUpper() {
|
||||
[[nodiscard]] inline auto ToUpper() {
|
||||
return rpl::map(Upper);
|
||||
}
|
||||
|
||||
inline auto ToBold() {
|
||||
[[nodiscard]] inline auto ToBold() {
|
||||
return rpl::map(Bold);
|
||||
}
|
||||
|
||||
inline auto ToItalic() {
|
||||
[[nodiscard]] inline auto ToSemibold() {
|
||||
return rpl::map(Semibold);
|
||||
}
|
||||
|
||||
[[nodiscard]] inline auto ToItalic() {
|
||||
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 Link(text, url);
|
||||
});
|
||||
}
|
||||
|
||||
inline auto ToRichLangValue() {
|
||||
[[nodiscard]] inline auto ToRichLangValue() {
|
||||
return rpl::map(RichLangValue);
|
||||
}
|
||||
|
||||
inline auto ToWithEntities() {
|
||||
[[nodiscard]] inline auto ToWithEntities() {
|
||||
return rpl::map(WithEntities);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue