feat: améliorer styles dark mode avec background unifié #20293a, bordures notes/cards (1px solid #000 light, #dedfe2 dark), width input 600px→800px, ajout bouton pin corner absolu (top-right, hover scale 1.06), suppression backgrounds/borders/outlines inputs (transparent + !important), nettoyage code dupliqué note-input-collapsed, styles todo-draft-row transparent, et corrections mineures formatage CSS (espaces, indentation)

This commit is contained in:
2026-04-19 21:46:47 -04:00
parent ef6f9cb486
commit f99c1cbecb
11 changed files with 1098 additions and 200 deletions
+86 -3
View File
@@ -1,4 +1,20 @@
document.addEventListener('DOMContentLoaded', () => {
// ===== Add Todo Button Handler (Android convention) =====
const addTodoBtn = document.querySelector('.sidebar-add-todo');
if (addTodoBtn) {
addTodoBtn.addEventListener('click', (e) => {
e.preventDefault();
if (!window.ShaarItRules) {
console.warn('[shaarit] ShaarItRules not available, cannot generate todo URL');
return;
}
const basePath = addTodoBtn.getAttribute('data-base-path') || '';
const todoUrl = window.ShaarItRules.generateTodoUrl();
const redirectUrl = `${basePath}/admin/shaare?post=${encodeURIComponent(todoUrl)}&tags=todo&title=%E2%9C%85%20`;
window.location.href = redirectUrl;
});
}
// ===== Theme Toggle =====
const themeCheckbox = document.getElementById('theme-toggle-checkbox');
const themeIconLight = document.getElementById('theme-icon-light');
@@ -88,14 +104,19 @@ document.addEventListener('DOMContentLoaded', () => {
const HIDDEN_TAGS_STORAGE_KEY = 'shaarli_hidden_tags';
// Default system tags that are hidden by default
// Harmonisé avec ShaarIt Android (PRESET_SYSTEM_TAGS).
const DEFAULT_HIDDEN_TAGS = [
'note',
'shaarli-pin',
'shaarli-note',
'todo',
'shaarli-todo',
'shaarli-pin',
'note-color-*',
'notebg-*',
'notefilter-*',
'font-*',
'readitlater',
'brain-dump',
'shaarli-archive'
];
@@ -1706,12 +1727,14 @@ document.addEventListener('DOMContentLoaded', () => {
const syncNoteCheckbox = () => {
if (!noteCheckbox) return;
noteCheckbox.checked = tags.some((tag) => /^note$/i.test(tag));
// Reconnaît les conventions Android (`note`, `#note`) et legacy (`shaarli-note`).
noteCheckbox.checked = tags.some((tag) => /^(note|#note|shaarli-note)$/i.test(tag));
};
const syncTodoCheckbox = () => {
if (!todoCheckbox) return;
todoCheckbox.checked = tags.some((tag) => /^shaarli-todo$/i.test(tag));
// Reconnaît les conventions Android (`todo`, `#todo`) et legacy (`shaarli-todo`).
todoCheckbox.checked = tags.some((tag) => /^(todo|#todo|shaarli-todo)$/i.test(tag));
};
// Helper functions to manage note emoji in title
@@ -1956,6 +1979,66 @@ document.addEventListener('DOMContentLoaded', () => {
form.addEventListener('submit', commitInputValue);
// === Todo migration: shaarli-todo → todo + Android URL ===
// Lors de la sauvegarde d'un todo, remplacer le tag legacy par la norme Android
// et générer une URL Android si vide ou legacy.
form.addEventListener('submit', () => {
try {
if (!window.ShaarItRules) return;
const urlField = form.querySelector('input[name="lf_url"]');
const url = urlField ? (urlField.value || '').trim() : '';
// Vérifier si c'est un todo (tag shaarli-todo ou todo)
const hasTodoTag = tags.some((t) => /^(todo|shaarli-todo)$/i.test(t));
if (!hasTodoTag) return;
// 1. Remplacer shaarli-todo par todo
const hadLegacyTag = tags.some((t) => /^shaarli-todo$/i.test(t));
if (hadLegacyTag) {
tags = tags.filter((t) => !/^shaarli-todo$/i.test(t));
if (!tags.some((t) => /^todo$/i.test(t))) {
tags.push('todo');
}
updateHiddenTags();
}
// 2. Générer URL Android si vide ou legacy
if (!url || /^https?:\/\/shaarli-todo/.test(url) || url === 'http://shaarli-todo') {
const newUrl = window.ShaarItRules.generateTodoUrl();
urlField.value = newUrl;
}
} catch (e) {
console.warn('[shaarit] todo migration failed:', e);
}
});
// === Content-type auto-tagging (harmonisation ShaarIt Android) ===
// À la soumission, détecte le type de contenu depuis l'URL et injecte
// les tags automatiques (video, podcast, radio, music, article, news,
// social, repository+dev, shopping, image, pdf...).
// Les tags déjà présents ne sont jamais dupliqués ; aucun tag n'est
// supprimé. Désactivé pour les notes/todos (URLs internes).
form.addEventListener('submit', () => {
try {
if (!window.ShaarItRules) return;
const urlField = form.querySelector('input[name="lf_url"]');
const url = urlField ? (urlField.value || '').trim() : '';
if (!url) return;
// Ne pas auto-tagger les notes/todos (URLs internes reconnues par ShaarItRules).
const fakeLink = { url: url, tags: tags };
if (window.ShaarItRules.isNote(fakeLink) || window.ShaarItRules.isTodo(fakeLink)) return;
const detection = window.ShaarItRules.detectContentType(url);
if (!detection || !detection.tags || detection.tags.length === 0) return;
tags = window.ShaarItRules.mergeAutoTags(tags, detection.tags);
updateHiddenTags();
} catch (e) {
console.warn('[shaarit] content-type auto-tagging failed:', e);
}
});
updateHiddenTags();
syncReadLaterCheckbox();
syncNoteCheckbox();