feat: loading AI + tooltips + auto-save silencieux + hover transparent fix
This commit is contained in:
+29
-16
@@ -319,7 +319,7 @@ async function openEditor(vaultName, filePath) {
|
||||
EditorView.updateListener.of((update) => {
|
||||
if (update.docChanged) {
|
||||
clearTimeout(window._obsigateAutoSaveTimer);
|
||||
window._obsigateAutoSaveTimer = setTimeout(() => saveFile(), 2000);
|
||||
window._obsigateAutoSaveTimer = setTimeout(() => saveFile(true), 2000);
|
||||
}
|
||||
}),
|
||||
];
|
||||
@@ -417,17 +417,19 @@ function closeEditor() {
|
||||
state.editorPath = null;
|
||||
}
|
||||
|
||||
async function saveFile() {
|
||||
async function saveFile(silent = false) {
|
||||
if ((!state.editorView && !state.fallbackEditorEl) || !state.editorVault || !state.editorPath) return;
|
||||
|
||||
const content = state.editorView ? state.editorView.state.doc.toString() : state.fallbackEditorEl.value;
|
||||
const saveBtn = document.getElementById("editor-save");
|
||||
const originalHTML = saveBtn.innerHTML;
|
||||
const originalHTML = saveBtn ? saveBtn.innerHTML : '';
|
||||
|
||||
try {
|
||||
saveBtn.disabled = true;
|
||||
saveBtn.innerHTML = '<i data-lucide="loader" style="width:16px;height:16px"></i>';
|
||||
safeCreateIcons();
|
||||
if (saveBtn && !silent) {
|
||||
saveBtn.disabled = true;
|
||||
saveBtn.innerHTML = '<i data-lucide="loader" style="width:16px;height:16px"></i>';
|
||||
safeCreateIcons();
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/file/${encodeURIComponent(state.editorVault)}/save?path=${encodeURIComponent(state.editorPath)}`, {
|
||||
method: "PUT",
|
||||
@@ -440,17 +442,28 @@ async function saveFile() {
|
||||
throw new Error(error.detail || "Erreur de sauvegarde");
|
||||
}
|
||||
|
||||
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);
|
||||
if (silent) {
|
||||
// Auto-save: brief visual feedback
|
||||
if (saveBtn) {
|
||||
saveBtn.innerHTML = '<i data-lucide="check" style="width:16px;height:16px"></i>';
|
||||
safeCreateIcons();
|
||||
setTimeout(() => {
|
||||
if (saveBtn) saveBtn.innerHTML = originalHTML;
|
||||
}, 1500);
|
||||
}
|
||||
}, 800);
|
||||
} 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);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error("Save error:", err);
|
||||
alert(`Erreur: ${err.message}`);
|
||||
|
||||
Reference in New Issue
Block a user