Skip to content

Commit

Permalink
fix: Zotero 7.0.0-beta.70 (#766)
Browse files Browse the repository at this point in the history
fix: #705
  • Loading branch information
windingwind committed Apr 9, 2024
2 parents 8729987 + 551dcbe commit dab10d3
Show file tree
Hide file tree
Showing 11 changed files with 504 additions and 498 deletions.
15 changes: 15 additions & 0 deletions addon/chrome/content/icons/section-16.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions addon/chrome/content/icons/section-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions addon/chrome/content/icons/swap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions addon/locale/en-US/mainWindow.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
itemPaneSection-header =
.label = Translate
itemPaneSection-sidenav =
.tooltiptext = Translate
4 changes: 4 additions & 0 deletions addon/locale/it-IT/mainWindow.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
itemPaneSection-header =
.label = Translate
itemPaneSection-sidenav =
.tooltiptext = Translate
4 changes: 4 additions & 0 deletions addon/locale/zh-CN/mainWindow.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
itemPaneSection-header =
.label = 翻译
itemPaneSection-sidenav =
.tooltiptext = 翻译
2 changes: 1 addition & 1 deletion addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"zotero": {
"id": "__addonID__",
"update_url": "__updateURL__",
"strict_min_version": "6.999",
"strict_min_version": "7.0.0-beta.70",
"strict_max_version": "7.0.*"
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Addon {
};
panel: {
tabOptionId: string;
activePanels: HTMLElement[];
activePanels: Record<string, (options: any) => void>;
windowPanel: Window | null;
};
popup: {
Expand Down Expand Up @@ -47,7 +47,7 @@ class Addon {
ztoolkit: createZToolkit(),
locale: {},
prefs: { window: null },
panel: { tabOptionId: "", activePanels: [], windowPanel: null },
panel: { tabOptionId: "", activePanels: {}, windowPanel: null },
popup: { currentPopup: null },
translate: {
selectedText: "",
Expand Down
9 changes: 9 additions & 0 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ async function onMainWindowLoad(win: Window): Promise<void> {
]);
// Create ztoolkit for every window
addon.data.ztoolkit = createZToolkit();

(win as any).MozXULElement.insertFTLIfNeeded(
`${config.addonRef}-mainWindow.ftl`,
);

registerReaderTabPanel();
registerPrefsWindow();
registerMenu();
Expand All @@ -87,6 +92,10 @@ async function onMainWindowLoad(win: Window): Promise<void> {

async function onMainWindowUnload(win: Window): Promise<void> {
ztoolkit.unregisterAll();

win.document
.querySelector(`[href="${config.addonRef}-mainWindow.ftl"]`)
?.remove();
}

function onShutdown(): void {
Expand Down
35 changes: 28 additions & 7 deletions src/modules/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,22 @@ export function updateReaderPopup() {
audiobox,
);
}
translateButton.hidden = task.status !== "waiting";
if (task.status !== "waiting") {
translateButton.style.display = "none";
} else {
translateButton.style.removeProperty("display");
}
textarea.hidden = hidePopupTextarea || task.status === "waiting";
textarea.value = task.result || task.raw;
textarea.style.fontSize = `${getPref("fontSize")}px`;
textarea.style.lineHeight = `${
Number(getPref("lineHeight")) * Number(getPref("fontSize"))
}px`;
addToNoteButton.hidden = !ZoteroContextPane.getActiveEditor();
if (!ZoteroContextPane.activeEditor) {
addToNoteButton.style.display = "none";
} else {
addToNoteButton.style.removeProperty("display");
}
updatePopupSize(popup, textarea);
}

Expand Down Expand Up @@ -113,9 +121,14 @@ export function buildReaderPopup(
ignoreIfExists: true,
},
{
tag: "div",
tag: "button",
namespace: "html",
id: makeId("translate"),
classList: ["wide-button", `${config.addonRef}-readerpopup`],
classList: [
"toolbar-button",
"wide-button",
`${config.addonRef}-readerpopup`,
],
properties: {
innerHTML: `${SVGIcon}${getString("readerpopup-translate-label")}`,
hidden: getPref("enableAuto"),
Expand Down Expand Up @@ -217,9 +230,17 @@ export function buildReaderPopup(
],
},
{
tag: "div",
tag: "button",
namespace: "html",
id: makeId("addtonote"),
classList: ["wide-button", `${config.addonRef}-readerpopup`],
classList: [
"toolbar-button",
"wide-button",
`${config.addonRef}-readerpopup`,
],
styles: {
marginTop: "8px",
},
properties: {
innerHTML: `${SVGIcon}${Zotero.getString("pdfReader.addToNote")}`,
},
Expand All @@ -229,7 +250,7 @@ export function buildReaderPopup(
type: "click",
listener: async (ev) => {
const noteEditor =
ZoteroContextPane && ZoteroContextPane.getActiveEditor();
ZoteroContextPane && ZoteroContextPane.activeEditor;
if (!noteEditor) {
return;
}
Expand Down
Loading

0 comments on commit dab10d3

Please sign in to comment.