Skip to content

Commit

Permalink
Merge branch 'master' into gh-3153
Browse files Browse the repository at this point in the history
  • Loading branch information
retorquere committed Feb 24, 2025
2 parents 06aa95f + 8a12d2a commit c52f81a
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/label-gun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
nag:
runs-on: ubuntu-latest
steps:
- uses: retorquere/label-gun@project
- uses: retorquere/label-gun@main
with:
token: ${{ github.token }}
label.exempt: question
Expand Down
11 changes: 5 additions & 6 deletions content/ExportOptions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Monkey } from './monkey-patch'
import * as l10n from './l10n'
import { Events } from './events'
import type { XUL } from '../typings/xul'

let enabled = true

Expand All @@ -27,11 +26,11 @@ Events.on('window-loaded', ({ win, href }: { win: Window; href: string }) => {
})

function mutex(e?: Event): void {
const exportFileData = document.getElementById('export-option-exportFileData') as XUL.Checkbox
const keepUpdated = document.getElementById('export-option-keepUpdated') as XUL.Checkbox
const worker = document.getElementById('export-option-worker') as XUL.Checkbox
const biblatexAPA = document.getElementById('export-option-biblatexAPA') as XUL.Checkbox
const biblatexChicago = document.getElementById('export-option-biblatexChicago') as XUL.Checkbox
const exportFileData = document.getElementById('export-option-exportFileData') as unknown as XUL.Checkbox
const keepUpdated = document.getElementById('export-option-keepUpdated') as unknown as XUL.Checkbox
const worker = document.getElementById('export-option-worker') as unknown as XUL.Checkbox
const biblatexAPA = document.getElementById('export-option-biblatexAPA') as unknown as XUL.Checkbox
const biblatexChicago = document.getElementById('export-option-biblatexChicago') as unknown as XUL.Checkbox

if (!exportFileData || !keepUpdated) return null

Expand Down
18 changes: 8 additions & 10 deletions content/Preferences.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as client from './client'
import { Path } from './file'

import type { XUL } from '../typings/xul'

import { log } from './logger'

import { Preference } from './prefs'
Expand Down Expand Up @@ -42,7 +40,7 @@ Events.on('preference-changed', (pref: string) => {
}
})

