Remote calendar link for external sync

This commit is contained in:
2025-04-07 13:58:08 +02:00
parent 811c83552f
commit b09d5e5ffd
5 changed files with 70 additions and 6 deletions

View File

@ -303,10 +303,36 @@ export class IcsCalendar extends inheritHtmlElement("div") {
this.calendar = new Calendar(this.node, {
plugins: [dayGridPlugin, iCalendarPlugin, listPlugin],
locales: [frLocale, enLocale],
customButtons: {
getCalendarLink: {
text: gettext("Copy calendar link"),
click: async (event: Event) => {
const button = event.target as HTMLButtonElement;
button.classList.add("text-copy");
button.setAttribute(
"tooltip",
gettext("Calendar link copied to the clipboard"),
);
navigator.clipboard.writeText(
new URL(
await makeUrl(calendarCalendarInternal),
window.location.origin,
).toString(),
);
setTimeout(() => {
button.classList.remove("text-copied");
button.classList.add("text-copied");
button.classList.remove("text-copy");
button.removeAttribute("tooltip");
}, 700);
},
},
},
height: "auto",
locale: this.locale,
initialView: this.currentView(),
headerToolbar: this.currentToolbar(),
footerToolbar: { start: "getCalendarLink" },
eventSources: await this.getEventSources(),
windowResize: () => {
this.calendar.changeView(this.currentView());

View File

@ -98,4 +98,21 @@ ics-calendar {
background: white;
}
}
.fc .fc-toolbar.fc-footer-toolbar {
margin-bottom: 0.5em;
}
button.text-copy,
button.text-copy:focus,
button.text-copy:hover {
background-color: green !important;
transition: 200ms linear;
}
button.text-copied,
button.text-copied:focus,
button.text-copied:hover {
transition: 200ms linear;
}
}