feat: AI Editor — toolbar avec menus dropdown, multi-provider (DeepSeek/OpenRouter/Gemini)
CI / lint (push) Failing after 7s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Successful in 11s

This commit is contained in:
2026-05-30 16:44:42 -04:00
parent ca84bfdf11
commit b92fd3da08
8 changed files with 796 additions and 1 deletions
+14
View File
@@ -2,6 +2,10 @@ import { state } from './state.js';
import { api } from './auth.js';
import { openFile, showWelcome } from './viewer.js';
import { refreshSidebarForContext, refreshTagsForContext } from './sidebar.js';
import { createAIToolbar, setToast } from './ai.js';
import { showToast } from './ui.js';
let _aiToolbarCreated = false;
// ---------------------------------------------------------------------------
// File extension → Lucide icon mapping
@@ -363,6 +367,16 @@ async function openEditor(vaultName, filePath) {
state: cmState,
parent: bodyEl,
});
// Set up AI toolbar (once)
if (!_aiToolbarCreated) {
setToast(showToast);
const container = document.getElementById('ai-toolbar-container');
if (container) {
createAIToolbar(container, () => state.editorView);
_aiToolbarCreated = true;
}
}
} catch (err) {
console.error("CodeMirror init failed, falling back to textarea:", err);
state.fallbackEditorEl = document.createElement("textarea");