MCPcopy
hub / github.com/MuiseDestiny/zotero-gpt / callback

Method callback

src/modules/views.ts:1295–1334  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1293 */
1294 private registerKey() {
1295 const callback = async () => {
1296 this.isInNote = false
1297 if (Zotero_Tabs.selectedIndex == 0) {
1298 const div = document.querySelector("#item-tree-main-default .row.selected")!
1299 if (div) {
1300 const rect = div.getBoundingClientRect()
1301 this.show(rect.x, rect.y + rect.height)
1302 } else {
1303 this.show()
1304 }
1305 } else {
1306 const reader = await ztoolkit.Reader.getReader()
1307 // const div = reader?._iframeWindow?.document.querySelector("#selection-menu")!
1308 const div = reader?._iframeWindow?.document.querySelector(".selection-popup")!
1309 if (div) {
1310 window.setTimeout(() => {
1311 this.messages = this.messages.concat(
1312 [
1313 {
1314 role: "user",
1315 content: `I am reading a PDF, and the following text is a part of the PDF. Please read it first, and I will ask you some question later: \n${Meet.Zotero.getPDFSelection()}`
1316 },
1317 {
1318 role: "assistant",
1319 content: "OK."
1320 }
1321 ]
1322 )
1323 const rect = div?.getBoundingClientRect()
1324 const windRect = document.documentElement.getBoundingClientRect()
1325 const ww = windRect.width *
1326 0.01 * Number((Zotero.Prefs.get(`${config.addonRef}.width`) as string).slice(0, -1))
1327 ww
1328 this.show(rect.left + rect.width * .5 - ww * .5, rect.bottom)
1329 }, 233)
1330 } else {
1331 this.show()
1332 }
1333 }
1334 }
1335 if (Zotero.isMac) {
1336 ztoolkit.Shortcut.register("event", {
1337 id: config.addonRef,

Callers

nothing calls this directly

Calls 2

showMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected