mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
29 lines
661 B
JavaScript
29 lines
661 B
JavaScript
class ContextMenuItemsContainer {
|
|
constructor(items) {
|
|
// clone the item array and the items themselves
|
|
this.items = items.map(item => Object.assign({}, item));
|
|
}
|
|
|
|
hideItem(cmd, hidden = true) {
|
|
if (hidden) {
|
|
this.items = this.items.filter(item => item.cmd !== cmd);
|
|
}
|
|
}
|
|
|
|
enableItem(cmd, enabled) {
|
|
const item = this.items.find(item => item.cmd === cmd);
|
|
|
|
if (!item) {
|
|
throw new Error(`Command ${cmd} has not been found!`);
|
|
}
|
|
|
|
item.enabled = enabled;
|
|
}
|
|
|
|
getItems() {
|
|
return this.items;
|
|
}
|
|
}
|
|
|
|
export default ContextMenuItemsContainer;
|