Des tonnes de modifications notamment VIM / Couleurs / typos

This commit is contained in:
2025-11-11 15:41:51 +01:00
parent 439880b08f
commit 6face7a02f
59 changed files with 7857 additions and 960 deletions

View File

@ -0,0 +1,165 @@
/**
* Keyboard Shortcuts Manager - Gère tous les raccourcis clavier de l'application
*/
class KeyboardShortcutsManager {
constructor() {
this.shortcuts = [
{ key: 'k', ctrl: true, description: 'Ouvrir la recherche', action: () => this.openSearch() },
{ key: 's', ctrl: true, description: 'Sauvegarder la note', action: () => this.saveNote() },
{ key: 'd', ctrl: true, description: 'Ouvrir la note du jour', action: () => this.openDailyNote() },
{ key: 'n', ctrl: true, description: 'Créer une nouvelle note', action: () => this.createNewNote() },
{ key: 'h', ctrl: true, description: 'Retour à la page d\'accueil', action: () => this.goHome() },
{ key: 'b', ctrl: true, description: 'Afficher/Masquer la sidebar', action: () => this.toggleSidebar() },
{ key: ',', ctrl: true, description: 'Ouvrir les paramètres', action: () => this.openSettings() },
{ key: 'p', ctrl: true, description: 'Afficher/Masquer la prévisualisation', action: () => this.togglePreview() },
{ key: 'f', ctrl: true, shift: true, description: 'Créer un nouveau dossier', action: () => this.createNewFolder() },
{ key: 'Escape', ctrl: false, description: 'Fermer les modales/dialogs', action: () => this.closeModals() }
];
this.init();
}
init() {
document.addEventListener('keydown', (event) => {
this.handleKeydown(event);
});
console.log('Keyboard shortcuts initialized:', this.shortcuts.length, 'shortcuts');
}
handleKeydown(event) {
// Ignorer si on tape dans un input/textarea (sauf pour les raccourcis système comme Ctrl+S)
const isInputField = event.target.tagName === 'INPUT' ||
event.target.tagName === 'TEXTAREA' ||
event.target.isContentEditable;
// Chercher un raccourci correspondant
for (const shortcut of this.shortcuts) {
const ctrlMatch = shortcut.ctrl ? (event.ctrlKey || event.metaKey) : !event.ctrlKey && !event.metaKey;
const shiftMatch = shortcut.shift ? event.shiftKey : !event.shiftKey;
const keyMatch = event.key.toLowerCase() === shortcut.key.toLowerCase();
if (ctrlMatch && shiftMatch && keyMatch) {
// Certains raccourcis fonctionnent même dans les champs de saisie
const allowInInput = ['s', 'k', 'd', 'h', 'b', ',', '/'].includes(shortcut.key.toLowerCase());
if (!isInputField || allowInInput) {
event.preventDefault();
shortcut.action();
return;
}
}
}
}
openSearch() {
// Déclencher le focus sur le champ de recherche
const searchInput = document.querySelector('header input[type="search"]');
if (searchInput) {
searchInput.focus();
searchInput.select();
console.log('Search opened via Ctrl+K');
}
}
saveNote() {
// Déclencher la sauvegarde de la note (géré par CodeMirror)
console.log('Save triggered via Ctrl+S');
// La sauvegarde est déjà gérée dans editor.js
}
openDailyNote() {
// Ouvrir la note du jour
const dailyBtn = document.querySelector('button[hx-get="/api/daily/today"]');
if (dailyBtn) {
dailyBtn.click();
console.log('Daily note opened via Ctrl+D');
}
}
createNewNote() {
if (typeof showNewNoteModal === 'function') {
showNewNoteModal();
console.log('New note modal opened via Ctrl+N');
}
}
goHome() {
const homeBtn = document.querySelector('button[hx-get="/api/home"]');
if (homeBtn) {
homeBtn.click();
console.log('Home opened via Ctrl+H');
}
}
toggleSidebar() {
if (typeof toggleSidebar === 'function') {
toggleSidebar();
console.log('Sidebar toggled via Ctrl+B');
}
}
openSettings() {
if (typeof openThemeModal === 'function') {
openThemeModal();
console.log('Settings opened via Ctrl+,');
}
}
togglePreview() {
if (typeof togglePreview === 'function') {
togglePreview();
console.log('Preview toggled via Ctrl+/');
}
}
createNewFolder() {
if (typeof showNewFolderModal === 'function') {
showNewFolderModal();
console.log('New folder modal opened via Ctrl+Shift+F');
}
}
closeModals() {
// Fermer les modales ouvertes
if (typeof hideNewNoteModal === 'function') {
const noteModal = document.getElementById('new-note-modal');
if (noteModal && noteModal.style.display !== 'none') {
hideNewNoteModal();
return;
}
}
if (typeof hideNewFolderModal === 'function') {
const folderModal = document.getElementById('new-folder-modal');
if (folderModal && folderModal.style.display !== 'none') {
hideNewFolderModal();
return;
}
}
if (typeof closeThemeModal === 'function') {
const themeModal = document.getElementById('theme-modal');
if (themeModal && themeModal.style.display !== 'none') {
closeThemeModal();
return;
}
}
console.log('Escape pressed');
}
getShortcuts() {
return this.shortcuts;
}
}
// Initialisation automatique
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
window.keyboardShortcuts = new KeyboardShortcutsManager();
});
} else {
window.keyboardShortcuts = new KeyboardShortcutsManager();
}