Skip to content

Commit

Permalink
chore: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Aug 20, 2023
1 parent 1ee7109 commit 41f1483
Show file tree
Hide file tree
Showing 16 changed files with 2,930 additions and 1,158 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"**/node_modules/**",
"**/scripts/**",
"**/*.js",
"**/*.bak"
"**/*.bak",
"**/*.yaml"
]
}
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
interval: 'weekly'
8 changes: 4 additions & 4 deletions ZOTERO_TOOLKIT.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ The bootstrapped plugin runs in a sandbox, which does not have default global va
This template registers the following variables to the global scope:

```ts
Zotero, ZoteroPane, Zotero_Tabs, window, document, rootURI, ztoolkit, addon;
Zotero, ZoteroPane, Zotero_Tabs, window, document, rootURI, ztoolkit, addon
```

### Create Elements API
Expand All @@ -288,9 +288,9 @@ The plugin template provides new APIs for bootstrap plugins. We have two reasons
- Zotero 7 requires createElement()/createElementNS() → createXULElement() for remaining XUL elements, while Zotero 6 doesn't support `createXULElement`. The React.createElement-like API `createElement` detects namespace(xul/html/svg) and creates elements automatically, with the return element in the corresponding TS element type.
```ts
createElement(document, "div"); // returns HTMLDivElement
createElement(document, "hbox"); // returns XUL.Box
createElement(document, "button", { namespace: "xul" }); // manually set namespace. returns XUL.Button
createElement(document, 'div') // returns HTMLDivElement
createElement(document, 'hbox') // returns XUL.Box
createElement(document, 'button', { namespace: 'xul' }) // manually set namespace. returns XUL.Button
```
### About Build
Expand Down
46 changes: 23 additions & 23 deletions addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
* [2] https://www.zotero.org/support/dev/zotero_7_for_developers
*/

var chromeHandle;
var chromeHandle

function install(data, reason) {}

async function startup({ id, version, resourceURI, rootURI }, reason) {
await Zotero.initializationPromise;
await Zotero.initializationPromise

// String 'rootURI' introduced in Zotero 7
if (!rootURI) {
rootURI = resourceURI.spec;
rootURI = resourceURI.spec
}

var aomStartup = Components.classes[
"@mozilla.org/addons/addon-manager-startup;1"
].getService(Components.interfaces.amIAddonManagerStartup);
var manifestURI = Services.io.newURI(rootURI + "manifest.json");
'@mozilla.org/addons/addon-manager-startup;1'
].getService(Components.interfaces.amIAddonManagerStartup)
var manifestURI = Services.io.newURI(rootURI + 'manifest.json')
chromeHandle = aomStartup.registerChrome(manifestURI, [
["content", "__addonRef__", rootURI + "chrome/content/"],
]);
['content', '__addonRef__', rootURI + 'chrome/content/'],
])

/**
* Global variables for plugin code.
Expand All @@ -33,44 +33,44 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
*/
const ctx = {
rootURI,
};
ctx._globalThis = ctx;
}
ctx._globalThis = ctx

Services.scriptloader.loadSubScript(
`${rootURI}/chrome/content/scripts/__addonRef__.js`,
ctx,
);
)
}

async function onMainWindowLoad({ window }, reason) {
Zotero.__addonInstance__?.hooks.onMainWindowLoad(window);
Zotero.__addonInstance__?.hooks.onMainWindowLoad(window)
}

async function onMainWindowUnload({ window }, reason) {
Zotero.__addonInstance__?.hooks.onMainWindowUnload(window);
Zotero.__addonInstance__?.hooks.onMainWindowUnload(window)
}

function shutdown({ id, version, resourceURI, rootURI }, reason) {
if (reason === APP_SHUTDOWN) {
return;
return
}

if (typeof Zotero === "undefined") {
Zotero = Components.classes["@zotero.org/Zotero;1"].getService(
if (typeof Zotero === 'undefined') {
Zotero = Components.classes['@zotero.org/Zotero;1'].getService(
Components.interfaces.nsISupports,
).wrappedJSObject;
).wrappedJSObject
}
Zotero.__addonInstance__?.hooks.onShutdown();
Zotero.__addonInstance__?.hooks.onShutdown()

Cc["@mozilla.org/intl/stringbundle;1"]
Cc['@mozilla.org/intl/stringbundle;1']
.getService(Components.interfaces.nsIStringBundleService)
.flushBundles();
.flushBundles()

Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`);
Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`)

if (chromeHandle) {
chromeHandle.destruct();
chromeHandle = null;
chromeHandle.destruct()
chromeHandle = null
}
}

Expand Down
11 changes: 7 additions & 4 deletions addon/prefs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/* eslint-disable no-undef */
pref("__prefsPrefix__.filters", '{"none":{"filter":"none","icon":"☀️","displayName":"None","name":"none"},"nord":{"filter":"invert(85%) sepia(70%) saturate(200%) hue-rotate(179deg) brightness(99%) contrast(90%)","icon":"✨","name":"nord","displayName":"Nord"},"dark":{"filter":"brightness(0.91) grayscale(0.15) invert(0.95) sepia(0.65) hue-rotate(180deg)","icon":"🌙","name":"dark","displayName":"Dark"}}');
pref("__prefsPrefix__.default_pdf_filter", "nord");
pref("__prefsPrefix__.current_theme", "dark");
pref("__prefsPrefix__.filters_by_id", "{}");
pref(
'__prefsPrefix__.filters',
'{"none":{"filter":"none","icon":"☀️","displayName":"None","name":"none"},"nord":{"filter":"invert(85%) sepia(70%) saturate(200%) hue-rotate(179deg) brightness(99%) contrast(90%)","icon":"✨","name":"nord","displayName":"Nord"},"dark":{"filter":"brightness(0.91) grayscale(0.15) invert(0.95) sepia(0.65) hue-rotate(180deg)","icon":"🌙","name":"dark","displayName":"Dark"}}',
)
pref('__prefsPrefix__.default_pdf_filter', 'nord')
pref('__prefsPrefix__.current_theme', 'dark')
pref('__prefsPrefix__.filters_by_id', '{}')
Loading

0 comments on commit 41f1483

Please sign in to comment.