Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(views/table): insert column to the right
Elian Dorancf31367acdd6
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.tsindex bbd1248642..22dba15b33 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.tsindex 005d76fc44..ffee1cc8b8 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.tsindex 5236f5621b..c6881c1fa1 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<StateInfo> {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<StateInfo> {if (referenceColumn && this.api) {this.newAttributePosition = this.api.getColumns().indexOf(referenceColumn);++ if (direction === "after") {+ this.newAttributePosition++;+ }} else {this.newAttributePosition = undefined;}