mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-09-20 02:51:40 +08:00
refactor(client/ts): use context_menu in note_type_chooser
This commit is contained in:
parent
5f0ace2886
commit
10f8da8015
@ -1,23 +1,10 @@
|
|||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
import { t } from "./i18n.js";
|
import { t } from "./i18n.js";
|
||||||
|
import { MenuItem } from "../menus/context_menu.js";
|
||||||
interface NoteTypeSeparator {
|
|
||||||
title: "----"
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NoteType {
|
|
||||||
title: string;
|
|
||||||
command?: string;
|
|
||||||
type: string;
|
|
||||||
uiIcon: string;
|
|
||||||
templateNoteId?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
type NoteTypeItem = NoteType | NoteTypeSeparator;
|
|
||||||
|
|
||||||
async function getNoteTypeItems(command?: string) {
|
async function getNoteTypeItems(command?: string) {
|
||||||
const items: NoteTypeItem[] = [
|
const items: MenuItem[] = [
|
||||||
{ title: t("note_types.text"), command: command, type: "text", uiIcon: "bx bx-note" },
|
{ title: t("note_types.text"), command: command, type: "text", uiIcon: "bx bx-note" },
|
||||||
{ title: t("note_types.code"), command: command, type: "code", uiIcon: "bx bx-code" },
|
{ title: t("note_types.code"), command: command, type: "code", uiIcon: "bx bx-code" },
|
||||||
{ title: t("note_types.saved-search"), command: command, type: "search", uiIcon: "bx bx-file-find" },
|
{ title: t("note_types.saved-search"), command: command, type: "search", uiIcon: "bx bx-file-find" },
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
import { MenuCommandItem } from "../../menus/context_menu.js";
|
||||||
import { t } from "../../services/i18n.js";
|
import { t } from "../../services/i18n.js";
|
||||||
import noteTypesService, { NoteType } from "../../services/note_types.js";
|
import noteTypesService from "../../services/note_types.js";
|
||||||
import BasicWidget from "../basic_widget.js";
|
import BasicWidget from "../basic_widget.js";
|
||||||
|
|
||||||
const TPL = `
|
const TPL = `
|
||||||
@ -127,11 +128,12 @@ export default class NoteTypeChooserDialog extends BasicWidget {
|
|||||||
if (noteType.title === '----') {
|
if (noteType.title === '----') {
|
||||||
this.$noteTypeDropdown.append($('<h6 class="dropdown-header">').append(t("note_type_chooser.templates")));
|
this.$noteTypeDropdown.append($('<h6 class="dropdown-header">').append(t("note_type_chooser.templates")));
|
||||||
} else {
|
} else {
|
||||||
|
const commandItem = (noteType as MenuCommandItem)
|
||||||
this.$noteTypeDropdown.append(
|
this.$noteTypeDropdown.append(
|
||||||
$('<a class="dropdown-item" tabindex="0">')
|
$('<a class="dropdown-item" tabindex="0">')
|
||||||
.attr("data-note-type", (noteType as NoteType).type)
|
.attr("data-note-type", commandItem.type)
|
||||||
.attr("data-template-note-id", (noteType as NoteType).templateNoteId || "")
|
.attr("data-template-note-id", commandItem.templateNoteId || "")
|
||||||
.append($("<span>").addClass((noteType as NoteType).uiIcon))
|
.append($("<span>").addClass(commandItem.uiIcon))
|
||||||
.append(` ${noteType.title}`)
|
.append(` ${noteType.title}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user