Loading data/template/default/editor.html +48 −2 Changes for data/template/default/editor.html: 48 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -102,6 +102,9 @@ SAVE: '${I18N_SAVE_BTN}', CUSTOM_COLOR: '${I18N_CUSTOM_COLOR}', THEME_VARIABLE: '${I18N_THEME_VARIABLE}', GLOBAL_CSS: '${I18N_GLOBAL_CSS}', GLOBAL_CSS_DESC: '${I18N_GLOBAL_CSS_DESC}', GLOBAL_CSS_SAVED: '${I18N_GLOBAL_CSS_SAVED}', }; </script> <script src="https://cdn.tailwindcss.com"></script> Loading Loading @@ -1368,12 +1371,28 @@ const statusEl = document.getElementById('prop-status'); const typeEl = document.getElementById('prop-widget-type'); // Root element has no editable properties // Root element: show GlobalCss editor if (elementId === 'WebEditor' || elementId === 'root') { elementSettingsPanel.innerHTML = '<p class="text-sm italic text-gray-500">' + I18N.ROOT_NO_PROPS + '</p>'; typeEl.style.display = 'none'; statusEl.textContent = ''; currentEditingElement = null; elementSettingsPanel.innerHTML = '<p class="text-sm text-gray-400">' + I18N.LOADING_PROPS + '</p>'; try { const resp = await sendApiRequest([{ command: 'GetGlobalCss' }]); const r = resp.find(item => item.status === 'success'); const css = (r && r.global_css) || ''; let html = '<form id="global-css-form">'; html += '<label class="block text-sm font-semibold text-gray-300 mb-1">' + I18N.GLOBAL_CSS + '</label>'; html += '<p class="text-xs text-gray-500 mb-2">' + I18N.GLOBAL_CSS_DESC + '</p>'; html += '<textarea id="global-css-textarea" class="w-full h-64 bg-gray-800 text-gray-200 text-xs font-mono p-2 rounded border border-gray-600 focus:border-blue-500 focus:outline-none" spellcheck="false">' + css.replace(/</g,'<').replace(/>/g,'>') + '</textarea>'; html += '<div class="flex items-center gap-2 mt-2">'; html += '<button type="button" class="prop-save-btn px-3 py-1 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded" onclick="saveGlobalCss()">' + I18N.SAVE_PROPERTIES + '</button>'; html += '<span id="global-css-status" class="text-xs"></span>'; html += '</div></form>'; elementSettingsPanel.innerHTML = html; } catch(e) { elementSettingsPanel.innerHTML = '<p class="text-sm text-red-400">Error: ' + e.message + '</p>'; } return; } Loading Loading @@ -1998,6 +2017,33 @@ } } /** * Save the GlobalCss textarea content to the backend. */ async function saveGlobalCss() { const textarea = document.getElementById('global-css-textarea'); const status = document.getElementById('global-css-status'); if (!textarea) return; try { status.textContent = I18N.SAVING; status.className = 'text-xs text-gray-400'; const resp = await sendApiRequest([{ command: 'SetGlobalCss', global_css: textarea.value }]); const r = resp.find(item => item.status === 'success'); if (r) { status.textContent = '\u2714 ' + I18N.GLOBAL_CSS_SAVED; status.className = 'text-xs text-green-400'; reloadIframe(); setTimeout(() => { status.textContent = ''; }, 2000); } else { status.textContent = I18N.SAVE_FAILED; status.className = 'text-xs text-red-400'; } } catch(e) { status.textContent = 'Error: ' + e.message; status.className = 'text-xs text-red-400'; } } /** * Collect form values and send update_element_properties to the backend. * @param {string} uuid The widget UUID. Loading src/edit.cpp +15 −0 Changes for src/edit.cpp: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2263,6 +2263,21 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso json_object_object_add(single_response, "message", json_object_new_string("Missing 'html' parameter.")); } handled = true; } else if (strcmp(command, "GetGlobalCss") == 0) { json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "global_css", json_object_new_string(GlobalCss.c_str())); handled = true; } else if (strcmp(command, "SetGlobalCss") == 0) { json_object *css_obj = nullptr; if (json_object_object_get_ex(single_request, "global_css", &css_obj)) { const char *cssData = json_object_get_string(css_obj); GlobalCss = cssData ? cssData : ""; json_object_object_add(single_response, "status", json_object_new_string("success")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Missing 'global_css' parameter.")); } handled = true; } else if (strcmp(command, "LoadXml") == 0) { // Load an XML template by name json_object *name_obj = nullptr; Loading src/translations.h +6 −0 Changes for src/translations.h: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -263,6 +263,9 @@ namespace blogi { {"I18N_EMPTY_DOC", "Leeres Dokument. Elemente über Werkzeuge hinzufügen."}, {"I18N_FAILED_LOAD_STRUCTURE","Struktur konnte nicht geladen werden"}, {"I18N_ROOT_NO_PROPS", "Wurzelelement — keine bearbeitbaren Eigenschaften."}, {"I18N_GLOBAL_CSS", "Globales CSS"}, {"I18N_GLOBAL_CSS_DESC", ":root-Variablen, @keyframes, @font-face und andere globale CSS-Regeln."}, {"I18N_GLOBAL_CSS_SAVED", "Globales CSS gespeichert."}, {"I18N_LOADING_PROPS", "Eigenschaften werden geladen..."}, {"I18N_COULD_NOT_FETCH", "Eigenschaften konnten nicht geladen werden."}, {"I18N_NO_CONFIG_PROPS", "Keine konfigurierbaren Eigenschaften für"}, Loading Loading @@ -612,6 +615,9 @@ namespace blogi { {"I18N_EMPTY_DOC", "Empty document. Add elements using the Toolbox above."}, {"I18N_FAILED_LOAD_STRUCTURE","Failed to load structure"}, {"I18N_ROOT_NO_PROPS", "Root element — no editable properties."}, {"I18N_GLOBAL_CSS", "Global CSS"}, {"I18N_GLOBAL_CSS_DESC", ":root variables, @keyframes, @font-face and other global CSS rules."}, {"I18N_GLOBAL_CSS_SAVED", "Global CSS saved."}, {"I18N_LOADING_PROPS", "Loading properties..."}, {"I18N_COULD_NOT_FETCH", "Could not fetch properties."}, {"I18N_NO_CONFIG_PROPS", "No configurable properties for"}, Loading Loading
data/template/default/editor.html +48 −2 Changes for data/template/default/editor.html: 48 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -102,6 +102,9 @@ SAVE: '${I18N_SAVE_BTN}', CUSTOM_COLOR: '${I18N_CUSTOM_COLOR}', THEME_VARIABLE: '${I18N_THEME_VARIABLE}', GLOBAL_CSS: '${I18N_GLOBAL_CSS}', GLOBAL_CSS_DESC: '${I18N_GLOBAL_CSS_DESC}', GLOBAL_CSS_SAVED: '${I18N_GLOBAL_CSS_SAVED}', }; </script> <script src="https://cdn.tailwindcss.com"></script> Loading Loading @@ -1368,12 +1371,28 @@ const statusEl = document.getElementById('prop-status'); const typeEl = document.getElementById('prop-widget-type'); // Root element has no editable properties // Root element: show GlobalCss editor if (elementId === 'WebEditor' || elementId === 'root') { elementSettingsPanel.innerHTML = '<p class="text-sm italic text-gray-500">' + I18N.ROOT_NO_PROPS + '</p>'; typeEl.style.display = 'none'; statusEl.textContent = ''; currentEditingElement = null; elementSettingsPanel.innerHTML = '<p class="text-sm text-gray-400">' + I18N.LOADING_PROPS + '</p>'; try { const resp = await sendApiRequest([{ command: 'GetGlobalCss' }]); const r = resp.find(item => item.status === 'success'); const css = (r && r.global_css) || ''; let html = '<form id="global-css-form">'; html += '<label class="block text-sm font-semibold text-gray-300 mb-1">' + I18N.GLOBAL_CSS + '</label>'; html += '<p class="text-xs text-gray-500 mb-2">' + I18N.GLOBAL_CSS_DESC + '</p>'; html += '<textarea id="global-css-textarea" class="w-full h-64 bg-gray-800 text-gray-200 text-xs font-mono p-2 rounded border border-gray-600 focus:border-blue-500 focus:outline-none" spellcheck="false">' + css.replace(/</g,'<').replace(/>/g,'>') + '</textarea>'; html += '<div class="flex items-center gap-2 mt-2">'; html += '<button type="button" class="prop-save-btn px-3 py-1 bg-blue-600 hover:bg-blue-500 text-white text-sm rounded" onclick="saveGlobalCss()">' + I18N.SAVE_PROPERTIES + '</button>'; html += '<span id="global-css-status" class="text-xs"></span>'; html += '</div></form>'; elementSettingsPanel.innerHTML = html; } catch(e) { elementSettingsPanel.innerHTML = '<p class="text-sm text-red-400">Error: ' + e.message + '</p>'; } return; } Loading Loading @@ -1998,6 +2017,33 @@ } } /** * Save the GlobalCss textarea content to the backend. */ async function saveGlobalCss() { const textarea = document.getElementById('global-css-textarea'); const status = document.getElementById('global-css-status'); if (!textarea) return; try { status.textContent = I18N.SAVING; status.className = 'text-xs text-gray-400'; const resp = await sendApiRequest([{ command: 'SetGlobalCss', global_css: textarea.value }]); const r = resp.find(item => item.status === 'success'); if (r) { status.textContent = '\u2714 ' + I18N.GLOBAL_CSS_SAVED; status.className = 'text-xs text-green-400'; reloadIframe(); setTimeout(() => { status.textContent = ''; }, 2000); } else { status.textContent = I18N.SAVE_FAILED; status.className = 'text-xs text-red-400'; } } catch(e) { status.textContent = 'Error: ' + e.message; status.className = 'text-xs text-red-400'; } } /** * Collect form values and send update_element_properties to the backend. * @param {string} uuid The widget UUID. Loading
src/edit.cpp +15 −0 Changes for src/edit.cpp: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -2263,6 +2263,21 @@ void blogi::webedit::WebEditor::JsonApi(const int tid, json_object *request, jso json_object_object_add(single_response, "message", json_object_new_string("Missing 'html' parameter.")); } handled = true; } else if (strcmp(command, "GetGlobalCss") == 0) { json_object_object_add(single_response, "status", json_object_new_string("success")); json_object_object_add(single_response, "global_css", json_object_new_string(GlobalCss.c_str())); handled = true; } else if (strcmp(command, "SetGlobalCss") == 0) { json_object *css_obj = nullptr; if (json_object_object_get_ex(single_request, "global_css", &css_obj)) { const char *cssData = json_object_get_string(css_obj); GlobalCss = cssData ? cssData : ""; json_object_object_add(single_response, "status", json_object_new_string("success")); } else { json_object_object_add(single_response, "status", json_object_new_string("error")); json_object_object_add(single_response, "message", json_object_new_string("Missing 'global_css' parameter.")); } handled = true; } else if (strcmp(command, "LoadXml") == 0) { // Load an XML template by name json_object *name_obj = nullptr; Loading
src/translations.h +6 −0 Changes for src/translations.h: 6 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -263,6 +263,9 @@ namespace blogi { {"I18N_EMPTY_DOC", "Leeres Dokument. Elemente über Werkzeuge hinzufügen."}, {"I18N_FAILED_LOAD_STRUCTURE","Struktur konnte nicht geladen werden"}, {"I18N_ROOT_NO_PROPS", "Wurzelelement — keine bearbeitbaren Eigenschaften."}, {"I18N_GLOBAL_CSS", "Globales CSS"}, {"I18N_GLOBAL_CSS_DESC", ":root-Variablen, @keyframes, @font-face und andere globale CSS-Regeln."}, {"I18N_GLOBAL_CSS_SAVED", "Globales CSS gespeichert."}, {"I18N_LOADING_PROPS", "Eigenschaften werden geladen..."}, {"I18N_COULD_NOT_FETCH", "Eigenschaften konnten nicht geladen werden."}, {"I18N_NO_CONFIG_PROPS", "Keine konfigurierbaren Eigenschaften für"}, Loading Loading @@ -612,6 +615,9 @@ namespace blogi { {"I18N_EMPTY_DOC", "Empty document. Add elements using the Toolbox above."}, {"I18N_FAILED_LOAD_STRUCTURE","Failed to load structure"}, {"I18N_ROOT_NO_PROPS", "Root element — no editable properties."}, {"I18N_GLOBAL_CSS", "Global CSS"}, {"I18N_GLOBAL_CSS_DESC", ":root variables, @keyframes, @font-face and other global CSS rules."}, {"I18N_GLOBAL_CSS_SAVED", "Global CSS saved."}, {"I18N_LOADING_PROPS", "Loading properties..."}, {"I18N_COULD_NOT_FETCH", "Could not fetch properties."}, {"I18N_NO_CONFIG_PROPS", "No configurable properties for"}, Loading