From cf31367acdd62f732b762eb12756f8e1368fdc29 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Mon, 14 Jul 2025 20:42:37 +0300 Subject: [PATCH] feat(views/table): insert column to the right --- apps/client/src/components/app_context.ts | 5 +++++ .../widgets/view_widgets/table_view/context_menu.ts | 10 ++++++++++ .../src/widgets/view_widgets/table_view/index.ts | 6 +++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.ts index bbd124864..22dba15b3 100644 --- a/apps/client/src/components/app_context.ts +++ b/apps/client/src/components/app_context.ts @@ -29,6 +29,7 @@ import type { CKTextEditor } from "@triliumnext/ckeditor5"; import type CodeMirror from "@triliumnext/codemirror"; import { StartupChecks } from "./startup_checks.js"; import type { CreateNoteOpts } from "../services/note_create.js"; +import { ColumnComponent } from "tabulator-tables"; interface Layout { getRootWidget: (appContext: AppContext) => RootWidget; @@ -282,6 +283,10 @@ export type CommandMappings = { customOpts: CreateNoteOpts; parentNotePath?: string; }; + addNoteListItem: CommandData & { + referenceColumn?: ColumnComponent; + direction?: "before" | "after"; + }; buildTouchBar: CommandData & { TouchBar: typeof TouchBar; diff --git a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts index 005d76fc4..ffee1cc8b 100644 --- a/apps/client/src/widgets/view_widgets/table_view/context_menu.ts +++ b/apps/client/src/widgets/view_widgets/table_view/context_menu.ts @@ -87,6 +87,16 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator: }); console.log("Add col"); } + }, + { + title: "Add column to the right", + handler: () => { + getParentComponent(e)?.triggerCommand("addNoteListItem", { + referenceColumn: column, + direction: "after" + }); + console.log("Add col after"); + } } ], selectMenuItemHandler() {}, diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 5236f5621..c6881c1fa 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -234,7 +234,7 @@ export default class TableView extends ViewMode { console.log("Save attributes", this.newAttribute); } - addNoteListItemEvent({ referenceColumn }: { referenceColumn?: ColumnComponent }) { + addNoteListItemEvent({ referenceColumn, direction }: EventData<"addNoteListItem">) { const attr: Attribute = { type: "label", name: "label:myLabel", @@ -243,6 +243,10 @@ export default class TableView extends ViewMode { if (referenceColumn && this.api) { this.newAttributePosition = this.api.getColumns().indexOf(referenceColumn); + + if (direction === "after") { + this.newAttributePosition++; + } } else { this.newAttributePosition = undefined; }