mirror of
https://gitlab.com/arnekeller/trilium-timeline.git
synced 2024-11-25 02:15:05 +00:00
Add event listener to activate a day note on click
This commit is contained in:
parent
26da3db508
commit
ffb3c7baf2
@ -145,6 +145,24 @@ async function renderTimeline() {
|
||||
// Add present time marker based on "timeline_present" label
|
||||
timeline.setCurrentTime(timeline_options.timeline_present);
|
||||
|
||||
// Add event listener to activate a day note on click
|
||||
timeline.on("click", async (e) => {
|
||||
const timelineHeight = timeline.dom.centerContainer.getBoundingClientRect().height;
|
||||
if (e.y <= timelineHeight) {
|
||||
// ignore clicks on the timeline
|
||||
return;
|
||||
}
|
||||
const effectiveY = e.y - timelineHeight;
|
||||
if (effectiveY > timeline.dom.bottom.children[0].children[0].getBoundingClientRect().height) {
|
||||
// ignore clicks on the month axis
|
||||
return;
|
||||
}
|
||||
const day = e.time.toISOString().substr(0, 10);
|
||||
const todayNote = await api.getDayNote(day);
|
||||
api.waitUntilSynced();
|
||||
await api.openTabWithNote(todayNote.noteId, true);
|
||||
});
|
||||
|
||||
// Create UI menu buttons from added groups (that are not forced into another group)
|
||||
menu.innerHTML = '';
|
||||
const toggle_groups = groups.get({filter:function(item){return(item.forceGroup===null && item.id!=='default')}});
|
||||
|
Loading…
Reference in New Issue
Block a user