Add conditional menu items and disable sticky notes at root

This commit is contained in:
Idrees Hassan
2025-11-14 00:28:14 -05:00
parent 7639c7c36a
commit 1175c40fa2
11 changed files with 144 additions and 58 deletions

39
dist/birb.js vendored
View File

@@ -1148,6 +1148,11 @@
return path === this.getPath(); return path === this.getPath();
} }
/** @override */
areStickyNotesEnabled() {
return this.getPath() !== ROOT_PATH;
}
/** @returns {HTMLElement|null} */ /** @returns {HTMLElement|null} */
getActiveEditorElement() { getActiveEditorElement() {
// @ts-expect-error // @ts-expect-error
@@ -1313,6 +1318,9 @@
* @param {(note: StickyNote) => void} onDelete * @param {(note: StickyNote) => void} onDelete
*/ */
function createNewStickyNote(stickyNotes, onSave, onDelete) { function createNewStickyNote(stickyNotes, onSave, onDelete) {
if (getContext().areStickyNotesEnabled() === false) {
return;
}
const id = Date.now().toString(); const id = Date.now().toString();
const site = getContext().getPath(); const site = getContext().getPath();
const stickyNote = new StickyNote(id, site, ""); const stickyNote = new StickyNote(id, site, "");
@@ -1334,23 +1342,34 @@
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
* @param {boolean} [removeMenu] * @param {boolean} [removeMenu]
* @param {boolean} [isDebug]
*/ */
constructor(text, action, removeMenu = true, isDebug = false) { constructor(text, action, removeMenu = true) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.removeMenu = removeMenu; this.removeMenu = removeMenu;
this.isDebug = isDebug;
} }
} }
class DebugMenuItem extends MenuItem { class ConditionalMenuItem extends MenuItem {
/**
* @param {string} text
* @param {() => void} action
* @param {() => boolean} condition
* @param {boolean} [removeMenu]
*/
constructor(text, action, condition, removeMenu = true) {
super(text, action, removeMenu);
this.condition = condition;
}
}
class DebugMenuItem extends ConditionalMenuItem {
/** /**
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
*/ */
constructor(text, action, removeMenu = true) { constructor(text, action, removeMenu = true) {
super(text, action, removeMenu, true); super(text, action, () => isDebug(), removeMenu);
} }
} }
@@ -1396,7 +1415,7 @@
let content = makeElement("birb-window-content"); let content = makeElement("birb-window-content");
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1453,7 +1472,7 @@
} }
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1955,9 +1974,7 @@
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
...(getContext().areStickyNotesEnabled() ? [ new ConditionalMenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote), () => getContext().areStickyNotesEnabled()),
new MenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote))
] : []),
new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)), new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)),
new DebugMenuItem("Freeze/Unfreeze", () => { new DebugMenuItem("Freeze/Unfreeze", () => {
frozen = !frozen; frozen = !frozen;
@@ -1994,7 +2011,7 @@
insertModal(`${birdBirb()} Mode`, message); insertModal(`${birdBirb()} Mode`, message);
}), }),
new Separator(), new Separator(),
new MenuItem("2025.11.14.16", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.16"); }, false), new MenuItem("2025.11.14.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.47"); }, false),
]; ];
const styleElement = document.createElement("style"); const styleElement = document.createElement("style");

BIN
dist/extension.zip vendored

Binary file not shown.

View File

