fix: loading AI toast + flash vert auto-save + refresh doc après close editor
Some checks failed
CI / lint (push) Failing after 4s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Successful in 16s

This commit is contained in:
Bruno Charest 2026-05-30 22:07:16 -04:00
parent adbeb54887
commit a4e2d0629a
2 changed files with 19 additions and 11 deletions

View File

@ -343,10 +343,11 @@ export async function createAIToolbar(container, getEditorView) {
showToast('AI: sélectionnez du texte à traiter', 'warning'); showToast('AI: sélectionnez du texte à traiter', 'warning');
return; return;
} }
showToast('⏳ AI: traitement en cours...', 'info');
try { try {
const result = await aiAction(endpoint, text, extra); const result = await aiAction(endpoint, text, extra);
replaceSelection(v, result, mode); replaceSelection(v, result, mode);
showToast('AI: texte traité', 'success'); showToast('AI: texte traité', 'success');
} catch (e) { } catch (e) {
const msg = String(e.message || e); const msg = String(e.message || e);
if (msg.includes('401')) { if (msg.includes('401')) {

View File

@ -406,6 +406,8 @@ async function waitForCodeMirror() {
} }
function closeEditor() { function closeEditor() {
const vault = state.editorVault;
const path = state.editorPath;
const modal = document.getElementById("editor-modal"); const modal = document.getElementById("editor-modal");
modal.classList.remove("active"); modal.classList.remove("active");
if (state.editorView) { if (state.editorView) {
@ -415,6 +417,10 @@ function closeEditor() {
state.fallbackEditorEl = null; state.fallbackEditorEl = null;
state.editorVault = null; state.editorVault = null;
state.editorPath = null; state.editorPath = null;
// Refresh file content if we're viewing the edited file
if (vault && path && state.currentVault === vault && state.currentPath === path) {
openFile(vault, path);
}
} }
async function saveFile(silent = false) { async function saveFile(silent = false) {
@ -443,26 +449,27 @@ async function saveFile(silent = false) {
} }
if (silent) { if (silent) {
// Auto-save: brief visual feedback // Auto-save: brief green flash on save button
if (saveBtn) { if (saveBtn) {
saveBtn.style.background = '#22c55e';
saveBtn.style.color = '#fff';
saveBtn.style.borderColor = '#22c55e';
saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>'; saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>';
safeCreateIcons(); safeCreateIcons();
setTimeout(() => { setTimeout(() => {
if (saveBtn) saveBtn.innerHTML = originalHTML; if (saveBtn) {
saveBtn.style.background = '';
saveBtn.style.color = '';
saveBtn.style.borderColor = '';
saveBtn.innerHTML = originalHTML;
}
}, 1500); }, 1500);
} }
} else { } else {
saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>'; saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>';
safeCreateIcons(); safeCreateIcons();
const _savedVault = state.editorVault; setTimeout(() => closeEditor(), 800);
const _savedPath = state.editorPath;
setTimeout(() => {
closeEditor();
if (state.currentVault === _savedVault && state.currentPath === _savedPath) {
openFile(_savedVault, _savedPath);
}
}, 800);
} }
} catch (err) { } catch (err) {
console.error("Save error:", err); console.error("Save error:", err);