fix: suppression boutons doublons Forge + delegation parent modal
CI / lint (push) Failing after 7s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Failing after -8s

- Retrait des 3 boutons (delete/cancel/save) de la barre Forge (doublons)
- Retrait des handlers JS associés dans editor-poc.html
- Le header parent ObsiGate reste visible quand Forge est ouvert
- Les boutons save/delete du parent délèguent à Forge via postMessage
- Forge écoute 'parent-save' et 'parent-delete' du parent
- state.editorVault/editorPath settés dans viewer.js pour le parent
This commit is contained in:
2026-06-15 13:57:21 -04:00
parent feeb46b873
commit cc2ec9e869
3 changed files with 41 additions and 28 deletions
+16 -21
View File
@@ -233,9 +233,6 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig
<button class="btn" id="btn-preview" title="Toggle preview">&#128065;</button>
<button class="btn btn-ai off" id="btn-ai" title="AI Panel (Ctrl+J)">&#10024;</button>
<div class="save-dot ok" id="save-dot"><span class="dot"></span><span id="save-label">Saved</span></div>
<button class="btn btn-square danger" id="forge-delete" title="Supprimer">&#128465;</button>
<button class="btn btn-square" id="forge-cancel" title="Annuler">&#10005;</button>
<button class="btn btn-square primary" id="forge-save" title="Sauvegarder (Ctrl+S)">&#10003;</button>
</div>
</div>
@@ -1407,26 +1404,24 @@ body { font-family: var(--sans); background: var(--bg); color: var(--text); heig
btnPreview.addEventListener('click', togglePreview);
// Action buttons (delete/cancel/save) — same as basic editor
document.getElementById('forge-save').addEventListener('click', function() { forceSave(); });
document.getElementById('forge-cancel').addEventListener('click', function() {
if (window.parent && window.parent !== window) {
window.parent.postMessage({ type: 'forge-close' }, '*');
// Listen for parent save/delete commands (parent modal buttons)
window.addEventListener('message', function(e) {
if (!e.data || !e.data.type) return;
if (e.data.type === 'parent-save') { forceSave(); }
if (e.data.type === 'parent-delete') {
if (!fileVault || !filePath) return;
if (!confirm('Supprimer definitivement ' + filePath + ' ?')) return;
fetch('/api/file/' + encodeURIComponent(fileVault) + '?path=' + encodeURIComponent(filePath), {
method: 'DELETE', credentials: 'include'
}).then(function(r) {
if (!r.ok) throw new Error('HTTP ' + r.status);
showToast('Fichier supprime', 'ok');
if (window.parent && window.parent !== window) {
window.parent.postMessage({ type: 'forge-close' }, '*');
}
}).catch(function(e) { showToast('Echec suppression: ' + e.message, 'err'); });
}
});
document.getElementById('forge-delete').addEventListener('click', function() {
if (!fileVault || !filePath) return;
if (!confirm('Supprimer definitivement ' + filePath + ' ?')) return;
fetch('/api/file/' + encodeURIComponent(fileVault) + '?path=' + encodeURIComponent(filePath), {
method: 'DELETE', credentials: 'include'
}).then(function(r) {
if (!r.ok) throw new Error('HTTP ' + r.status);
showToast('Fichier supprime', 'ok');
if (window.parent && window.parent !== window) {
window.parent.postMessage({ type: 'forge-close' }, '*');
}
}).catch(function(e) { showToast('Echec suppression: ' + e.message, 'err'); });
});
document.getElementById('poc-title').addEventListener('input', function() { markDirty(); });
+22
View File
@@ -491,6 +491,20 @@ function closeEditor() {
}
async function saveFile(silent = false) {
// If Forge is open, delegate save to the iframe
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame && forgeFrame.contentWindow) {
if (!state.editorVault || !state.editorPath) return;
var saveBtn = document.getElementById("editor-save");
var saveDot = document.getElementById("editor-save-dot");
var saveLabel = document.getElementById("editor-save-label");
if (saveDot) { saveDot.className = 'editor-save-dot saving'; }
if (saveLabel) saveLabel.textContent = 'Saving...';
if (saveBtn) { saveBtn.disabled = true; }
forgeFrame.contentWindow.postMessage({ type: 'parent-save' }, '*');
return;
}
if ((!state.editorView && !state.fallbackEditorEl) || !state.editorVault || !state.editorPath) return;
const content = state.editorView ? state.editorView.state.doc.toString() : state.fallbackEditorEl.value;
@@ -559,6 +573,14 @@ async function saveFile(silent = false) {
}
async function deleteFile() {
// If Forge is open, delegate delete to the iframe
var forgeFrame = document.getElementById("forge-iframe");
if (forgeFrame && forgeFrame.contentWindow) {
if (!state.editorVault || !state.editorPath) return;
forgeFrame.contentWindow.postMessage({ type: 'parent-delete' }, '*');
return;
}
if (!state.editorVault || !state.editorPath) return;
const deleteBtn = document.getElementById("editor-delete");
+3 -7
View File
@@ -525,14 +525,10 @@ export function renderFile(data) {
forgeBtn.addEventListener("click", () => {
var modal = document.getElementById("editor-modal");
var container = modal.querySelector(".editor-container");
var headerEl = modal.querySelector(".editor-header");
var footerEl = modal.querySelector(".editor-footer");
var bodyEl = document.getElementById("editor-body");
// Hide header/footer since Forge has its own
if (headerEl) headerEl.style.display = "none";
if (footerEl) footerEl.style.display = "none";
// Make container fill the modal
if (container) container.style.maxHeight = "100vh";
// Set editor state so parent buttons work
state.editorVault = data.vault;
state.editorPath = data.path;
bodyEl.innerHTML = "";
bodyEl.style.overflow = "hidden";
var iframe = document.createElement("iframe");