@@ -1148,6 +1148,11 @@
return path === this.getPath(); return path === this.getPath();
} }
/** @override */
areStickyNotesEnabled() {
return this.getPath() !== ROOT_PATH;
}
/** @returns {HTMLElement|null} */ /** @returns {HTMLElement|null} */
getActiveEditorElement() { getActiveEditorElement() {
// @ts-expect-error // @ts-expect-error
@@ -1313,6 +1318,9 @@
* @param {(note: StickyNote) => void} onDelete * @param {(note: StickyNote) => void} onDelete
*/ */
function createNewStickyNote(stickyNotes, onSave, onDelete) { function createNewStickyNote(stickyNotes, onSave, onDelete) {
if (getContext().areStickyNotesEnabled() === false) {
return;
}
const id = Date.now().toString(); const id = Date.now().toString();
const site = getContext().getPath(); const site = getContext().getPath();
const stickyNote = new StickyNote(id, site, ""); const stickyNote = new StickyNote(id, site, "");
@@ -1334,23 +1342,34 @@
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
* @param {boolean} [removeMenu] * @param {boolean} [removeMenu]
* @param {boolean} [isDebug]
*/ */
constructor(text, action, removeMenu = true, isDebug = false) { constructor(text, action, removeMenu = true) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.removeMenu = removeMenu; this.removeMenu = removeMenu;
this.isDebug = isDebug;
} }
} }
class DebugMenuItem extends MenuItem { class ConditionalMenuItem extends MenuItem {
/**
* @param {string} text
* @param {() => void} action
* @param {() => boolean} condition
* @param {boolean} [removeMenu]
*/
constructor(text, action, condition, removeMenu = true) {
super(text, action, removeMenu);
this.condition = condition;
}
}
class DebugMenuItem extends ConditionalMenuItem {
/** /**
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
*/ */
constructor(text, action, removeMenu = true) { constructor(text, action, removeMenu = true) {
super(text, action, removeMenu, true); super(text, action, () => isDebug(), removeMenu);
} }
} }
@@ -1396,7 +1415,7 @@
let content = makeElement("birb-window-content"); let content = makeElement("birb-window-content");
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1453,7 +1472,7 @@
} }
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1955,9 +1974,7 @@
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
...(getContext().areStickyNotesEnabled() ? [ new ConditionalMenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote), () => getContext().areStickyNotesEnabled()),
new MenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote))
] : []),
new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)), new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)),
new DebugMenuItem("Freeze/Unfreeze", () => { new DebugMenuItem("Freeze/Unfreeze", () => {
frozen = !frozen; frozen = !frozen;
@@ -1994,7 +2011,7 @@
insertModal(`${birdBirb()} Mode`, message); insertModal(`${birdBirb()} Mode`, message);
}), }),
new Separator(), new Separator(),
new MenuItem("2025.11.14.16", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.16"); }, false), new MenuItem("2025.11.14.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.47"); }, false),
]; ];
const styleElement = document.createElement("style"); const styleElement = document.createElement("style");

View File

