mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
feat(views/table): insert column to the right
This commit is contained in:
@@ -29,6 +29,7 @@ import type { CKTextEditor } from "@triliumnext/ckeditor5";
|
|||||||
import type CodeMirror from "@triliumnext/codemirror";
|
import type CodeMirror from "@triliumnext/codemirror";
|
||||||
import { StartupChecks } from "./startup_checks.js";
|
import { StartupChecks } from "./startup_checks.js";
|
||||||
import type { CreateNoteOpts } from "../services/note_create.js";
|
import type { CreateNoteOpts } from "../services/note_create.js";
|
||||||
|
import { ColumnComponent } from "tabulator-tables";
|
||||||
|
|
||||||
interface Layout {
|
interface Layout {
|
||||||
getRootWidget: (appContext: AppContext) => RootWidget;
|
getRootWidget: (appContext: AppContext) => RootWidget;
|
||||||
@@ -282,6 +283,10 @@ export type CommandMappings = {
|
|||||||
customOpts: CreateNoteOpts;
|
customOpts: CreateNoteOpts;
|
||||||
parentNotePath?: string;
|
parentNotePath?: string;
|
||||||
};
|
};
|
||||||
|
addNoteListItem: CommandData & {
|
||||||
|
referenceColumn?: ColumnComponent;
|
||||||
|
direction?: "before" | "after";
|
||||||
|
};
|
||||||
|
|
||||||
buildTouchBar: CommandData & {
|
buildTouchBar: CommandData & {
|
||||||
TouchBar: typeof TouchBar;
|
TouchBar: typeof TouchBar;
|
||||||
|
|||||||
@@ -87,6 +87,16 @@ function showColumnContextMenu(_e: UIEvent, column: ColumnComponent, tabulator:
|
|||||||
});
|
});
|
||||||
console.log("Add col");
|
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() {},
|
selectMenuItemHandler() {},
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||||||
console.log("Save attributes", this.newAttribute);
|
console.log("Save attributes", this.newAttribute);
|
||||||
}
|
}
|
||||||
|
|
||||||
addNoteListItemEvent({ referenceColumn }: { referenceColumn?: ColumnComponent }) {
|
addNoteListItemEvent({ referenceColumn, direction }: EventData<"addNoteListItem">) {
|
||||||
const attr: Attribute = {
|
const attr: Attribute = {
|
||||||
type: "label",
|
type: "label",
|
||||||
name: "label:myLabel",
|
name: "label:myLabel",
|
||||||
@@ -243,6 +243,10 @@ export default class TableView extends ViewMode<StateInfo> {
|
|||||||
|
|
||||||
if (referenceColumn && this.api) {
|
if (referenceColumn && this.api) {
|
||||||
this.newAttributePosition = this.api.getColumns().indexOf(referenceColumn);
|
this.newAttributePosition = this.api.getColumns().indexOf(referenceColumn);
|
||||||
|
|
||||||
|
if (direction === "after") {
|
||||||
|
this.newAttributePosition++;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.newAttributePosition = undefined;
|
this.newAttributePosition = undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user