Skip to content

Commit

Permalink
Fix localisation in external windows by passing in global addon ins…
Browse files Browse the repository at this point in the history
…tance
  • Loading branch information
Dominic-DallOsto committed Aug 19, 2024
1 parent a630d90 commit 0b35c6f
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/cita/sourceItemWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ class SourceItemWrapper extends ItemWrapper {
async importCitations() {
// open a new window where the user can paste in bibliographic text, or select a file
const args = {
Wikicite: Wikicite,
addon: addon,
};
const retVals: { text?: string; path?: string } = {};
window.openDialog(
Expand Down Expand Up @@ -776,7 +776,7 @@ class SourceItemWrapper extends ItemWrapper {
async addCitationsByIdentifier() {
// open a new window where the user can paste in identifier strings
const args = {
Wikicite: Wikicite,
addon: addon,
};
const retVals: { text?: string } = {};
window.openDialog(
Expand Down
2 changes: 1 addition & 1 deletion src/cita/wikidata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export default class {
Zotero.ItemTypes.getLocalizedString(item.type),
],
),
Wikicite: Wikicite,
addon: addon,
};
const selection: { value?: number } = {};
window.openDialog(
Expand Down
2 changes: 1 addition & 1 deletion src/components/itemPane/citationsBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function CitationsBox(props: {
function openEditor(citation: Citation): Zotero.Item | undefined {
const args = {
citation: citation,
Wikicite: Wikicite,
addon: addon,
};
const retVals: { [key: string]: any } = {};
window.openDialog(
Expand Down
5 changes: 3 additions & 2 deletions src/dialogs/citation-importer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import CitationImporter from "./CitationImporter";
import * as React from "react";
import { createRoot } from "react-dom/client";
import Wikicite from "../../cita/wikicite";

const { Wikicite } = (window as any).arguments[0];
({ addon: window.addon } = (window as any).arguments[0]);
const retVals: { path?: string; text?: string } = (window as any).arguments[1];

function onCancel() {
Expand Down Expand Up @@ -33,7 +34,7 @@ async function onImportFile() {
window.close();
}

function onImportText(text) {
function onImportText(text: string) {
retVals.text = text;
window.close();
}
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/editor/CitationEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const visibleBaseFieldNames = ["title", "publicationTitle", "date"];
// consider providing at least some read only information about the citation
// such as label of the source item, OCIs, and Zotero link status
const CitationEditor = (props: {
checkCitationPID: (type: string, value: string) => boolean;
checkCitationPID: (type: PIDType, value: string) => boolean;
item: ItemWrapper;
itemBox: any;
getString: (name: string) => string;
Expand Down
7 changes: 3 additions & 4 deletions src/dialogs/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import ItemWrapper from "../../cita/itemWrapper";
import * as React from "react";
import { createRoot } from "react-dom/client";
import Citation from "../../cita/citation";
import Wikicite from "../../cita/wikicite";

let citation: Citation;
let Wikicite: any;
({ citation, Wikicite } = (window as any).arguments[0]);
({ citation, addon: window.addon } = (window as any).arguments[0]);
const retVals: { item?: Zotero.Item } = (window as any).arguments[1];

let newItem: ItemWrapper;

function onCancel() {
Expand All @@ -27,7 +26,7 @@ function onSave() {
window.close();
}

function checkPID(type: string, value: string) {
function checkPID(type: PIDType, value: string) {
return citation.source.checkPID(type, value, {
alert: true,
parentWindow: window,
Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/identifier-importer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import IdentifierImporter from "./IdentifierImporter";
import * as React from "react";
import { createRoot } from "react-dom/client";
import Wikicite from "../../cita/wikicite";

const { Wikicite } = (window as any).arguments[0];
({ addon: window.addon } = (window as any).arguments[0]);
const retVals: { text?: string } = (window as any).arguments[1];

function onCancel() {
Expand Down
8 changes: 6 additions & 2 deletions src/dialogs/selector/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Selector from "./Selector";
import * as React from "react";
import { createRoot } from "react-dom/client";
import Wikicite from "../../cita/wikicite";

let choices: string[];
let message: string;
let Wikicite: any;
({ choices: choices, message, Wikicite } = (window as any).arguments[0]);
({
choices: choices,
message,
addon: window.addon,
} = (window as any).arguments[0]);
const retVals: { value?: number } = (window as any).arguments[1];

function onCancel() {
Expand Down

0 comments on commit 0b35c6f

Please sign in to comment.