Bruno Charest 08c29c9efe
Some checks failed
CI / lint (push) Failing after 4s
CI / test (push) Has been skipped
CI / build (push) Has been skipped
CI / security (push) Successful in 8s
feat: palette de commandes Ctrl+P — navigation rapide fichiers + commandes
2026-06-02 12:30:41 -04:00

90 lines
2.8 KiB
JavaScript

/* ObsiGate — Module orchestrator (ES modules).
Replaces the monolithic frontend/app.js IIFE.
All code lives in frontend/js/*.js modules. */
import * as UI from './ui.js';
import * as Utils from './utils.js';
// Wire up AI toolbar toast (avoids circular import in utils.js)
window._obsigateShowToast = UI.showToast;
import * as Sidebar from './sidebar.js';
import * as Auth from './auth.js';
import * as Viewer from './viewer.js';
import * as Sync from './sync.js';
import { initGraphView } from './graph.js';
import * as Legacy from './legacy.js';
import { initCommandPalette } from './palette.js';
// =========================================================================
// Initialization — mirrors the original app.js init() ordering
// =========================================================================
async function init() {
UI.initTheme();
UI.initHeaderMenu();
UI.initCustomDropdowns();
document.getElementById("theme-toggle").addEventListener("click", UI.toggleTheme);
document.getElementById("header-logo").addEventListener("click", Legacy.goHome);
const refreshBtn = document.getElementById("header-refresh-btn");
if (refreshBtn) refreshBtn.addEventListener("click", Legacy.goHome);
Legacy.initSearch();
UI.initSidebarToggle();
UI.initMobile();
Sidebar.initVaultContext();
Legacy.initSidebarTabs();
Legacy.initHelpModal();
Legacy.initConfigModal();
Sidebar.initSidebarFilter();
UI.initSidebarResize();
Utils.initEditor();
Auth.initLoginForm();
Legacy.initRecentTab();
UI.RightSidebarManager.init();
UI.FindInPageManager.init();
UI.ContextMenuManager.init();
UI.TabManager.init();
initCommandPalette();
const authOk = await Auth.AuthManager.initAuth();
if (authOk) {
Legacy.initSyncStatus();
try {
await Promise.all([Legacy.loadVaultSettings(), Sidebar.loadVaults(), Sidebar.loadTags()]);
Legacy.DashboardRecentWidget.init();
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get("popup") === "true") {
document.body.classList.add("popup-mode");
}
if (window.location.hash && window.location.hash.startsWith("#file=")) {
const hashVal = window.location.hash.substring(6);
const sepIndex = hashVal.indexOf(":");
if (sepIndex > -1) {
const vault = decodeURIComponent(hashVal.substring(0, sepIndex));
const path = decodeURIComponent(hashVal.substring(sepIndex + 1));
Viewer.openFile(vault, path);
}
} else if (urlParams.get("popup") !== "true") {
Legacy.showWelcome();
}
} catch (err) {
console.error("Failed to initialize ObsiGate:", err);
UI.showToast("Erreur lors de l'initialisation", "error");
}
}
initGraphView();
Utils.safeCreateIcons();
}
document.addEventListener("DOMContentLoaded", () => {
init();
Sync.init();
});