Skip to content

Commit 285d77b

Browse files
committed
code style and bump version
1 parent 7c1d613 commit 285d77b

File tree

5 files changed

+30
-32
lines changed

5 files changed

+30
-32
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-awesome-reader",
33
"name": "Awesome Reader",
4-
"version": "0.1.2",
4+
"version": "0.1.3",
55
"minAppVersion": "0.15.0",
66
"description": "Make Obsidian a proper Reader.",
77
"author": "AwesomeDog",

src/EpubView.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const EpubReader = ({contents, title, scrolled, tocOffset, initLocation,
5757
}
5858
/>
5959
</div>;
60-
}
60+
};
6161

6262
export class EpubView extends FileView {
6363
allowNoFile: false;
@@ -79,13 +79,13 @@ export class EpubView extends FileView {
7979
}
8080

8181
async setInitLocation(initLocation: string | number) {
82-
this.plugin.settings.bookInitLocations[this.file.path] = initLocation
83-
await this.plugin.saveSettings()
82+
this.plugin.settings.bookInitLocations[this.file.path] = initLocation;
83+
await this.plugin.saveSettings();
8484
}
8585

8686
async getInitLocation() {
87-
const location = this.plugin.settings.bookInitLocations[this.file.path]
88-
return location ? location : null
87+
const location = this.plugin.settings.bookInitLocations[this.file.path];
88+
return location ? location : null;
8989
}
9090

9191

@@ -108,10 +108,10 @@ export class EpubView extends FileView {
108108
// @ts-ignore
109109
initLocation={await this.getInitLocation()}
110110
saveLocation={(location: string | number) => {
111-
this.setInitLocation(location)
111+
this.setInitLocation(location);
112112
}}
113113
tocMemo={(toc: any) => {
114-
this.fileToc = toc
114+
this.fileToc = toc;
115115
}}
116116
/>,
117117
this.contentEl

src/main.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import 'src/styles.css'
1+
import 'src/styles.css';
22
import {App, Menu, MenuItem, Plugin, PluginSettingTab, Setting, TFile, WorkspaceLeaf} from 'obsidian';
33
import {EpubView} from "./EpubView";
44
import {getPdfTocMd, openOrCreateNote} from "./utils";
55

6-
7-
// Remember to rename these classes and interfaces!
86
export interface AwesomeReaderPluginSettings {
97
scrolledView: boolean;
108
bookInitLocations: Record<string, string | number>;
@@ -13,7 +11,7 @@ export interface AwesomeReaderPluginSettings {
1311
const DEFAULT_SETTINGS: AwesomeReaderPluginSettings = {
1412
scrolledView: false,
1513
bookInitLocations: {}
16-
}
14+
};
1715

1816
export default class AwesomeReaderPlugin extends Plugin {
1917
settings: AwesomeReaderPluginSettings;
@@ -48,7 +46,7 @@ export default class AwesomeReaderPlugin extends Plugin {
4846
}
4947
}
5048
),
51-
)
49+
);
5250

5351
// This adds a settings tab so the user can configure various aspects of the plugin
5452
this.addSettingTab(new AwesomeReaderSettingTab(this.app, this));
@@ -62,7 +60,6 @@ export default class AwesomeReaderPlugin extends Plugin {
6260

6361
async loadSettings() {
6462
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
65-
console.log(this.settings)
6663
}
6764

6865
async saveSettings() {

src/utils.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export async function openOrCreateNote(app: App, file: TFile, toc: string) {
1010
`---\nbookname: "${file.basename}.${file.extension}"\n---\n\n` + toc
1111
);
1212
}
13-
const leaf = app.workspace.getMostRecentLeaf()
13+
const leaf = app.workspace.getMostRecentLeaf();
1414
if (leaf instanceof WorkspaceLeaf) {
1515
const fileLeaf = app.workspace.createLeafBySplit(leaf);
1616
await fileLeaf.openFile(noteFile as TFile, {active: true});
@@ -20,40 +20,40 @@ export async function openOrCreateNote(app: App, file: TFile, toc: string) {
2020
export function getEpubTocMd(rawToc: any) {
2121
function dfs(node: { label: string; subitems: any; }, output: any[], depth: number) {
2222
if (!node) return;
23-
const cleanedLabel = node.label.replace(/\u0000/g, '').trim()
24-
output.push("#".repeat(depth) + " " + cleanedLabel)
23+
const cleanedLabel = node.label.replace(/\u0000/g, '').trim();
24+
output.push("#".repeat(depth) + " " + cleanedLabel);
2525
for (let sub of node.subitems) {
26-
dfs(sub, output, depth + 1)
26+
dfs(sub, output, depth + 1);
2727
}
2828
}
2929

3030
if (!rawToc) return "";
31-
const output: any[] = []
31+
const output: any[] = [];
3232
for (let sub of rawToc) {
33-
dfs(sub, output, 1)
33+
dfs(sub, output, 1);
3434
}
35-
return output.join("\n\n")
35+
return output.join("\n\n");
3636
}
3737

3838
export async function getPdfTocMd(file: TFile) {
39-
const pdfjsLib = await loadPdfJs()
40-
const content = await this.app.vault.adapter.readBinary(file.path);
41-
const pdf = await pdfjsLib.getDocument(new Uint8Array(content)).promise
42-
const rawToc = await pdf.getOutline()
39+
const pdfjsLib = await loadPdfJs();
40+
const content = await this.app.vault.readBinary(file.path);
41+
const pdf = await pdfjsLib.getDocument(new Uint8Array(content)).promise;
42+
const rawToc = await pdf.getOutline();
4343

4444
function dfs(node: { title: string; items: any; }, output: any[], depth: number) {
4545
if (!node) return;
46-
const cleanedLabel = node.title.replace(/\u0000/g, '').trim()
47-
output.push("#".repeat(depth) + " " + cleanedLabel)
46+
const cleanedLabel = node.title.replace(/\u0000/g, '').trim();
47+
output.push("#".repeat(depth) + " " + cleanedLabel);
4848
for (let sub of node.items) {
49-
dfs(sub, output, depth + 1)
49+
dfs(sub, output, depth + 1);
5050
}
5151
}
5252

5353
if (!rawToc) return "";
54-
const output: any[] = []
54+
const output: any[] = [];
5555
for (let sub of rawToc) {
56-
dfs(sub, output, 1)
56+
dfs(sub, output, 1);
5757
}
58-
return output.join("\n\n")
58+
return output.join("\n\n");
5959
}

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"0.1.0": "0.15.0",
3-
"0.1.2": "0.15.0"
3+
"0.1.2": "0.15.0",
4+
"0.1.3": "0.15.0"
45
}

0 commit comments

Comments
 (0)