Skip to content

Commit

Permalink
chore: remove console.logs
Browse files Browse the repository at this point in the history
  • Loading branch information
OverflowCat committed Jan 17, 2023
1 parent b06fa8b commit 82cdef8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Logseq PDF Navigation

![toolbar](https://user-images.githubusercontent.com/20166026/213020002-a1837684-7cd4-4fde-a2ae-73239b1fdb77.png)

This is a plugin that helps you navigate through a PDF document in Logseq when there are internal links. Jumping back to where you click the link is painful; this plugin adds button to the PDF toolbar, which provides go back and forward functionality.

## Demo
Expand Down
14 changes: 5 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ class PdfHistory {
back() {
console.log("Back");
if (this.canGoBack()) this.locations[--this.current_idx].scrollIntoView();
console.log(this.locations, this.current_idx);
// console.log(this.locations, this.current_idx);
}

forward() {
console.log("Forward", this.locations);
if (this.canGoForward()) this.locations[++this.current_idx].scrollIntoView();
console.log(this.locations, this.current_idx);
// console.log(this.locations, this.current_idx);
}

canGoBack() {
Expand All @@ -48,13 +48,11 @@ class pdfLocation {
}

scrollIntoView() {
console.log("scrollIntoView");
top?.window.lsPdfViewer.scrollPageIntoView({
pageNumber: this.page,
destArray: [null, { name: "XYZ" },
this.left, this.top]
});
console.log("scrolledIntoView");
}
}

Expand Down Expand Up @@ -82,12 +80,10 @@ function initialize(ele) {
let pdfHistory = new PdfHistory();

function callback(e) {
isDebug && console.log({ top });
const ele = e.srcElement;
if (ele.tagName !== 'A' || ele.className !== "internalLink")
return;
const viewer = top?.lsPdfViewer;
console.log(viewer.scroll);

/* An example of viewer._location
{
Expand All @@ -100,11 +96,11 @@ function initialize(ele) {
} */
const pre = new pdfLocation(viewer._location.pageNumber, viewer._location.left, viewer._location.top);
setTimeout(() => {
console.log(viewer.scroll)
// console.log(viewer.scroll)
const post = new pdfLocation(viewer._location.pageNumber, viewer._location.left, viewer._location.top);
pdfHistory.add(pre, post);
}, 100);
console.log({ pdfHistory });
// console.log({ pdfHistory });
}

setTimeout(() => {
Expand Down Expand Up @@ -156,7 +152,7 @@ const right_arr = `
<line y1="8" x1="15" y2="12" x2="19"></line>
</svg>`;

const isDebug = true;
const isDebug = false;

logseq.ready(() => {
isDebug && logseq.App.showMsg("❤️ logseq-pdf-nav has bean loaded!");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-pdf-nav",
"version": "0.1.0",
"version": "0.1.1",
"description": "Jump back after you click internal links of PDF in Logseq.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 82cdef8

Please sign in to comment.