mirror of
https://github.com/zadam/trilium.git
synced 2025-12-04 22:44:25 +01:00
Compare commits
2 Commits
309fbab2e6
...
9682df6240
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9682df6240 | ||
|
|
a718908385 |
@ -2,13 +2,15 @@ import { t } from "../services/i18n.js";
|
|||||||
import contextMenu, { type ContextMenuEvent, type MenuItem } from "./context_menu.js";
|
import contextMenu, { type ContextMenuEvent, type MenuItem } from "./context_menu.js";
|
||||||
import appContext, { type CommandNames } from "../components/app_context.js";
|
import appContext, { type CommandNames } from "../components/app_context.js";
|
||||||
import type { ViewScope } from "../services/link.js";
|
import type { ViewScope } from "../services/link.js";
|
||||||
|
import utils from "../services/utils.js";
|
||||||
|
import { getClosestNtxId } from "../widgets/widget_utils.js";
|
||||||
|
|
||||||
function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewScope = {}, hoistedNoteId: string | null = null) {
|
function openContextMenu(notePath: string, e: ContextMenuEvent, viewScope: ViewScope = {}, hoistedNoteId: string | null = null) {
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
x: e.pageX,
|
x: e.pageX,
|
||||||
y: e.pageY,
|
y: e.pageY,
|
||||||
items: getItems(),
|
items: getItems(),
|
||||||
selectMenuItemHandler: ({ command }) => handleLinkContextMenuItem(command, notePath, viewScope, hoistedNoteId)
|
selectMenuItemHandler: ({ command }) => handleLinkContextMenuItem(command, e, notePath, viewScope, hoistedNoteId)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,7 +23,7 @@ function getItems(): MenuItem<CommandNames>[] {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleLinkContextMenuItem(command: string | undefined, notePath: string, viewScope = {}, hoistedNoteId: string | null = null) {
|
function handleLinkContextMenuItem(command: string | undefined, e: ContextMenuEvent, notePath: string, viewScope = {}, hoistedNoteId: string | null = null) {
|
||||||
if (!hoistedNoteId) {
|
if (!hoistedNoteId) {
|
||||||
hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId ?? null;
|
hoistedNoteId = appContext.tabManager.getActiveContext()?.hoistedNoteId ?? null;
|
||||||
}
|
}
|
||||||
@ -29,15 +31,8 @@ function handleLinkContextMenuItem(command: string | undefined, notePath: string
|
|||||||
if (command === "openNoteInNewTab") {
|
if (command === "openNoteInNewTab") {
|
||||||
appContext.tabManager.openContextWithNote(notePath, { hoistedNoteId, viewScope });
|
appContext.tabManager.openContextWithNote(notePath, { hoistedNoteId, viewScope });
|
||||||
} else if (command === "openNoteInNewSplit") {
|
} else if (command === "openNoteInNewSplit") {
|
||||||
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
|
const ntxId = getNtxId(e);
|
||||||
|
if (!ntxId) return;
|
||||||
if (!subContexts) {
|
|
||||||
logError("subContexts is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { ntxId } = subContexts[subContexts.length - 1];
|
|
||||||
|
|
||||||
appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath, hoistedNoteId, viewScope });
|
appContext.triggerCommand("openNewNoteSplit", { ntxId, notePath, hoistedNoteId, viewScope });
|
||||||
} else if (command === "openNoteInNewWindow") {
|
} else if (command === "openNoteInNewWindow") {
|
||||||
appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope });
|
appContext.triggerCommand("openInWindow", { notePath, hoistedNoteId, viewScope });
|
||||||
@ -46,6 +41,16 @@ function handleLinkContextMenuItem(command: string | undefined, notePath: string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNtxId(e: ContextMenuEvent) {
|
||||||
|
if (utils.isDesktop()) {
|
||||||
|
const subContexts = appContext.tabManager.getActiveContext()?.getSubContexts();
|
||||||
|
if (!subContexts) return null;
|
||||||
|
return subContexts[subContexts.length - 1].ntxId;
|
||||||
|
} else {
|
||||||
|
return getClosestNtxId(e.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
getItems,
|
getItems,
|
||||||
handleLinkContextMenuItem,
|
handleLinkContextMenuItem,
|
||||||
|
|||||||
@ -2627,7 +2627,8 @@ iframe.print-iframe {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
body.mobile .split-note-container-widget {
|
body.mobile {
|
||||||
|
.split-note-container-widget {
|
||||||
flex-direction: column !important;
|
flex-direction: column !important;
|
||||||
|
|
||||||
.note-split {
|
.note-split {
|
||||||
@ -2638,4 +2639,10 @@ iframe.print-iframe {
|
|||||||
border-top: 1px solid var(--main-border-color);
|
border-top: 1px solid var(--main-border-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#root-widget.virtual-keyboard-opened .note-split:not(:focus-within) {
|
||||||
|
max-height: 80px;
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -19,3 +19,9 @@ export function onWheelHorizontalScroll(event: WheelEvent) {
|
|||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
(event.currentTarget as HTMLElement).scrollLeft += event.deltaY + event.deltaX;
|
(event.currentTarget as HTMLElement).scrollLeft += event.deltaY + event.deltaX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getClosestNtxId(element: HTMLElement) {
|
||||||
|
const closestNtxEl = element.closest<HTMLElement>("[data-ntx-id]");
|
||||||
|
if (!closestNtxEl) return null;
|
||||||
|
return closestNtxEl.dataset.ntxId ?? null;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user