feat(views/table): insert child note

This commit is contained in:
Elian Doran
2025-07-14 13:37:18 +03:00
parent 402540f483
commit c13969217c
3 changed files with 22 additions and 3 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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,