From 3ab512eeca9166e362e87d1e87bd4551208b0a05 Mon Sep 17 00:00:00 2001 From: geoffreychen777 Date: Sat, 6 Apr 2024 22:55:19 +0100 Subject: [PATCH] update(api): bump up to v0.1.7 --- paperlib-api/dist/api.d.ts | 12 ++++---- paperlib-api/dist/utils.mjs | 60 +++++++++++++++++++++++++++++++++++- paperlib-api/package.json | 2 +- paperlib-api/release-note.md | 5 +++ 4 files changed, 71 insertions(+), 8 deletions(-) diff --git a/paperlib-api/dist/api.d.ts b/paperlib-api/dist/api.d.ts index 007eb830..c310d390 100644 --- a/paperlib-api/dist/api.d.ts +++ b/paperlib-api/dist/api.d.ts @@ -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'; @@ -2233,9 +2232,10 @@ declare type Proxied = { 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. @@ -2254,19 +2254,19 @@ declare class ReferenceService { * @param cite - The cite object. * @returns The BibItem. */ - exportBibItem(cite: Cite): string; + exportBibItem(paperEntities: PaperEntity[]): Promise; /** * Export BibTex key. * @param cite - The cite object. * @returns The BibTex key. */ - exportBibTexKey(cite: Cite): string; + exportBibTexKey(paperEntities: PaperEntity[]): Promise; /** * Export BibTex body string. * @param cite - The cite object. * @returns The BibTex body string. */ - exportBibTexBody(cite: Cite): string; + exportBibTexBody(paperEntities: PaperEntity[]): Promise; /** * Export BibTex body string in folder. * @param folderName - The folder name. @@ -2277,7 +2277,7 @@ declare class ReferenceService { * @param cite - The cite object. * @returns The plain text. */ - exportPlainText(cite: Cite): Promise; + exportPlainText(paperEntities: PaperEntity[]): Promise; /** * Export plain text in folder. * @param folderName - The folder name. diff --git a/paperlib-api/dist/utils.mjs b/paperlib-api/dist/utils.mjs index 446530b8..6b0285d0 100644 --- a/paperlib-api/dist/utils.mjs +++ b/paperlib-api/dist/utils.mjs @@ -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, @@ -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 }; @@ -204,4 +262,4 @@ const metadataUtils = { mergeMetadata }; -export { chunkRun, metadataUtils, stringUtils, urlUtils }; +export { chunkRun, convertKeyboardEvent, formatShortcut, metadataUtils, Process as processId, stringUtils, urlUtils }; diff --git a/paperlib-api/package.json b/paperlib-api/package.json index 3458e30f..50310e4a 100644 --- a/paperlib-api/package.json +++ b/paperlib-api/package.json @@ -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": { diff --git a/paperlib-api/release-note.md b/paperlib-api/release-note.md index 0b897fae..fb09037f 100644 --- a/paperlib-api/release-note.md +++ b/paperlib-api/release-note.md @@ -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`.