Loading data/template/default/editor.html +66 −1 Changes for data/template/default/editor.html: 66 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1914,6 +1914,12 @@ html += `<button type="button" class="prop-save-btn" style="white-space:nowrap;padding:6px 10px;" onclick="openMediaBrowser('${inputId}')">Browse</button>`; html += `</div>`; break; case 'media_url': html += `<div style="display:flex;gap:6px;align-items:center;">`; html += `<input class="prop-input" type="text" id="${inputId}" name="${field.key}" value="${escapeHtml(String(val))}" placeholder="${field.placeholder || '/media/getimage/...'}" style="flex:1;">`; html += `<button type="button" class="prop-save-btn" style="white-space:nowrap;padding:6px 10px;" onclick="openMediaUrlBrowser('${inputId}')">Browse</button>`; html += `</div>`; break; case 'textarea': html += `<textarea class="prop-textarea" id="${inputId}" name="${field.key}" placeholder="${field.placeholder || ''}">${escapeHtml(String(val))}</textarea>`; break; Loading Loading @@ -2743,9 +2749,11 @@ // --- Media Browser --- let _mediaBrowserTargetInput = null; let _mediaBrowserMode = 'id'; // 'id' = set media UUID, 'url' = set full image URL async function openMediaBrowser(targetInputId) { _mediaBrowserTargetInput = targetInputId; _mediaBrowserMode = 'id'; // Remove existing modal if any let old = document.getElementById('media-browser-modal'); if (old) old.remove(); Loading Loading @@ -2788,6 +2796,50 @@ } } async function openMediaUrlBrowser(targetInputId) { _mediaBrowserMode = 'url'; _mediaBrowserTargetInput = targetInputId; // Reuse the same modal infrastructure let old = document.getElementById('media-browser-modal'); if (old) old.remove(); const overlay = document.createElement('div'); overlay.id = 'media-browser-modal'; overlay.className = 'modal-overlay'; overlay.onclick = (e) => { if (e.target === overlay) overlay.remove(); }; const modal = document.createElement('div'); modal.className = 'modal-content'; modal.style.width = '600px'; modal.style.maxHeight = '80vh'; modal.style.display = 'flex'; modal.style.flexDirection = 'column'; modal.innerHTML = ` <h3 style="margin:0 0 12px 0; color:#1f2937; font-size:1.1rem;">Select Background Image</h3> <div id="media-browser-nav" style="margin-bottom:8px;"></div> <div id="media-browser-content" style="flex:1; overflow-y:auto; min-height:200px;"> <p style="color:#6b7280;">Loading albums...</p> </div> <div style="margin-top:12px; text-align:right;"> <button type="button" onclick="document.getElementById('media-browser-modal').remove()" style="padding:6px 16px; background:#6b7280; color:#fff; border:none; border-radius:6px; cursor:pointer;">Cancel</button> </div> `; overlay.appendChild(modal); document.body.appendChild(overlay); try { const resp = await sendApiRequest([{ command: 'media_list_albums' }]); const result = resp.find(r => r.albums); if (!result || !result.albums) { document.getElementById('media-browser-content').innerHTML = '<p style="color:#dc2626;">Failed to load albums.</p>'; return; } renderAlbumList(result.albums); } catch (e) { document.getElementById('media-browser-content').innerHTML = `<p style="color:#dc2626;">Error: ${e.message}</p>`; } } function renderAlbumList(albums) { const content = document.getElementById('media-browser-content'); const nav = document.getElementById('media-browser-nav'); Loading Loading @@ -2917,7 +2969,20 @@ } function selectMediaItem(mediaId, ext, filename) { // Set the media_id input // URL mode: set full image URL path and close if (_mediaBrowserMode === 'url') { const input = document.getElementById(_mediaBrowserTargetInput); if (input) { input.value = '/media/getimage/' + mediaId + '.' + ext; input.dispatchEvent(new Event('input', { bubbles: true })); } const modal = document.getElementById('media-browser-modal'); if (modal) modal.remove(); if (typeof scheduleAutoSave === 'function') scheduleAutoSave(); return; } // Default ID mode: set the media_id input const input = document.getElementById(_mediaBrowserTargetInput); if (input) { input.value = mediaId; Loading src/webedit/container/container.cpp +1 −1 Changes for src/webedit/container/container.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -255,7 +255,7 @@ extern "C" { }; addField("background_color", "Background Color (Dark)", "color_var", nullptr, true); addField("l_background_color", "Background Color (Light)", "color_var"); addField("background_image", "Background Image URL", "text", "e.g. /media/img.webp", true); addField("background_image", "Background Image URL", "media_url", "/media/getimage/...", true); addField("background_size", "Background Size", "select", nullptr, true, mkOpts({"cover","contain","auto","100% 100%"})); addField("background_position", "Background Position", "select", nullptr, true, mkOpts({"center","top","bottom","left","right","top left","top right","bottom left","bottom right"})); addField("background_repeat", "Background Repeat", "select", nullptr, false, mkOpts({"no-repeat","repeat","repeat-x","repeat-y"})); Loading Loading
data/template/default/editor.html +66 −1 Changes for data/template/default/editor.html: 66 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -1914,6 +1914,12 @@ html += `<button type="button" class="prop-save-btn" style="white-space:nowrap;padding:6px 10px;" onclick="openMediaBrowser('${inputId}')">Browse</button>`; html += `</div>`; break; case 'media_url': html += `<div style="display:flex;gap:6px;align-items:center;">`; html += `<input class="prop-input" type="text" id="${inputId}" name="${field.key}" value="${escapeHtml(String(val))}" placeholder="${field.placeholder || '/media/getimage/...'}" style="flex:1;">`; html += `<button type="button" class="prop-save-btn" style="white-space:nowrap;padding:6px 10px;" onclick="openMediaUrlBrowser('${inputId}')">Browse</button>`; html += `</div>`; break; case 'textarea': html += `<textarea class="prop-textarea" id="${inputId}" name="${field.key}" placeholder="${field.placeholder || ''}">${escapeHtml(String(val))}</textarea>`; break; Loading Loading @@ -2743,9 +2749,11 @@ // --- Media Browser --- let _mediaBrowserTargetInput = null; let _mediaBrowserMode = 'id'; // 'id' = set media UUID, 'url' = set full image URL async function openMediaBrowser(targetInputId) { _mediaBrowserTargetInput = targetInputId; _mediaBrowserMode = 'id'; // Remove existing modal if any let old = document.getElementById('media-browser-modal'); if (old) old.remove(); Loading Loading @@ -2788,6 +2796,50 @@ } } async function openMediaUrlBrowser(targetInputId) { _mediaBrowserMode = 'url'; _mediaBrowserTargetInput = targetInputId; // Reuse the same modal infrastructure let old = document.getElementById('media-browser-modal'); if (old) old.remove(); const overlay = document.createElement('div'); overlay.id = 'media-browser-modal'; overlay.className = 'modal-overlay'; overlay.onclick = (e) => { if (e.target === overlay) overlay.remove(); }; const modal = document.createElement('div'); modal.className = 'modal-content'; modal.style.width = '600px'; modal.style.maxHeight = '80vh'; modal.style.display = 'flex'; modal.style.flexDirection = 'column'; modal.innerHTML = ` <h3 style="margin:0 0 12px 0; color:#1f2937; font-size:1.1rem;">Select Background Image</h3> <div id="media-browser-nav" style="margin-bottom:8px;"></div> <div id="media-browser-content" style="flex:1; overflow-y:auto; min-height:200px;"> <p style="color:#6b7280;">Loading albums...</p> </div> <div style="margin-top:12px; text-align:right;"> <button type="button" onclick="document.getElementById('media-browser-modal').remove()" style="padding:6px 16px; background:#6b7280; color:#fff; border:none; border-radius:6px; cursor:pointer;">Cancel</button> </div> `; overlay.appendChild(modal); document.body.appendChild(overlay); try { const resp = await sendApiRequest([{ command: 'media_list_albums' }]); const result = resp.find(r => r.albums); if (!result || !result.albums) { document.getElementById('media-browser-content').innerHTML = '<p style="color:#dc2626;">Failed to load albums.</p>'; return; } renderAlbumList(result.albums); } catch (e) { document.getElementById('media-browser-content').innerHTML = `<p style="color:#dc2626;">Error: ${e.message}</p>`; } } function renderAlbumList(albums) { const content = document.getElementById('media-browser-content'); const nav = document.getElementById('media-browser-nav'); Loading Loading @@ -2917,7 +2969,20 @@ } function selectMediaItem(mediaId, ext, filename) { // Set the media_id input // URL mode: set full image URL path and close if (_mediaBrowserMode === 'url') { const input = document.getElementById(_mediaBrowserTargetInput); if (input) { input.value = '/media/getimage/' + mediaId + '.' + ext; input.dispatchEvent(new Event('input', { bubbles: true })); } const modal = document.getElementById('media-browser-modal'); if (modal) modal.remove(); if (typeof scheduleAutoSave === 'function') scheduleAutoSave(); return; } // Default ID mode: set the media_id input const input = document.getElementById(_mediaBrowserTargetInput); if (input) { input.value = mediaId; Loading
src/webedit/container/container.cpp +1 −1 Changes for src/webedit/container/container.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -255,7 +255,7 @@ extern "C" { }; addField("background_color", "Background Color (Dark)", "color_var", nullptr, true); addField("l_background_color", "Background Color (Light)", "color_var"); addField("background_image", "Background Image URL", "text", "e.g. /media/img.webp", true); addField("background_image", "Background Image URL", "media_url", "/media/getimage/...", true); addField("background_size", "Background Size", "select", nullptr, true, mkOpts({"cover","contain","auto","100% 100%"})); addField("background_position", "Background Position", "select", nullptr, true, mkOpts({"center","top","bottom","left","right","top left","top right","bottom left","bottom right"})); addField("background_repeat", "Background Repeat", "select", nullptr, false, mkOpts({"no-repeat","repeat","repeat-x","repeat-y"})); Loading