fix(editor): le bouton Sauvegarder ne reste plus bloque sur le spinner (BUG-054)
This commit is contained in:
@@ -365,6 +365,9 @@ function escapeHtml(str) {
|
||||
async function openEditor(vaultName, filePath) {
|
||||
state.editorVault = vaultName;
|
||||
state.editorPath = filePath;
|
||||
// A previous session may have left the shared save button in its spinner
|
||||
// state (manual save, Forge, failed request). BUG-054.
|
||||
resetSaveButton();
|
||||
|
||||
const modal = document.getElementById("editor-modal");
|
||||
const titleInput = document.getElementById("editor-title-input");
|
||||
@@ -582,6 +585,7 @@ function closeEditor() {
|
||||
const modal = document.getElementById("editor-modal");
|
||||
if (!modal) return;
|
||||
modal.classList.remove("active");
|
||||
resetSaveButton();
|
||||
stopCollab();
|
||||
if (state.editorView) {
|
||||
state.editorView.destroy();
|
||||
@@ -683,6 +687,26 @@ async function reloadExternalWrite(vault, path) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the save button to its idle state (checkmark, enabled).
|
||||
*
|
||||
* The button (`#editor-save`) is a single shared DOM node reused across every
|
||||
* edition session, including inline mode where it travels with the editor
|
||||
* container. A manual save swaps its content for a spinner and disables it; if
|
||||
* that state is not cleared on success/failure, the spinner leaks into the next
|
||||
* session and only a full page reload (which re-parses index.html) brings the
|
||||
* checkmark back. BUG-054.
|
||||
*/
|
||||
function resetSaveButton() {
|
||||
const saveBtn = document.getElementById("editor-save");
|
||||
if (!saveBtn) return;
|
||||
saveBtn.disabled = false;
|
||||
saveBtn.innerHTML = '✓';
|
||||
saveBtn.style.background = '';
|
||||
saveBtn.style.color = '';
|
||||
saveBtn.style.borderColor = '';
|
||||
}
|
||||
|
||||
async function saveFile(silent = false) {
|
||||
// If Forge is open, delegate save to the iframe
|
||||
var forgeFrame = document.getElementById("forge-iframe");
|
||||
@@ -750,6 +774,7 @@ async function saveFile(silent = false) {
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Save error:", err);
|
||||
resetSaveButton();
|
||||
if (saveDot) { saveDot.className = 'editor-save-dot err'; }
|
||||
if (saveLabel) saveLabel.textContent = 'Erreur';
|
||||
// If offline, queue the save for later sync
|
||||
|
||||
Reference in New Issue
Block a user