mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 11:56:01 +01:00
fix(views/table): insert above/below not working in nested trees
This commit is contained in:
@@ -9,7 +9,7 @@ import froca from "../../../services/froca.js";
|
|||||||
import type Component from "../../../components/component.js";
|
import type Component from "../../../components/component.js";
|
||||||
|
|
||||||
export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
|
export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
|
||||||
tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote));
|
tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote, tabulator));
|
||||||
tabulator.on("headerContext", (e, col) => showColumnContextMenu(e, col, tabulator));
|
tabulator.on("headerContext", (e, col) => showColumnContextMenu(e, col, tabulator));
|
||||||
|
|
||||||
// Pressing the expand button prevents bubbling and the context menu remains menu when it shouldn't.
|
// Pressing the expand button prevents bubbling and the context menu remains menu when it shouldn't.
|
||||||
@@ -103,9 +103,19 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: FNote) {
|
export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: FNote, tabulator: Tabulator) {
|
||||||
const e = _e as MouseEvent;
|
const e = _e as MouseEvent;
|
||||||
const rowData = row.getData() as TableData;
|
const rowData = row.getData() as TableData;
|
||||||
|
|
||||||
|
let parentNoteId: string = parentNote.noteId;
|
||||||
|
|
||||||
|
if (tabulator.options.dataTree) {
|
||||||
|
const parentRow = row.getTreeParent();
|
||||||
|
if (parentRow) {
|
||||||
|
parentNoteId = parentRow.getData().noteId as string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contextMenu.show({
|
contextMenu.show({
|
||||||
items: [
|
items: [
|
||||||
...link_context_menu.getItems(),
|
...link_context_menu.getItems(),
|
||||||
@@ -114,6 +124,7 @@ export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: F
|
|||||||
title: t("table_view.row-insert-above"),
|
title: t("table_view.row-insert-above"),
|
||||||
uiIcon: "bx bx-list-plus",
|
uiIcon: "bx bx-list-plus",
|
||||||
handler: () => getParentComponent(e)?.triggerCommand("addNewRow", {
|
handler: () => getParentComponent(e)?.triggerCommand("addNewRow", {
|
||||||
|
parentNotePath: parentNoteId,
|
||||||
customOpts: {
|
customOpts: {
|
||||||
target: "before",
|
target: "before",
|
||||||
targetBranchId: rowData.branchId,
|
targetBranchId: rowData.branchId,
|
||||||
@@ -139,6 +150,7 @@ export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: F
|
|||||||
title: t("table_view.row-insert-below"),
|
title: t("table_view.row-insert-below"),
|
||||||
uiIcon: "bx bx-empty",
|
uiIcon: "bx bx-empty",
|
||||||
handler: () => getParentComponent(e)?.triggerCommand("addNewRow", {
|
handler: () => getParentComponent(e)?.triggerCommand("addNewRow", {
|
||||||
|
parentNotePath: parentNoteId,
|
||||||
customOpts: {
|
customOpts: {
|
||||||
target: "after",
|
target: "after",
|
||||||
targetBranchId: rowData.branchId,
|
targetBranchId: rowData.branchId,
|
||||||
|
|||||||
Reference in New Issue
Block a user