fix: chrome/content -> content (#213)
This commit is contained in:
parent
e0aedcc144
commit
bf1ff3a6fb
71
README.md
71
README.md
@ -247,7 +247,7 @@ Steps of build:
|
|||||||
- Prepare locale files to [avoid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)
|
- Prepare locale files to [avoid conflict](https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)
|
||||||
- Rename `**/*.flt` to `**/${addonRef}-*.flt`
|
- Rename `**/*.flt` to `**/${addonRef}-*.flt`
|
||||||
- Prefix each fluent message with `addonRef-`
|
- Prefix each fluent message with `addonRef-`
|
||||||
- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/chrome/content/scripts`.
|
- Use ESBuild to build `.ts` source code to `.js`, build `src/index.ts` to `./build/addon/content/scripts`.
|
||||||
- (Production mode only) Zip the `./build/addon` to `./build/*.xpi`
|
- (Production mode only) Zip the `./build/addon` to `./build/*.xpi`
|
||||||
- (Production mode only) Prepare `update.json` or `update-beta.json`
|
- (Production mode only) Prepare `update.json` or `update-beta.json`
|
||||||
|
|
||||||
@ -340,55 +340,36 @@ This section shows the directory structure of a template.
|
|||||||
|
|
||||||
- All `.js/.ts` code files are in `./src`;
|
- All `.js/.ts` code files are in `./src`;
|
||||||
- Addon config files: `./addon/manifest.json`;
|
- Addon config files: `./addon/manifest.json`;
|
||||||
- UI files: `./addon/chrome/content/*.xhtml`.
|
- UI files: `./addon/content/*.xhtml`.
|
||||||
- Locale files: `./addon/locale/**/*.flt`;
|
- Locale files: `./addon/locale/**/*.flt`;
|
||||||
- Preferences file: `./addon/prefs.js`;
|
- Preferences file: `./addon/prefs.js`;
|
||||||
> Don't break the lines in the `prefs.js`
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
.
|
.
|
||||||
|-- .eslintrc.json # eslint conf
|
|
||||||
|-- .gitattributes # git conf
|
|
||||||
|-- .github/ # github conf
|
|-- .github/ # github conf
|
||||||
|-- .gitignore # git conf
|
|-- .vscode/ # vscode conf
|
||||||
|-- .prettierrc # prettier conf
|
|-- addon # static files
|
||||||
|-- .release-it.json # release-it conf
|
| |-- bootstrap.js
|
||||||
|-- .vscode # vs code conf
|
| |-- content
|
||||||
| |-- extensions.json
|
| | |-- icons
|
||||||
| |-- launch.json
|
| | | |-- favicon.png
|
||||||
| |-- setting.json
|
| | | `-- favicon@0.5x.png
|
||||||
| `-- toolkit.code-snippets
|
| | |-- preferences.xhtml
|
||||||
|-- package-lock.json # npm conf
|
|
||||||
|-- package.json # npm conf
|
|
||||||
|-- LICENSE
|
|
||||||
|-- README.md
|
|
||||||
|-- addon
|
|
||||||
| |-- bootstrap.js # addon load/unload script, like a main.c
|
|
||||||
| |-- chrome
|
|
||||||
| | `-- content
|
|
||||||
| | |-- icons/
|
|
||||||
| | |-- preferences.xhtml # preference panel
|
|
||||||
| | `-- zoteroPane.css
|
| | `-- zoteroPane.css
|
||||||
| |-- locale # locale
|
| |-- locale
|
||||||
| | |-- en-US
|
| | |-- en-US
|
||||||
| | | |-- addon.ftl
|
| | | |-- addon.ftl
|
||||||
|
| | | |-- mainWindow.ftl
|
||||||
| | | `-- preferences.ftl
|
| | | `-- preferences.ftl
|
||||||
| | `-- zh-CN
|
| | `-- zh-CN
|
||||||
| | |-- addon.ftl
|
| | |-- addon.ftl
|
||||||
|
| | |-- mainWindow.ftl
|
||||||
| | `-- preferences.ftl
|
| | `-- preferences.ftl
|
||||||
| |-- manifest.json # addon config
|
| |-- manifest.json
|
||||||
| `-- prefs.js
|
| `-- prefs.js
|
||||||
|-- build/ # build dir
|
|-- build # build dir
|
||||||
|-- scripts # scripts for dev
|
|-- node_modules
|
||||||
| |-- build.mjs # script to build plugin
|
|-- src # source code of scripts
|
||||||
| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc
|
|
||||||
| |-- server.mjs # script to start a development server
|
|
||||||
| |-- start.mjs # script to start Zotero process
|
|
||||||
| |-- stop.mjs # script to kill Zotero process
|
|
||||||
| |-- utils.mjs # utils functions for dev scripts
|
|
||||||
| |-- update-template.json # template of `update.json`
|
|
||||||
| `-- zotero-cmd-template.json # template of local env
|
|
||||||
|-- src # source code
|
|
||||||
| |-- addon.ts # base class
|
| |-- addon.ts # base class
|
||||||
| |-- hooks.ts # lifecycle hooks
|
| |-- hooks.ts # lifecycle hooks
|
||||||
| |-- index.ts # main entry
|
| |-- index.ts # main entry
|
||||||
@ -399,11 +380,23 @@ This section shows the directory structure of a template.
|
|||||||
| |-- locale.ts
|
| |-- locale.ts
|
||||||
| |-- prefs.ts
|
| |-- prefs.ts
|
||||||
| |-- wait.ts
|
| |-- wait.ts
|
||||||
| `-- window.ts
|
| |-- window.ts
|
||||||
|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig
|
| `-- ztoolkit.ts
|
||||||
|-- typings # ts typings
|
|-- typings # ts typings
|
||||||
| `-- global.d.ts
|
| `-- global.d.ts
|
||||||
`-- update.json
|
|
||||||
|
|-- .env # enviroment config (do not check into repo)
|
||||||
|
|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold
|
||||||
|
|-- .gitignore # git conf
|
||||||
|
|-- .gitattributes # git conf
|
||||||
|
|-- .prettierrc # prettier conf, https://prettier.io/
|
||||||
|
|-- eslint.config.mjs # eslint conf, https://eslint.org/
|
||||||
|
|-- LICENSE
|
||||||
|
|-- package-lock.json
|
||||||
|
|-- package.json
|
||||||
|
|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig
|
||||||
|
|-- README.md
|
||||||
|
`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold
|
||||||
```
|
```
|
||||||
|
|
||||||
## Disclaimer
|
## Disclaimer
|
||||||
|
6
addon/bootstrap.js
vendored
6
addon/bootstrap.js
vendored
@ -24,7 +24,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
|
|||||||
].getService(Components.interfaces.amIAddonManagerStartup);
|
].getService(Components.interfaces.amIAddonManagerStartup);
|
||||||
var manifestURI = Services.io.newURI(rootURI + "manifest.json");
|
var manifestURI = Services.io.newURI(rootURI + "manifest.json");
|
||||||
chromeHandle = aomStartup.registerChrome(manifestURI, [
|
chromeHandle = aomStartup.registerChrome(manifestURI, [
|
||||||
["content", "__addonRef__", rootURI + "chrome/content/"],
|
["content", "__addonRef__", rootURI + "content/"],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +39,7 @@ async function startup({ id, version, resourceURI, rootURI }, reason) {
|
|||||||
ctx._globalThis = ctx;
|
ctx._globalThis = ctx;
|
||||||
|
|
||||||
Services.scriptloader.loadSubScript(
|
Services.scriptloader.loadSubScript(
|
||||||
`${rootURI}/chrome/content/scripts/__addonRef__.js`,
|
`${rootURI}/content/scripts/__addonRef__.js`,
|
||||||
ctx,
|
ctx,
|
||||||
);
|
);
|
||||||
Zotero.__addonInstance__.hooks.onStartup();
|
Zotero.__addonInstance__.hooks.onStartup();
|
||||||
@ -69,7 +69,7 @@ function shutdown({ id, version, resourceURI, rootURI }, reason) {
|
|||||||
.getService(Components.interfaces.nsIStringBundleService)
|
.getService(Components.interfaces.nsIStringBundleService)
|
||||||
.flushBundles();
|
.flushBundles();
|
||||||
|
|
||||||
Cu.unload(`${rootURI}/chrome/content/scripts/__addonRef__.js`);
|
Cu.unload(`${rootURI}/content/scripts/__addonRef__.js`);
|
||||||
|
|
||||||
if (chromeHandle) {
|
if (chromeHandle) {
|
||||||
chromeHandle.destruct();
|
chromeHandle.destruct();
|
||||||
|
Before Width: | Height: | Size: 677 B After Width: | Height: | Size: 677 B |
Before Width: | Height: | Size: 836 B After Width: | Height: | Size: 836 B |
@ -6,8 +6,8 @@
|
|||||||
"homepage_url": "__homepage__",
|
"homepage_url": "__homepage__",
|
||||||
"author": "__author__",
|
"author": "__author__",
|
||||||
"icons": {
|
"icons": {
|
||||||
"48": "chrome/content/icons/favicon@0.5x.png",
|
"48": "content/icons/favicon@0.5x.png",
|
||||||
"96": "chrome/content/icons/favicon.png"
|
"96": "content/icons/favicon.png"
|
||||||
},
|
},
|
||||||
"applications": {
|
"applications": {
|
||||||
"zotero": {
|
"zotero": {
|
||||||
|
@ -251,7 +251,7 @@ Obsidian风格的指令输入模块,它通过接受文本来运行插件,并
|
|||||||
- 准备本地化文件以避免冲突,查看官方文档了解更多(<https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)>
|
- 准备本地化文件以避免冲突,查看官方文档了解更多(<https://www.zotero.org/support/dev/zotero_7_for_developers#avoiding_localization_conflicts)>
|
||||||
- 重命名`**/*.flt` 为 `**/${addonRef}-*.flt`
|
- 重命名`**/*.flt` 为 `**/${addonRef}-*.flt`
|
||||||
- 在每个消息前加上 `addonRef-`
|
- 在每个消息前加上 `addonRef-`
|
||||||
- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/chrome/content/scripts`
|
- 使用 Esbuild 来将 `.ts` 源码构建为 `.js`,从 `src/index.ts` 构建到`./build/addon/content/scripts`
|
||||||
- (仅在生产模式下工作) 压缩 `./build/addon` 目录为 `./build/*.xpi`
|
- (仅在生产模式下工作) 压缩 `./build/addon` 目录为 `./build/*.xpi`
|
||||||
- (仅在生产模式下工作) 准备 `update.json` 或 `update-beta.json`
|
- (仅在生产模式下工作) 准备 `update.json` 或 `update-beta.json`
|
||||||
|
|
||||||
@ -340,55 +340,36 @@ Zotero 文档已过时且不完整,克隆 <https://github.com/zotero/zotero>
|
|||||||
|
|
||||||
- 所有的 `.js/.ts` 代码都在 `./src`;
|
- 所有的 `.js/.ts` 代码都在 `./src`;
|
||||||
- 插件配置文件:`./addon/manifest.json`;
|
- 插件配置文件:`./addon/manifest.json`;
|
||||||
- UI 文件: `./addon/chrome/content/*.xhtml`.
|
- UI 文件: `./addon/content/*.xhtml`.
|
||||||
- 区域设置文件: `./addon/locale/**/*.flt`;
|
- 区域设置文件: `./addon/locale/**/*.flt`;
|
||||||
- 首选项文件: `./addon/prefs.js`;
|
- 首选项文件: `./addon/prefs.js`;
|
||||||
> 不要在 `prefs.js` 中换行
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
.
|
.
|
||||||
|-- .eslintrc.json # eslint conf
|
|
||||||
|-- .gitattributes # git conf
|
|
||||||
|-- .github/ # github conf
|
|-- .github/ # github conf
|
||||||
|-- .gitignore # git conf
|
|-- .vscode/ # vscode conf
|
||||||
|-- .prettierrc # prettier conf
|
|-- addon # static files
|
||||||
|-- .release-it.json # release-it conf
|
| |-- bootstrap.js
|
||||||
|-- .vscode # vs code conf
|
| |-- content
|
||||||
| |-- extensions.json
|
| | |-- icons
|
||||||
| |-- launch.json
|
| | | |-- favicon.png
|
||||||
| |-- setting.json
|
| | | `-- favicon@0.5x.png
|
||||||
| `-- toolkit.code-snippets
|
| | |-- preferences.xhtml
|
||||||
|-- package-lock.json # npm conf
|
|
||||||
|-- package.json # npm conf
|
|
||||||
|-- LICENSE
|
|
||||||
|-- README.md
|
|
||||||
|-- addon
|
|
||||||
| |-- bootstrap.js # addon load/unload script, like a main.c
|
|
||||||
| |-- chrome
|
|
||||||
| | `-- content
|
|
||||||
| | |-- icons/
|
|
||||||
| | |-- preferences.xhtml # preference panel
|
|
||||||
| | `-- zoteroPane.css
|
| | `-- zoteroPane.css
|
||||||
| |-- locale # locale
|
| |-- locale
|
||||||
| | |-- en-US
|
| | |-- en-US
|
||||||
| | | |-- addon.ftl
|
| | | |-- addon.ftl
|
||||||
|
| | | |-- mainWindow.ftl
|
||||||
| | | `-- preferences.ftl
|
| | | `-- preferences.ftl
|
||||||
| | `-- zh-CN
|
| | `-- zh-CN
|
||||||
| | |-- addon.ftl
|
| | |-- addon.ftl
|
||||||
|
| | |-- mainWindow.ftl
|
||||||
| | `-- preferences.ftl
|
| | `-- preferences.ftl
|
||||||
| |-- manifest.json # addon config
|
| |-- manifest.json
|
||||||
| `-- prefs.js
|
| `-- prefs.js
|
||||||
|-- build/ # build dir
|
|-- build # build dir
|
||||||
|-- scripts # scripts for dev
|
|-- node_modules
|
||||||
| |-- build.mjs # script to build plugin
|
|-- src # source code of scripts
|
||||||
| |-- scripts.mjs # scripts send to Zotero, such as reload, openDevTool, etc
|
|
||||||
| |-- server.mjs # script to start a development server
|
|
||||||
| |-- start.mjs # script to start Zotero process
|
|
||||||
| |-- stop.mjs # script to kill Zotero process
|
|
||||||
| |-- utils.mjs # utils functions for dev scripts
|
|
||||||
| |-- update-template.json # template of `update.json`
|
|
||||||
| `-- zotero-cmd-template.json # template of local env
|
|
||||||
|-- src # source code
|
|
||||||
| |-- addon.ts # base class
|
| |-- addon.ts # base class
|
||||||
| |-- hooks.ts # lifecycle hooks
|
| |-- hooks.ts # lifecycle hooks
|
||||||
| |-- index.ts # main entry
|
| |-- index.ts # main entry
|
||||||
@ -399,11 +380,23 @@ Zotero 文档已过时且不完整,克隆 <https://github.com/zotero/zotero>
|
|||||||
| |-- locale.ts
|
| |-- locale.ts
|
||||||
| |-- prefs.ts
|
| |-- prefs.ts
|
||||||
| |-- wait.ts
|
| |-- wait.ts
|
||||||
| `-- window.ts
|
| |-- window.ts
|
||||||
|-- tsconfig.json # https://code.visualstudio.com/docs/languages/jsconfig
|
| `-- ztoolkit.ts
|
||||||
|-- typings # ts typings
|
|-- typings # ts typings
|
||||||
| `-- global.d.ts
|
| `-- global.d.ts
|
||||||
`-- update.json
|
|
||||||
|
|-- .env # enviroment config (do not check into repo)
|
||||||
|
|-- .env.example # template of enviroment config, https://github.com/northword/zotero-plugin-scaffold
|
||||||
|
|-- .gitignore # git conf
|
||||||
|
|-- .gitattributes # git conf
|
||||||
|
|-- .prettierrc # prettier conf, https://prettier.io/
|
||||||
|
|-- eslint.config.mjs # eslint conf, https://eslint.org/
|
||||||
|
|-- LICENSE
|
||||||
|
|-- package-lock.json
|
||||||
|
|-- package.json
|
||||||
|
|-- tsconfig.json # typescript conf, https://code.visualstudio.com/docs/languages/jsconfig
|
||||||
|
|-- README.md
|
||||||
|
`-- zotero-plugin.config.ts # scaffold conf, https://github.com/northword/zotero-plugin-scaffold
|
||||||
```
|
```
|
||||||
|
|
||||||
## Disclaimer 免责声明
|
## Disclaimer 免责声明
|
||||||
|
@ -71,7 +71,7 @@ export class BasicExampleFactory {
|
|||||||
static registerPrefs() {
|
static registerPrefs() {
|
||||||
Zotero.PreferencePanes.register({
|
Zotero.PreferencePanes.register({
|
||||||
pluginID: config.addonID,
|
pluginID: config.addonID,
|
||||||
src: rootURI + "chrome/content/preferences.xhtml",
|
src: rootURI + "content/preferences.xhtml",
|
||||||
label: getString("prefs-title"),
|
label: getString("prefs-title"),
|
||||||
image: `chrome://${config.addonRef}/content/icons/favicon.png`,
|
image: `chrome://${config.addonRef}/content/icons/favicon.png`,
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ import { getString } from "../utils/locale";
|
|||||||
|
|
||||||
export async function registerPrefsScripts(_window: Window) {
|
export async function registerPrefsScripts(_window: Window) {
|
||||||
// This function is called when the prefs window is opened
|
// This function is called when the prefs window is opened
|
||||||
// See addon/chrome/content/preferences.xul onpaneload
|
// See addon/content/preferences.xhtml onpaneload
|
||||||
if (!addon.data.prefs) {
|
if (!addon.data.prefs) {
|
||||||
addon.data.prefs = {
|
addon.data.prefs = {
|
||||||
window: _window,
|
window: _window,
|
||||||
|
@ -31,7 +31,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
bundle: true,
|
bundle: true,
|
||||||
target: "firefox115",
|
target: "firefox115",
|
||||||
outfile: `build/addon/chrome/content/scripts/${pkg.config.addonRef}.js`,
|
outfile: `build/addon/content/scripts/${pkg.config.addonRef}.js`,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user