Commit 70a924ee authored by Jan Köster's avatar Jan Köster
Browse files

test

parent f971700f
Loading
Loading
Loading
Loading
+86 −1
Changes for editor/widgets/textbox/textbox.cpp: 86 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -84,6 +84,19 @@ extern "C" {
            std::string width        = "";
            std::string height       = "";

            // Spacing
            std::string paddingTop    = "";
            std::string paddingRight  = "";
            std::string paddingBottom = "";
            std::string paddingLeft   = "";
            std::string lineHeight    = "";
            std::string letterSpacing = "";
            std::string wordSpacing   = "";

            // Mobile spacing overrides
            std::string m_lineHeight    = "";
            std::string m_letterSpacing = "";

            // Light mode overrides (empty = inherit dark value)
            std::string l_fontColor  = "";
            std::string ml_fontColor = "";
@@ -271,6 +284,14 @@ extern "C" {
                addField("content", "Content", "richtext");
                addField("width", "Width", "text", "e.g. 100%", "desktop");
                addField("height", "Height", "text", "e.g. auto", "desktop");
                // Spacing
                addField("padding_top",    "Innenabstand oben",   "text", "z.B. 8px", "desktop");
                addField("padding_right",  "Innenabstand rechts", "text", "z.B. 8px", "desktop");
                addField("padding_bottom", "Innenabstand unten",  "text", "z.B. 8px", "desktop");
                addField("padding_left",   "Innenabstand links",  "text", "z.B. 8px", "desktop");
                addField("line_height",    "Zeilenabstand",       "text", "z.B. 1.5 oder 24px", "desktop");
                addField("letter_spacing", "Buchstabenabstand",   "text", "z.B. 0.05em", "desktop");
                addField("word_spacing",   "Wortabstand",         "text", "z.B. 0.1em", "desktop");
                addField("font_family", "Font Family", "text", "e.g. Arial, sans-serif");
                addField("font_size", "Font Size", "text", "e.g. 16px", "desktop");
                addField("font_color", "Font Color (Dark)", "color_var", nullptr, "desktop");
@@ -301,6 +322,8 @@ extern "C" {
                addField("m_width", "Width", "text", "e.g. 100%", "mobile");
                addField("m_height", "Height", "text", "e.g. auto", "mobile");
                addField("m_font_size", "Font Size", "text", "e.g. 14px", "mobile");
                addField("m_line_height",    "Zeilenabstand",     "text", "z.B. 1.5", "mobile");
                addField("m_letter_spacing", "Buchstabenabstand", "text", "z.B. 0.05em", "mobile");
                addField("m_font_color", "Font Color", "color_var", nullptr, "mobile");
                addField("m_text_align", "Text Align", "select", nullptr, "mobile", mkOpts({"left","center","right","justify"}));
                addField("m_hidden", "Hidden", "checkbox", nullptr, "mobile");
@@ -349,6 +372,17 @@ extern "C" {
                element->SetAttribute("width", width.c_str());
                element->SetAttribute("height", height.c_str());

                // Spacing
                element->SetAttribute("padding_top",    paddingTop.c_str());
                element->SetAttribute("padding_right",  paddingRight.c_str());
                element->SetAttribute("padding_bottom", paddingBottom.c_str());
                element->SetAttribute("padding_left",   paddingLeft.c_str());
                element->SetAttribute("line_height",    lineHeight.c_str());
                element->SetAttribute("letter_spacing", letterSpacing.c_str());
                element->SetAttribute("word_spacing",   wordSpacing.c_str());
                element->SetAttribute("m_line_height",    m_lineHeight.c_str());
                element->SetAttribute("m_letter_spacing", m_letterSpacing.c_str());

                // Light mode overrides
                element->SetAttribute("l_font_color", l_fontColor.c_str());
                element->SetAttribute("ml_font_color", ml_fontColor.c_str());
@@ -431,6 +465,17 @@ extern "C" {
                val = xml_data->Attribute("height");
                if (val) height = val;

                // Spacing
                val = xml_data->Attribute("padding_top");    if (val) paddingTop    = val;
                val = xml_data->Attribute("padding_right");  if (val) paddingRight  = val;
                val = xml_data->Attribute("padding_bottom"); if (val) paddingBottom = val;
                val = xml_data->Attribute("padding_left");   if (val) paddingLeft   = val;
                val = xml_data->Attribute("line_height");    if (val) lineHeight    = val;
                val = xml_data->Attribute("letter_spacing"); if (val) letterSpacing = val;
                val = xml_data->Attribute("word_spacing");   if (val) wordSpacing   = val;
                val = xml_data->Attribute("m_line_height");    if (val) m_lineHeight    = val;
                val = xml_data->Attribute("m_letter_spacing"); if (val) m_letterSpacing = val;

                // Light mode overrides
                val = xml_data->Attribute("l_font_color");
                if (val) l_fontColor = val;
@@ -493,6 +538,15 @@ extern "C" {
                json_object_object_add(obj, "icon_color", json_object_new_string(iconColor.c_str()));
                json_object_object_add(obj, "width", json_object_new_string(width.c_str()));
                json_object_object_add(obj, "height", json_object_new_string(height.c_str()));
                json_object_object_add(obj, "padding_top",    json_object_new_string(paddingTop.c_str()));
                json_object_object_add(obj, "padding_right",  json_object_new_string(paddingRight.c_str()));
                json_object_object_add(obj, "padding_bottom", json_object_new_string(paddingBottom.c_str()));
                json_object_object_add(obj, "padding_left",   json_object_new_string(paddingLeft.c_str()));
                json_object_object_add(obj, "line_height",    json_object_new_string(lineHeight.c_str()));
                json_object_object_add(obj, "letter_spacing", json_object_new_string(letterSpacing.c_str()));
                json_object_object_add(obj, "word_spacing",   json_object_new_string(wordSpacing.c_str()));
                json_object_object_add(obj, "m_line_height",    json_object_new_string(m_lineHeight.c_str()));
                json_object_object_add(obj, "m_letter_spacing", json_object_new_string(m_letterSpacing.c_str()));
                json_object_object_add(obj, "content", json_object_new_string(content.c_str()));
                json_object_object_add(obj, "l_font_color", json_object_new_string(l_fontColor.c_str()));
                json_object_object_add(obj, "ml_font_color", json_object_new_string(ml_fontColor.c_str()));
@@ -573,6 +627,22 @@ extern "C" {
                if (json_object_object_get_ex(obj, "height", &val_obj)) {
                    val = json_object_get_string(val_obj); if (val) height = val;
                }
                auto readStr = [&](const char *key, std::string &dest) {
                    json_object *v = nullptr;
                    if (json_object_object_get_ex(obj, key, &v)) {
                        const char *s = json_object_get_string(v);
                        if (s) dest = s;
                    }
                };
                readStr("padding_top",      paddingTop);
                readStr("padding_right",    paddingRight);
                readStr("padding_bottom",   paddingBottom);
                readStr("padding_left",     paddingLeft);
                readStr("line_height",      lineHeight);
                readStr("letter_spacing",   letterSpacing);
                readStr("word_spacing",     wordSpacing);
                readStr("m_line_height",    m_lineHeight);
                readStr("m_letter_spacing", m_letterSpacing);
                if (json_object_object_get_ex(obj, "content", &val_obj)) {
                    val = json_object_get_string(val_obj);
                    if (val) content = val; // Allow empty content
@@ -688,7 +758,17 @@ extern "C" {
                // Unique CSS class for responsive targeting
                std::string responsiveClass = std::string("we-") + getInstanceId().c_str();

                std::string style = "padding: 8px;";
                // Padding: individual sides if set, else fallback to 8px
                std::string style;
                bool hasCustomPadding = !paddingTop.empty() || !paddingRight.empty()
                                     || !paddingBottom.empty() || !paddingLeft.empty();
                if (hasCustomPadding) {
                    auto pad = [](const std::string &v) { return v.empty() ? "0" : v; };
                    style += "padding:" + pad(paddingTop) + " " + pad(paddingRight)
                           + " " + pad(paddingBottom) + " " + pad(paddingLeft) + ";";
                } else {
                    style += "padding:8px;";
                }
                if (!width.empty())      style += " width: " + width + ";";
                if (!height.empty())     style += " height: " + height + ";";
                if (!fontFamily.empty()) style += " font-family: " + fontFamily + ";";
@@ -700,6 +780,9 @@ extern "C" {
                if (whiteSpace != "normal") style += " white-space: " + whiteSpace + ";";
                if (textDecoration != "none" && !textDecoration.empty()) style += " text-decoration: " + textDecoration + ";";
                if (!underlineColor.empty()) style += " text-decoration-color: " + underlineColor + ";";
                if (!lineHeight.empty())    style += " line-height: " + lineHeight + ";";
                if (!letterSpacing.empty()) style += " letter-spacing: " + letterSpacing + ";";
                if (!wordSpacing.empty())   style += " word-spacing: " + wordSpacing + ";";
                if (hidden) style += " display: none;";

                // Underline color for richtext content: <u> tags and inline-styled spans
@@ -724,6 +807,8 @@ extern "C" {
                if (!m_textAlign.empty()) mobileCSS += " text-align: " + m_textAlign + " !important;";
                if (!m_width.empty()) mobileCSS += " width: " + m_width + " !important;";
                if (!m_height.empty())       mobileCSS += " height: "         + m_height       + " !important;";
                if (!m_lineHeight.empty())    mobileCSS += " line-height: "    + m_lineHeight    + " !important;";
                if (!m_letterSpacing.empty()) mobileCSS += " letter-spacing: " + m_letterSpacing + " !important;";
                if (m_hidden) mobileCSS += " display: none !important;";
                else if (hidden) mobileCSS += " display: block !important;";