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');
|
||||
return;
|
||||
}
|
||||
showToast('⏳ AI: traitement en cours...', 'info');
|
||||
try {
|
||||
const result = await aiAction(endpoint, text, extra);
|
||||
replaceSelection(v, result, mode);
|
||||
showToast('AI: texte traité', 'success');
|
||||
showToast('AI: texte traité ✓', 'success');
|
||||
} catch (e) {
|
||||
const msg = String(e.message || e);
|
||||
if (msg.includes('401')) {
|
||||
|
||||
@ -406,6 +406,8 @@ async function waitForCodeMirror() {
|
||||
}
|
||||
|
||||
function closeEditor() {
|
||||
const vault = state.editorVault;
|
||||
const path = state.editorPath;
|
||||
const modal = document.getElementById("editor-modal");
|
||||
modal.classList.remove("active");
|
||||
if (state.editorView) {
|
||||
@ -415,6 +417,10 @@ function closeEditor() {
|
||||
state.fallbackEditorEl = null;
|
||||
state.editorVault = 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) {
|
||||
@ -443,26 +449,27 @@ async function saveFile(silent = false) {
|
||||
}
|
||||
|
||||
if (silent) {
|
||||
// Auto-save: brief visual feedback
|
||||
// Auto-save: brief green flash on save button
|
||||
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>';
|
||||
safeCreateIcons();
|
||||
setTimeout(() => {
|
||||
if (saveBtn) saveBtn.innerHTML = originalHTML;
|
||||
if (saveBtn) {
|
||||
saveBtn.style.background = '';
|
||||
saveBtn.style.color = '';
|
||||
saveBtn.style.borderColor = '';
|
||||
saveBtn.innerHTML = originalHTML;
|
||||
}
|
||||
}, 1500);
|
||||
}
|
||||
} else {
|
||||
saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>';
|
||||
safeCreateIcons();
|
||||
|
||||
const _savedVault = state.editorVault;
|
||||
const _savedPath = state.editorPath;
|
||||
setTimeout(() => {
|
||||
closeEditor();
|
||||
if (state.currentVault === _savedVault && state.currentPath === _savedPath) {
|
||||
openFile(_savedVault, _savedPath);
|
||||
}
|
||||
}, 800);
|
||||
setTimeout(() => closeEditor(), 800);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Save error:", err);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user