chore: initial project commit
This commit is contained in:
76
addon/content/scripts/preferences.js
Normal file
76
addon/content/scripts/preferences.js
Normal file
@@ -0,0 +1,76 @@
|
||||
/* eslint-disable no-undef */
|
||||
|
||||
const OrgExportAnnotationsPrefs = {
|
||||
init() {
|
||||
try {
|
||||
console.log("[OrgExportAnnotationsPrefs] Initializing preferences pane");
|
||||
} catch (error) {
|
||||
console.error("[OrgExportAnnotationsPrefs] Init error:", error);
|
||||
}
|
||||
},
|
||||
async browseNotesPath() {
|
||||
const fp = new FilePicker();
|
||||
// Use browsingContext for Zotero 8+, fall back to window for Zotero 7
|
||||
const context = window.browsingContext || window;
|
||||
fp.init(context, "Select Notes Directory", fp.modeGetFolder);
|
||||
|
||||
const result = await new Promise((resolve) => fp.open(resolve));
|
||||
if (result === fp.returnOK) {
|
||||
const input = document.getElementById("orgexportannotations-notes-path");
|
||||
if (input) {
|
||||
input.value = fp.file.path;
|
||||
input.dispatchEvent(new Event("change"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async browsePandocPath() {
|
||||
const fp = new FilePicker();
|
||||
// Use browsingContext for Zotero 8+, fall back to window for Zotero 7
|
||||
const context = window.browsingContext || window;
|
||||
fp.init(context, "Select Pandoc Executable", fp.modeOpen);
|
||||
|
||||
const result = await new Promise((resolve) => fp.open(resolve));
|
||||
if (result === fp.returnOK) {
|
||||
const input = document.getElementById("orgexportannotations-pandoc-path");
|
||||
if (input) {
|
||||
input.value = fp.file.path;
|
||||
input.dispatchEvent(new Event("change"));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
async testPandoc() {
|
||||
const input = document.getElementById("orgexportannotations-pandoc-path");
|
||||
const pandocPath = (input && input.value) || "pandoc";
|
||||
|
||||
try {
|
||||
await Zotero.Utilities.Internal.exec(pandocPath, ["--version"]);
|
||||
alert("Pandoc is working correctly!");
|
||||
} catch (_error) {
|
||||
alert(`Pandoc not found at: ${pandocPath}\n\nPlease check the path.`);
|
||||
}
|
||||
},
|
||||
|
||||
async exportAllNow() {
|
||||
try {
|
||||
if (Zotero.OrgExportAnnotations && Zotero.OrgExportAnnotations.hooks) {
|
||||
await Zotero.OrgExportAnnotations.hooks.onMenuExportAll();
|
||||
}
|
||||
} catch (error) {
|
||||
alert(`Export failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
|
||||
async forceExportAllNow() {
|
||||
try {
|
||||
if (Zotero.OrgExportAnnotations && Zotero.OrgExportAnnotations.hooks) {
|
||||
await Zotero.OrgExportAnnotations.hooks.onMenuForceExportAll();
|
||||
}
|
||||
} catch (error) {
|
||||
alert(`Force export failed: ${error.message}`);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
window.OrgExportAnnotationsPrefs = OrgExportAnnotationsPrefs;
|
||||
Reference in New Issue
Block a user