Commit 4cb2d399 authored by jan.koester's avatar jan.koester
Browse files

test

parent 5ac955bb
Loading
Loading
Loading
Loading
+30 −11
Changes for editor/src/htmlimport.cpp: 30 added lines, 11 removed lines.
Original line number Diff line number Diff line
@@ -1123,18 +1123,29 @@ void blogi::htmlimport::htmlElementToWidgetXml(
                libhtmlpp::Element *child = el->firstChild();
                if (child) childFrames.push_back({child, w, nullptr, elementEnv});

            } else if (tag == "div" || tag == "label") {
            } else if (tag == "div" || tag == "label" || tag == "figure" ||
                       tag == "figcaption" || tag == "picture" || tag == "li") {
                // <label> (e.g. a clickable selectable-option "card" wrapping
                // an icon/image and its caption -- common in multi-step forms)
                // has no dedicated widget type, but unlike <a>/<button> its
                // own semantics (associating with a form control) aren't
                // visually significant for import purposes -- it's just
                // another styled box. Treating it exactly like a <div>
                // (rather than falling through to the generic CustomHtml
                // fallback below, which serializes the whole subtree as
                // opaque HTML) keeps its own background/padding/etc AND lets
                // its children -- e.g. an <img> card icon -- become their own
                // proper widgets instead of being lost inside that blob.
                // an icon/image and its caption -- common in multi-step forms),
                // <figure>/<figcaption> (an image or other content plus its
                // caption), and <picture> (a set of <source> variants plus a
                // fallback <img>) have no dedicated widget type, but none of
                // their own semantics are visually significant for import
                // purposes -- each is just another styled box. Treating them
                // exactly like a <div> (rather than falling through to the
                // generic CustomHtml fallback below, which serializes the
                // whole subtree as opaque HTML) keeps their own
                // background/padding/etc AND lets their children -- most
                // importantly a <figure>'s or <picture>'s <img> -- become
                // their own proper Image widget instead of being invisible
                // inside that blob (both to the editor and to the "import
                // external images into MediaDB" step, which only ever scans
                // actual Image widgets, never CustomHtml text). See the
                // "source" branch below for <picture>'s other child type.
                // <li> only ever reaches here already pre-filtered by the
                // "ul"/"ol" branch below, which only pushes a <li> as a real
                // child widget (rather than a plain-text Item) when it has
                // rich element content -- see that branch's own comment.
                bool isGrid = cssProps.count("display") && cssProps["display"] == "grid";
                tinyxml2::XMLElement *w = doc.NewElement(isGrid ? "Grid" : "Container");

@@ -1660,6 +1671,14 @@ void blogi::htmlimport::htmlElementToWidgetXml(
                       tag == "base" || tag == "DOCTYPE" || tag == "!doctype") {
                // Skip document-level elements

            } else if (tag == "source") {
                // A <picture>'s (or <video>'s/<audio>'s) <source> has no
                // visual representation of its own -- it only ever supplies
                // a srcset/media/type hint for choosing among variants -- so
                // unlike its sibling fallback <img> (handled above, now that
                // <picture> decomposes like a <div>), it produces no widget
                // at all rather than an empty/near-empty CustomHtml blob.

            } else {
                tinyxml2::XMLElement *w = doc.NewElement("CustomHtml");
                tinyxml2::XMLElement *htmlContent = doc.NewElement("HtmlContent");