fix(build): type definitions for context menu

This commit is contained in:
Elian Doran 2025-02-24 21:35:35 +02:00
parent 7874e88b4a
commit 23d01ec351
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -18,7 +18,9 @@ interface ConvertToAttachmentResponse {
attachment?: FAttachment;
}
type TreeCommandNames = FilteredCommandNames<ContextMenuCommandData>;
// This will include all commands that implement ContextMenuCommandData, but it will not work if it additional options are added via the `|` operator,
// so they need to be added manually.
export type TreeCommandNames = FilteredCommandNames<ContextMenuCommandData> | "openBulkActionsDialog";
export default class TreeContextMenu implements SelectMenuItemEventListener<TreeCommandNames> {
private treeWidget: NoteTreeWidget;

View File

@ -2,12 +2,10 @@ import server from "./server.js";
import froca from "./froca.js";
import { t } from "./i18n.js";
import type { MenuItem } from "../menus/context_menu.js";
import type { ContextMenuCommandData, FilteredCommandNames } from "../components/app_context.js";
import type { TreeCommandNames } from "../menus/tree_context_menu.js";
type NoteTypeCommandNames = FilteredCommandNames<ContextMenuCommandData>;
async function getNoteTypeItems(command?: NoteTypeCommandNames) {
const items: MenuItem<NoteTypeCommandNames>[] = [
async function getNoteTypeItems(command?: TreeCommandNames) {
const items: MenuItem<TreeCommandNames>[] = [
{ title: t("note_types.text"), command, type: "text", uiIcon: "bx bx-note" },
{ title: t("note_types.code"), command, type: "code", uiIcon: "bx bx-code" },
{ title: t("note_types.saved-search"), command, type: "search", uiIcon: "bx bx-file-find" },