MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / attachDailyNoteHeaderLink

Function attachDailyNoteHeaderLink

src/bases/calendar-core.ts:2033–2072  ·  view source on GitHub ↗
(
	headerCell: HTMLElement,
	date: Date,
	viewType: string,
	plugin: TaskNotesPlugin,
	handleClick: DateTitleClickHandler = handleDateTitleClick
)

Source from the content-addressed store, hash-verified

2031 * header explicitly while leaving the built-in navLink behavior alone elsewhere.
2032 */
2033export function attachDailyNoteHeaderLink(
2034 headerCell: HTMLElement,
2035 date: Date,
2036 viewType: string,
2037 plugin: TaskNotesPlugin,
2038 handleClick: DateTitleClickHandler = handleDateTitleClick
2039): void {
2040 if (viewType !== "timeGridDay") {
2041 return;
2042 }
2043
2044 const linkEl =
2045 headerCell.querySelector<HTMLElement>(".fc-col-header-cell-cushion") || headerCell;
2046 const title = `Go to ${format(date, "d MMMM yyyy")}`;
2047
2048 linkEl.setAttribute("data-navlink", "");
2049 linkEl.setAttribute("title", title);
2050 linkEl.setAttribute("aria-label", title);
2051 linkEl.classList.add("tasknotes-calendar-daily-note-link");
2052 linkEl.dataset.tasknotesDailyNoteDate = date.toISOString();
2053
2054 if (linkEl.matches("a") && !linkEl.getAttribute("href")) {
2055 linkEl.setAttribute("href", "#");
2056 }
2057
2058 if (linkEl.dataset.tasknotesDailyNoteLinkAttached === "true") {
2059 return;
2060 }
2061
2062 linkEl.dataset.tasknotesDailyNoteLinkAttached = "true";
2063 linkEl.addEventListener("click", (event) => {
2064 event.preventDefault();
2065 event.stopPropagation();
2066 const target = event.currentTarget as HTMLElement | null;
2067 const targetDate = target?.dataset.tasknotesDailyNoteDate
2068 ? new Date(target.dataset.tasknotesDailyNoteDate)
2069 : date;
2070 void handleClick(targetDate, plugin);
2071 });
2072}
2073
2074/**
2075 * Calculate pre-populated values for task creation from calendar date selection

Calls 1

handleClickFunction · 0.85

Tested by

no test coverage detected