Loading data/template/default/editor.html +54 −2 Changes for data/template/default/editor.html: 54 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -521,6 +521,42 @@ let currentSelectedElementId = "WebEditor"; // Default to the root element let availablePlugins = []; // Cache the fetched plugins // --- Auto-save debounce for property changes --- let _autoSaveTimer = null; const AUTO_SAVE_DELAY = 800; // ms after last change before auto-saving function scheduleAutoSave() { if (_autoSaveTimer) clearTimeout(_autoSaveTimer); _autoSaveTimer = setTimeout(() => { _autoSaveTimer = null; if (currentEditingElement) { saveElementProperties(currentEditingElement.uuid, currentEditingElement.name); } }, AUTO_SAVE_DELAY); } // --- Tree expand/collapse state persistence --- const TREE_STATE_KEY = 'editorTreeExpandedNodes'; function getExpandedNodes() { try { const raw = sessionStorage.getItem(TREE_STATE_KEY); return raw ? new Set(JSON.parse(raw)) : null; // null = no saved state yet } catch { return null; } } function saveExpandedNodes(expandedSet) { try { sessionStorage.setItem(TREE_STATE_KEY, JSON.stringify([...expandedSet])); } catch {} } function getCurrentExpandedNodes() { const expanded = new Set(); document.querySelectorAll('.tree-children').forEach(el => { if (!el.classList.contains('hidden')) { const uuid = el.getAttribute('data-parent-uuid'); if (uuid) expanded.add(uuid); } }); return expanded; } // --- Cookie Utility --- function getCookie(name) { const nameEQ = name + "="; Loading Loading @@ -795,6 +831,8 @@ childrenContainer.classList.add('hidden'); toggleIcon.textContent = '▶'; } // Persist current expand/collapse state saveExpandedNodes(getCurrentExpandedNodes()); } } Loading Loading @@ -899,8 +937,12 @@ childrenContainer.classList.add('tree-children'); childrenContainer.setAttribute('data-parent-uuid', nodeData.uuid); // Collapse level 2+ by default if (level >= 1) { // Restore expand/collapse state from session, default expanded for level 0 const savedState = getExpandedNodes(); const shouldCollapse = savedState ? !savedState.has(nodeData.uuid) // saved state exists: follow it : level >= 1; // first load: collapse level 2+ if (shouldCollapse) { childrenContainer.classList.add('hidden'); const toggleIcon = nodeContent.querySelector('.tree-toggle'); if (toggleIcon) toggleIcon.textContent = '▶'; Loading Loading @@ -1065,6 +1107,7 @@ document.querySelectorAll('.tree-toggle').forEach(el => { if (el.style.visibility !== 'hidden') el.textContent = '▼'; }); saveExpandedNodes(getCurrentExpandedNodes()); } /** Loading @@ -1077,6 +1120,7 @@ document.querySelectorAll('.tree-toggle').forEach(el => { if (el.style.visibility !== 'hidden') el.textContent = '▶'; }); saveExpandedNodes(getCurrentExpandedNodes()); } Loading Loading @@ -1337,6 +1381,13 @@ html += '</form>'; elementSettingsPanel.innerHTML = html; // Attach auto-save listeners to all form inputs const form = document.getElementById('prop-editor-form'); if (form) { form.addEventListener('input', scheduleAutoSave); form.addEventListener('change', scheduleAutoSave); } } /** Loading @@ -1359,6 +1410,7 @@ const ci = document.getElementById('${inputId}'); if(this.checked){ ci.disabled=true; ci.style.opacity='0.4'; ci.dataset.noneVal='true'; } else { ci.disabled=false; ci.style.opacity='1'; delete ci.dataset.noneVal; } scheduleAutoSave(); "> none</label>`; html += `</div>`; break; Loading Loading
data/template/default/editor.html +54 −2 Changes for data/template/default/editor.html: 54 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -521,6 +521,42 @@ let currentSelectedElementId = "WebEditor"; // Default to the root element let availablePlugins = []; // Cache the fetched plugins // --- Auto-save debounce for property changes --- let _autoSaveTimer = null; const AUTO_SAVE_DELAY = 800; // ms after last change before auto-saving function scheduleAutoSave() { if (_autoSaveTimer) clearTimeout(_autoSaveTimer); _autoSaveTimer = setTimeout(() => { _autoSaveTimer = null; if (currentEditingElement) { saveElementProperties(currentEditingElement.uuid, currentEditingElement.name); } }, AUTO_SAVE_DELAY); } // --- Tree expand/collapse state persistence --- const TREE_STATE_KEY = 'editorTreeExpandedNodes'; function getExpandedNodes() { try { const raw = sessionStorage.getItem(TREE_STATE_KEY); return raw ? new Set(JSON.parse(raw)) : null; // null = no saved state yet } catch { return null; } } function saveExpandedNodes(expandedSet) { try { sessionStorage.setItem(TREE_STATE_KEY, JSON.stringify([...expandedSet])); } catch {} } function getCurrentExpandedNodes() { const expanded = new Set(); document.querySelectorAll('.tree-children').forEach(el => { if (!el.classList.contains('hidden')) { const uuid = el.getAttribute('data-parent-uuid'); if (uuid) expanded.add(uuid); } }); return expanded; } // --- Cookie Utility --- function getCookie(name) { const nameEQ = name + "="; Loading Loading @@ -795,6 +831,8 @@ childrenContainer.classList.add('hidden'); toggleIcon.textContent = '▶'; } // Persist current expand/collapse state saveExpandedNodes(getCurrentExpandedNodes()); } } Loading Loading @@ -899,8 +937,12 @@ childrenContainer.classList.add('tree-children'); childrenContainer.setAttribute('data-parent-uuid', nodeData.uuid); // Collapse level 2+ by default if (level >= 1) { // Restore expand/collapse state from session, default expanded for level 0 const savedState = getExpandedNodes(); const shouldCollapse = savedState ? !savedState.has(nodeData.uuid) // saved state exists: follow it : level >= 1; // first load: collapse level 2+ if (shouldCollapse) { childrenContainer.classList.add('hidden'); const toggleIcon = nodeContent.querySelector('.tree-toggle'); if (toggleIcon) toggleIcon.textContent = '▶'; Loading Loading @@ -1065,6 +1107,7 @@ document.querySelectorAll('.tree-toggle').forEach(el => { if (el.style.visibility !== 'hidden') el.textContent = '▼'; }); saveExpandedNodes(getCurrentExpandedNodes()); } /** Loading @@ -1077,6 +1120,7 @@ document.querySelectorAll('.tree-toggle').forEach(el => { if (el.style.visibility !== 'hidden') el.textContent = '▶'; }); saveExpandedNodes(getCurrentExpandedNodes()); } Loading Loading @@ -1337,6 +1381,13 @@ html += '</form>'; elementSettingsPanel.innerHTML = html; // Attach auto-save listeners to all form inputs const form = document.getElementById('prop-editor-form'); if (form) { form.addEventListener('input', scheduleAutoSave); form.addEventListener('change', scheduleAutoSave); } } /** Loading @@ -1359,6 +1410,7 @@ const ci = document.getElementById('${inputId}'); if(this.checked){ ci.disabled=true; ci.style.opacity='0.4'; ci.dataset.noneVal='true'; } else { ci.disabled=false; ci.style.opacity='1'; delete ci.dataset.noneVal; } scheduleAutoSave(); "> none</label>`; html += `</div>`; break; Loading