mirror of
https://github.com/akaalias/extract-highlights-plugin.git
synced 2026-07-22 05:10:29 +00:00
Adds loading of PDF
This commit is contained in:
parent
1b566dc567
commit
416518a85a
4 changed files with 36 additions and 6 deletions
|
|
@ -1 +1 @@
|
|||
{"headlineText":"Highlights for: \"$NOTE_TITLE\"","addFootnotes":false,"useBoldForHighlights":true,"createLinks":false,"autoCapitalize":true}
|
||||
{"headlineText":"Highlights for: \"$NOTE_TITLE\"","addFootnotes":true,"useBoldForHighlights":false,"createLinks":true,"autoCapitalize":true}
|
||||
17
main.js
17
main.js
File diff suppressed because one or more lines are too long
|
|
@ -20,6 +20,7 @@
|
|||
"@types/chai": "^4.2.14",
|
||||
"@types/mocha": "^8.2.0",
|
||||
"@types/node": "^14.14.14",
|
||||
"@types/pdfjs-dist": "^2.1.7",
|
||||
"chai": "^4.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"ignore-styles": "^5.0.1",
|
||||
|
|
@ -27,10 +28,12 @@
|
|||
"jsdom-global": "^3.0.2",
|
||||
"mocha": "^8.2.1",
|
||||
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
|
||||
"pdfjs-dist": "^2.5.207",
|
||||
"rollup": "^2.35.1",
|
||||
"ts-node": "^9.1.1",
|
||||
"tslib": "^1.14.1",
|
||||
"typescript": "^4.1.3"
|
||||
"typescript": "^4.1.3",
|
||||
"worker-loader": "^3.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron": "^10.2.0"
|
||||
|
|
|
|||
18
src/main.ts
18
src/main.ts
|
|
@ -1,7 +1,6 @@
|
|||
import {Plugin, Notice, addIcon, View, MarkdownView, Workspace} from "obsidian"
|
||||
import ExtractHighlightsPluginSettings from "./ExtractHighlightsPluginSettings"
|
||||
import ExtractHighlightsPluginSettingsTab from "./ExtractHighlightsPluginSettingsTab"
|
||||
import {Position} from "codemirror";
|
||||
import ToggleHighlight from "./ToggleHighlight";
|
||||
|
||||
addIcon('target', '<path d="M50 88C29.0132 88 12 70.9868 12 50C12 29.0132 29.0132 12 50 12C70.9868 12 88 29.0132 88 50C87.9761 70.9769 70.9769 87.9761 50 88ZM50 22.8571C35.0094 22.8571 22.8571 35.0094 22.8571 50C22.8571 64.9906 35.0094 77.1429 50 77.1429C64.9906 77.1429 77.1429 64.9906 77.1429 50C77.1429 35.0094 64.9906 22.8571 50 22.8571ZM50 66.2857C41.0056 66.2857 33.7143 58.9943 33.7143 50C33.7143 41.0056 41.0056 33.7143 50 33.7143C58.9943 33.7143 66.2857 41.0056 66.2857 50C66.2857 54.3192 64.5699 58.4616 61.5157 61.5157C58.4616 64.5699 54.3192 66.2857 50 66.2857Z" fill="#646464"/>')
|
||||
|
|
@ -69,7 +68,24 @@ export default class ExtractHighlightsPlugin extends Plugin {
|
|||
extractHighlights(): void {
|
||||
let activeLeaf: any = this.app.workspace.activeLeaf ?? null
|
||||
|
||||
console.log(this.app.workspace.activeLeaf?.view);
|
||||
|
||||
try {
|
||||
if (this.app.workspace.activeLeaf?.view.icon == "pdf-file") {
|
||||
console.log("Process PDF");
|
||||
var pdfPath = activeLeaf?.view.file.path;
|
||||
|
||||
// pdfjsLib.GlobalWorkerOptions.workerSrc = './node_modules/pdfjs-dist/build/pdf.worker.js'
|
||||
|
||||
console.log(pdfPath);
|
||||
|
||||
const vaultPath = activeLeaf?.view.file.vault.adapter.basePath;
|
||||
const path = "file://" + vaultPath + "/" + pdfPath;
|
||||
|
||||
// @ts-ignore
|
||||
var loadingTask = pdfjsLib.getDocument(path);
|
||||
}
|
||||
|
||||
if (activeLeaf?.view?.data) {
|
||||
let highlightsText = this.processHighlights(activeLeaf.view);
|
||||
let saveStatus = this.saveToClipboard(highlightsText);
|
||||
|
|
|
|||
Loading…
Reference in a new issue