function setQuickCopy(node: XUL.Menuitem): void {
function setQuickCopy(node: XUL.MenuItem): void {
if (!node) return

let mode = ''
Expand Down Expand Up @@ -89,7 +87,7 @@ class ZoteroPreferences {
this.observed = [...node.getElementsByTagNameNS('http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul', 'menulist')].find(added => added.id === 'zotero-quickCopy-menu')
this.observer.observe(this.observed, { childList: true, subtree: true })
}
else if (this.observed?.tagName === 'menulist' && (node = [...mutation.addedNodes].find((added: XUL.Menuitem) => added.tagName === 'menuitem' && added.label?.match(/Better BibTeX.*Quick Copy/)))) {
else if (this.observed?.tagName === 'menulist' && (node = [...mutation.addedNodes].find((added: XUL.MenuItem) => added.tagName === 'menuitem' && added.label?.match(/Better BibTeX.*Quick Copy/)))) {
node.id = 'translator-bbt-quick-copy'
setQuickCopy(node)
}
Expand Down Expand Up @@ -136,7 +134,7 @@ class AutoExportPane {
if (details) details.style.display = auto_exports.length ? 'grid' : 'none'
if (!auto_exports.length) return null

const menulist: XUL.Menulist = doc.querySelector<HTMLElement>('#bbt-prefs-auto-export-select') as XUL.Menulist
const menulist = doc.querySelector<XUL.MenuList>('#bbt-prefs-auto-export-select')
const menupopup = doc.querySelector('#bbt-prefs-auto-export-select menupopup')
let selected
if (menulist.selectedItem) {
Expand All @@ -145,7 +143,7 @@ class AutoExportPane {
}

// list changed
if (Array.from(menupopup.children).map(ae => (ae as unknown as XUL.Menuitem).value).join('\t') !== auto_exports.map(ae => ae.path).join('\t')) {
if (Array.from(menupopup.children).map(ae => (ae as unknown as XUL.MenuItem).value).join('\t') !== auto_exports.map(ae => ae.path).join('\t')) {
menulist.querySelectorAll('menuitem').forEach(e => e.remove())
for (const ae of auto_exports) {
const menuitem = menulist.appendItem(this.label(ae), ae.path)
Expand Down Expand Up @@ -206,7 +204,7 @@ class AutoExportPane {

case 'DOIandURL':
case 'bibtexURL':
(node as unknown as XUL.Menulist).value = selected[field]
(node as unknown as XUL.MenuList).value = selected[field]
break

case 'cacherate':
Expand Down Expand Up @@ -243,7 +241,7 @@ class AutoExportPane {
}

public async remove() {
const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist
const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList
if (!menulist.selectedItem) return

if (!Services.prompt.confirm(null, l10n.localize('better-bibtex_auto-export_delete'), l10n.localize('better-bibtex_auto-export_delete_confirm'))) return
Expand All @@ -256,7 +254,7 @@ class AutoExportPane {
}

public async run() {
const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist
const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList
if (!menulist.selectedItem) return

AutoExport.run(menulist.selectedItem.getAttribute('value'))
Expand All @@ -266,7 +264,7 @@ class AutoExportPane {
public async edit(node) {
let path: string
if (!(path = node.getAttribute('data-ae-path'))) {
const menulist: XUL.Menulist = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.Menulist
const menulist: XUL.MenuList = $window.document.querySelector('#bbt-prefs-auto-export-select') as unknown as XUL.MenuList
path = menulist.selectedItem.getAttribute('value')
}
const ae = AutoExport.get(path)
Expand Down
1 change: 0 additions & 1 deletion content/better-bibtex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ declare const FileUtils: any
import { MenuManager } from 'zotero-plugin-toolkit'
const Menu = new MenuManager

import type { XUL } from '../typings/xul'
import { DebugLog } from 'zotero-plugin/debug-log'
DebugLog.register('Better BibTeX', ['extensions.zotero.translators.better-bibtex.'])

Expand Down
2 changes: 1 addition & 1 deletion setup/templates/items/serialized-item.d.ts.mako
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export interface Attachment extends ItemBase {

export interface RegularItem extends ItemBase {
itemType: ${' | '.join(["'" + itemType + "'" for itemType in itemTypes if itemType not in ['note', 'annotation', 'attachment']])}
citationKey: string
// citationKey: string

// fields common to all items
creators: Array<Creator>
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
"downlevelIteration": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"skipLibCheck": true,
"typeRoots": [
"./node_modules",
"./node_modules/@types",
"./gen/typings",
"./typings"
],
"skipDefaultLibCheck": true,
"types": ["zotero-types"],
"lib": [ "es2017", "dom", "dom.iterable", "webworker", "ES2021.WeakRef" ]
},
"include": [
Expand All @@ -31,7 +32,6 @@
"setup/**/*",
"gen/**/*",
"typings/*",
"node_modules/zotero-types"
],
"exclude": [
"headless",
Expand Down
4 changes: 2 additions & 2 deletions typings/async-indexed-db.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ declare module 'async-indexed-db' {
indexNames: DOMStringList
// transaction: IDBTransaction
autoIncrement: boolean
async add(value: any, key?: IDBValidKey | IDBKeyRange | null): Promise<IDBValidKey>
add(value: any, key?: IDBValidKey | IDBKeyRange | null): Promise<IDBValidKey>
clear(): Promise<void>
// count(key?: IDBValidKey | IDBKeyRange | null): IDBRequest<number>
// createIndex(name: string, keyPath: string | string[], options?: IDBIndexParameters): IDBIndex
Expand All @@ -30,5 +30,5 @@ declare module 'async-indexed-db' {
// put(value: any, key?: IDBValidKey | IDBKeyRange | null): IDBRequest<IDBValidKey>
}

export = AsyncIndexedDB
export default AsyncIndexedDB
}
2 changes: 2 additions & 0 deletions typings/markup.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare type IZoteroMarkupNode = any;

export interface MarkupNode {
nodeName: string
childNodes?: IZoteroMarkupNode[]
Expand Down
8 changes: 4 additions & 4 deletions typings/puqeue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ declare module 'puqeue' {
class Queue {
protected _queue: Handler[]

constructor(options: { name?: string, maxOperationCount?: number } = {})
constructor(options?: { name?: string, maxOperationCount?: number })
get name(): string
get maxOperationCount(): number
set maxOperationCount(maxOperationCount: number): void
set maxOperationCount(maxOperationCount: number)
get operationCount(): number
async add(todo: Handler, options: { priority?: number } = {}): Promise<any>
async waitAll(todo: Handler): Promise<any>
add(todo: Handler, options?: { priority?: number }): Promise<any>
waitAll(todo: Handler): Promise<any>
}

export = Queue
Expand Down
1 change: 0 additions & 1 deletion typings/translators.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export namespace Translators {
minVersion: string
maxVersion: string
translatorType: number
browserSupport: string
inRepository: false
priority: number
target: string
Expand Down
70 changes: 0 additions & 70 deletions typings/xul.d.ts

This file was deleted.

0 comments on commit c52f81a

Please sign in to comment.