Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d842f2a80 |
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "zotero-org-export-annotations",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "zotero-org-export-annotations",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"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",
|
||||
"config": {
|
||||
"addonName": "Zotero Org Export Annotations",
|
||||
|
||||
@@ -31,6 +31,10 @@ export class OrgExportAnnotationsAddon {
|
||||
this.log(`Initialized version ${this.version}`);
|
||||
}
|
||||
|
||||
isBetterNotesInstalled(): boolean {
|
||||
return Boolean(Zotero.BetterNotes?.api?.convert?.note2md);
|
||||
}
|
||||
|
||||
log(message: string, ...args: unknown[]): void {
|
||||
if (this.data.env === "development" || this.prefs?.debug) {
|
||||
Zotero.debug(`[OrgExportAnnotations] ${message}`, false);
|
||||
|
||||
+12
-4
@@ -12,14 +12,22 @@ export interface Hooks {
|
||||
onMenuExportSelected(): Promise<void>;
|
||||
}
|
||||
|
||||
function showNotification(message: string): void {
|
||||
function showNotification(message: string, headline = "Org Export"): void {
|
||||
const pw = new Zotero.ProgressWindow({ closeOnClick: true });
|
||||
pw.changeHeadline("Org Export");
|
||||
pw.changeHeadline(headline);
|
||||
pw.addDescription(message);
|
||||
pw.show();
|
||||
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 {
|
||||
let notifierIDs: string[] = [];
|
||||
|
||||
@@ -35,8 +43,8 @@ export function createHooks(addon: OrgExportAnnotationsAddon): Hooks {
|
||||
Zotero.uiReadyPromise,
|
||||
]);
|
||||
|
||||
if (!Zotero.BetterNotes) {
|
||||
addon.warn("Better Notes plugin not found - some features may not work");
|
||||
if (!addon.isBetterNotesInstalled()) {
|
||||
warnBetterNotesRequired(addon);
|
||||
}
|
||||
|
||||
Zotero.PreferencePanes.register({
|
||||
|
||||
@@ -9,6 +9,7 @@ Zotero.OrgExportAnnotations = {
|
||||
log: addon.log.bind(addon),
|
||||
error: addon.error.bind(addon),
|
||||
warn: addon.warn.bind(addon),
|
||||
isBetterNotesInstalled: addon.isBetterNotesInstalled.bind(addon),
|
||||
get id() {
|
||||
return addon.id;
|
||||
},
|
||||
|
||||
@@ -9,6 +9,13 @@ export async function convertToOrg(
|
||||
const mdPath = PathUtils.join(notesPath, `${citationKey}.md`);
|
||||
|
||||
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);
|
||||
await Zotero.File.putContentsAsync(mdPath, mdContent);
|
||||
|
||||
|
||||
@@ -143,8 +143,11 @@ export class OrgExporter {
|
||||
throw new Error("Notes path is not configured");
|
||||
}
|
||||
|
||||
if (!Zotero.BetterNotes?.api?.convert?.note2md) {
|
||||
throw new Error("Better Notes plugin is required but not found");
|
||||
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"
|
||||
);
|
||||
}
|
||||
|
||||
await this.prefs.ensureNotesDirectory();
|
||||
|
||||
Reference in New Issue
Block a user