Changement des ilink vers markdown pur
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* DailyNotes - Gère les raccourcis et interactions pour les daily notes
|
||||
*/
|
||||
@ -23,7 +24,7 @@ function initDailyNotesShortcut() {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Daily notes shortcuts initialized (Ctrl/Cmd+D)');
|
||||
debug('Daily notes shortcuts initialized (Ctrl/Cmd+D)');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
45
frontend/src/debug.js
Normal file
45
frontend/src/debug.js
Normal file
@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Debug utility - Conditional logging
|
||||
* Set DEBUG to true to enable console logs, false to disable
|
||||
*/
|
||||
|
||||
// Change this to false in production to disable all debug logs
|
||||
export const DEBUG = false;
|
||||
|
||||
/**
|
||||
* Conditional console.log
|
||||
* Only logs if DEBUG is true
|
||||
*/
|
||||
export function debug(...args) {
|
||||
if (DEBUG) {
|
||||
console.log(...args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditional console.warn
|
||||
* Only logs if DEBUG is true
|
||||
*/
|
||||
export function debugWarn(...args) {
|
||||
if (DEBUG) {
|
||||
console.warn(...args);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditional console.error
|
||||
* Always logs errors regardless of DEBUG flag
|
||||
*/
|
||||
export function debugError(...args) {
|
||||
console.error(...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditional console.info
|
||||
* Only logs if DEBUG is true
|
||||
*/
|
||||
export function debugInfo(...args) {
|
||||
if (DEBUG) {
|
||||
console.info(...args);
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
import { EditorState } from '@codemirror/state';
|
||||
import { EditorView } from '@codemirror/view';
|
||||
import { basicSetup } from '@codemirror/basic-setup';
|
||||
@ -13,7 +14,7 @@ let vimExtension = null;
|
||||
try {
|
||||
const { vim } = await import('@replit/codemirror-vim');
|
||||
vimExtension = vim;
|
||||
console.log('✅ Vim extension loaded and ready');
|
||||
debug('✅ Vim extension loaded and ready');
|
||||
} catch (error) {
|
||||
console.warn('⚠️ Vim extension not available:', error.message);
|
||||
}
|
||||
@ -118,7 +119,7 @@ class MarkdownEditor {
|
||||
if (window.vimModeManager && window.vimModeManager.isEnabled()) {
|
||||
if (vimExtension) {
|
||||
extensions.push(vimExtension());
|
||||
console.log('✅ Vim mode enabled in editor');
|
||||
debug('✅ Vim mode enabled in editor');
|
||||
} else {
|
||||
console.warn('⚠️ Vim mode requested but extension not loaded yet');
|
||||
}
|
||||
@ -246,10 +247,28 @@ class MarkdownEditor {
|
||||
const html = marked.parse(contentWithoutFrontMatter);
|
||||
// Permettre les attributs HTMX et onclick dans DOMPurify
|
||||
const cleanHtml = DOMPurify.sanitize(html, {
|
||||
ADD_ATTR: ['hx-get', 'hx-target', 'hx-swap', 'onclick']
|
||||
ADD_ATTR: ['hx-get', 'hx-target', 'hx-swap', 'hx-push-url', 'onclick']
|
||||
});
|
||||
this.preview.innerHTML = cleanHtml;
|
||||
|
||||
// Post-processing : convertir les liens Markdown vers .md en liens HTMX cliquables
|
||||
this.preview.querySelectorAll('a[href$=".md"]').forEach(link => {
|
||||
const href = link.getAttribute('href');
|
||||
// Ne traiter que les liens relatifs (pas les URLs complètes http://)
|
||||
if (href && !href.startsWith('http://') && !href.startsWith('https://') && !href.startsWith('//')) {
|
||||
debug('[Preview] Converting Markdown link to HTMX:', href);
|
||||
|
||||
// Transformer en lien HTMX interne
|
||||
link.setAttribute('hx-get', `/api/notes/${href}`);
|
||||
link.setAttribute('hx-target', '#editor-container');
|
||||
link.setAttribute('hx-swap', 'innerHTML');
|
||||
link.setAttribute('hx-push-url', 'true');
|
||||
link.setAttribute('href', '#');
|
||||
link.setAttribute('onclick', 'return false;');
|
||||
link.classList.add('internal-link');
|
||||
}
|
||||
});
|
||||
|
||||
// Traiter les nouveaux éléments HTMX
|
||||
if (typeof htmx !== 'undefined') {
|
||||
htmx.process(this.preview);
|
||||
@ -289,7 +308,7 @@ class MarkdownEditor {
|
||||
const targetElement = link.getAttribute('hx-target') || '#editor-container';
|
||||
const swapMethod = link.getAttribute('hx-swap') || 'innerHTML';
|
||||
|
||||
console.log('[InternalLink] Clicked:', target);
|
||||
debug('[InternalLink] Clicked:', target);
|
||||
|
||||
if (target && typeof htmx !== 'undefined') {
|
||||
htmx.ajax('GET', target, {
|
||||
@ -300,7 +319,7 @@ class MarkdownEditor {
|
||||
});
|
||||
});
|
||||
|
||||
console.log('[Preview] Setup', freshLinks.length, 'internal link handlers');
|
||||
debug('[Preview] Setup', freshLinks.length, 'internal link handlers');
|
||||
}
|
||||
|
||||
syncToTextarea() {
|
||||
@ -334,7 +353,7 @@ class MarkdownEditor {
|
||||
}
|
||||
|
||||
async reloadWithVimMode() {
|
||||
console.log('Reloading editor with Vim mode...');
|
||||
debug('Reloading editor with Vim mode...');
|
||||
await this.initEditor();
|
||||
}
|
||||
}
|
||||
@ -654,7 +673,7 @@ class SlashCommands {
|
||||
|
||||
// Commande spéciale avec modal (comme /ilink)
|
||||
if (command.isModal && command.handler) {
|
||||
console.log('Executing modal command:', command.name);
|
||||
debug('Executing modal command:', command.name);
|
||||
// NE PAS cacher la palette tout de suite car le handler a besoin de slashPos
|
||||
// La palette sera cachée par le handler lui-même
|
||||
command.handler();
|
||||
@ -685,7 +704,7 @@ class SlashCommands {
|
||||
// Sauvegarder la position du slash IMMÉDIATEMENT avant toute autre opération
|
||||
const savedSlashPos = this.slashPos;
|
||||
|
||||
console.log('[SlashCommands] openLinkInserter - savedSlashPos:', savedSlashPos);
|
||||
debug('[SlashCommands] openLinkInserter - savedSlashPos:', savedSlashPos);
|
||||
|
||||
if (!savedSlashPos) {
|
||||
console.error('[SlashCommands] No slash position available!');
|
||||
@ -698,7 +717,7 @@ class SlashCommands {
|
||||
|
||||
// S'assurer que le LinkInserter global existe, le créer si nécessaire
|
||||
if (!window.linkInserter) {
|
||||
console.log('Initializing LinkInserter...');
|
||||
debug('Initializing LinkInserter...');
|
||||
window.linkInserter = new LinkInserter();
|
||||
}
|
||||
|
||||
@ -706,14 +725,14 @@ class SlashCommands {
|
||||
window.linkInserter.open({
|
||||
editorView: this.editorView,
|
||||
onSelect: ({ title, path }) => {
|
||||
console.log('[SlashCommands] onSelect callback received:', { title, path });
|
||||
console.log('[SlashCommands] savedSlashPos:', savedSlashPos);
|
||||
debug('[SlashCommands] onSelect callback received:', { title, path });
|
||||
debug('[SlashCommands] savedSlashPos:', savedSlashPos);
|
||||
|
||||
// Créer un lien HTMX cliquable dans le preview
|
||||
// Format : <a href="#" onclick="return false;" hx-get="/api/notes/path" hx-target="#editor-container" hx-swap="innerHTML">Title</a>
|
||||
// Le onclick="return false;" empêche le comportement par défaut du # qui pourrait rediriger
|
||||
const linkHtml = `<a href="#" onclick="return false;" hx-get="/api/notes/${path}" hx-target="#editor-container" hx-swap="innerHTML">${title}</a>`;
|
||||
console.log('[SlashCommands] Inserting:', linkHtml);
|
||||
// Créer un lien Markdown standard
|
||||
// Format : [Title](path/to/note.md)
|
||||
// Le post-processing dans updatePreview() le rendra cliquable avec HTMX
|
||||
const linkMarkdown = `[${title}](${path})`;
|
||||
debug('[SlashCommands] Inserting Markdown link:', linkMarkdown);
|
||||
|
||||
const { state, dispatch } = this.editorView;
|
||||
const { from } = state.selection.main;
|
||||
@ -721,15 +740,15 @@ class SlashCommands {
|
||||
// Remplacer depuis le "/" jusqu'au curseur actuel
|
||||
const replaceFrom = savedSlashPos.absolutePos;
|
||||
|
||||
console.log('[SlashCommands] Replacing from', replaceFrom, 'to', from);
|
||||
debug('[SlashCommands] Replacing from', replaceFrom, 'to', from);
|
||||
|
||||
dispatch(state.update({
|
||||
changes: { from: replaceFrom, to: from, insert: linkHtml },
|
||||
selection: { anchor: replaceFrom + linkHtml.length }
|
||||
changes: { from: replaceFrom, to: from, insert: linkMarkdown },
|
||||
selection: { anchor: replaceFrom + linkMarkdown.length }
|
||||
}));
|
||||
|
||||
this.editorView.focus();
|
||||
console.log('[SlashCommands] Link inserted successfully');
|
||||
debug('[SlashCommands] Markdown link inserted successfully');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* Favorites - Gère le système de favoris
|
||||
*/
|
||||
@ -8,33 +9,33 @@ class FavoritesManager {
|
||||
}
|
||||
|
||||
init() {
|
||||
console.log('FavoritesManager: Initialisation...');
|
||||
debug('FavoritesManager: Initialisation...');
|
||||
|
||||
// Charger les favoris au démarrage
|
||||
this.refreshFavorites();
|
||||
|
||||
// Écouter les événements HTMX pour mettre à jour les boutons
|
||||
document.body.addEventListener('htmx:afterSwap', (event) => {
|
||||
console.log('HTMX afterSwap:', event.detail.target.id);
|
||||
debug('HTMX afterSwap:', event.detail.target.id);
|
||||
|
||||
if (event.detail.target.id === 'file-tree') {
|
||||
console.log('File-tree chargé, ajout des boutons favoris...');
|
||||
debug('File-tree chargé, ajout des boutons favoris...');
|
||||
setTimeout(() => this.attachFavoriteButtons(), 100);
|
||||
}
|
||||
|
||||
if (event.detail.target.id === 'favorites-list') {
|
||||
console.log('Favoris rechargés, mise à jour des boutons...');
|
||||
debug('Favoris rechargés, mise à jour des boutons...');
|
||||
setTimeout(() => this.attachFavoriteButtons(), 100);
|
||||
}
|
||||
});
|
||||
|
||||
// Attacher les boutons après un délai pour laisser HTMX charger le file-tree
|
||||
setTimeout(() => {
|
||||
console.log('Tentative d\'attachement des boutons favoris après délai...');
|
||||
debug('Tentative d\'attachement des boutons favoris après délai...');
|
||||
this.attachFavoriteButtons();
|
||||
}, 1000);
|
||||
|
||||
console.log('FavoritesManager: Initialisé');
|
||||
debug('FavoritesManager: Initialisé');
|
||||
}
|
||||
|
||||
refreshFavorites() {
|
||||
@ -47,7 +48,7 @@ class FavoritesManager {
|
||||
}
|
||||
|
||||
async addFavorite(path, isDir, title) {
|
||||
console.log('addFavorite appelé avec:', { path, isDir, title });
|
||||
debug('addFavorite appelé avec:', { path, isDir, title });
|
||||
|
||||
try {
|
||||
// Utiliser URLSearchParams au lieu de FormData pour le format application/x-www-form-urlencoded
|
||||
@ -56,7 +57,7 @@ class FavoritesManager {
|
||||
params.append('is_dir', isDir ? 'true' : 'false');
|
||||
params.append('title', title || '');
|
||||
|
||||
console.log('Params créés:', {
|
||||
debug('Params créés:', {
|
||||
path: params.get('path'),
|
||||
is_dir: params.get('is_dir'),
|
||||
title: params.get('title')
|
||||
@ -74,9 +75,9 @@ class FavoritesManager {
|
||||
const html = await response.text();
|
||||
document.getElementById('favorites-list').innerHTML = html;
|
||||
this.attachFavoriteButtons();
|
||||
console.log('Favori ajouté:', path);
|
||||
debug('Favori ajouté:', path);
|
||||
} else if (response.status === 409) {
|
||||
console.log('Déjà en favoris');
|
||||
debug('Déjà en favoris');
|
||||
} else {
|
||||
const errorText = await response.text();
|
||||
console.error('Erreur ajout favori:', response.status, response.statusText, errorText);
|
||||
@ -103,7 +104,7 @@ class FavoritesManager {
|
||||
const html = await response.text();
|
||||
document.getElementById('favorites-list').innerHTML = html;
|
||||
this.attachFavoriteButtons();
|
||||
console.log('Favori retiré:', path);
|
||||
debug('Favori retiré:', path);
|
||||
} else {
|
||||
console.error('Erreur retrait favori:', response.statusText);
|
||||
}
|
||||
@ -130,96 +131,95 @@ class FavoritesManager {
|
||||
}
|
||||
|
||||
attachFavoriteButtons() {
|
||||
console.log('attachFavoriteButtons: Début...');
|
||||
|
||||
debug('attachFavoriteButtons: Début...');
|
||||
|
||||
// Supprimer tous les boutons favoris existants pour les recréer avec le bon état
|
||||
document.querySelectorAll('.add-to-favorites').forEach(btn => btn.remove());
|
||||
|
||||
// Ajouter des boutons étoile aux éléments du file tree
|
||||
this.getFavoritesPaths().then(favoritePaths => {
|
||||
console.log('Chemins favoris:', favoritePaths);
|
||||
|
||||
debug('Chemins favoris:', favoritePaths);
|
||||
|
||||
// Dossiers
|
||||
const folderHeaders = document.querySelectorAll('.folder-header');
|
||||
console.log('Nombre de folder-header trouvés:', folderHeaders.length);
|
||||
|
||||
debug('Nombre de folder-header trouvés:', folderHeaders.length);
|
||||
|
||||
folderHeaders.forEach(header => {
|
||||
if (!header.querySelector('.add-to-favorites')) {
|
||||
const folderItem = header.closest('.folder-item');
|
||||
const path = folderItem?.getAttribute('data-path');
|
||||
|
||||
console.log('Dossier trouvé:', path);
|
||||
|
||||
if (path) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'add-to-favorites';
|
||||
button.innerHTML = '⭐';
|
||||
button.title = 'Ajouter aux favoris';
|
||||
|
||||
// Extraire le nom avant d'ajouter le bouton
|
||||
const name = header.querySelector('.folder-name')?.textContent?.trim() || path.split('/').pop();
|
||||
|
||||
const folderItem = header.closest('.folder-item');
|
||||
const path = folderItem?.getAttribute('data-path');
|
||||
|
||||
debug('Dossier trouvé:', path);
|
||||
|
||||
if (path) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'add-to-favorites';
|
||||
button.innerHTML = '⭐';
|
||||
button.title = 'Ajouter aux favoris';
|
||||
|
||||
// Extraire le nom avant d'ajouter le bouton
|
||||
const name = header.querySelector('.folder-name')?.textContent?.trim() || path.split('/').pop();
|
||||
|
||||
button.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
debug('Ajout dossier aux favoris:', path, name);
|
||||
this.addFavorite(path, true, name);
|
||||
};
|
||||
|
||||
if (favoritePaths.includes(path)) {
|
||||
button.classList.add('is-favorite');
|
||||
button.title = 'Retirer des favoris';
|
||||
button.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
console.log('Ajout dossier aux favoris:', path, name);
|
||||
this.addFavorite(path, true, name);
|
||||
debug('Retrait dossier des favoris:', path);
|
||||
this.removeFavorite(path);
|
||||
};
|
||||
|
||||
if (favoritePaths.includes(path)) {
|
||||
button.classList.add('is-favorite');
|
||||
button.title = 'Retirer des favoris';
|
||||
button.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
console.log('Retrait dossier des favoris:', path);
|
||||
this.removeFavorite(path);
|
||||
};
|
||||
}
|
||||
|
||||
header.appendChild(button);
|
||||
}
|
||||
|
||||
header.appendChild(button);
|
||||
}
|
||||
});
|
||||
|
||||
// Fichiers
|
||||
const fileItems = document.querySelectorAll('.file-item');
|
||||
console.log('Nombre de file-item trouvés:', fileItems.length);
|
||||
|
||||
debug('Nombre de file-item trouvés:', fileItems.length);
|
||||
|
||||
fileItems.forEach(fileItem => {
|
||||
if (!fileItem.querySelector('.add-to-favorites')) {
|
||||
const path = fileItem.getAttribute('data-path');
|
||||
|
||||
console.log('Fichier trouvé:', path);
|
||||
|
||||
if (path) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'add-to-favorites';
|
||||
button.innerHTML = '⭐';
|
||||
button.title = 'Ajouter aux favoris';
|
||||
|
||||
// Extraire le nom avant d'ajouter le bouton
|
||||
const name = fileItem.textContent.trim().replace('📄', '').trim().replace('.md', '');
|
||||
|
||||
const path = fileItem.getAttribute('data-path');
|
||||
|
||||
debug('Fichier trouvé:', path);
|
||||
|
||||
if (path) {
|
||||
const button = document.createElement('button');
|
||||
button.className = 'add-to-favorites';
|
||||
button.innerHTML = '⭐';
|
||||
button.title = 'Ajouter aux favoris';
|
||||
|
||||
// Extraire le nom avant d'ajouter le bouton
|
||||
const name = fileItem.textContent.trim().replace('📄', '').trim().replace('.md', '');
|
||||
|
||||
button.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
debug('Ajout fichier aux favoris:', path, name);
|
||||
this.addFavorite(path, false, name);
|
||||
};
|
||||
|
||||
if (favoritePaths.includes(path)) {
|
||||
button.classList.add('is-favorite');
|
||||
button.title = 'Retirer des favoris';
|
||||
button.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.log('Ajout fichier aux favoris:', path, name);
|
||||
this.addFavorite(path, false, name);
|
||||
debug('Retrait fichier des favoris:', path);
|
||||
this.removeFavorite(path);
|
||||
};
|
||||
|
||||
if (favoritePaths.includes(path)) {
|
||||
button.classList.add('is-favorite');
|
||||
button.title = 'Retirer des favoris';
|
||||
button.onclick = (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.log('Retrait fichier des favoris:', path);
|
||||
this.removeFavorite(path);
|
||||
};
|
||||
}
|
||||
|
||||
fileItem.appendChild(button);
|
||||
}
|
||||
|
||||
fileItem.appendChild(button);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('attachFavoriteButtons: Terminé');
|
||||
|
||||
debug('attachFavoriteButtons: Terminé');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* FileTree - Gère l'arborescence hiérarchique avec drag & drop
|
||||
* Utilise la délégation d'événements pour éviter les problèmes de listeners perdus
|
||||
@ -12,7 +13,7 @@ class FileTree {
|
||||
init() {
|
||||
this.setupEventListeners();
|
||||
|
||||
console.log('FileTree initialized with event delegation');
|
||||
debug('FileTree initialized with event delegation');
|
||||
}
|
||||
|
||||
setupEventListeners() {
|
||||
@ -112,27 +113,33 @@ class FileTree {
|
||||
}
|
||||
};
|
||||
|
||||
// Drag over - délégué sur les folder-headers
|
||||
// Drag over - délégué sur les folder-headers et la racine
|
||||
this.dragOverHandler = (e) => {
|
||||
const folderHeader = e.target.closest('.folder-header');
|
||||
if (folderHeader) {
|
||||
this.handleDragOver(e, folderHeader);
|
||||
const rootHeader = e.target.closest('.sidebar-section-header[data-section="notes"]');
|
||||
const target = folderHeader || rootHeader;
|
||||
if (target) {
|
||||
this.handleDragOver(e, target);
|
||||
}
|
||||
};
|
||||
|
||||
// Drag leave - délégué
|
||||
this.dragLeaveHandler = (e) => {
|
||||
const folderHeader = e.target.closest('.folder-header');
|
||||
if (folderHeader) {
|
||||
this.handleDragLeave(e, folderHeader);
|
||||
const rootHeader = e.target.closest('.sidebar-section-header[data-section="notes"]');
|
||||
const target = folderHeader || rootHeader;
|
||||
if (target) {
|
||||
this.handleDragLeave(e, target);
|
||||
}
|
||||
};
|
||||
|
||||
// Drop - délégué
|
||||
this.dropHandler = (e) => {
|
||||
const folderHeader = e.target.closest('.folder-header');
|
||||
if (folderHeader) {
|
||||
this.handleDrop(e, folderHeader);
|
||||
const rootHeader = e.target.closest('.sidebar-section-header[data-section="notes"]');
|
||||
const target = folderHeader || rootHeader;
|
||||
if (target) {
|
||||
this.handleDrop(e, target);
|
||||
}
|
||||
};
|
||||
|
||||
@ -152,7 +159,7 @@ class FileTree {
|
||||
// Vérifier si le swap concerne le file-tree
|
||||
const target = event.detail?.target;
|
||||
if (target && (target.id === 'file-tree' || target.closest('#file-tree'))) {
|
||||
console.log('FileTree: afterSwap detected, updating attributes...');
|
||||
debug('FileTree: afterSwap detected, updating attributes...');
|
||||
this.updateDraggableAttributes();
|
||||
}
|
||||
});
|
||||
@ -162,14 +169,14 @@ class FileTree {
|
||||
const target = event.detail?.target;
|
||||
// Ignorer les swaps de statut (auto-save-status, save-status)
|
||||
if (target && target.id === 'file-tree') {
|
||||
console.log('FileTree: oobAfterSwap detected, updating attributes...');
|
||||
debug('FileTree: oobAfterSwap detected, updating attributes...');
|
||||
this.updateDraggableAttributes();
|
||||
}
|
||||
});
|
||||
|
||||
// Écouter les restaurations d'historique (bouton retour du navigateur)
|
||||
document.body.addEventListener('htmx:historyRestore', () => {
|
||||
console.log('FileTree: History restored, re-initializing event listeners...');
|
||||
debug('FileTree: History restored, re-initializing event listeners...');
|
||||
// Réinitialiser complètement les event listeners après restauration de l'historique
|
||||
setTimeout(() => {
|
||||
this.setupEventListeners();
|
||||
@ -214,7 +221,7 @@ class FileTree {
|
||||
this.draggedPath = path;
|
||||
this.draggedType = type;
|
||||
|
||||
console.log('Drag start:', { type, path, name });
|
||||
debug('Drag start:', { type, path, name });
|
||||
}
|
||||
|
||||
handleDragEnd(e) {
|
||||
@ -242,20 +249,23 @@ class FileTree {
|
||||
this.draggedType = null;
|
||||
}
|
||||
|
||||
handleDragOver(e, folderHeader) {
|
||||
handleDragOver(e, target) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const folderItem = folderHeader.closest('.folder-item');
|
||||
if (!folderItem) return;
|
||||
// Gérer soit un folder-header dans un folder-item, soit la racine (sidebar-section-header)
|
||||
const isRoot = target.classList.contains('sidebar-section-header');
|
||||
const targetElement = isRoot ? target : target.closest('.folder-item');
|
||||
|
||||
const targetPath = folderItem.dataset.path;
|
||||
if (!targetElement) return;
|
||||
|
||||
const targetPath = targetElement.dataset.path;
|
||||
|
||||
// Empêcher de déplacer un dossier dans lui-même ou dans ses enfants
|
||||
if (this.draggedType === 'folder' && this.draggedPath) {
|
||||
if (targetPath === this.draggedPath || targetPath.startsWith(this.draggedPath + '/')) {
|
||||
e.dataTransfer.dropEffect = 'none';
|
||||
folderItem.classList.remove('drag-over');
|
||||
targetElement.classList.remove('drag-over');
|
||||
this.removeDestinationIndicator();
|
||||
return;
|
||||
}
|
||||
@ -263,34 +273,37 @@ class FileTree {
|
||||
|
||||
e.dataTransfer.dropEffect = 'move';
|
||||
|
||||
if (folderItem && !folderItem.classList.contains('drag-over')) {
|
||||
// Retirer la classe des autres dossiers
|
||||
document.querySelectorAll('.folder-item.drag-over').forEach(f => {
|
||||
if (f !== folderItem) {
|
||||
if (targetElement && !targetElement.classList.contains('drag-over')) {
|
||||
// Retirer la classe des autres dossiers et de la racine
|
||||
document.querySelectorAll('.folder-item.drag-over, .sidebar-section-header.drag-over').forEach(f => {
|
||||
if (f !== targetElement) {
|
||||
f.classList.remove('drag-over');
|
||||
}
|
||||
});
|
||||
folderItem.classList.add('drag-over');
|
||||
targetElement.classList.add('drag-over');
|
||||
|
||||
// Afficher l'indicateur de destination
|
||||
this.showDestinationIndicator(folderItem, targetPath);
|
||||
this.showDestinationIndicator(targetElement, targetPath, isRoot);
|
||||
}
|
||||
}
|
||||
|
||||
handleDragLeave(e, folderHeader) {
|
||||
const folderItem = folderHeader.closest('.folder-item');
|
||||
if (!folderItem) return;
|
||||
handleDragLeave(e, target) {
|
||||
// Gérer soit un folder-header dans un folder-item, soit la racine (sidebar-section-header)
|
||||
const isRoot = target.classList.contains('sidebar-section-header');
|
||||
const targetElement = isRoot ? target : target.closest('.folder-item');
|
||||
|
||||
// Vérifier que la souris a vraiment quitté le dossier
|
||||
const rect = folderHeader.getBoundingClientRect();
|
||||
if (!targetElement) return;
|
||||
|
||||
// Vérifier que la souris a vraiment quitté l'élément
|
||||
const rect = target.getBoundingClientRect();
|
||||
if (e.clientX < rect.left || e.clientX >= rect.right ||
|
||||
e.clientY < rect.top || e.clientY >= rect.bottom) {
|
||||
folderItem.classList.remove('drag-over');
|
||||
targetElement.classList.remove('drag-over');
|
||||
this.removeDestinationIndicator();
|
||||
}
|
||||
}
|
||||
|
||||
showDestinationIndicator(folderItem, targetPath) {
|
||||
showDestinationIndicator(targetElement, targetPath, isRoot) {
|
||||
let indicator = document.getElementById('drag-destination-indicator');
|
||||
if (!indicator) {
|
||||
indicator = document.createElement('div');
|
||||
@ -299,8 +312,7 @@ class FileTree {
|
||||
document.body.appendChild(indicator);
|
||||
}
|
||||
|
||||
const folderName = folderItem.querySelector('.folder-name').textContent.trim();
|
||||
const isRoot = folderItem.dataset.isRoot === 'true';
|
||||
const folderName = targetElement.querySelector('.folder-name').textContent.trim();
|
||||
const displayPath = isRoot ? 'notes/' : targetPath;
|
||||
|
||||
indicator.innerHTML = `
|
||||
@ -318,14 +330,17 @@ class FileTree {
|
||||
}
|
||||
}
|
||||
|
||||
handleDrop(e, folderHeader) {
|
||||
handleDrop(e, target) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
const folderItem = folderHeader.closest('.folder-item');
|
||||
if (!folderItem) return;
|
||||
// Gérer soit un folder-header dans un folder-item, soit la racine (sidebar-section-header)
|
||||
const isRoot = target.classList.contains('sidebar-section-header');
|
||||
const targetElement = isRoot ? target : target.closest('.folder-item');
|
||||
|
||||
folderItem.classList.remove('drag-over');
|
||||
if (!targetElement) return;
|
||||
|
||||
targetElement.classList.remove('drag-over');
|
||||
|
||||
// Supprimer l'indicateur de destination
|
||||
this.removeDestinationIndicator();
|
||||
@ -333,9 +348,9 @@ class FileTree {
|
||||
const sourcePath = e.dataTransfer.getData('application/note-path') ||
|
||||
e.dataTransfer.getData('text/plain');
|
||||
const sourceType = e.dataTransfer.getData('application/note-type');
|
||||
const targetFolderPath = folderItem.dataset.path;
|
||||
const targetFolderPath = targetElement.dataset.path;
|
||||
|
||||
console.log('Drop event:', {
|
||||
debug('Drop event:', {
|
||||
sourcePath,
|
||||
sourceType,
|
||||
targetFolderPath,
|
||||
@ -364,7 +379,7 @@ class FileTree {
|
||||
const sourceDir = sourcePath.includes('/') ?
|
||||
sourcePath.substring(0, sourcePath.lastIndexOf('/')) : '';
|
||||
if (sourceDir === targetFolderPath) {
|
||||
console.log('Déjà dans le même dossier parent, rien à faire');
|
||||
debug('Déjà dans le même dossier parent, rien à faire');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -377,12 +392,12 @@ class FileTree {
|
||||
// Si targetFolderPath est vide (racine), ne pas ajouter de slash
|
||||
const destinationPath = targetFolderPath === '' ? itemName : targetFolderPath + '/' + itemName;
|
||||
|
||||
console.log(`Déplacement: ${sourcePath} → ${destinationPath}`);
|
||||
debug(`Déplacement: ${sourcePath} → ${destinationPath}`);
|
||||
this.moveFile(sourcePath, destinationPath);
|
||||
}
|
||||
|
||||
async moveFile(sourcePath, destinationPath) {
|
||||
console.log('moveFile called:', { sourcePath, destinationPath });
|
||||
debug('moveFile called:', { sourcePath, destinationPath });
|
||||
|
||||
try {
|
||||
// Utiliser htmx.ajax() au lieu de fetch() manuel
|
||||
@ -392,7 +407,7 @@ class FileTree {
|
||||
values: { source: sourcePath, destination: destinationPath },
|
||||
swap: 'none' // On ne swap rien directement, le serveur utilise hx-swap-oob
|
||||
}).then(() => {
|
||||
console.log(`Fichier déplacé: ${sourcePath} -> ${destinationPath}`);
|
||||
debug(`Fichier déplacé: ${sourcePath} -> ${destinationPath}`);
|
||||
}).catch((error) => {
|
||||
console.error('Erreur lors du déplacement:', error);
|
||||
alert('Erreur lors du déplacement du fichier');
|
||||
@ -504,7 +519,7 @@ window.handleNewFolder = async function(event) {
|
||||
swap: 'none' // On ne swap rien directement, le serveur utilise hx-swap-oob
|
||||
}).then(() => {
|
||||
window.hideNewFolderModal();
|
||||
console.log(`Dossier créé: ${folderName}`);
|
||||
debug(`Dossier créé: ${folderName}`);
|
||||
}).catch((error) => {
|
||||
console.error('Erreur lors de la création du dossier:', error);
|
||||
alert('Erreur lors de la création du dossier');
|
||||
@ -722,7 +737,7 @@ class SelectionManager {
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`${paths.length} élément(s) supprimé(s)`);
|
||||
debug(`${paths.length} élément(s) supprimé(s)`);
|
||||
|
||||
// Fermer la modale
|
||||
this.hideDeleteConfirmationModal();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* Font Manager - Gère le changement de polices
|
||||
*/
|
||||
@ -67,7 +68,7 @@ class FontManager {
|
||||
const savedSize = localStorage.getItem('fontSize') || 'medium';
|
||||
this.applyFontSize(savedSize);
|
||||
|
||||
console.log('FontManager initialized with font:', savedFont, 'size:', savedSize);
|
||||
debug('FontManager initialized with font:', savedFont, 'size:', savedSize);
|
||||
}
|
||||
|
||||
applyFont(fontId) {
|
||||
@ -88,7 +89,7 @@ class FontManager {
|
||||
// Sauvegarder le choix
|
||||
localStorage.setItem('selectedFont', fontId);
|
||||
|
||||
console.log('Police appliquée:', font.name);
|
||||
debug('Police appliquée:', font.name);
|
||||
}
|
||||
|
||||
applyFontSize(sizeId) {
|
||||
@ -109,7 +110,7 @@ class FontManager {
|
||||
// Sauvegarder le choix
|
||||
localStorage.setItem('fontSize', sizeId);
|
||||
|
||||
console.log('Taille de police appliquée:', sizeId, size);
|
||||
debug('Taille de police appliquée:', sizeId, size);
|
||||
}
|
||||
|
||||
getCurrentSize() {
|
||||
@ -130,7 +131,7 @@ class FontManager {
|
||||
link.href = `https://fonts.googleapis.com/css2?family=${fontParam}&display=swap`;
|
||||
document.head.appendChild(link);
|
||||
|
||||
console.log('Google Font chargée:', fontParam);
|
||||
debug('Google Font chargée:', fontParam);
|
||||
}
|
||||
|
||||
getCurrentFont() {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* Keyboard Shortcuts Manager - Gère tous les raccourcis clavier de l'application
|
||||
*/
|
||||
@ -25,7 +26,7 @@ class KeyboardShortcutsManager {
|
||||
this.handleKeydown(event);
|
||||
});
|
||||
|
||||
console.log('Keyboard shortcuts initialized:', this.shortcuts.length, 'shortcuts');
|
||||
debug('Keyboard shortcuts initialized:', this.shortcuts.length, 'shortcuts');
|
||||
}
|
||||
|
||||
handleKeydown(event) {
|
||||
@ -59,13 +60,13 @@ class KeyboardShortcutsManager {
|
||||
if (searchInput) {
|
||||
searchInput.focus();
|
||||
searchInput.select();
|
||||
console.log('Search opened via Ctrl+K');
|
||||
debug('Search opened via Ctrl+K');
|
||||
}
|
||||
}
|
||||
|
||||
saveNote() {
|
||||
// Déclencher la sauvegarde de la note (géré par CodeMirror)
|
||||
console.log('Save triggered via Ctrl+S');
|
||||
debug('Save triggered via Ctrl+S');
|
||||
// La sauvegarde est déjà gérée dans editor.js
|
||||
}
|
||||
|
||||
@ -74,14 +75,14 @@ class KeyboardShortcutsManager {
|
||||
const dailyBtn = document.querySelector('button[hx-get="/api/daily/today"]');
|
||||
if (dailyBtn) {
|
||||
dailyBtn.click();
|
||||
console.log('Daily note opened via Ctrl+D');
|
||||
debug('Daily note opened via Ctrl+D');
|
||||
}
|
||||
}
|
||||
|
||||
createNewNote() {
|
||||
if (typeof showNewNoteModal === 'function') {
|
||||
showNewNoteModal();
|
||||
console.log('New note modal opened via Ctrl+N');
|
||||
debug('New note modal opened via Ctrl+N');
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,35 +90,35 @@ class KeyboardShortcutsManager {
|
||||
const homeBtn = document.querySelector('button[hx-get="/api/home"]');
|
||||
if (homeBtn) {
|
||||
homeBtn.click();
|
||||
console.log('Home opened via Ctrl+H');
|
||||
debug('Home opened via Ctrl+H');
|
||||
}
|
||||
}
|
||||
|
||||
toggleSidebar() {
|
||||
if (typeof toggleSidebar === 'function') {
|
||||
toggleSidebar();
|
||||
console.log('Sidebar toggled via Ctrl+B');
|
||||
debug('Sidebar toggled via Ctrl+B');
|
||||
}
|
||||
}
|
||||
|
||||
openSettings() {
|
||||
if (typeof openThemeModal === 'function') {
|
||||
openThemeModal();
|
||||
console.log('Settings opened via Ctrl+,');
|
||||
debug('Settings opened via Ctrl+,');
|
||||
}
|
||||
}
|
||||
|
||||
togglePreview() {
|
||||
if (typeof togglePreview === 'function') {
|
||||
togglePreview();
|
||||
console.log('Preview toggled via Ctrl+/');
|
||||
debug('Preview toggled via Ctrl+/');
|
||||
}
|
||||
}
|
||||
|
||||
createNewFolder() {
|
||||
if (typeof showNewFolderModal === 'function') {
|
||||
showNewFolderModal();
|
||||
console.log('New folder modal opened via Ctrl+Shift+F');
|
||||
debug('New folder modal opened via Ctrl+Shift+F');
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,7 +148,7 @@ class KeyboardShortcutsManager {
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Escape pressed');
|
||||
debug('Escape pressed');
|
||||
}
|
||||
|
||||
getShortcuts() {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* LinkInserter - Modal de recherche pour insérer des liens vers d'autres notes
|
||||
* Intégré dans l'éditeur CodeMirror 6
|
||||
@ -137,7 +138,7 @@ class LinkInserter {
|
||||
}
|
||||
|
||||
handleKeyNavigation(event) {
|
||||
console.log('[LinkInserter] Key pressed:', event.key, 'Results:', this.results.length);
|
||||
debug('[LinkInserter] Key pressed:', event.key, 'Results:', this.results.length);
|
||||
|
||||
if (this.results.length === 0) {
|
||||
if (event.key === 'Escape') {
|
||||
@ -149,27 +150,27 @@ class LinkInserter {
|
||||
|
||||
switch (event.key) {
|
||||
case 'ArrowDown':
|
||||
console.log('[LinkInserter] Arrow Down - moving to index:', this.selectedIndex + 1);
|
||||
debug('[LinkInserter] Arrow Down - moving to index:', this.selectedIndex + 1);
|
||||
event.preventDefault();
|
||||
this.selectedIndex = Math.min(this.selectedIndex + 1, this.results.length - 1);
|
||||
this.updateSelection();
|
||||
break;
|
||||
|
||||
case 'ArrowUp':
|
||||
console.log('[LinkInserter] Arrow Up - moving to index:', this.selectedIndex - 1);
|
||||
debug('[LinkInserter] Arrow Up - moving to index:', this.selectedIndex - 1);
|
||||
event.preventDefault();
|
||||
this.selectedIndex = Math.max(this.selectedIndex - 1, 0);
|
||||
this.updateSelection();
|
||||
break;
|
||||
|
||||
case 'Enter':
|
||||
console.log('[LinkInserter] Enter pressed - calling selectResult()');
|
||||
debug('[LinkInserter] Enter pressed - calling selectResult()');
|
||||
event.preventDefault();
|
||||
this.selectResult();
|
||||
break;
|
||||
|
||||
case 'Escape':
|
||||
console.log('[LinkInserter] Escape pressed - closing modal');
|
||||
debug('[LinkInserter] Escape pressed - closing modal');
|
||||
event.preventDefault();
|
||||
this.close();
|
||||
break;
|
||||
@ -189,7 +190,7 @@ class LinkInserter {
|
||||
}
|
||||
|
||||
selectResult() {
|
||||
console.log('[LinkInserter] selectResult called, results:', this.results.length);
|
||||
debug('[LinkInserter] selectResult called, results:', this.results.length);
|
||||
|
||||
if (this.results.length === 0) {
|
||||
console.warn('[LinkInserter] No results to select');
|
||||
@ -197,11 +198,11 @@ class LinkInserter {
|
||||
}
|
||||
|
||||
const selected = this.results[this.selectedIndex];
|
||||
console.log('[LinkInserter] Selected:', selected);
|
||||
console.log('[LinkInserter] Callback exists:', !!this.callback);
|
||||
debug('[LinkInserter] Selected:', selected);
|
||||
debug('[LinkInserter] Callback exists:', !!this.callback);
|
||||
|
||||
if (selected && this.callback) {
|
||||
console.log('[LinkInserter] Calling callback with:', { title: selected.title, path: selected.path });
|
||||
debug('[LinkInserter] Calling callback with:', { title: selected.title, path: selected.path });
|
||||
|
||||
// Sauvegarder le callback localement avant de fermer
|
||||
const callback = this.callback;
|
||||
@ -211,7 +212,7 @@ class LinkInserter {
|
||||
|
||||
// Puis appeler le callback après un petit délai pour que le modal se ferme proprement
|
||||
setTimeout(() => {
|
||||
console.log('[LinkInserter] Executing callback now...');
|
||||
debug('[LinkInserter] Executing callback now...');
|
||||
callback({
|
||||
title: selected.title,
|
||||
path: selected.path
|
||||
@ -254,7 +255,7 @@ class LinkInserter {
|
||||
|
||||
// Click handler
|
||||
item.addEventListener('click', (e) => {
|
||||
console.log('[LinkInserter] Item clicked, index:', index);
|
||||
debug('[LinkInserter] Item clicked, index:', index);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.selectedIndex = index;
|
||||
@ -336,7 +337,7 @@ class LinkInserter {
|
||||
* @param {Function} options.onSelect - Callback appelé avec {title, path}
|
||||
*/
|
||||
open({ editorView, onSelect }) {
|
||||
console.log('[LinkInserter] open() called with callback:', !!onSelect);
|
||||
debug('[LinkInserter] open() called with callback:', !!onSelect);
|
||||
|
||||
if (this.isOpen) return;
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* SearchModal - Système de recherche modale avec raccourcis clavier
|
||||
* Inspiré des Command Palettes modernes (VSCode, Notion, etc.)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* SidebarSections - Gère les sections rétractables de la sidebar
|
||||
* Permet de replier/déplier les favoris et le répertoire de notes
|
||||
@ -12,7 +13,7 @@ class SidebarSections {
|
||||
}
|
||||
|
||||
init() {
|
||||
console.log('SidebarSections: Initialisation...');
|
||||
debug('SidebarSections: Initialisation...');
|
||||
|
||||
// Restaurer l'état sauvegardé au démarrage
|
||||
this.restoreStates();
|
||||
@ -22,12 +23,12 @@ class SidebarSections {
|
||||
const targetId = event.detail?.target?.id;
|
||||
|
||||
if (targetId === 'favorites-list') {
|
||||
console.log('Favoris rechargés, restauration de l\'état...');
|
||||
debug('Favoris rechargés, restauration de l\'état...');
|
||||
setTimeout(() => this.restoreSectionState('favorites'), 50);
|
||||
}
|
||||
|
||||
if (targetId === 'file-tree') {
|
||||
console.log('File-tree rechargé, restauration de l\'état...');
|
||||
debug('File-tree rechargé, restauration de l\'état...');
|
||||
setTimeout(() => this.restoreSectionState('notes'), 50);
|
||||
}
|
||||
});
|
||||
@ -38,14 +39,14 @@ class SidebarSections {
|
||||
// Ne restaurer l'état que pour les swaps du file-tree complet
|
||||
// Les swaps de statut (auto-save-status) ne doivent pas déclencher la restauration
|
||||
if (targetId === 'file-tree') {
|
||||
console.log('File-tree rechargé (oob), restauration de l\'état...');
|
||||
debug('File-tree rechargé (oob), restauration de l\'état...');
|
||||
setTimeout(() => this.restoreSectionState('notes'), 50);
|
||||
}
|
||||
});
|
||||
|
||||
// Écouter les restaurations d'historique (bouton retour du navigateur)
|
||||
document.body.addEventListener('htmx:historyRestore', () => {
|
||||
console.log('SidebarSections: History restored, restoring section states...');
|
||||
debug('SidebarSections: History restored, restoring section states...');
|
||||
// Restaurer les états des sections après restauration de l'historique
|
||||
setTimeout(() => {
|
||||
this.restoreSectionState('favorites');
|
||||
@ -53,7 +54,7 @@ class SidebarSections {
|
||||
}, 100);
|
||||
});
|
||||
|
||||
console.log('SidebarSections: Initialisé');
|
||||
debug('SidebarSections: Initialisé');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +76,7 @@ class SidebarSections {
|
||||
if (!section) return;
|
||||
|
||||
localStorage.setItem(section.key, isExpanded.toString());
|
||||
console.log(`État sauvegardé: ${sectionName} = ${isExpanded}`);
|
||||
debug(`État sauvegardé: ${sectionName} = ${isExpanded}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -113,7 +114,7 @@ class SidebarSections {
|
||||
}
|
||||
|
||||
this.setSectionState(sectionName, newState);
|
||||
console.log(`Section ${sectionName} ${newState ? 'ouverte' : 'fermée'}`);
|
||||
debug(`Section ${sectionName} ${newState ? 'ouverte' : 'fermée'}`);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,7 +149,7 @@ class SidebarSections {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`État restauré: ${sectionName} = ${isExpanded ? 'ouvert' : 'fermé'}`);
|
||||
debug(`État restauré: ${sectionName} = ${isExpanded ? 'ouvert' : 'fermé'}`);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* ThemeManager - Gère le système de thèmes de l'application
|
||||
* Permet de changer entre différents thèmes et persiste le choix dans localStorage
|
||||
@ -70,7 +71,7 @@ class ThemeManager {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('ThemeManager initialized with theme:', this.currentTheme);
|
||||
debug('ThemeManager initialized with theme:', this.currentTheme);
|
||||
}
|
||||
|
||||
loadTheme() {
|
||||
@ -91,7 +92,7 @@ class ThemeManager {
|
||||
// Mettre à jour les cartes de thème si la modale est ouverte
|
||||
this.updateThemeCards();
|
||||
|
||||
console.log('Theme applied:', themeId);
|
||||
debug('Theme applied:', themeId);
|
||||
}
|
||||
|
||||
openThemeModal() {
|
||||
@ -163,7 +164,7 @@ window.selectTheme = function(themeId) {
|
||||
};
|
||||
|
||||
window.switchSettingsTab = function(tabName) {
|
||||
console.log('Switching to tab:', tabName);
|
||||
debug('Switching to tab:', tabName);
|
||||
|
||||
// Désactiver tous les onglets
|
||||
const tabs = document.querySelectorAll('.settings-tab');
|
||||
@ -191,7 +192,7 @@ window.switchSettingsTab = function(tabName) {
|
||||
const section = document.getElementById(sectionId);
|
||||
if (section) {
|
||||
section.style.display = 'block';
|
||||
console.log('Showing section:', sectionId);
|
||||
debug('Showing section:', sectionId);
|
||||
} else {
|
||||
console.error('Section not found:', sectionId);
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
// Fonction pour détecter si on est sur mobile
|
||||
function isMobileDevice() {
|
||||
return window.innerWidth <= 768;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { debug, debugError } from './debug.js';
|
||||
/**
|
||||
* Vim Mode Manager - Gère l'activation/désactivation du mode Vim dans CodeMirror
|
||||
*/
|
||||
@ -8,7 +9,7 @@ class VimModeManager {
|
||||
this.vim = null; // Extension Vim de CodeMirror
|
||||
this.editorView = null; // Instance EditorView actuelle
|
||||
|
||||
console.log('VimModeManager initialized, enabled:', this.enabled);
|
||||
debug('VimModeManager initialized, enabled:', this.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,7 +61,7 @@ class VimModeManager {
|
||||
// Import dynamique du package Vim
|
||||
const { vim } = await import('@replit/codemirror-vim');
|
||||
this.vim = vim;
|
||||
console.log('✅ Vim extension loaded successfully');
|
||||
debug('✅ Vim extension loaded successfully');
|
||||
return this.vim;
|
||||
} catch (error) {
|
||||
console.warn('⚠️ Vim mode is not available. The @replit/codemirror-vim package is not installed.');
|
||||
@ -118,14 +119,14 @@ if (typeof window !== 'undefined') {
|
||||
|
||||
// Afficher un message
|
||||
const message = enabled ? '✅ Mode Vim activé' : '❌ Mode Vim désactivé';
|
||||
console.log(message);
|
||||
debug(message);
|
||||
|
||||
// Recharger l'éditeur actuel si il existe
|
||||
if (window.currentMarkdownEditor && window.currentMarkdownEditor.reloadWithVimMode) {
|
||||
await window.currentMarkdownEditor.reloadWithVimMode();
|
||||
console.log('Editor reloaded with Vim mode:', enabled);
|
||||
debug('Editor reloaded with Vim mode:', enabled);
|
||||
} else {
|
||||
console.log('No editor to reload. Vim mode will be applied when opening a note.');
|
||||
debug('No editor to reload. Vim mode will be applied when opening a note.');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user