zotero-plugin 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug-log.d.ts +5 -0
- package/debug-log.js +19 -10
- package/package.json +2 -1
package/debug-log.d.ts
CHANGED
package/debug-log.js
CHANGED
|
@@ -7,18 +7,24 @@ const tar_js_1 = tslib_1.__importDefault(require("tar-js"));
|
|
|
7
7
|
const pako_1 = require("pako");
|
|
8
8
|
class DebugLogSender {
|
|
9
9
|
constructor() {
|
|
10
|
+
this.id = {
|
|
11
|
+
menu: 'debug-log-sender-menu',
|
|
12
|
+
menupopup: 'debug-log-sender-menupopup',
|
|
13
|
+
menuitem: 'debug-log-sender',
|
|
14
|
+
};
|
|
10
15
|
this.plugins = {};
|
|
11
16
|
}
|
|
12
17
|
convertLegacy() {
|
|
13
|
-
var _a
|
|
18
|
+
var _a;
|
|
19
|
+
if (!Zotero.DebugLogSender)
|
|
20
|
+
return;
|
|
21
|
+
const plugins = Zotero.DebugLogSender.plugins || {};
|
|
22
|
+
delete Zotero.DebugLogSender;
|
|
14
23
|
const doc = Zotero.getMainWindow().document;
|
|
15
24
|
(_a = doc.querySelector('menuitem#debug-log-menu')) === null || _a === void 0 ? void 0 : _a.remove();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.register(plugin, preferences);
|
|
19
|
-
}
|
|
25
|
+
for (const [plugin, preferences] of Object.entries(plugins)) {
|
|
26
|
+
this.register(plugin, preferences);
|
|
20
27
|
}
|
|
21
|
-
(_c = Zotero.DebugLogSender) === null || _c === void 0 ? true : delete _c.plugins;
|
|
22
28
|
}
|
|
23
29
|
element(name, attrs = {}) {
|
|
24
30
|
const doc = Zotero.getMainWindow().document;
|
|
@@ -33,15 +39,16 @@ class DebugLogSender {
|
|
|
33
39
|
var _a;
|
|
34
40
|
this.convertLegacy();
|
|
35
41
|
const doc = Zotero.getMainWindow().document;
|
|
36
|
-
let menupopup = doc.querySelector(
|
|
42
|
+
let menupopup = doc.querySelector(`#${this.id.menupopup}`);
|
|
37
43
|
if (!menupopup) {
|
|
38
44
|
menupopup = doc.querySelector('menupopup#menu_HelpPopup')
|
|
39
|
-
.appendChild(this.element('menu', { id:
|
|
40
|
-
.appendChild(this.element('menupopup', { id:
|
|
45
|
+
.appendChild(this.element('menu', { id: this.id.menu, label: 'Send debug log to file.io' }))
|
|
46
|
+
.appendChild(this.element('menupopup', { id: this.id.menupopup }));
|
|
41
47
|
}
|
|
42
|
-
(_a = doc.querySelector(
|
|
48
|
+
(_a = doc.querySelector(`.${this.id.menuitem}[label=${JSON.stringify(plugin)}]`)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
43
49
|
const menuitem = menupopup.appendChild(this.element('menuitem', {
|
|
44
50
|
label: plugin,
|
|
51
|
+
class: this.id.menuitem,
|
|
45
52
|
'data-preferences': JSON.stringify(preferences || []),
|
|
46
53
|
}));
|
|
47
54
|
menuitem.addEventListener('command', event => this.send(event.currentTarget));
|
|
@@ -49,8 +56,10 @@ class DebugLogSender {
|
|
|
49
56
|
unregister(plugin) {
|
|
50
57
|
var _a, _b;
|
|
51
58
|
const doc = Zotero.getMainWindow().document;
|
|
59
|
+
Zotero.debug(`debug-log-sender: removing .debug-log-sender[label=${JSON.stringify(plugin)}]: ${!!doc.querySelector(`.debug-log-sender[label=${JSON.stringify(plugin)}]`)}`);
|
|
52
60
|
(_a = doc.querySelector(`.debug-log-sender[label=${JSON.stringify(plugin)}]`)) === null || _a === void 0 ? void 0 : _a.remove();
|
|
53
61
|
const menupopup = doc.querySelector('#debug-log-sender-menupopup');
|
|
62
|
+
Zotero.debug(`debug-log-sender: removing #debug-log-sender-menupopup: ${menupopup && menupopup.children.length}`);
|
|
54
63
|
if (menupopup && !menupopup.children.length)
|
|
55
64
|
(_b = doc.querySelector('#debug-log-sender-menu')) === null || _b === void 0 ? void 0 : _b.remove();
|
|
56
65
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zotero-plugin",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "Zotero plugin builder",
|
|
5
5
|
"homepage": "https://github.com/retorquere/zotero-plugin/wiki",
|
|
6
6
|
"bin": {
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
"postversion": "git push --follow-tags",
|
|
20
20
|
"test": "eslint . --ext .ts && npm run build",
|
|
21
21
|
"build": "tsc && chmod +x bin/*.js",
|
|
22
|
+
"pack": "npm test && npm pack",
|
|
22
23
|
"prepublishOnly": "npm install && npm run build",
|
|
23
24
|
"ncu": "ncu -u && npm i && git add package.json package-lock.json && git commit -m ncu"
|
|
24
25
|
},
|