mirror of
https://github.com/zadam/trilium.git
synced 2025-10-29 10:39:00 +01:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type { EventData } from "../../components/app_context.js";
|
|
import { t } from "../../services/i18n.js";
|
|
import OnClickButtonWidget from "./onclick_button.js";
|
|
|
|
export default class ClosePaneButton extends OnClickButtonWidget {
|
|
isEnabled() {
|
|
return (
|
|
super.isEnabled() &&
|
|
// main note context should not be closeable
|
|
this.noteContext &&
|
|
!!this.noteContext.mainNtxId
|
|
);
|
|
}
|
|
|
|
async noteContextReorderEvent({ ntxIdsInOrder }: EventData<"noteContextReorder">) {
|
|
this.refresh();
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
|
|
this.icon("bx-x")
|
|
.title(t("close_pane_button.close_this_pane"))
|
|
.titlePlacement("bottom")
|
|
.onClick((widget, e) => {
|
|
// to avoid split pane container detecting click within the pane which would try to activate this
|
|
// pane (which is being removed)
|
|
e.stopPropagation();
|
|
|
|
widget.triggerCommand("closeThisNoteSplit", { ntxId: widget.getClosestNtxId() });
|
|
})
|
|
.class("icon-action");
|
|
}
|
|
}
|