fix: loading AI toast + flash vert auto-save + refresh doc après close editor
This commit is contained in:
parent
adbeb54887
commit
a4e2d0629a
@ -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')) {
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user