Skip to content

Commit

Permalink
update(api): bump up to v0.1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyChen777 committed Apr 6, 2024
1 parent d9d7dc0 commit 3ab512e
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 8 deletions.
12 changes: 6 additions & 6 deletions paperlib-api/dist/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import { BrowserWindow } from 'electron';
import { BrowserWindowConstructorOptions } from 'electron';
import Cite from 'citation-js';
import { CookieJar } from 'tough-cookie';
import { List } from 'realm';
import { ObjectID } from 'bson';
Expand Down Expand Up @@ -2233,9 +2232,10 @@ declare type Proxied<T> = {

declare class ReferenceService {
private readonly _paperService;
private readonly _hookService;
private readonly _preferenceService;
private readonly _logService;
constructor(_paperService: PaperService, _preferenceService: PreferenceService, _logService: LogService);
constructor(_paperService: PaperService, _hookService: HookService, _preferenceService: PreferenceService, _logService: LogService);
private _setupCitePlugin;
/**
* Abbreviate the publication name according to the abbreviation list set in the preference interface.
Expand All @@ -2254,19 +2254,19 @@ declare class ReferenceService {
* @param cite - The cite object.
* @returns The BibItem.
*/
exportBibItem(cite: Cite): string;
exportBibItem(paperEntities: PaperEntity[]): Promise<string>;
/**
* Export BibTex key.
* @param cite - The cite object.
* @returns The BibTex key.
*/
exportBibTexKey(cite: Cite): string;
exportBibTexKey(paperEntities: PaperEntity[]): Promise<string>;
/**
* Export BibTex body string.
* @param cite - The cite object.
* @returns The BibTex body string.
*/
exportBibTexBody(cite: Cite): string;
exportBibTexBody(paperEntities: PaperEntity[]): Promise<string>;
/**
* Export BibTex body string in folder.
* @param folderName - The folder name.
Expand All @@ -2277,7 +2277,7 @@ declare class ReferenceService {
* @param cite - The cite object.
* @returns The plain text.
*/
exportPlainText(cite: Cite): Promise<string>;
exportPlainText(paperEntities: PaperEntity[]): Promise<string>;
/**
* Export plain text in folder.
* @param folderName - The folder name.
Expand Down
60 changes: 59 additions & 1 deletion paperlib-api/dist/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ function mergeMetadata(originPaperEntityDraft, paperEntityDraft, scrapedpaperEnt
return { paperEntityDraft, mergePriorityLevel };
}

var Process = /* @__PURE__ */ ((Process2) => {
Process2["main"] = "mainProcess";
Process2["extension"] = "extensionProcess";
Process2["renderer"] = "rendererProcess";
return Process2;
})(Process || {});

const formatString = ({
str,
removeNewline = false,
Expand Down Expand Up @@ -186,6 +193,57 @@ function isLocalPath(string) {
return /^\.{0,2}\//.test(string);
}

const isMac = process.platform === "darwin";
const formatShortcut = (event) => {
let shortcutKeys = [];
if (event.ctrlKey) {
shortcutKeys.push("Control");
}
if (event.metaKey) {
if (isMac) {
shortcutKeys.push("Command");
} else {
shortcutKeys.push("Meta");
}
}
if (event.altKey) {
shortcutKeys.push("Alt");
}
if (event.shiftKey) {
shortcutKeys.push("Shift");
}
let key = event.key.trim();
if (key !== "Meta") {
if (event.code === "Space") {
key = event.code.trim();
}
if (key.length === 1) {
key = key.toUpperCase();
}
if (!shortcutKeys.includes(key)) {
shortcutKeys.push(key);
}
}
return shortcutKeys;
};
const convertKeyboardEvent = (e) => {
return {
ctrlKey: e.ctrlKey,
metaKey: e.metaKey,
altKey: e.altKey,
shiftKey: e.shiftKey,
key: e.key,
code: e.code,
preventDefault: () => {
e.preventDefault();
},
stopPropagation: () => {
e.stopPropagation();
},
isInput: e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement
};
};

const stringUtils = {
formatString
};
Expand All @@ -204,4 +262,4 @@ const metadataUtils = {
mergeMetadata
};

export { chunkRun, metadataUtils, stringUtils, urlUtils };
export { chunkRun, convertKeyboardEvent, formatShortcut, metadataUtils, Process as processId, stringUtils, urlUtils };
2 changes: 1 addition & 1 deletion paperlib-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "paperlib-api",
"version": "0.1.6",
"version": "0.1.7",
"author": "Paperlib",
"description": "The API for paperlib extension development.",
"exports": {
Expand Down
5 changes: 5 additions & 0 deletions paperlib-api/release-note.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Paperlib API Release Note

## v0.1.7

- all functions in `referenceService` now receive a `PaperEntity[]` rather than a citation.js object.
- add `PLMainAPI.windowProcessManagementService.isFocused(...)` to check if a window is focused.

## v0.1.6

- add `dataContextMenuExportBibItemClicked` for `PLMainAPI.contextMenuService`.
Expand Down

0 comments on commit 3ab512e

Please sign in to comment.