-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom UI for selecting from partial QID matches
- Loading branch information
1 parent
61248bf
commit f900bfe
Showing
7 changed files
with
140 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import * as React from "react"; | ||
import * as PropTypes from "prop-types"; | ||
|
||
const Selector = (props: { | ||
choices: string[]; | ||
message: string; | ||
getString: (name: string) => string; | ||
onCancel: () => void; | ||
onConfirm: () => void; | ||
}) => ( | ||
<div> | ||
<div id="selector-description"> | ||
<label>{props.message}</label> | ||
</div> | ||
<select size={10} id="selector-list"> | ||
{props.choices.map((text) => ( | ||
<option>{text}</option> | ||
))} | ||
</select> | ||
<div id="selector-buttons"> | ||
<button onClick={props.onCancel}> | ||
{props.getString("wikicite.wikidata.reconcile.approx.cancel")} | ||
</button> | ||
<button onClick={props.onConfirm}> | ||
{props.getString("wikicite.wikidata.reconcile.approx.confirm")} | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
|
||
Selector.propTypes = { | ||
choices: PropTypes.arrayOf(PropTypes.string), | ||
message: PropTypes.string, | ||
getString: PropTypes.func, | ||
onCancel: PropTypes.func, | ||
onConfirm: PropTypes.func, | ||
}; | ||
|
||
export default Selector; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Selector from "./Selector"; | ||
import * as React from "react"; | ||
import { createRoot } from "react-dom/client"; | ||
|
||
let choices: string[]; | ||
let message: string; | ||
let Wikicite: any; | ||
({ choices: choices, message, Wikicite } = (window as any).arguments[0]); | ||
const retVals: { value?: number } = (window as any).arguments[1]; | ||
|
||
function onCancel() { | ||
window.close(); | ||
} | ||
|
||
function onConfirm() { | ||
retVals.value = ( | ||
document.getElementById("selector-list") as HTMLSelectElement | ||
).selectedIndex; | ||
window.close(); | ||
} | ||
|
||
window.addEventListener("load", () => { | ||
document.title = Wikicite.getString( | ||
"wikicite.wikidata.reconcile.approx.title", | ||
); | ||
const root = createRoot(document.getElementById("root")!); | ||
root.render( | ||
<Selector | ||
choices={choices} | ||
message={message} | ||
getString={(name) => Wikicite.getString(name)} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
/>, | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<window id="selector" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" | ||
xmlns:html="http://www.w3.org/1999/xhtml"> | ||
<linkset> | ||
<html:link rel="stylesheet" href="chrome://global/skin/" type="text/css" /> | ||
<html:link rel="stylesheet" href="chrome://zotero/skin/zotero.css" type="text/css" /> | ||
<html:link rel="stylesheet" href="chrome://zotero-platform/content/zotero.css" type="text/css" /> | ||
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/selector.css" type="text/css" /> | ||
<html:link rel="stylesheet" href="chrome://__addonRef__/content/skin/default/overlay.css" type="text/css" /> | ||
<html:link rel="localization" href="__addonRef__-addon.ftl" /> | ||
</linkset> | ||
|
||
<script type="text/javascript" src="chrome://zotero/content/include.js"></script> | ||
<script src="chrome://__addonRef__/content/scripts/dialogs/selector/index.js"></script> | ||
|
||
<html:div id="root"></html:div> | ||
</window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
window#selector { | ||
width: 100%; | ||
height: 100%; | ||
padding: 1em; | ||
} | ||
|
||
div#selector-description { | ||
margin-bottom: 10px; | ||
} | ||
|
||
#selector-list { | ||
margin-top: 10px; | ||
margin-bottom: 10px; | ||
width: 100%; | ||
height: 100%; | ||
overflow: auto; | ||
} | ||
|
||
div#selector-buttons { | ||
margin-top: 10px; | ||
text-align: right; | ||
} | ||
|
||
div#selector-buttons > button { | ||
margin-left: 5px; | ||
margin-right: 5px; | ||
} | ||
|
||
#root { | ||
height: 100%; | ||
width: 100%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters