mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
feat(collections/calendar): change click behaviour on mobile
This commit is contained in:
parent
c081a596df
commit
c4a426566f
@ -21,6 +21,7 @@ import ActionButton from "../../react/ActionButton";
|
|||||||
import { RefObject } from "preact";
|
import { RefObject } from "preact";
|
||||||
import TouchBar, { TouchBarButton, TouchBarLabel, TouchBarSegmentedControl, TouchBarSpacer } from "../../react/TouchBar";
|
import TouchBar, { TouchBarButton, TouchBarLabel, TouchBarSegmentedControl, TouchBarSpacer } from "../../react/TouchBar";
|
||||||
import { openCalendarContextMenu } from "./context_menu";
|
import { openCalendarContextMenu } from "./context_menu";
|
||||||
|
import { isMobile } from "../../../services/utils";
|
||||||
|
|
||||||
interface CalendarViewData {
|
interface CalendarViewData {
|
||||||
|
|
||||||
@ -266,7 +267,7 @@ function useEventDisplayCustomization(parentNote: FNote) {
|
|||||||
|
|
||||||
// Prepend the icon to the title, if any.
|
// Prepend the icon to the title, if any.
|
||||||
if (iconClass) {
|
if (iconClass) {
|
||||||
let titleContainer;
|
let titleContainer: HTMLElement | null = null;
|
||||||
switch (e.view.type) {
|
switch (e.view.type) {
|
||||||
case "timeGridWeek":
|
case "timeGridWeek":
|
||||||
case "dayGridMonth":
|
case "dayGridMonth":
|
||||||
@ -285,6 +286,9 @@ function useEventDisplayCustomization(parentNote: FNote) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Disable the default context menu.
|
||||||
|
e.el.dataset.noContextMenu = "true";
|
||||||
|
|
||||||
// Append promoted attributes to the end of the event container.
|
// Append promoted attributes to the end of the event container.
|
||||||
if (promotedAttributes) {
|
if (promotedAttributes) {
|
||||||
let promotedAttributesHtml = "";
|
let promotedAttributesHtml = "";
|
||||||
@ -310,12 +314,18 @@ function useEventDisplayCustomization(parentNote: FNote) {
|
|||||||
$(mainContainer ?? e.el).append($(promotedAttributesHtml));
|
$(mainContainer ?? e.el).append($(promotedAttributesHtml));
|
||||||
}
|
}
|
||||||
|
|
||||||
e.el.addEventListener("contextmenu", async (contextMenuEvent) => {
|
async function onContextMenu(contextMenuEvent: PointerEvent) {
|
||||||
const note = await froca.getNote(e.event.extendedProps.noteId);
|
const note = await froca.getNote(e.event.extendedProps.noteId);
|
||||||
if (!note) return;
|
if (!note) return;
|
||||||
|
|
||||||
openCalendarContextMenu(contextMenuEvent, note, parentNote);
|
openCalendarContextMenu(contextMenuEvent, note, parentNote);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if (isMobile()) {
|
||||||
|
e.el.addEventListener("click", onContextMenu);
|
||||||
|
} else {
|
||||||
|
e.el.addEventListener("contextmenu", onContextMenu);
|
||||||
|
}
|
||||||
}, []);
|
}, []);
|
||||||
return { eventDidMount };
|
return { eventDidMount };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user