mirror of
https://github.com/zadam/trilium.git
synced 2025-11-15 17:55:52 +01:00
feat(views/board): add context menu with delete
This commit is contained in:
@@ -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 { BoardData } from "./config";
|
||||
import SpacedUpdate from "../../../services/spaced_update";
|
||||
import { showNoteContextMenu } from "./context_menu";
|
||||
|
||||
const TPL = /*html*/`
|
||||
<div class="board-view">
|
||||
@@ -133,6 +134,7 @@ export default class BoardView extends ViewMode<BoardData> {
|
||||
this.$root = $(TPL);
|
||||
setupHorizontalScrollViaWheel(this.$root);
|
||||
this.$container = this.$root.find(".board-view-container");
|
||||
showNoteContextMenu(this.$container);
|
||||
this.spacedUpdate = new SpacedUpdate(() => this.onSave(), 5_000);
|
||||
this.persistentData = {
|
||||
columns: []
|
||||
|
||||
Reference in New Issue
Block a user