mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 10:15:52 +01:00
feat(views/board): add context menu with delete
This commit is contained in:
@@ -1968,5 +1968,8 @@
|
|||||||
},
|
},
|
||||||
"table_context_menu": {
|
"table_context_menu": {
|
||||||
"delete_row": "Delete row"
|
"delete_row": "Delete row"
|
||||||
|
},
|
||||||
|
"board_view": {
|
||||||
|
"delete-note": "Delete Note"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
import contextMenu from "../../../menus/context_menu.js";
|
||||||
|
import branches from "../../../services/branches.js";
|
||||||
|
import { t } from "../../../services/i18n.js";
|
||||||
|
|
||||||
|
export function showNoteContextMenu($container: JQuery<HTMLElement>) {
|
||||||
|
$container.on("contextmenu", ".board-note", (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
const $el = $(event.currentTarget);
|
||||||
|
const noteId = $el.data("note-id");
|
||||||
|
const branchId = $el.data("branch-id");
|
||||||
|
if (!noteId) return;
|
||||||
|
|
||||||
|
contextMenu.show({
|
||||||
|
x: event.pageX,
|
||||||
|
y: event.pageY,
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
title: t("board_view.delete-note"),
|
||||||
|
uiIcon: "bx bx-trash",
|
||||||
|
handler: () => branches.deleteNotes([ branchId ], false, false)
|
||||||
|
}
|
||||||
|
],
|
||||||
|
selectMenuItemHandler: () => {}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import noteCreateService from "../../../services/note_create";
|
|||||||
import appContext, { EventData } from "../../../components/app_context";
|
import appContext, { EventData } from "../../../components/app_context";
|
||||||
import { BoardData } from "./config";
|
import { BoardData } from "./config";
|
||||||
import SpacedUpdate from "../../../services/spaced_update";
|
import SpacedUpdate from "../../../services/spaced_update";
|
||||||
|
import { showNoteContextMenu } from "./context_menu";
|
||||||
|
|
||||||
const TPL = /*html*/`
|
const TPL = /*html*/`
|
||||||
<div class="board-view">
|
<div class="board-view">
|
||||||
@@ -133,6 +134,7 @@ export default class BoardView extends ViewMode<BoardData> {
|
|||||||
this.$root = $(TPL);
|
this.$root = $(TPL);
|
||||||
setupHorizontalScrollViaWheel(this.$root);
|
setupHorizontalScrollViaWheel(this.$root);
|
||||||
this.$container = this.$root.find(".board-view-container");
|
this.$container = this.$root.find(".board-view-container");
|
||||||
|
showNoteContextMenu(this.$container);
|
||||||
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
||||||
this.persistentData = {
|
this.persistentData = {
|
||||||
columns: []
|
columns: []
|
||||||
|
|||||||
Reference in New Issue
Block a user