added shortcutMenu properties. see #130
This commit is contained in:
parent
5d72ebb155
commit
d5d967144a
1 changed files with 19 additions and 1 deletions
|
|
@ -19,7 +19,7 @@
|
|||
// Some original methods are derived from https://github.com/ali-raheem/Aify/blob/cfadf52f576b7be3720b5b73af7c8d3129c054da/plugin/html/actions.js
|
||||
|
||||
import { getPrompts } from './mzta-prompts.js';
|
||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay } from './mzta-utils.js'
|
||||
import { getLanguageDisplayName, getMenuContextCompose, getMenuContextDisplay, i18nConditionalGet } from './mzta-utils.js'
|
||||
|
||||
export class mzta_Menus {
|
||||
|
||||
|
|
@ -33,6 +33,10 @@ export class mzta_Menus {
|
|||
//{ id: 'ItemC', act: (info, tab) => { console.log('ItemC', info, tab, info.menuItemId); alert('ItemC') } },
|
||||
];
|
||||
|
||||
shortcutMenu = [
|
||||
//{ id: 'ItemD', label: 'LabelD' },
|
||||
];
|
||||
|
||||
constructor(openChatGPT) {
|
||||
this.menu_context_compose = getMenuContextCompose();
|
||||
this.menu_context_display = getMenuContextDisplay();
|
||||
|
|
@ -45,6 +49,7 @@ export class mzta_Menus {
|
|||
async initialize() {
|
||||
this.allPrompts = [];
|
||||
this.rootMenu = [];
|
||||
this.shortcutMenu = [];
|
||||
this.menu_listeners = {};
|
||||
this.allPrompts = await getPrompts(true);
|
||||
this.allPrompts.sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
|
@ -140,10 +145,23 @@ export class mzta_Menus {
|
|||
}
|
||||
}
|
||||
|
||||
loadShortcutMenu() {
|
||||
this.shortcutMenu = [];
|
||||
this.allPrompts.forEach((prompt) => {
|
||||
this.addShortcutMenu(prompt);
|
||||
});
|
||||
}
|
||||
|
||||
addShortcutMenu(prompt) {
|
||||
let curr_menu_entry = {id: prompt.id, label: i18nConditionalGet(prompt.name), type: prompt.type};
|
||||
this.shortcutMenu.push(curr_menu_entry);
|
||||
}
|
||||
|
||||
async loadMenus() {
|
||||
await this.initialize();
|
||||
await this.addMenu(this.rootMenu);
|
||||
this.addClickListener();
|
||||
this.loadShortcutMenu();
|
||||
}
|
||||
|
||||
listener(info, tab) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue