change: proxy handler

This commit is contained in:
xiangyu 2022-09-29 18:00:38 +08:00
parent 48cca11808
commit eb15f873b5
3 changed files with 22 additions and 1661 deletions

View File

@ -3,7 +3,4 @@ skin __addonRef__ default chrome/skin/default/__addonRef__/
locale __addonRef__ en-US chrome/locale/en-US/
locale __addonRef__ zh-CN chrome/locale/zh-CN/
component {9BC3D762-9038-486A-9D70-C997AF848A7D} components/zotero-protocol-handler.js
contract @mozilla.org/network/protocol;1?name=zotero {9BC3D762-9038-486A-9D70-C997AF848A7D}
overlay chrome://zotero/content/zoteroPane.xul chrome://__addonRef__/content/overlay.xul

File diff suppressed because it is too large Load Diff

View File

@ -182,6 +182,7 @@ class AddonEvents extends AddonBase {
public async onInit() {
Zotero.debug("Knowledge4Zotero: init called");
this.initProxyHandler();
this.addEditorInstanceListener();
// Register the callback in Zotero as an item observer
@ -221,6 +222,27 @@ class AddonEvents extends AddonBase {
this._Addon.sync.setSync();
}
private initProxyHandler() {
const openNoteExtension = {
noContent: true,
doAction: async (uri: any) => {
let message = {
type: "onNoteLink",
content: {
params: await this._Addon.knowledge.getNoteFromLink(uri.spec),
},
};
await this._Addon.events.onEditorEvent(message);
},
newChannel: function (uri: any) {
this.doAction(uri);
},
};
Services.io.getProtocolHandler("zotero").wrappedJSObject._extensions[
"zotero://note"
] = openNoteExtension;
}
private async initWorkspaceTab() {
let state = Zotero.Session.state.windows.find((x) => x.type === "pane");
Zotero.debug("initWorkspaceTab");