@@ -2,7 +2,7 @@
"manifest_version": 3, "manifest_version": 3,
"name": "Pocket Bird", "name": "Pocket Bird",
"description": "It's a pet bird in your browser, what more could you want?", "description": "It's a pet bird in your browser, what more could you want?",
"version": "2025.11.14.16", "version": "2025.11.14.47",
"homepage_url": "https://idreesinc.com", "homepage_url": "https://idreesinc.com",
"icons": { "icons": {
"48": "images/icons/transparent/48x48x1.png", "48": "images/icons/transparent/48x48x1.png",

41
dist/obsidian/main.js vendored
View File

@@ -2,7 +2,7 @@
const { Plugin, Notice } = require('obsidian'); const { Plugin, Notice } = require('obsidian');
module.exports = class PocketBird extends Plugin { module.exports = class PocketBird extends Plugin {
onload() { onload() {
console.log("Loading Pocket Bird version 2025.11.14.16..."); console.log("Loading Pocket Bird version 2025.11.14.47...");
const OBSIDIAN_PLUGIN = this; const OBSIDIAN_PLUGIN = this;
(function () { (function () {
'use strict'; 'use strict';
@@ -1154,6 +1154,11 @@ module.exports = class PocketBird extends Plugin {
return path === this.getPath(); return path === this.getPath();
} }
/** @override */
areStickyNotesEnabled() {
return this.getPath() !== ROOT_PATH;
}
/** @returns {HTMLElement|null} */ /** @returns {HTMLElement|null} */
getActiveEditorElement() { getActiveEditorElement() {
// @ts-expect-error // @ts-expect-error
@@ -1319,6 +1324,9 @@ module.exports = class PocketBird extends Plugin {
* @param {(note: StickyNote) => void} onDelete * @param {(note: StickyNote) => void} onDelete
*/ */
function createNewStickyNote(stickyNotes, onSave, onDelete) { function createNewStickyNote(stickyNotes, onSave, onDelete) {
if (getContext().areStickyNotesEnabled() === false) {
return;
}
const id = Date.now().toString(); const id = Date.now().toString();
const site = getContext().getPath(); const site = getContext().getPath();
const stickyNote = new StickyNote(id, site, ""); const stickyNote = new StickyNote(id, site, "");
@@ -1340,23 +1348,34 @@ module.exports = class PocketBird extends Plugin {
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
* @param {boolean} [removeMenu] * @param {boolean} [removeMenu]
* @param {boolean} [isDebug]
*/ */
constructor(text, action, removeMenu = true, isDebug = false) { constructor(text, action, removeMenu = true) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.removeMenu = removeMenu; this.removeMenu = removeMenu;
this.isDebug = isDebug;
} }
} }
class DebugMenuItem extends MenuItem { class ConditionalMenuItem extends MenuItem {
/**
* @param {string} text
* @param {() => void} action
* @param {() => boolean} condition
* @param {boolean} [removeMenu]
*/
constructor(text, action, condition, removeMenu = true) {
super(text, action, removeMenu);
this.condition = condition;
}
}
class DebugMenuItem extends ConditionalMenuItem {
/** /**
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
*/ */
constructor(text, action, removeMenu = true) { constructor(text, action, removeMenu = true) {
super(text, action, removeMenu, true); super(text, action, () => isDebug(), removeMenu);
} }
} }
@@ -1402,7 +1421,7 @@ module.exports = class PocketBird extends Plugin {
let content = makeElement("birb-window-content"); let content = makeElement("birb-window-content");
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1459,7 +1478,7 @@ module.exports = class PocketBird extends Plugin {
} }
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1961,9 +1980,7 @@ module.exports = class PocketBird extends Plugin {
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
...(getContext().areStickyNotesEnabled() ? [ new ConditionalMenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote), () => getContext().areStickyNotesEnabled()),
new MenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote))
] : []),
new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)), new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)),
new DebugMenuItem("Freeze/Unfreeze", () => { new DebugMenuItem("Freeze/Unfreeze", () => {
frozen = !frozen; frozen = !frozen;
@@ -2000,7 +2017,7 @@ module.exports = class PocketBird extends Plugin {
insertModal(`${birdBirb()} Mode`, message); insertModal(`${birdBirb()} Mode`, message);
}), }),
new Separator(), new Separator(),
new MenuItem("2025.11.14.16", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.16"); }, false), new MenuItem("2025.11.14.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.47"); }, false),
]; ];
const styleElement = document.createElement("style"); const styleElement = document.createElement("style");

View File

@@ -1,7 +1,7 @@
{ {
"id": "pocket-bird", "id": "pocket-bird",
"name": "Pocket Bird", "name": "Pocket Bird",
"version": "2025.11.14.16", "version": "2025.11.14.47",
"minAppVersion": "0.15.0", "minAppVersion": "0.15.0",
"description": "It's a pet bird in your Obsidian, what more could you want?", "description": "It's a pet bird in your Obsidian, what more could you want?",
"author": "Idrees Hassan", "author": "Idrees Hassan",

View File

@@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Pocket Bird // @name Pocket Bird
// @namespace https://idreesinc.com // @namespace https://idreesinc.com
// @version 2025.11.14.16 // @version 2025.11.14.47
// @description It's a bird that hops around your web browser, the future is here // @description It's a bird that hops around your web browser, the future is here
// @author Idrees // @author Idrees
// @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js // @downloadURL https://github.com/IdreesInc/Pocket-Bird/raw/refs/heads/main/dist/userscript/birb.user.js
@@ -1162,6 +1162,11 @@
return path === this.getPath(); return path === this.getPath();
} }
/** @override */
areStickyNotesEnabled() {
return this.getPath() !== ROOT_PATH;
}
/** @returns {HTMLElement|null} */ /** @returns {HTMLElement|null} */
getActiveEditorElement() { getActiveEditorElement() {
// @ts-expect-error // @ts-expect-error
@@ -1327,6 +1332,9 @@
* @param {(note: StickyNote) => void} onDelete * @param {(note: StickyNote) => void} onDelete
*/ */
function createNewStickyNote(stickyNotes, onSave, onDelete) { function createNewStickyNote(stickyNotes, onSave, onDelete) {
if (getContext().areStickyNotesEnabled() === false) {
return;
}
const id = Date.now().toString(); const id = Date.now().toString();
const site = getContext().getPath(); const site = getContext().getPath();
const stickyNote = new StickyNote(id, site, ""); const stickyNote = new StickyNote(id, site, "");
@@ -1348,23 +1356,34 @@
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
* @param {boolean} [removeMenu] * @param {boolean} [removeMenu]
* @param {boolean} [isDebug]
*/ */
constructor(text, action, removeMenu = true, isDebug = false) { constructor(text, action, removeMenu = true) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.removeMenu = removeMenu; this.removeMenu = removeMenu;
this.isDebug = isDebug;
} }
} }
class DebugMenuItem extends MenuItem { class ConditionalMenuItem extends MenuItem {
/**
* @param {string} text
* @param {() => void} action
* @param {() => boolean} condition
* @param {boolean} [removeMenu]
*/
constructor(text, action, condition, removeMenu = true) {
super(text, action, removeMenu);
this.condition = condition;
}
}
class DebugMenuItem extends ConditionalMenuItem {
/** /**
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
*/ */
constructor(text, action, removeMenu = true) { constructor(text, action, removeMenu = true) {
super(text, action, removeMenu, true); super(text, action, () => isDebug(), removeMenu);
} }
} }
@@ -1410,7 +1429,7 @@
let content = makeElement("birb-window-content"); let content = makeElement("birb-window-content");
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1467,7 +1486,7 @@
} }
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -1969,9 +1988,7 @@
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
...(getContext().areStickyNotesEnabled() ? [ new ConditionalMenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote), () => getContext().areStickyNotesEnabled()),
new MenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote))
] : []),
new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)), new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)),
new DebugMenuItem("Freeze/Unfreeze", () => { new DebugMenuItem("Freeze/Unfreeze", () => {
frozen = !frozen; frozen = !frozen;
@@ -2008,7 +2025,7 @@
insertModal(`${birdBirb()} Mode`, message); insertModal(`${birdBirb()} Mode`, message);
}), }),
new Separator(), new Separator(),
new MenuItem("2025.11.14.16", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.16"); }, false), new MenuItem("2025.11.14.47", () => { alert("Thank you for using Pocket Bird! You are on version: 2025.11.14.47"); }, false),
]; ];
const styleElement = document.createElement("style"); const styleElement = document.createElement("style");

