feat: AI Editor — toolbar avec menus dropdown, multi-provider (DeepSeek/OpenRouter/Gemini)
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user