Added spoiler support to export.

This commit is contained in:
23rd 2021-12-23 00:28:27 +03:00 committed by John Preston
parent 1cca4d71bd
commit 4252066cf6
6 changed files with 26 additions and 1 deletions

View File

@ -531,3 +531,16 @@ div.toast_shown {
background-image: url(../images/media_video@2x.png)
}
}
.spoiler {
background: #e8e8e8;
}
.spoiler.hidden {
background: #a9a9a9;
cursor: pointer;
border-radius: 3px;
}
.spoiler.hidden span {
opacity: 0;
user-select: none;
}

View File

@ -52,6 +52,12 @@ function ShowMentionName() {
return false;
}
function ShowSpoiler(target) {
if (target.classList.contains("hidden")) {
target.classList.toggle("hidden");
}
}
function AddClass(element, name) {
var current = element.className;
var expression = new RegExp('(^|\\s)' + name + '(\\s|$)', 'g');

View File

@ -154,7 +154,7 @@ std::vector<TextPart> ParseText(
[](const MTPDmessageEntityBlockquote&) {
return Type::Blockquote; },
[](const MTPDmessageEntityBankCard&) { return Type::BankCard; },
[](const MTPDmessageEntitySpoiler&) { return Type::Unknown; }); // #TODO spoiler
[](const MTPDmessageEntitySpoiler&) { return Type::Spoiler; });
part.text = mid(start, length);
part.additional = entity.match(
[](const MTPDmessageEntityPre &data) {

View File

@ -541,6 +541,7 @@ struct TextPart {
Strike,
Blockquote,
BankCard,
Spoiler,
};
Type type = Type::Text;
Utf8String text;

View File

@ -270,6 +270,10 @@ QByteArray FormatText(
return "<blockquote>" + text + "</blockquote>";
case Type::BankCard:
return text;
case Type::Spoiler: return "<span class=\"spoiler hidden\" "
"onclick=\"ShowSpoiler(this)\">"
"<span aria-hidden=\"true\">"
+ text + "</span></span>";
}
Unexpected("Type in text entities serialization.");
}) | ranges::to_vector);

View File

@ -176,6 +176,7 @@ QByteArray SerializeText(
case Type::Strike: return "strikethrough";
case Type::Blockquote: return "blockquote";
case Type::BankCard: return "bank_card";
case Type::Spoiler: return "spoiler";
}
Unexpected("Type in SerializeText.");
}();