feat: optimiser l'interface des notes avec émoji 📝 automatique dans les titres, redirection intelligente vers vue Notes au clic sur titre, retour URL dynamique post-sauvegarde, auto-ouverture note via hash #open-note-{id}, réduction tailles boutons actions (36px→28px hover, 32px→30px), suppression gaps entre boutons (0.25rem→0), link-footer nowrap avec overflow hidden, et changement placeholder "Page title"→"Note title"
This commit is contained in:
@@ -1602,6 +1602,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const tagsTextInput = form.querySelector('.bookmark-tags-text-input');
|
||||
const readLaterCheckbox = form.querySelector('.bookmark-toggle-readlater');
|
||||
const noteCheckbox = form.querySelector('.bookmark-toggle-note');
|
||||
const titleInput = form.querySelector('input[name="lf_title"]');
|
||||
const isDarkTheme = document.documentElement.getAttribute('data-theme') === 'dark';
|
||||
|
||||
// Markdown editor
|
||||
@@ -1676,6 +1677,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
.map((tag) => normalizeTag(tag))
|
||||
.filter(Boolean);
|
||||
|
||||
// Update return URL based on bookmark type (note vs regular)
|
||||
const returnUrlInput = form.querySelector('input[name="returnurl"]');
|
||||
if (returnUrlInput) {
|
||||
form.addEventListener('submit', () => {
|
||||
const isNote = noteCheckbox?.checked || tags.some((tag) => /^note$/i.test(tag));
|
||||
if (isNote) {
|
||||
returnUrlInput.value = `${shaarli.basePath}/?searchtags=note`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const updateHiddenTags = () => {
|
||||
hiddenTagsInput.value = tags.join(' ');
|
||||
};
|
||||
@@ -1690,6 +1702,44 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
noteCheckbox.checked = tags.some((tag) => /^note$/i.test(tag));
|
||||
};
|
||||
|
||||
// Helper functions to manage note emoji in title
|
||||
const NOTE_EMOJI = '📝';
|
||||
|
||||
const hasNoteEmoji = (title) => {
|
||||
return title && title.startsWith(NOTE_EMOJI);
|
||||
};
|
||||
|
||||
const addNoteEmoji = (title) => {
|
||||
if (!title) return NOTE_EMOJI + ' ';
|
||||
if (hasNoteEmoji(title)) return title;
|
||||
return NOTE_EMOJI + ' ' + title;
|
||||
};
|
||||
|
||||
const removeNoteEmoji = (title) => {
|
||||
if (!title) return '';
|
||||
if (title.startsWith(NOTE_EMOJI + ' ')) {
|
||||
return title.substring(NOTE_EMOJI.length + 1);
|
||||
}
|
||||
if (title.startsWith(NOTE_EMOJI)) {
|
||||
return title.substring(NOTE_EMOJI.length);
|
||||
}
|
||||
return title;
|
||||
};
|
||||
|
||||
const updateNoteTitle = (isNote) => {
|
||||
if (!titleInput) return;
|
||||
const currentTitle = titleInput.value || '';
|
||||
if (isNote) {
|
||||
if (!hasNoteEmoji(currentTitle)) {
|
||||
titleInput.value = addNoteEmoji(currentTitle);
|
||||
}
|
||||
} else {
|
||||
if (hasNoteEmoji(currentTitle)) {
|
||||
titleInput.value = removeNoteEmoji(currentTitle);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const addTag = (rawTag) => {
|
||||
const tag = normalizeTag(rawTag);
|
||||
if (!tag) return;
|
||||
@@ -1804,6 +1854,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
if (noteCheckbox.checked) {
|
||||
tags.push('note');
|
||||
updateNoteTitle(true);
|
||||
} else {
|
||||
updateNoteTitle(false);
|
||||
}
|
||||
|
||||
updateHiddenTags();
|
||||
@@ -1838,6 +1891,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
syncNoteCheckbox();
|
||||
renderTags();
|
||||
refreshAutocomplete();
|
||||
|
||||
// Initial title update if note tag is present
|
||||
if (noteCheckbox && noteCheckbox.checked && titleInput) {
|
||||
const currentTitle = titleInput.value || '';
|
||||
if (!hasNoteEmoji(currentTitle) && !currentTitle.trim()) {
|
||||
titleInput.value = NOTE_EMOJI + ' ';
|
||||
} else if (!hasNoteEmoji(currentTitle)) {
|
||||
titleInput.value = addNoteEmoji(currentTitle);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2740,6 +2803,27 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
var url = urlEl.textContent.trim();
|
||||
var realUrl = (titleEl && titleEl.getAttribute('href')) || url;
|
||||
|
||||
// Check if this is a note bookmark (has 'note' tag)
|
||||
var isNote = false;
|
||||
var noteId = card.dataset.id || '';
|
||||
card.querySelectorAll('.link-tag[data-tag]').forEach(function(tagEl) {
|
||||
if (tagEl.dataset.tag === 'note') {
|
||||
isNote = true;
|
||||
}
|
||||
});
|
||||
|
||||
// Add click handler for note bookmarks to redirect to notes page
|
||||
if (isNote && titleEl) {
|
||||
titleEl.addEventListener('click', function(e) {
|
||||
// Only redirect if it's a left-click without modifiers
|
||||
if (e.button === 0 && !e.ctrlKey && !e.metaKey && !e.shiftKey) {
|
||||
e.preventDefault();
|
||||
var basePath = (typeof shaarli !== 'undefined' && shaarli.basePath) ? shaarli.basePath : '';
|
||||
window.location.href = basePath + '/?searchtags=note#open-note-' + noteId;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (isMediaUrl(url) || isMediaUrl(realUrl)) {
|
||||
var actionsDiv = card.querySelector('.link-actions');
|
||||
if (!actionsDiv) return;
|
||||
|
||||
Reference in New Issue
Block a user