#include "richtexteditor.h" #include "richtexteditortoolbar.h" #include #include #include #include #include const bool simplifyRichTextDefault = true; using namespace Qt::StringLiterals; // Richtext simplification filter helpers: Elements to be discarded static inline bool filterElement(QStringView name) { return name != "meta"_L1 && name != "style"_L1; } // Richtext simplification filter helpers: Filter attributes of elements static inline void filterAttributes(QStringView name, QXmlStreamAttributes *atts, bool *paragraphAlignmentFound) { if (atts->isEmpty()) return; // No style attributes for if (name == "body"_L1) { atts->clear(); return; } // Clean out everything except 'align' for 'p' if (name == "p"_L1) { for (auto it = atts->begin(); it != atts->end(); ) { if (it->name() == "align"_L1) { ++it; *paragraphAlignmentFound = true; } else { it = atts->erase(it); } } return; } } // Richtext simplification filter helpers: Check for blank QStringView. static inline bool isWhiteSpace(QStringView in) { return std::all_of(in.cbegin(), in.cend(), [](QChar c) { return c.isSpace(); }); } // Richtext simplification filter: Remove hard-coded font settings, //