Commit 3cc475a8 authored by jan.koester's avatar jan.koester
Browse files

test

parent 89485382
Loading
Loading
Loading
Loading
+8 −0
Changes for data/themes/default/editor.html: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1387,6 +1387,14 @@
            // Update the visual selection state in the tree
            updateSelectionVisual(elementId);

            // Highlight the element in the renderer iframe
            try {
                var iframeWin = renderingIframe.contentWindow;
                if (iframeWin) {
                    iframeWin.postMessage({ type: 'highlightElement', elementId: elementId }, '*');
                }
            } catch(e) { /* cross-origin or not loaded yet */ }

            // Placeholder: Load element settings here
            loadElementSettings(elementId);
        }
+8 −0
Changes for data/themes/minimal/editor.html: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -1387,6 +1387,14 @@
            // Update the visual selection state in the tree
            updateSelectionVisual(elementId);

            // Highlight the element in the renderer iframe
            try {
                var iframeWin = renderingIframe.contentWindow;
                if (iframeWin) {
                    iframeWin.postMessage({ type: 'highlightElement', elementId: elementId }, '*');
                }
            } catch(e) { /* cross-origin or not loaded yet */ }

            // Placeholder: Load element settings here
            loadElementSettings(elementId);
        }
+41 −0
Changes for src/edit.cpp: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2929,6 +2929,47 @@ void blogi::webedit::WebEditor::Renderer(
                el = el->nextElement();
            }
        }

        // Inject click-to-select and highlight script into rendered preview
        libhtmlpp::HtmlElement selectScript("script");
        selectScript.appendChild(libhtmlpp::TextElement(
            "(function(){"
            "var currentHighlight=null;"
            "function highlight(el){"
            "  if(currentHighlight)currentHighlight.style.outline=currentHighlight._oldOutline||'';"
            "  if(el){"
            "    el._oldOutline=el.style.outline;"
            "    el.style.outline='2px solid red';"
            "  }"
            "  currentHighlight=el;"
            "}"
            "document.addEventListener('click',function(e){"
            "  var t=e.target;"
            "  while(t&&t!==document.body){"
            "    if(t.id&&t.id.indexOf('we-')===0){"
            "      e.preventDefault();e.stopPropagation();"
            "      var uid=t.id.substring(3);"
            "      highlight(t);"
            "      if(window.parent&&window.parent!==window){"
            "        window.parent.postMessage({type:'elementClicked',elementId:uid},'*');"
            "      }"
            "      return;"
            "    }"
            "    t=t.parentElement;"
            "  }"
            "},true);"
            "window.addEventListener('message',function(e){"
            "  if(e.data&&e.data.type==='highlightElement'){"
            "    var uid=e.data.elementId;"
            "    if(!uid){highlight(null);return;}"
            "    var el=document.getElementById('we-'+uid);"
            "    highlight(el||null);"
            "    if(el)el.scrollIntoView({behavior:'smooth',block:'nearest'});"
            "  }"
            "});"
            "})();"
        ));
        root->appendChild(selectScript);
    }

    // If publish preview requested, wrap the rendered content through the target plugin