Commit f12b9a71 authored by jan.koester's avatar jan.koester
Browse files

test

parent 10970d08
Loading
Loading
Loading
Loading
+22 −6
Changes for src/edit.cpp: 22 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -359,6 +359,13 @@ blogi::webedit::EditPlugin* blogi::webedit::WebEditor::createPluginByName(const
void blogi::webedit::WebEditor::loadWidgetsFromXml(tinyxml2::XMLElement *xmlEl, EditPlugin *parent) {
    if (!xmlEl) return;

    // If loading from root element, read GlobalCss attribute
    if (!parent) {
        const char *gcss = xmlEl->Attribute("GlobalCss");
        if (gcss) GlobalCss = gcss;
        else GlobalCss.clear();
    }

    EditPlugin *lastSibling = nullptr;

    tinyxml2::XMLElement *childXml = xmlEl->FirstChildElement();
@@ -1294,12 +1301,10 @@ void blogi::webedit::WebEditor::importHtmlToWidgets(const std::string &html) {
    }

    if (!globalCss.empty()) {
        tinyxml2::XMLElement *w = CurDoc.NewElement("CustomHtml");
        tinyxml2::XMLElement *htmlContent = CurDoc.NewElement("HtmlContent");
        std::string styleBlock = "<style>\n" + globalCss + "</style>";
        htmlContent->SetText(styleBlock.c_str());
        w->InsertEndChild(htmlContent);
        CurRootEl->InsertEndChild(w);
        GlobalCss = globalCss;
        CurRootEl->SetAttribute("GlobalCss", GlobalCss.c_str());
    } else {
        GlobalCss.clear();
    }

    if (root) {
@@ -1316,6 +1321,8 @@ void blogi::webedit::WebEditor::saveDocumentXml(libhttppp::HttpRequest &curreq)
    CurRootEl = CurDoc.NewElement("WebEditor");
    CurRootEl->SetAttribute("Version", "1.0");
    CurRootEl->SetAttribute("editor", "blogi");
    if (!GlobalCss.empty())
        CurRootEl->SetAttribute("GlobalCss", GlobalCss.c_str());
    CurDoc.InsertEndChild(CurRootEl);

    // Serialize each document element
@@ -1378,6 +1385,8 @@ std::string blogi::webedit::WebEditor::serializeCurrentXml() {
    CurRootEl = CurDoc.NewElement("WebEditor");
    CurRootEl->SetAttribute("Version", "1.0");
    CurRootEl->SetAttribute("editor", "blogi");
    if (!GlobalCss.empty())
        CurRootEl->SetAttribute("GlobalCss", GlobalCss.c_str());
    CurDoc.InsertEndChild(CurRootEl);

    // Serialize each document element
@@ -2628,6 +2637,13 @@ void blogi::webedit::WebEditor::Renderer(
    }

    if(root){
        // Emit global CSS (e.g. :root vars, @keyframes, @font-face) before widgets
        if (!GlobalCss.empty()) {
            libhtmlpp::HtmlElement globalStyle("style");
            globalStyle.appendChild(libhtmlpp::TextElement(GlobalCss.c_str()));
            root->appendChild(globalStyle);
        }

        // Render user-created document elements (if any)
        if (DocRoot) {
            const EditPlugin *el = DocRoot;
+3 −0
Changes for src/edit.h: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -133,6 +133,9 @@ namespace blogi {
                std::unique_ptr<EditPluginLoad> Plugins=nullptr;
                PluginArgs                                  &Args;

                // Global CSS (e.g. :root vars, @keyframes, @font-face) from HTML import
                std::string                         GlobalCss;

                // Document tree: user-created widget instances
                // DocElements owns the memory; DocRoot is the first top-level element
                std::vector<std::unique_ptr<EditPlugin>> DocElements;