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
No known key found for this signature in database
3 changed files with 22 additions and 3 deletions

View File

@ -1952,7 +1952,8 @@
"hide-column": "Hide column \"{{title}}\"", "hide-column": "Hide column \"{{title}}\"",
"show-hide-columns": "Show/hide columns", "show-hide-columns": "Show/hide columns",
"row-insert-above": "Insert row above", "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": { "book_properties_config": {
"hide-weekends": "Hide weekends", "hide-weekends": "Hide weekends",

View File

@ -5,6 +5,7 @@ import branches from "../../../services/branches.js";
import { t } from "../../../services/i18n.js"; import { t } from "../../../services/i18n.js";
import link_context_menu from "../../../menus/link_context_menu.js"; import link_context_menu from "../../../menus/link_context_menu.js";
import type FNote from "../../../entities/fnote.js"; import type FNote from "../../../entities/fnote.js";
import froca from "../../../services/froca.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));
@ -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"), title: t("table_view.row-insert-below"),
uiIcon: "bx bx-empty", uiIcon: "bx bx-empty",

View File

@ -229,8 +229,8 @@ export default class TableView extends ViewMode<StateInfo> {
console.log("Save attributes", this.newAttribute); console.log("Save attributes", this.newAttribute);
} }
addNewRowCommand({ customOpts }: { customOpts: CreateNoteOpts }) { addNewRowCommand({ customOpts, parentNotePath: customNotePath }: { customOpts: CreateNoteOpts, parentNotePath?: string }) {
const parentNotePath = this.args.parentNotePath; const parentNotePath = customNotePath ?? this.args.parentNotePath;
if (parentNotePath) { if (parentNotePath) {
const opts: CreateNoteOpts = { const opts: CreateNoteOpts = {
activate: false, activate: false,