Update: TypeScript Definitions
This commit is contained in:
parent
165add92fa
commit
eaffc800f0
@ -2,7 +2,7 @@ import { Addon, addonName } from "./addon";
|
|||||||
import AddonModule from "./module";
|
import AddonModule from "./module";
|
||||||
|
|
||||||
class AddonEvents extends AddonModule {
|
class AddonEvents extends AddonModule {
|
||||||
private notifierCallback: object;
|
private notifierCallback: any;
|
||||||
constructor(parent: Addon) {
|
constructor(parent: Addon) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.notifierCallback = {
|
this.notifierCallback = {
|
||||||
|
266
typing/data.d.ts
vendored
Normal file
266
typing/data.d.ts
vendored
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
// chrome/content/zotero/xpcom/data/dataObject.js
|
||||||
|
|
||||||
|
declare interface _ZoteroDataObject {
|
||||||
|
objectType: string;
|
||||||
|
id: number;
|
||||||
|
libraryID: number;
|
||||||
|
library: _ZoteroLibrary;
|
||||||
|
key: string;
|
||||||
|
libraryKey: string;
|
||||||
|
parentKey: string;
|
||||||
|
parentID: number;
|
||||||
|
itemTypeID: number;
|
||||||
|
parentItem: _ZoteroItem;
|
||||||
|
getRelations: () => object;
|
||||||
|
getRelationsByPredicate: (predicate: string) => string[];
|
||||||
|
addRelation: (predicate: string, object: object) => boolean;
|
||||||
|
hasRelation: (predicate: string, object: object) => boolean;
|
||||||
|
removeRelation: (predicate: string, object: object) => boolean;
|
||||||
|
setRelations: (newRelations: object) => boolean;
|
||||||
|
hasChanged: () => boolean;
|
||||||
|
isEditable: (_op: string = "edit") => boolean;
|
||||||
|
save: (options?: any) => Promise<boolean>;
|
||||||
|
saveTx: (options?: any) => Promise<boolean>;
|
||||||
|
eraseTx: (options?: any) => Promise<boolean>;
|
||||||
|
erase: (options?: any) => Promise<boolean>;
|
||||||
|
_version: number;
|
||||||
|
_synced: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroDataObjectConstructable {
|
||||||
|
new (): _ZoteroDataObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/item.js
|
||||||
|
|
||||||
|
declare interface _ZoteroItem extends _ZoteroDataObject {
|
||||||
|
isRegularItem: () => boolean;
|
||||||
|
isAttachment: () => boolean;
|
||||||
|
isAnnotation: () => boolean;
|
||||||
|
isPDFAttachment: () => boolean;
|
||||||
|
getTags: () => { tag: string; type: number }[];
|
||||||
|
addTag: (name: string, type: number) => boolean;
|
||||||
|
removeTag: (tag: string) => boolean;
|
||||||
|
// Only regular item
|
||||||
|
addToCollection: (id: number) => void;
|
||||||
|
getNotes: () => _ZoteroItem[];
|
||||||
|
getCollections: () => number[];
|
||||||
|
getAttachments: () => _ZoteroItem[];
|
||||||
|
getField: (
|
||||||
|
name: string,
|
||||||
|
unformatted?: boolean,
|
||||||
|
includeBaseMapped?: boolean
|
||||||
|
) => any;
|
||||||
|
setField: (name: string, value: string | number) => void;
|
||||||
|
getCreators: () => {
|
||||||
|
firstName?: string;
|
||||||
|
lastName: string;
|
||||||
|
fieldMode: number;
|
||||||
|
creatorTypeID: number;
|
||||||
|
}[];
|
||||||
|
getCreatorsJSON: () => {
|
||||||
|
firstName?: string;
|
||||||
|
lastName?: string;
|
||||||
|
name?: string;
|
||||||
|
creatorType: string;
|
||||||
|
}[];
|
||||||
|
// Only image annotation & attachment item
|
||||||
|
getFilePathAsync: () => string;
|
||||||
|
// Only notes
|
||||||
|
isNote: () => boolean;
|
||||||
|
getNote: () => string;
|
||||||
|
setNote: (content: string) => void;
|
||||||
|
getNoteTitle: () => string;
|
||||||
|
// Only Annotation
|
||||||
|
annotationType: string;
|
||||||
|
annotationComment: string;
|
||||||
|
annotationText: string;
|
||||||
|
annotationPosition: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroItemConstructable {
|
||||||
|
new (itemTypeOrID?: string): _ZoteroItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/items.js
|
||||||
|
|
||||||
|
declare class _ZoteroItems {
|
||||||
|
[attr: string]: any;
|
||||||
|
get: (
|
||||||
|
ids: number | number[] | string | string[]
|
||||||
|
) => _ZoteroItem | _ZoteroItem[];
|
||||||
|
getAll: (
|
||||||
|
libraryID: number,
|
||||||
|
onlyTopLevel: boolean = false,
|
||||||
|
includeDeleted: boolean = false,
|
||||||
|
asIDs: boolean = false
|
||||||
|
) => Promise<Array<Zotero.Item | number>>;
|
||||||
|
getAPIData: (libraryID, apiPath) => string; // item data in web API format
|
||||||
|
apiDataGenerator: (params: object) => Promise<string>;
|
||||||
|
copyChildItems: (fromItem: _ZoteroItem, toItem: _ZoteroItem) => Promise<void>;
|
||||||
|
moveChildItems: (
|
||||||
|
fromItem: _ZoteroItem,
|
||||||
|
toItem: _ZoteroItem,
|
||||||
|
includeTrashed: boolean = false
|
||||||
|
) => Promise<void>;
|
||||||
|
merge: (item: _ZoteroItem, otherItems: _ZoteroItem[]) => Promise<any>;
|
||||||
|
trash: (ids: number[]) => Promise<void>;
|
||||||
|
trashTx: (ids: number[]) => Promise<void>;
|
||||||
|
emptyTrash: (libraryID: number, options: object = {}) => Promise<number>; // return deleted items count
|
||||||
|
addToPublications: (
|
||||||
|
items: _ZoteroItem[],
|
||||||
|
options: object = {}
|
||||||
|
) => Promise<void>;
|
||||||
|
removeFromPublications: (items: _ZoteroItem[]) => Promise<void>;
|
||||||
|
purge: () => Promise<void>; // Purge unused data values
|
||||||
|
getFirstCreatorFromJSON: (json: JSON) => any;
|
||||||
|
getFirstCreatorFromData: (itemTypeID: number, creatorsData: object) => string;
|
||||||
|
keepParents: (items: _ZoteroItem[]) => _ZoteroItem[]; // Returns an array of items with children of selected parents removed
|
||||||
|
getSortTitle: (title: string | number) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/collection.js
|
||||||
|
|
||||||
|
declare interface _ZoteroCollection extends _ZoteroDataObject {
|
||||||
|
name: string;
|
||||||
|
version: number;
|
||||||
|
synced: boolean;
|
||||||
|
treeViewID: string;
|
||||||
|
treeViewImage: string;
|
||||||
|
loadFromRow: (row: object[]) => void;
|
||||||
|
hasChildCollections: (includeTrashed: boolean = false) => boolean;
|
||||||
|
hasChildItems: () => boolean;
|
||||||
|
getChildCollections: (asIDs: boolean) => _ZoteroCollection[] | number[];
|
||||||
|
getChildItems: (
|
||||||
|
asIDs: boolean,
|
||||||
|
includeDeleted: boolean
|
||||||
|
) => _ZoteroItem[] | number[];
|
||||||
|
addItem: (itemID: number, options: object = {}) => Promise<any>; // do not require save
|
||||||
|
addItems: (itemIDs: number[], options: object = {}) => Promise<any>; // do not require save
|
||||||
|
removeItem: (itemID: number, options: object = {}) => Promise<any>;
|
||||||
|
removeItems: (itemIDs: number[], options: object = {}) => Promise<any>;
|
||||||
|
hasItem: (item: number | _ZoteroItem) => boolean;
|
||||||
|
hasDescendent: (type: string, id: number) => boolean;
|
||||||
|
diff: (collection: _ZoteroCollection, includeMatches: boolean) => Array<any>;
|
||||||
|
clone: (libraryID: number) => _ZoteroCollection; // not saved
|
||||||
|
isCollection: () => true;
|
||||||
|
serialize: (nested: boolean) => {
|
||||||
|
primary: {
|
||||||
|
collectionID: number;
|
||||||
|
libraryID: number;
|
||||||
|
key: string;
|
||||||
|
};
|
||||||
|
fields: {
|
||||||
|
name: string;
|
||||||
|
parentKey: string;
|
||||||
|
};
|
||||||
|
childCollections: _ZoteroCollection[];
|
||||||
|
childItems: _ZoteroItem[];
|
||||||
|
descendents: object[];
|
||||||
|
};
|
||||||
|
fromJSON: (json: JSON, options: object = {}) => void;
|
||||||
|
toJSON: (options: object = {}) => JSON;
|
||||||
|
getDescendents: (
|
||||||
|
nested: boolean,
|
||||||
|
type: string,
|
||||||
|
includeDeletedItems: boolean = false,
|
||||||
|
level: number = 1
|
||||||
|
) => object[];
|
||||||
|
getLinkedCollection: (
|
||||||
|
libraryID: number,
|
||||||
|
bidrectional: boolean
|
||||||
|
) => Promise<_ZoteroCollection>;
|
||||||
|
addLinkedCollection: (collection: _ZoteroCollection) => Promise<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroCollectionConstructable {
|
||||||
|
new (params: object = {}): _ZoteroCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/collections.js
|
||||||
|
|
||||||
|
declare class _ZoteroCollections {
|
||||||
|
getName: () => string;
|
||||||
|
getChildItems: (arg1: boolean, arg2: boolean) => Array<_ZoteroItem>;
|
||||||
|
getByLibrary: (
|
||||||
|
libraryID: number,
|
||||||
|
recursive: boolean = false
|
||||||
|
) => _ZoteroCollection[];
|
||||||
|
getByParent: (
|
||||||
|
parentCollectionID: number,
|
||||||
|
recursive: boolean = false
|
||||||
|
) => _ZoteroCollection[];
|
||||||
|
getCollectionsContainingItems: (
|
||||||
|
itemIDs: number[],
|
||||||
|
asIDs: boolean = false
|
||||||
|
) => _ZoteroItem[] | number[];
|
||||||
|
registerChildCollection: (
|
||||||
|
collectionID: number,
|
||||||
|
childCollectionID: number
|
||||||
|
) => void;
|
||||||
|
unregisterChildCollection: (
|
||||||
|
collectionID: number,
|
||||||
|
childCollectionID: number
|
||||||
|
) => void;
|
||||||
|
registerChildItem: (collectionID: number, itemID: number) => void;
|
||||||
|
unregisterChildItem: (collectionID: number, itemID: number) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/library.js
|
||||||
|
|
||||||
|
declare interface _ZoteroLibrary {
|
||||||
|
libraryID: number;
|
||||||
|
id: number;
|
||||||
|
libraryType: "user" | "group";
|
||||||
|
libraryTypeID: number;
|
||||||
|
isGroup: boolean;
|
||||||
|
libraryVersion: number;
|
||||||
|
syncable: boolean;
|
||||||
|
lastSync: string;
|
||||||
|
name: string;
|
||||||
|
treeViewID: string;
|
||||||
|
treeViewImage: string;
|
||||||
|
hasTrash: boolean;
|
||||||
|
allowsLinkedFiles: boolean;
|
||||||
|
editable: boolean;
|
||||||
|
filesEditable: boolean;
|
||||||
|
storageVersion: number;
|
||||||
|
archived: boolean;
|
||||||
|
storageDownloadNeeded: boolean;
|
||||||
|
loadAllDataTypes: () => Promise<any>;
|
||||||
|
getDataLoaded: (objectType: string) => boolean;
|
||||||
|
setDataLoading: (objectType: string) => void;
|
||||||
|
getDataLoadedPromise: (objectType: string) => Promise<any>;
|
||||||
|
setDataLoaded: (objectType: string) => void;
|
||||||
|
waitForDataLoad: (objectType: string) => Promise<any>;
|
||||||
|
isChildObjectAllowed: (type: string) => boolean;
|
||||||
|
updateLastSyncTime: () => void;
|
||||||
|
save: (options?: any) => Promise<boolean>;
|
||||||
|
saveTx: (options?: any) => Promise<boolean>;
|
||||||
|
eraseTx: (options?: any) => Promise<boolean>;
|
||||||
|
erase: (options?: any) => Promise<boolean>;
|
||||||
|
hasCollections: () => boolean;
|
||||||
|
updateCollections: () => Promise<any>;
|
||||||
|
hasSearches: () => boolean;
|
||||||
|
updateSearches: () => Promise<any>;
|
||||||
|
hasItems: () => Promise<boolean>;
|
||||||
|
hasItem: (item: _ZoteroItem) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroLibraryConstructable {
|
||||||
|
new (params: object = {}): _ZoteroLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/libraries.js
|
||||||
|
|
||||||
|
declare class _ZoteroLibraries {
|
||||||
|
[attr: string]: any;
|
||||||
|
userLibraryID: number = 1;
|
||||||
|
userLibrary: _ZoteroLibrary;
|
||||||
|
register: (library: _ZoteroLibrary) => void;
|
||||||
|
unregister: (libraryID: number) => void;
|
||||||
|
init: () => void;
|
||||||
|
exists: (libraryID: number) => boolean;
|
||||||
|
getAll: () => _ZoteroLibrary[];
|
||||||
|
get: (libraryID: number) => _ZoteroLibrary;
|
||||||
|
}
|
176
typing/global.d.ts
vendored
176
typing/global.d.ts
vendored
@ -81,165 +81,67 @@ declare const OS: {
|
|||||||
|
|
||||||
declare const NetUtil: { [attr: string]: any };
|
declare const NetUtil: { [attr: string]: any };
|
||||||
|
|
||||||
declare interface ZoteroItem {
|
|
||||||
getFilePathAsync(): any;
|
|
||||||
id: number;
|
|
||||||
isRegularItem: () => boolean;
|
|
||||||
isNote: () => boolean;
|
|
||||||
getNote: () => string;
|
|
||||||
setNote: (string) => void;
|
|
||||||
getNoteTitle: () => string;
|
|
||||||
isAttachment: () => boolean;
|
|
||||||
isAnnotation: () => boolean;
|
|
||||||
isPDFAttachment: () => boolean;
|
|
||||||
addTag: (name: string, type: number) => boolean;
|
|
||||||
removeTag(tag: string): boolean;
|
|
||||||
itemTypeID: number;
|
|
||||||
libraryID: number;
|
|
||||||
parentID: number;
|
|
||||||
parentItem: ZoteroItem;
|
|
||||||
key: string;
|
|
||||||
_version: any;
|
|
||||||
getField: (
|
|
||||||
name: string,
|
|
||||||
unformatted?: boolean,
|
|
||||||
includeBaseMapped?: boolean
|
|
||||||
) => any;
|
|
||||||
setField: (name: string, value: string | number) => void;
|
|
||||||
getCreators: () => {
|
|
||||||
firstName?: string;
|
|
||||||
lastName: string;
|
|
||||||
fieldMode: number;
|
|
||||||
creatorTypeID: number;
|
|
||||||
}[];
|
|
||||||
getCreatorsJSON: () => {
|
|
||||||
firstName?: string;
|
|
||||||
lastName?: string;
|
|
||||||
name?: string;
|
|
||||||
creatorType: string;
|
|
||||||
}[];
|
|
||||||
getNotes: () => ZoteroItem[];
|
|
||||||
getCollections: () => number[];
|
|
||||||
getAttachments: () => ZoteroItem[];
|
|
||||||
getTags: () => { tag: string; type: number }[];
|
|
||||||
annotationType?: string;
|
|
||||||
annotationComment?: string;
|
|
||||||
annotationText?: string;
|
|
||||||
annotationPosition: string;
|
|
||||||
save: (obj?: any) => Promise<void>;
|
|
||||||
saveTx: (obj?: any) => Promise<void>;
|
|
||||||
addToCollection(id: number);
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://stackoverflow.com/questions/39040108/import-class-in-definition-file-d-ts
|
// https://stackoverflow.com/questions/39040108/import-class-in-definition-file-d-ts
|
||||||
declare const Zotero: {
|
declare const Zotero: {
|
||||||
[attr: string]: any;
|
[attr: string]: any;
|
||||||
debug: (args: any) => void;
|
debug: (message, level?, maxDepth?, stack?) => void;
|
||||||
|
log: (
|
||||||
|
message,
|
||||||
|
type?,
|
||||||
|
sourceName?,
|
||||||
|
sourceLine?,
|
||||||
|
lineNumber?,
|
||||||
|
columnNumber?
|
||||||
|
) => void;
|
||||||
Prefs: {
|
Prefs: {
|
||||||
get: (key: string) => any;
|
get: (pref: string, global: boolean = false) => boolean | string | number;
|
||||||
set: (key: string, value: any) => any;
|
set: (
|
||||||
|
pref: string,
|
||||||
|
value: boolean | string | number,
|
||||||
|
global: boolean = false
|
||||||
|
) => any;
|
||||||
};
|
};
|
||||||
Items: {
|
Notifier: {
|
||||||
get: (key: string | number) => ZoteroItem;
|
registerObserver: (
|
||||||
|
ref: { notify: Function },
|
||||||
|
types?: string[],
|
||||||
|
id?: string,
|
||||||
|
priority?: null
|
||||||
|
) => string;
|
||||||
|
unregisterObserver: (id: String) => void;
|
||||||
};
|
};
|
||||||
Reader: Reader;
|
DataObject: _ZoteroDataObjectConstructable;
|
||||||
Notes: Notes;
|
Item: _ZoteroItemConstructable;
|
||||||
Knowledge4Zotero: import("../src/addon");
|
Items: _ZoteroItems;
|
||||||
};
|
Collection: _ZoteroCollectionConstructable;
|
||||||
|
Collections: _ZoteroCollection;
|
||||||
declare const ZoteroPane: {
|
Library: _ZoteroLibraryConstructable;
|
||||||
[attr: string]: any;
|
Libraries: _ZoteroLibraries;
|
||||||
canEdit: () => boolean;
|
Reader: _ZoteroReader;
|
||||||
displayCannotEditLibraryMessage: () => void;
|
EditorInstance: _ZoteroEditorInstanceConstructable;
|
||||||
getSelectedCollection: (arg: boolean) => ZoteroCollection;
|
EditorInstanceUtilities: _ZoteroEditorInstanceUtilities;
|
||||||
getSelectedItems: () => Array<ZoteroItem>;
|
Notes: _ZoteroNotes;
|
||||||
|
AddonTemplate: import("../src/addon");
|
||||||
};
|
};
|
||||||
|
|
||||||
declare const ZoteroPane_Local: {
|
declare const ZoteroPane_Local: {
|
||||||
getSelectedCollection: () => ZoteroCollection;
|
getSelectedCollection: () => _ZoteroCollection;
|
||||||
newNote: (popup?, parentKey?, text?, citeURI?) => Promise<number>;
|
newNote: (popup?, parentKey?, text?, citeURI?) => Promise<number>;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare const Zotero_File_Interface: {
|
declare const Zotero_File_Interface: {
|
||||||
exportItemsToClipboard: (items: ZoteroItem[], translatorID: string) => void;
|
exportItemsToClipboard: (items: _ZoteroItem[], translatorID: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare class ZoteroCollection {
|
|
||||||
getName: () => string;
|
|
||||||
getChildItems: (arg1: boolean, arg2: boolean) => Array<ZoteroItem>;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare class Zotero_File_Exporter {
|
declare class Zotero_File_Exporter {
|
||||||
items: ZoteroItem[];
|
items: _ZoteroItem[];
|
||||||
save = async () => {};
|
save = async () => {};
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const Components: any;
|
declare const Components: any;
|
||||||
declare const Services: any;
|
declare const Services: any;
|
||||||
|
|
||||||
declare class Reader {
|
|
||||||
[attr: string]: any;
|
|
||||||
_readers: Array<ReaderObj>;
|
|
||||||
getByTabID: (tabID: string) => ReaderObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare class ReaderObj {
|
|
||||||
[attr: string]: any;
|
|
||||||
itemID: number;
|
|
||||||
_iframeWindow: XULWindow;
|
|
||||||
_initPromise: Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare class EditorInstance {
|
|
||||||
[attr: string]: any;
|
|
||||||
_iframeWindow: XULWindow;
|
|
||||||
_item: ZoteroItem;
|
|
||||||
_initPromise: Promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare class Notes {
|
|
||||||
_editorInstances: EditorInstance[];
|
|
||||||
registerEditorInstance: (instance: EditorInstance) => void;
|
|
||||||
// custom
|
|
||||||
_registerEditorInstance?: (instance: EditorInstance) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare const ZoteroContextPane: {
|
declare const ZoteroContextPane: {
|
||||||
[attr: string]: any;
|
[attr: string]: any;
|
||||||
getActiveEditor: () => EditorInstance;
|
getActiveEditor: () => _ZoteroEditorInstance;
|
||||||
};
|
};
|
||||||
|
|
||||||
declare class Annotation {
|
|
||||||
text: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare const Zotero_Tabs: {
|
|
||||||
_getTab(tabId: string);
|
|
||||||
jump(workspaceTabId: Number);
|
|
||||||
close(tabId: string);
|
|
||||||
select(tabId: string);
|
|
||||||
add(arg0: {
|
|
||||||
type: string;
|
|
||||||
title: any;
|
|
||||||
index: any;
|
|
||||||
data: object;
|
|
||||||
select: boolean;
|
|
||||||
onClose: Function;
|
|
||||||
});
|
|
||||||
_tabs: Array<any>;
|
|
||||||
selectedID: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const openWindowByType: (
|
|
||||||
uri: string,
|
|
||||||
type: string,
|
|
||||||
features: string
|
|
||||||
) => Window;
|
|
||||||
|
|
||||||
declare class Shortcut {
|
|
||||||
id: number;
|
|
||||||
func: any;
|
|
||||||
modifiers: string;
|
|
||||||
key: string;
|
|
||||||
keycode?: string;
|
|
||||||
}
|
|
||||||
|
121
typing/note.d.ts
vendored
Normal file
121
typing/note.d.ts
vendored
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
// chrome/content/zotero/xpcom/editorInstance.js
|
||||||
|
|
||||||
|
declare interface _ZoteroEditorInstance {
|
||||||
|
[attr: string]: any;
|
||||||
|
init: (options: {
|
||||||
|
onNavigate?: Function;
|
||||||
|
item?: _ZoteroItem;
|
||||||
|
reloaded?: boolean;
|
||||||
|
viewMode?: string;
|
||||||
|
readOnly?: boolean;
|
||||||
|
disableUI?: boolean;
|
||||||
|
onReturn?: Function;
|
||||||
|
iframeWindow?: XUL.Element;
|
||||||
|
popup?: any;
|
||||||
|
state?: any;
|
||||||
|
placeholder?: any;
|
||||||
|
}) => Promise<void>;
|
||||||
|
uninit: () => Promise<void>;
|
||||||
|
focus: () => void;
|
||||||
|
notify: (event, type, ids, extraData) => Promise<void>;
|
||||||
|
saveSync: () => void;
|
||||||
|
insertAnnotations: (annotations: any) => Promise<void>;
|
||||||
|
_postMessage: (message: any) => void;
|
||||||
|
_isReadOnly: () => boolean;
|
||||||
|
_getFont: () => { fontSize: number; fontFamily: string };
|
||||||
|
_handleFontChange: () => void;
|
||||||
|
_handleStyleChange: () => void;
|
||||||
|
_handleSpellCheckChange: () => void;
|
||||||
|
_showInLibrary: (ids: number | number[]) => void;
|
||||||
|
importImages: (annotations: any) => Promise<void>;
|
||||||
|
_digestItems: (ids: number[]) => string | null;
|
||||||
|
_messageHandler: (e: MessageEvent) => Promise<void>;
|
||||||
|
_updateCitationItems: (citationItemsList: object[]) => Promise<void>;
|
||||||
|
_feedSubscription: (subscription: object) => Promise<void>;
|
||||||
|
_importImage: (src: string, download: boolean) => Promise<string>;
|
||||||
|
_openPopup: (
|
||||||
|
x: number,
|
||||||
|
y: number,
|
||||||
|
pos: any,
|
||||||
|
itemGroups: any
|
||||||
|
) => Promise<void>;
|
||||||
|
_updateCitationItems: (citationItemsList: object[]) => Promise<void>;
|
||||||
|
_getSpellChecker: () => any;
|
||||||
|
_ensureNoteCreated: () => Promise<void>;
|
||||||
|
_save: (noteData: object, skipDateModifiedUpdate: boolean) => Promise<void>;
|
||||||
|
_arrayBufferToBase64: (buffer: Buffer) => string;
|
||||||
|
_dataURLtoBlob: (dataurl: string) => Blob | null;
|
||||||
|
_getDataURL: (item: _ZoteroItem) => Promise<string>;
|
||||||
|
_openQuickFormatDialog: (
|
||||||
|
nodeID: number,
|
||||||
|
citationData: any,
|
||||||
|
filterLibraryIDs: any,
|
||||||
|
openedEmpty: any
|
||||||
|
) => Promise<void>;
|
||||||
|
getItemFromURIs: (uris: string[]) => Promise<_ZoteroItem>;
|
||||||
|
createNoteFromAnnotations: (
|
||||||
|
annotations: _ZoteroItem[],
|
||||||
|
parentID: number
|
||||||
|
) => Promise<_ZoteroItem>;
|
||||||
|
_iframeWindow: XULWindow;
|
||||||
|
_item: _ZoteroItem;
|
||||||
|
_initPromise: Promise;
|
||||||
|
_viewMode: string;
|
||||||
|
_reloaded: boolean;
|
||||||
|
_readOnly: boolean;
|
||||||
|
_filesReadOnly: boolean;
|
||||||
|
_disableUI: boolean;
|
||||||
|
_onReturn: Function;
|
||||||
|
_popup: any;
|
||||||
|
_state: any;
|
||||||
|
_disableSaving: boolean;
|
||||||
|
_subscriptions: [];
|
||||||
|
_quickFormatWindow: any;
|
||||||
|
_citationItemsList: any;
|
||||||
|
_prefObserverIDs: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroEditorInstanceConstructable {
|
||||||
|
new (): _ZoteroEditorInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class _ZoteroEditorInstanceUtilities {
|
||||||
|
serializeAnnotations: (
|
||||||
|
annotations: object[],
|
||||||
|
skipEmbeddingItemData: boolean
|
||||||
|
) => { html: string; citationItems: _ZoteroItem[] };
|
||||||
|
_transformTextToHTML: (text: string) => string;
|
||||||
|
_formatCitationItemPreview: (citationItem: _ZoteroItem) => string;
|
||||||
|
formatCitation: (citation: object) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// chrome/content/zotero/xpcom/data/notes.js
|
||||||
|
|
||||||
|
declare class _ZoteroNotes {
|
||||||
|
[attr: string]: any;
|
||||||
|
AUTO_SYNC_DELAY: number = 15;
|
||||||
|
MAX_TITLE_LENGTH: number = 120;
|
||||||
|
defaultNote: string;
|
||||||
|
notePrefix: string;
|
||||||
|
noteSuffix: string;
|
||||||
|
_editorInstances: _ZoteroEditorInstance[];
|
||||||
|
_downloadInProgressPromise: Promise;
|
||||||
|
registerEditorInstance: (instance: _ZoteroEditorInstance) => void;
|
||||||
|
unregisterEditorInstance: (instance: _ZoteroEditorInstance) => Promise<void>;
|
||||||
|
updateUser: (fromUserID: number, toUserID: number) => Promise<void>;
|
||||||
|
replaceAllItemKeys: (
|
||||||
|
item: _ZoteroItem,
|
||||||
|
itemKeyMap: Map<string, string>
|
||||||
|
) => void;
|
||||||
|
replaceItemKey: (
|
||||||
|
item: _ZoteroItem,
|
||||||
|
fromItemKey: string,
|
||||||
|
toItemKey: string
|
||||||
|
) => void;
|
||||||
|
getExportableNote: (item: _ZoteroItem) => Promise<string>;
|
||||||
|
ensureEmbeddedImagesAreAvailable: (item: _ZoteroItem) => Promise<boolean>;
|
||||||
|
copyEmbeddedImages: (fromItemKey: string, toItemKey: string) => Promise<void>;
|
||||||
|
promptToIgnoreMissingImage: () => boolean;
|
||||||
|
deleteUnusedEmbeddedImages: (item: _ZoteroItem) => Promise<void>;
|
||||||
|
hasSchemaVersion: (note: _ZoteroItem) => boolean;
|
||||||
|
}
|
16
typing/pane.d.ts
vendored
Normal file
16
typing/pane.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// chrome/content/zotero/zoteroPane.js
|
||||||
|
|
||||||
|
declare const ZoteroPane: {
|
||||||
|
[attr: string]: any;
|
||||||
|
collectionsView: any;
|
||||||
|
itemsView: {
|
||||||
|
onSelect: {
|
||||||
|
addListener: (Function) => any;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
progressWindow: any;
|
||||||
|
canEdit: () => boolean;
|
||||||
|
displayCannotEditLibraryMessage: () => void;
|
||||||
|
getSelectedCollection: (arg: boolean) => _ZoteroCollection;
|
||||||
|
getSelectedItems: () => Array<_ZoteroItem>;
|
||||||
|
};
|
154
typing/reader.d.ts
vendored
Normal file
154
typing/reader.d.ts
vendored
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
// chrome/content/zotero/xpcom/reader.js
|
||||||
|
|
||||||
|
declare interface _ZoteroReaderState {
|
||||||
|
pageIndex: number;
|
||||||
|
scale: string;
|
||||||
|
rotation: number;
|
||||||
|
top: number;
|
||||||
|
left: number;
|
||||||
|
sidebarView: number;
|
||||||
|
sidebarWidth: number;
|
||||||
|
scrollMode: number;
|
||||||
|
spreadMode: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare interface _ZoteroReaderLocation {
|
||||||
|
annotationKey: String;
|
||||||
|
pageIndex: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class _ZoteroReaderInstance {
|
||||||
|
[attr: string]: any;
|
||||||
|
constructor();
|
||||||
|
pdfStateFileName: string = ".zotero-pdf-state";
|
||||||
|
annotationItemIDs: number[];
|
||||||
|
itemID: number;
|
||||||
|
state: _ZoteroReaderState;
|
||||||
|
_instanceID: string;
|
||||||
|
_window: Window;
|
||||||
|
_iframeWindow: Window;
|
||||||
|
_title: string;
|
||||||
|
_isReaderInitialized: boolean;
|
||||||
|
_showItemPaneToggle: boolean;
|
||||||
|
_initPromise: Promise;
|
||||||
|
focus: () => void;
|
||||||
|
open: (options: {
|
||||||
|
itemID: number;
|
||||||
|
state: _ZoteroReaderState;
|
||||||
|
location: _ZoteroReaderLocation;
|
||||||
|
}) => Promise<boolean>;
|
||||||
|
updateTitle: () => void;
|
||||||
|
setAnnotations: (items: _ZoteroItem[]) => void;
|
||||||
|
unsetAnnotations(keys: number[] | string[]);
|
||||||
|
navigate: (location: _ZoteroReaderLocation) => Promise<void>;
|
||||||
|
enableAddToNote: (enable: boolean) => void;
|
||||||
|
setSidebarWidth: (width: number) => void;
|
||||||
|
setSidebarOpen: (open: boolean) => void;
|
||||||
|
focusLastToolbarButton: () => void;
|
||||||
|
tabToolbar: (reverse: any) => void;
|
||||||
|
focusFirst: () => void;
|
||||||
|
setBottomPlaceholderHeight: (height: number) => Promise<void>;
|
||||||
|
setToolbarPlaceholderWidth: (height: number) => Promise<void>;
|
||||||
|
isHandToolActive: () => boolean;
|
||||||
|
isZoomAutoActive: () => boolean;
|
||||||
|
isZoomPageWidthActive: () => boolean;
|
||||||
|
isZoomPageHeightActive: () => boolean;
|
||||||
|
allowNavigateFirstPage: () => boolean;
|
||||||
|
allowNavigateLastPage: () => boolean;
|
||||||
|
allowNavigateBack: () => boolean;
|
||||||
|
allowNavigateForward: () => boolean;
|
||||||
|
promptToTransferAnnotations: () => boolean;
|
||||||
|
promptToDeletePages: (num: number) => boolean;
|
||||||
|
reload: () => void;
|
||||||
|
menuCmd: (
|
||||||
|
cmd: "transferFromPDF" | "export" | "showInLibrary"
|
||||||
|
) => Promise<void>;
|
||||||
|
_initIframeWindow: () => boolean;
|
||||||
|
_setState: (state: _ZoteroReaderState) => Promise<void>;
|
||||||
|
_getState: () => Promise<_ZoteroReaderState>;
|
||||||
|
_isReadOnly: () => boolean;
|
||||||
|
_dataURLtoBlob: (dataurl: string) => Blob;
|
||||||
|
_getColorIcon: (color: string, selected: boolean) => string;
|
||||||
|
_openTagsPopup: (item: _ZoteroItem, selector: string) => void;
|
||||||
|
_openPagePopup: (data: any) => void;
|
||||||
|
_openAnnotationPopup: (data: any) => void;
|
||||||
|
_openColorPopup: (data: any) => void;
|
||||||
|
_openThumbnailPopup: (data: any) => void;
|
||||||
|
_openSelectorPopup: (data: any) => void;
|
||||||
|
_postMessage: (message: object, transfer?: any) => Promise<void>;
|
||||||
|
_handleMessage: (event: MessageEvent) => Promise<void>;
|
||||||
|
_waitForReader: () => Promise<void>;
|
||||||
|
_getAnnotation: (item: _ZoteroItem) => JSON | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class _ZoteroReaderTab extends _ZoteroReaderInstance {
|
||||||
|
constructor(options: {
|
||||||
|
itemID: number;
|
||||||
|
title: startCloseTimer;
|
||||||
|
sidebarWidth: number;
|
||||||
|
sidebarOpen: boolean;
|
||||||
|
bottomPlaceholderHeight: number;
|
||||||
|
index: number;
|
||||||
|
tabID: string;
|
||||||
|
background: boolean;
|
||||||
|
});
|
||||||
|
close: () => void;
|
||||||
|
_toggleNoteSidebar: (isToggled?: boolean) => void;
|
||||||
|
_setTitleValue: (title: string) => void;
|
||||||
|
_addToNote: (annotations: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class _ZoteroReaderWindow extends _ZoteroReaderInstance {
|
||||||
|
constructor(options: {
|
||||||
|
sidebarWidth: number;
|
||||||
|
sidebarOpen: boolean;
|
||||||
|
bottomPlaceholderHeigh: number;
|
||||||
|
});
|
||||||
|
init: () => void;
|
||||||
|
close: () => void;
|
||||||
|
_setTitleValue: (title: string) => void;
|
||||||
|
_handleKeyPress: (event: KeyboardEvent) => void;
|
||||||
|
_onViewMenuOpen: () => void;
|
||||||
|
_onGoMenuOpen: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class _ZoteroReader {
|
||||||
|
[attr: string]: any;
|
||||||
|
constructor();
|
||||||
|
_readers: Array<_ZoteroReaderInstance>;
|
||||||
|
_sidebarWidth: number;
|
||||||
|
_sidebarOpen: boolean;
|
||||||
|
_bottomPlaceholderHeight: number;
|
||||||
|
_notifierID: string;
|
||||||
|
onChangeSidebarWidth: (width: number) => void;
|
||||||
|
onChangeSidebarOpen: (open: boolean) => void;
|
||||||
|
getSidebarWidth: () => number;
|
||||||
|
init: () => Promise<void>;
|
||||||
|
_loadSidebarState: () => void;
|
||||||
|
_setSidebarState: () => void;
|
||||||
|
getSidebarOpen: () => boolean;
|
||||||
|
setSidebarWidth: (width: number) => void;
|
||||||
|
setSidebarOpen: (open: boolean) => void;
|
||||||
|
setBottomPlaceholderHeight: (height: number) => void;
|
||||||
|
notify: (event, type, ids, extraData) => void;
|
||||||
|
getByTabID: (tabID: string) => _ZoteroReaderInstance;
|
||||||
|
getWindowStates: () => { type: "reader"; itemID: number; title: string }[];
|
||||||
|
openURI: (
|
||||||
|
itemURI: string,
|
||||||
|
location: _ZoteroReaderLocation,
|
||||||
|
options: any
|
||||||
|
) => Promise<void>;
|
||||||
|
open: (
|
||||||
|
itemID: number,
|
||||||
|
location: _ZoteroReaderLocation,
|
||||||
|
options: {
|
||||||
|
title: string;
|
||||||
|
tabIndex: number;
|
||||||
|
tabID: string;
|
||||||
|
openInBackground: boolean;
|
||||||
|
openInWindow: boolean;
|
||||||
|
allowDuplicate: boolean;
|
||||||
|
} = {}
|
||||||
|
) => Promise<void>;
|
||||||
|
triggerAnnotationsImportCheck: (itemID: number) => Promise<void>;
|
||||||
|
}
|
51
typing/tabs.d.ts
vendored
Normal file
51
typing/tabs.d.ts
vendored
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// chrome/content/zotero/tabs.js
|
||||||
|
|
||||||
|
declare interface TabInstance {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
title: string;
|
||||||
|
data?: any;
|
||||||
|
selected?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare const Zotero_Tabs: {
|
||||||
|
selectedID: string;
|
||||||
|
selectedType: string;
|
||||||
|
selectedIndex: number;
|
||||||
|
deck: Element;
|
||||||
|
_tabs: TabInstance[];
|
||||||
|
|
||||||
|
_getTab: (tabId: string) => { tab: TabInstance; tabIndex: number };
|
||||||
|
_update: () => void;
|
||||||
|
getTabIDByItemID: (itemID: number) => string;
|
||||||
|
init: () => void;
|
||||||
|
getState: () => TabInstance[];
|
||||||
|
restoreState: (tabs: TabInstance[]) => void;
|
||||||
|
add: (options: {
|
||||||
|
id: string;
|
||||||
|
type: string;
|
||||||
|
data: any;
|
||||||
|
title: string;
|
||||||
|
index: number;
|
||||||
|
select: boolean;
|
||||||
|
onClose: Function;
|
||||||
|
}) => { id: string; container: XUL.Element };
|
||||||
|
rename: (id: string, title: string) => void;
|
||||||
|
updateLibraryTabIcon: () => void;
|
||||||
|
close: (ids: string | string[]) => void;
|
||||||
|
closeAll: () => void;
|
||||||
|
undoClose: () => void;
|
||||||
|
move: (id: string, newIndex: number) => void;
|
||||||
|
select: (id: string, reopening: boolean, options?: any) => void;
|
||||||
|
unload: (id: string) => void;
|
||||||
|
unloadUnusedTabs: () => void;
|
||||||
|
selectPrev: () => void;
|
||||||
|
selectPrev: () => void;
|
||||||
|
selectNext: () => void;
|
||||||
|
selectLast: () => void;
|
||||||
|
jump: (index: number) => void;
|
||||||
|
_openMenu: (x: number, y: number, id: string) => void;
|
||||||
|
_updateTabBar: () => void;
|
||||||
|
_showTabBar: () => void;
|
||||||
|
_hideTabBar: () => void;
|
||||||
|
};
|
2
typing/xul.d.ts
vendored
2
typing/xul.d.ts
vendored
@ -44,7 +44,7 @@ declare namespace XUL {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ItemElement extends XUL.Element {
|
class ItemElement extends XUL.Element {
|
||||||
public item?: ZoteroItem;
|
public item?: _ZoteroItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Box extends XUL.Element {
|
class Box extends XUL.Element {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user