Texthandler edited
Move the handling of adding whether the message has been edited to texthandler.
This commit is contained in:
@@ -7,10 +7,13 @@
|
||||
#include <QUrl>
|
||||
|
||||
#include <events/roommessageevent.h>
|
||||
#include <qstringliteral.h>
|
||||
#include <util.h>
|
||||
|
||||
#include <cmark.h>
|
||||
|
||||
#include <Kirigami/PlatformTheme>
|
||||
|
||||
static const QStringList allowedTags = {
|
||||
QStringLiteral("font"), QStringLiteral("del"), QStringLiteral("h1"), QStringLiteral("h2"), QStringLiteral("h3"), QStringLiteral("h4"),
|
||||
QStringLiteral("h5"), QStringLiteral("h6"), QStringLiteral("blockquote"), QStringLiteral("p"), QStringLiteral("a"), QStringLiteral("ul"),
|
||||
@@ -150,6 +153,31 @@ QString TextHandler::handleRecieveRichText(Qt::TextFormat inputFormat, const Neo
|
||||
}
|
||||
}
|
||||
|
||||
if (auto e = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||
bool isEdited =
|
||||
!e->unsignedJson().isEmpty() && e->unsignedJson().contains("m.relations") && e->unsignedJson()["m.relations"].toObject().contains("m.replace");
|
||||
if (isEdited) {
|
||||
Kirigami::PlatformTheme *theme = static_cast<Kirigami::PlatformTheme *>(qmlAttachedPropertiesObject<Kirigami::PlatformTheme>(this, true));
|
||||
|
||||
QString editTextColor;
|
||||
if (theme != nullptr) {
|
||||
editTextColor = theme->disabledTextColor().name();
|
||||
} else {
|
||||
editTextColor = QStringLiteral("#000000");
|
||||
}
|
||||
QString editedString = QStringLiteral(" <span style=\"color:") + editTextColor + QStringLiteral("\">(edited)</span>");
|
||||
if (outputString.endsWith(QStringLiteral("</p>"))) {
|
||||
outputString.insert(outputString.length() - 4, editedString);
|
||||
} else if (outputString.endsWith(QStringLiteral("</pre>")) || outputString.endsWith(QStringLiteral("</blockquote>"))
|
||||
|| outputString.endsWith(QStringLiteral("</table>")) || outputString.endsWith(QStringLiteral("</ol>"))
|
||||
|| outputString.endsWith(QStringLiteral("</ul>"))) {
|
||||
outputString.append("<p>" + editedString + "</p>");
|
||||
} else {
|
||||
outputString.append(editedString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace <del> with <s>
|
||||
* Note: <s> is still not a valid tag for the message from the server. We
|
||||
|
||||
Reference in New Issue
Block a user