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

test

parent 964c421a
Loading
Loading
Loading
Loading
+94 −2
Changes for editor/widgets/textbox/textbox.cpp: 94 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <sstream>
#include <iostream>
#include <cstring>
#include <map>
#include <string>

#include <tinyxml2.h>
#include <htmlpp/html.h>
@@ -102,8 +104,12 @@ extern "C" {

            // Character counter
            bool showCharCount            = false;
            std::string charCountSymbol   = "none";   // none, checkmark, check_green, arrow, star, hash, bullet, eye
            std::string charCountPosition = "after";  // after, before, top_right, bottom_right
            std::string charCountSymbol   = "none";
            std::string charCountPosition = "after";

            // List bullet style
            std::string listBullet      = "default"; // default,disc,circle,square,none,checkmark,check_green,arrow,arrow_small,star,dash,diamond,cross
            std::string listBulletColor = "";

        public:

@@ -313,6 +319,12 @@ extern "C" {
                    mkOpts({"none","checkmark","check_green","arrow","star","hash","bullet","eye"}));
                addField("char_count_position", "Zähler-Position", "select", nullptr, "all",
                    mkOpts({"after","before","top_right","bottom_right"}));
                // List bullet style
                addField("list_bullet", "Aufzählungssymbol", "select", nullptr, "all",
                    mkOpts({"default","disc","circle","square","none",
                            "checkmark","check_green","arrow","arrow_small",
                            "star","dash","diamond","cross"}));
                addField("list_bullet_color", "Aufzählungsfarbe", "color_var", nullptr, "all");
                return arr;
            }

@@ -357,6 +369,10 @@ extern "C" {
                element->SetAttribute("char_count_symbol", charCountSymbol.c_str());
                element->SetAttribute("char_count_position", charCountPosition.c_str());

                // List bullet
                element->SetAttribute("list_bullet", listBullet.c_str());
                element->SetAttribute("list_bullet_color", listBulletColor.c_str());

                if (!customCss.empty()) {
                    tinyxml2::XMLElement* cssEl = doc->NewElement("CustomCss");
                    cssEl->SetText(customCss.c_str());
@@ -447,6 +463,12 @@ extern "C" {
                val = xml_data->Attribute("char_count_position");
                if (val) charCountPosition = val;

                // List bullet
                val = xml_data->Attribute("list_bullet");
                if (val) listBullet = val;
                val = xml_data->Attribute("list_bullet_color");
                if (val) listBulletColor = val;

                tinyxml2::XMLElement* cssEl = xml_data->FirstChildElement("CustomCss");
                if (cssEl) {
                    const char* cssVal = cssEl->GetText();
@@ -485,6 +507,8 @@ extern "C" {
                json_object_object_add(obj, "show_char_count", json_object_new_boolean(showCharCount));
                json_object_object_add(obj, "char_count_symbol", json_object_new_string(charCountSymbol.c_str()));
                json_object_object_add(obj, "char_count_position", json_object_new_string(charCountPosition.c_str()));
                json_object_object_add(obj, "list_bullet", json_object_new_string(listBullet.c_str()));
                json_object_object_add(obj, "list_bullet_color", json_object_new_string(listBulletColor.c_str()));
                const char *result = json_object_to_json_string_ext(obj, JSON_C_TO_STRING_NOSLASHESCAPE);
                std::string out(result);
                json_object_put(obj);
@@ -614,6 +638,14 @@ extern "C" {
                    val = json_object_get_string(val_obj);
                    if (val) charCountPosition = val;
                }
                if (json_object_object_get_ex(obj, "list_bullet", &val_obj)) {
                    val = json_object_get_string(val_obj);
                    if (val) listBullet = val;
                }
                if (json_object_object_get_ex(obj, "list_bullet_color", &val_obj)) {
                    val = json_object_get_string(val_obj);
                    if (val) listBulletColor = val;
                }

                json_object_put(obj);
            }
@@ -731,6 +763,66 @@ extern "C" {
                    el.appendChild(cssStyle);
                }

                // --- List bullet style ---
                if (listBullet != "default" && !listBullet.empty()) {
                    std::string sel = "." + responsiveClass;
                    std::string colorProp = listBulletColor.empty()
                        ? "currentColor"
                        : listBulletColor;
                    std::string bulletCss;

                    if (listBullet == "disc" || listBullet == "circle" || listBullet == "square") {
                        bulletCss =
                            sel + " ul," + sel + " ol{"
                            "list-style-type:" + listBullet + ";"
                            "padding-left:1.4em;}"
                            + sel + " ul>li::marker," + sel + " ol>li::marker{"
                            "color:" + colorProp + ";}";
                    } else if (listBullet == "none") {
                        bulletCss =
                            sel + " ul," + sel + " ol{"
                            "list-style-type:none;padding-left:0;}"
                            + sel + " ul>li::before," + sel + " ol>li::before{"
                            "content:none;}";
                    } else {
                        // Custom symbol via ::before
                        static const std::map<std::string,std::string> symbolMap = {
                            {"checkmark",  "\\2713\\00a0"},   // ✓
                            {"check_green","\\2713\\00a0"},   // ✓ (color set separately)
                            {"arrow",      "\\2192\\00a0"},   // →
                            {"arrow_small","\\25B6\\00a0"},   // ▶
                            {"star",       "\\2605\\00a0"},   // ★
                            {"dash",       "\\2013\\00a0"},   // –
                            {"diamond",    "\\25C6\\00a0"},   // ◆
                            {"cross",      "\\2715\\00a0"},   // ✕
                        };
                        std::string sym = "\\2022\\00a0"; // • fallback
                        auto it = symbolMap.find(listBullet);
                        if (it != symbolMap.end()) sym = it->second;

                        std::string bulletColor = colorProp;
                        if (listBullet == "check_green" && listBulletColor.empty())
                            bulletColor = "#3ad43a";

                        bulletCss =
                            sel + " ul," + sel + " ol{"
                            "list-style-type:none;padding-left:1.4em;}"
                            + sel + " ul>li," + sel + " ol>li{"
                            "position:relative;}"
                            + sel + " ul>li::before," + sel + " ol>li::before{"
                            "content:\"" + sym + "\";"
                            "color:" + bulletColor + ";"
                            "position:absolute;left:-1.2em;"
                            "font-size:0.95em;}";
                    }

                    if (!bulletCss.empty()) {
                        libhtmlpp::HtmlElement bulletStyle("style");
                        bulletStyle.appendChild(libhtmlpp::TextElement(bulletCss.c_str()));
                        el.appendChild(bulletStyle);
                    }
                }

                // --- Character counter badge helper ---
                auto appendCharCountBadge = [&](libhtmlpp::HtmlElement &target) {
                    size_t charCount = countVisibleChars(content);