mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 14:17:12 +02:00
Added spoiler support to export.
This commit is contained in:
parent
1cca4d71bd
commit
4252066cf6
6 changed files with 26 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -541,6 +541,7 @@ struct TextPart {
|
|||
Strike,
|
||||
Blockquote,
|
||||
BankCard,
|
||||
Spoiler,
|
||||
};
|
||||
Type type = Type::Text;
|
||||
Utf8String text;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.");
|
||||
}();
|
||||
|
|
Loading…
Add table
Reference in a new issue