feat: warn when Better Notes is not installed
CI / build (push) Successful in 23s
Release / build (push) Successful in 1m18s
Release / update-rolling-release (push) Successful in 8s
Release / publish-release (push) Successful in 8s

Add isBetterNotesInstalled() helper and surface a warning notification
on startup plus clear errors during export stating Better Notes is a
requirement. Bump version to 1.0.3.
This commit is contained in:
Ignacio Ballesteros
2026-09-29 17:55:36 +02:00
parent 2366db009b
commit 8d842f2a80
7 changed files with 32 additions and 9 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
{ {
"name": "zotero-org-export-annotations", "name": "zotero-org-export-annotations",
"version": "1.0.2", "version": "1.0.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "zotero-org-export-annotations", "name": "zotero-org-export-annotations",
"version": "1.0.2", "version": "1.0.3",
"license": "GPL-3.0-or-later", "license": "GPL-3.0-or-later",
"devDependencies": { "devDependencies": {
"@types/node": "^20.11.0", "@types/node": "^20.11.0",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "zotero-org-export-annotations", "name": "zotero-org-export-annotations",
"version": "1.0.2", "version": "1.0.3",
"description": "Export Zotero PDF/EPUB annotations to Org-mode files for Emacs integration", "description": "Export Zotero PDF/EPUB annotations to Org-mode files for Emacs integration",
"config": { "config": {
"addonName": "Zotero Org Export Annotations", "addonName": "Zotero Org Export Annotations",
+4
View File
@@ -31,6 +31,10 @@ export class OrgExportAnnotationsAddon {
this.log(`Initialized version ${this.version}`); this.log(`Initialized version ${this.version}`);
} }
isBetterNotesInstalled(): boolean {
return Boolean(Zotero.BetterNotes?.api?.convert?.note2md);
}
log(message: string, ...args: unknown[]): void { log(message: string, ...args: unknown[]): void {
if (this.data.env === "development" || this.prefs?.debug) { if (this.data.env === "development" || this.prefs?.debug) {
Zotero.debug(`[OrgExportAnnotations] ${message}`, false); Zotero.debug(`[OrgExportAnnotations] ${message}`, false);
+12 -4
View File
@@ -12,14 +12,22 @@ export interface Hooks {
onMenuExportSelected(): Promise<void>; onMenuExportSelected(): Promise<void>;
} }
function showNotification(message: string): void { function showNotification(message: string, headline = "Org Export"): void {
const pw = new Zotero.ProgressWindow({ closeOnClick: true }); const pw = new Zotero.ProgressWindow({ closeOnClick: true });
pw.changeHeadline("Org Export"); pw.changeHeadline(headline);
pw.addDescription(message); pw.addDescription(message);
pw.show(); pw.show();
pw.startCloseTimer(4000); pw.startCloseTimer(4000);
} }
function warnBetterNotesRequired(addon: OrgExportAnnotationsAddon): void {
const message =
"Better Notes plugin is required for Org export.\n" +
"Please install it from: https://github.com/windingwind/zotero-better-notes";
addon.warn(message);
showNotification(message, "Org Export - Missing Requirement");
}
export function createHooks(addon: OrgExportAnnotationsAddon): Hooks { export function createHooks(addon: OrgExportAnnotationsAddon): Hooks {
let notifierIDs: string[] = []; let notifierIDs: string[] = [];
@@ -35,8 +43,8 @@ export function createHooks(addon: OrgExportAnnotationsAddon): Hooks {
Zotero.uiReadyPromise, Zotero.uiReadyPromise,
]); ]);
if (!Zotero.BetterNotes) { if (!addon.isBetterNotesInstalled()) {
addon.warn("Better Notes plugin not found - some features may not work"); warnBetterNotesRequired(addon);
} }
Zotero.PreferencePanes.register({ Zotero.PreferencePanes.register({
+1
View File
@@ -9,6 +9,7 @@ Zotero.OrgExportAnnotations = {
log: addon.log.bind(addon), log: addon.log.bind(addon),
error: addon.error.bind(addon), error: addon.error.bind(addon),
warn: addon.warn.bind(addon), warn: addon.warn.bind(addon),
isBetterNotesInstalled: addon.isBetterNotesInstalled.bind(addon),
get id() { get id() {
return addon.id; return addon.id;
}, },
+7
View File
@@ -9,6 +9,13 @@ export async function convertToOrg(
const mdPath = PathUtils.join(notesPath, `${citationKey}.md`); const mdPath = PathUtils.join(notesPath, `${citationKey}.md`);
try { try {
if (!Zotero.OrgExportAnnotations.isBetterNotesInstalled()) {
throw new Error(
"Better Notes plugin is required for Org export. " +
"Please install it from: https://github.com/windingwind/zotero-better-notes"
);
}
const mdContent = await Zotero.BetterNotes!.api.convert.note2md(note, notesPath); const mdContent = await Zotero.BetterNotes!.api.convert.note2md(note, notesPath);
await Zotero.File.putContentsAsync(mdPath, mdContent); await Zotero.File.putContentsAsync(mdPath, mdContent);
+5 -2
View File
@@ -143,8 +143,11 @@ export class OrgExporter {
throw new Error("Notes path is not configured"); throw new Error("Notes path is not configured");
} }
if (!Zotero.BetterNotes?.api?.convert?.note2md) { if (!Zotero.OrgExportAnnotations.isBetterNotesInstalled()) {
throw new Error("Better Notes plugin is required but not found"); throw new Error(
"Better Notes plugin is required for Org export. " +
"Please install it from: https://github.com/windingwind/zotero-better-notes"
);
} }
await this.prefs.ensureNotesDirectory(); await this.prefs.ensureNotesDirectory();