Loading editor/src/htmlimport.cpp +34 −16 Changes for editor/src/htmlimport.cpp: 34 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -476,6 +476,35 @@ std::string mapToVerticalAlign(const std::string &cssValue, bool allowStretch) return ""; } // Sets a widget's own "align_items"/"direction" attributes directly from the // imported CSS `align-items`/`flex-direction` values, and marks whichever of // them was actually consumed as known so it doesn't also leak into // CustomCss. Both are plain passthroughs, not lossy translations like // `justify-content` -> `vertical_align`: Container/Section/Article/List's // own `align_items` field already uses the same value domain as real CSS // align-items, and their `direction` field's "horizontal"/"vertical" means // exactly what CSS `flex-direction: row`/`column` means, just spelled // differently. void applyFlexLayoutAttributes(tinyxml2::XMLElement *w, std::map<std::string,std::string> &cssProps, std::vector<std::string> &knownCss) { if (cssProps.count("align-items")) { w->SetAttribute("align_items", cssProps["align-items"].c_str()); knownCss.push_back("align-items"); } if (cssProps.count("flex-direction")) { const std::string &fd = cssProps["flex-direction"]; if (fd == "row" || fd == "row-reverse") { w->SetAttribute("direction", "horizontal"); knownCss.push_back("flex-direction"); } else if (fd == "column" || fd == "column-reverse") { w->SetAttribute("direction", "vertical"); knownCss.push_back("flex-direction"); } } } } // namespace std::string blogi::htmlimport::extractCustomCss( Loading Loading @@ -799,6 +828,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -841,6 +871,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -911,6 +942,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -1096,20 +1128,6 @@ void blogi::htmlimport::htmlElementToWidgetXml( w->SetAttribute("margin", cssProps["margin"].c_str()); if (cssMeansHidden(cssProps)) w->SetAttribute("hidden", "true"); // "row"/"column" match List's own "horizontal"/"vertical" // enum 1:1 in meaning even though the words differ. if (cssProps.count("flex-direction")) { const std::string &fd = cssProps["flex-direction"]; if (fd == "row" || fd == "row-reverse") w->SetAttribute("direction", "horizontal"); else if (fd == "column" || fd == "column-reverse") w->SetAttribute("direction", "vertical"); } // List's align_items field already uses raw CSS align-items // keywords (flex-start/center/flex-end/stretch/baseline), so // this is a direct passthrough, not a translation. if (cssProps.count("align-items")) w->SetAttribute("align_items", cssProps["align-items"].c_str()); libhtmlpp::Element *liEl = el->firstChild(); while (liEl) { Loading @@ -1131,8 +1149,8 @@ void blogi::htmlimport::htmlElementToWidgetXml( std::vector<std::string> knownCss = { "font-size","color","line-height","list-style-type", "padding","margin","width","height","display","visibility", "flex-direction","gap","align-items"}; "padding","margin","width","height","display","visibility","gap"}; applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading editor/widgets/article/article.cpp +22 −5 Changes for editor/widgets/article/article.cpp: 22 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -684,6 +684,18 @@ extern "C" { val = json_object_get_string(val_obj); if (val) m_verticalAlign = val; } if (json_object_object_get_ex(obj, "direction", &val_obj)) { val = json_object_get_string(val_obj); if (val) direction = val; } if (json_object_object_get_ex(obj, "m_direction", &val_obj)) { val = json_object_get_string(val_obj); if (val) m_direction = val; } if (json_object_object_get_ex(obj, "align_items", &val_obj)) { val = json_object_get_string(val_obj); if (val) alignItems = val; } if (json_object_object_get_ex(obj, "hidden", &val_obj)) { if (json_object_is_type(val_obj, json_type_string)) { const char *s = json_object_get_string(val_obj); Loading Loading @@ -766,11 +778,13 @@ extern "C" { if (!height.empty()) { style += " height: " + height + ";"; } if (!verticalAlign.empty()) { style += " display: flex; flex-direction: column;"; if (!verticalAlign.empty() || !direction.empty() || !alignItems.empty()) { style += " display: flex; flex-direction: " + std::string(direction == "horizontal" ? "row" : "column") + ";"; if (verticalAlign == "top") style += " justify-content: flex-start;"; else if (verticalAlign == "center") style += " justify-content: center;"; else if (verticalAlign == "bottom") style += " justify-content: flex-end;"; if (!alignItems.empty()) style += " align-items: " + alignItems + ";"; } if (hidden) { style += " display: none;"; Loading Loading @@ -805,15 +819,18 @@ extern "C" { if (!m_minHeight.empty()) mobileCSS += " min-height: " + m_minHeight + " !important;"; if (!m_width.empty()) mobileCSS += " width: " + m_width + " !important;"; if (!m_height.empty()) mobileCSS += " height: " + m_height + " !important;"; if (!m_verticalAlign.empty()) { mobileCSS += " display: flex !important; flex-direction: column !important;"; if (!m_verticalAlign.empty() || !m_direction.empty()) { std::string effectiveDirection = !m_direction.empty() ? m_direction : direction; mobileCSS += " display: flex !important; flex-direction: " + std::string(effectiveDirection == "horizontal" ? "row" : "column") + " !important;"; if (m_verticalAlign == "top") mobileCSS += " justify-content: flex-start !important;"; else if (m_verticalAlign == "center") mobileCSS += " justify-content: center !important;"; else if (m_verticalAlign == "bottom") mobileCSS += " justify-content: flex-end !important;"; } if (m_hidden) mobileCSS += " display: none !important;"; else if (hidden) { if (!m_verticalAlign.empty() || !verticalAlign.empty()) if (!m_verticalAlign.empty() || !verticalAlign.empty() || !m_direction.empty() || !direction.empty() || !alignItems.empty()) mobileCSS += " display: flex !important;"; else mobileCSS += " display: block !important;"; Loading Loading
editor/src/htmlimport.cpp +34 −16 Changes for editor/src/htmlimport.cpp: 34 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -476,6 +476,35 @@ std::string mapToVerticalAlign(const std::string &cssValue, bool allowStretch) return ""; } // Sets a widget's own "align_items"/"direction" attributes directly from the // imported CSS `align-items`/`flex-direction` values, and marks whichever of // them was actually consumed as known so it doesn't also leak into // CustomCss. Both are plain passthroughs, not lossy translations like // `justify-content` -> `vertical_align`: Container/Section/Article/List's // own `align_items` field already uses the same value domain as real CSS // align-items, and their `direction` field's "horizontal"/"vertical" means // exactly what CSS `flex-direction: row`/`column` means, just spelled // differently. void applyFlexLayoutAttributes(tinyxml2::XMLElement *w, std::map<std::string,std::string> &cssProps, std::vector<std::string> &knownCss) { if (cssProps.count("align-items")) { w->SetAttribute("align_items", cssProps["align-items"].c_str()); knownCss.push_back("align-items"); } if (cssProps.count("flex-direction")) { const std::string &fd = cssProps["flex-direction"]; if (fd == "row" || fd == "row-reverse") { w->SetAttribute("direction", "horizontal"); knownCss.push_back("flex-direction"); } else if (fd == "column" || fd == "column-reverse") { w->SetAttribute("direction", "vertical"); knownCss.push_back("flex-direction"); } } } } // namespace std::string blogi::htmlimport::extractCustomCss( Loading Loading @@ -799,6 +828,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -841,6 +871,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -911,6 +942,7 @@ void blogi::htmlimport::htmlElementToWidgetXml( knownCss.push_back("justify-content"); } } applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading Loading @@ -1096,20 +1128,6 @@ void blogi::htmlimport::htmlElementToWidgetXml( w->SetAttribute("margin", cssProps["margin"].c_str()); if (cssMeansHidden(cssProps)) w->SetAttribute("hidden", "true"); // "row"/"column" match List's own "horizontal"/"vertical" // enum 1:1 in meaning even though the words differ. if (cssProps.count("flex-direction")) { const std::string &fd = cssProps["flex-direction"]; if (fd == "row" || fd == "row-reverse") w->SetAttribute("direction", "horizontal"); else if (fd == "column" || fd == "column-reverse") w->SetAttribute("direction", "vertical"); } // List's align_items field already uses raw CSS align-items // keywords (flex-start/center/flex-end/stretch/baseline), so // this is a direct passthrough, not a translation. if (cssProps.count("align-items")) w->SetAttribute("align_items", cssProps["align-items"].c_str()); libhtmlpp::Element *liEl = el->firstChild(); while (liEl) { Loading @@ -1131,8 +1149,8 @@ void blogi::htmlimport::htmlElementToWidgetXml( std::vector<std::string> knownCss = { "font-size","color","line-height","list-style-type", "padding","margin","width","height","display","visibility", "flex-direction","gap","align-items"}; "padding","margin","width","height","display","visibility","gap"}; applyFlexLayoutAttributes(w, cssProps, knownCss); std::string custom = extractCustomCss(cssProps, knownCss, mediaRules, cssClass, elemId); if (!custom.empty()) { tinyxml2::XMLElement *ccEl = doc.NewElement("CustomCss"); Loading
editor/widgets/article/article.cpp +22 −5 Changes for editor/widgets/article/article.cpp: 22 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -684,6 +684,18 @@ extern "C" { val = json_object_get_string(val_obj); if (val) m_verticalAlign = val; } if (json_object_object_get_ex(obj, "direction", &val_obj)) { val = json_object_get_string(val_obj); if (val) direction = val; } if (json_object_object_get_ex(obj, "m_direction", &val_obj)) { val = json_object_get_string(val_obj); if (val) m_direction = val; } if (json_object_object_get_ex(obj, "align_items", &val_obj)) { val = json_object_get_string(val_obj); if (val) alignItems = val; } if (json_object_object_get_ex(obj, "hidden", &val_obj)) { if (json_object_is_type(val_obj, json_type_string)) { const char *s = json_object_get_string(val_obj); Loading Loading @@ -766,11 +778,13 @@ extern "C" { if (!height.empty()) { style += " height: " + height + ";"; } if (!verticalAlign.empty()) { style += " display: flex; flex-direction: column;"; if (!verticalAlign.empty() || !direction.empty() || !alignItems.empty()) { style += " display: flex; flex-direction: " + std::string(direction == "horizontal" ? "row" : "column") + ";"; if (verticalAlign == "top") style += " justify-content: flex-start;"; else if (verticalAlign == "center") style += " justify-content: center;"; else if (verticalAlign == "bottom") style += " justify-content: flex-end;"; if (!alignItems.empty()) style += " align-items: " + alignItems + ";"; } if (hidden) { style += " display: none;"; Loading Loading @@ -805,15 +819,18 @@ extern "C" { if (!m_minHeight.empty()) mobileCSS += " min-height: " + m_minHeight + " !important;"; if (!m_width.empty()) mobileCSS += " width: " + m_width + " !important;"; if (!m_height.empty()) mobileCSS += " height: " + m_height + " !important;"; if (!m_verticalAlign.empty()) { mobileCSS += " display: flex !important; flex-direction: column !important;"; if (!m_verticalAlign.empty() || !m_direction.empty()) { std::string effectiveDirection = !m_direction.empty() ? m_direction : direction; mobileCSS += " display: flex !important; flex-direction: " + std::string(effectiveDirection == "horizontal" ? "row" : "column") + " !important;"; if (m_verticalAlign == "top") mobileCSS += " justify-content: flex-start !important;"; else if (m_verticalAlign == "center") mobileCSS += " justify-content: center !important;"; else if (m_verticalAlign == "bottom") mobileCSS += " justify-content: flex-end !important;"; } if (m_hidden) mobileCSS += " display: none !important;"; else if (hidden) { if (!m_verticalAlign.empty() || !verticalAlign.empty()) if (!m_verticalAlign.empty() || !verticalAlign.empty() || !m_direction.empty() || !direction.empty() || !alignItems.empty()) mobileCSS += " display: flex !important;"; else mobileCSS += " display: block !important;"; Loading