Revert to Paragraph format after a heading

This commit is contained in:
James Graham
2026-02-07 12:46:44 +00:00
parent c32235ffe3
commit 690bc0d385
3 changed files with 14 additions and 4 deletions

View File

@@ -6,6 +6,7 @@
#include "chattextitemhelper.h"
#include "clipboard.h"
#include "neochatroom.h"
#include "richformat.h"
ChatKeyHelper::ChatKeyHelper(QObject *parent)
: QObject(parent)
@@ -184,7 +185,12 @@ bool ChatKeyHelper::insertReturn(Qt::KeyboardModifiers modifiers)
if (cursor.isNull()) {
return false;
}
cursor.insertBlock();
// If there was a heading we always want to revert to Paragraph format.
auto newBlockFormat = RichFormat::blockFormatForFormat(RichFormat::Paragraph);
auto newCharFormat = cursor.charFormat();
newCharFormat.merge(RichFormat::charFormatForFormat(static_cast<RichFormat::Format>(cursor.blockFormat().headingLevel()), true));
cursor.insertBlock(newBlockFormat, newCharFormat);
return true;
}