mirror of
https://github.com/zadam/trilium.git
synced 2025-10-26 07:46:30 +01:00
feat(views/table): insert child note
This commit is contained in:
@@ -1952,7 +1952,8 @@
|
||||
"hide-column": "Hide column \"{{title}}\"",
|
||||
"show-hide-columns": "Show/hide columns",
|
||||
"row-insert-above": "Insert row above",
|
||||
"row-insert-below": "Insert row below"
|
||||
"row-insert-below": "Insert row below",
|
||||
"row-insert-child": "Insert child note"
|
||||
},
|
||||
"book_properties_config": {
|
||||
"hide-weekends": "Hide weekends",
|
||||
|
||||
@@ -5,6 +5,7 @@ import branches from "../../../services/branches.js";
|
||||
import { t } from "../../../services/i18n.js";
|
||||
import link_context_menu from "../../../menus/link_context_menu.js";
|
||||
import type FNote from "../../../entities/fnote.js";
|
||||
import froca from "../../../services/froca.js";
|
||||
|
||||
export function setupContextMenu(tabulator: Tabulator, parentNote: FNote) {
|
||||
tabulator.on("rowContext", (e, row) => showRowContextMenu(e, row, parentNote));
|
||||
@@ -118,6 +119,23 @@ export function showRowContextMenu(_e: UIEvent, row: RowComponent, parentNote: F
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t("table_view.row-insert-child"),
|
||||
uiIcon: "bx bx-empty",
|
||||
handler: async () => {
|
||||
const branchId = row.getData().branchId;
|
||||
const note = await froca.getBranch(branchId)?.getNote();
|
||||
const bestNotePath = note?.getBestNotePath(parentNote.noteId);
|
||||
const target = e.target;
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
const component = $(target).closest(".component").prop("component");
|
||||
component.triggerCommand("addNewRow", {
|
||||
parentNotePath: bestNotePath?.join("/")
|
||||
});
|
||||
}
|
||||
},
|
||||
{
|
||||
title: t("table_view.row-insert-below"),
|
||||
uiIcon: "bx bx-empty",
|
||||
|
||||
@@ -229,8 +229,8 @@ export default class TableView extends ViewMode<StateInfo> {
|
||||
console.log("Save attributes", this.newAttribute);
|
||||
}
|
||||
|
||||
addNewRowCommand({ customOpts }: { customOpts: CreateNoteOpts }) {
|
||||
const parentNotePath = this.args.parentNotePath;
|
||||
addNewRowCommand({ customOpts, parentNotePath: customNotePath }: { customOpts: CreateNoteOpts, parentNotePath?: string }) {
|
||||
const parentNotePath = customNotePath ?? this.args.parentNotePath;
|
||||
if (parentNotePath) {
|
||||
const opts: CreateNoteOpts = {
|
||||
activate: false,
|
||||
|
||||
Reference in New Issue
Block a user