View File

@@ -31,6 +31,7 @@ import {
} from './stickyNotes.js'; } from './stickyNotes.js';
import { import {
MenuItem, MenuItem,
ConditionalMenuItem,
DebugMenuItem, DebugMenuItem,
Separator, Separator,
insertMenu, insertMenu,
@@ -193,9 +194,7 @@ Promise.all([
const menuItems = [ const menuItems = [
new MenuItem(`Pet ${birdBirb()}`, pet), new MenuItem(`Pet ${birdBirb()}`, pet),
new MenuItem("Field Guide", insertFieldGuide), new MenuItem("Field Guide", insertFieldGuide),
...(getContext().areStickyNotesEnabled() ? [ new ConditionalMenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote), () => getContext().areStickyNotesEnabled()),
new MenuItem("Sticky Note", () => createNewStickyNote(stickyNotes, save, deleteStickyNote))
] : []),
new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)), new MenuItem(`Hide ${birdBirb()}`, () => birb.setVisible(false)),
new DebugMenuItem("Freeze/Unfreeze", () => { new DebugMenuItem("Freeze/Unfreeze", () => {
frozen = !frozen; frozen = !frozen;

View File

@@ -305,6 +305,11 @@ export class ObsidianContext extends Context {
return path === this.getPath(); return path === this.getPath();
} }
/** @override */
areStickyNotesEnabled() {
return this.getPath() !== ROOT_PATH;
}
/** @returns {HTMLElement|null} */ /** @returns {HTMLElement|null} */
getActiveEditorElement() { getActiveEditorElement() {
// @ts-expect-error // @ts-expect-error

View File

@@ -15,23 +15,34 @@ export class MenuItem {
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
* @param {boolean} [removeMenu] * @param {boolean} [removeMenu]
* @param {boolean} [isDebug]
*/ */
constructor(text, action, removeMenu = true, isDebug = false) { constructor(text, action, removeMenu = true) {
this.text = text; this.text = text;
this.action = action; this.action = action;
this.removeMenu = removeMenu; this.removeMenu = removeMenu;
this.isDebug = isDebug;
} }
} }
export class DebugMenuItem extends MenuItem { export class ConditionalMenuItem extends MenuItem {
/**
* @param {string} text
* @param {() => void} action
* @param {() => boolean} condition
* @param {boolean} [removeMenu]
*/
constructor(text, action, condition, removeMenu = true) {
super(text, action, removeMenu);
this.condition = condition;
}
}
export class DebugMenuItem extends ConditionalMenuItem {
/** /**
* @param {string} text * @param {string} text
* @param {() => void} action * @param {() => void} action
*/ */
constructor(text, action, removeMenu = true) { constructor(text, action, removeMenu = true) {
super(text, action, removeMenu, true); super(text, action, () => isDebug(), removeMenu);
} }
} }
@@ -77,7 +88,7 @@ export function insertMenu(menuItems, title, updateLocationCallback) {
let content = makeElement("birb-window-content"); let content = makeElement("birb-window-content");
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }
@@ -134,7 +145,7 @@ export function switchMenuItems(menuItems, updateLocationCallback) {
} }
const removeCallback = () => removeMenu(); const removeCallback = () => removeMenu();
for (const item of menuItems) { for (const item of menuItems) {
if (!item.isDebug || isDebug()) { if (!(item instanceof ConditionalMenuItem) || item.condition()) {
content.appendChild(makeMenuItem(item, removeCallback)); content.appendChild(makeMenuItem(item, removeCallback));
} }
} }

View File

@@ -129,6 +129,9 @@ export function drawStickyNotes(stickyNotes, onSave, onDelete) {
* @param {(note: StickyNote) => void} onDelete * @param {(note: StickyNote) => void} onDelete
*/ */
export function createNewStickyNote(stickyNotes, onSave, onDelete) { export function createNewStickyNote(stickyNotes, onSave, onDelete) {
if (getContext().areStickyNotesEnabled() === false) {
return;
}
const id = Date.now().toString(); const id = Date.now().toString();
const site = getContext().getPath(); const site = getContext().getPath();
const stickyNote = new StickyNote(id, site, ""); const stickyNote = new StickyNote(id, site, "");