├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .npmrc ├── LICENSE ├── README.md ├── esbuild.config.mjs ├── manifest.json ├── package.json ├── resources └── img1.png ├── src ├── EpubView.tsx ├── main.ts ├── styles.css └── utils.ts ├── tsconfig.json ├── version-bump.mjs └── versions.json /.editorconfig: -------------------------------------------------------------------------------- 1 | # top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | insert_final_newline = true 8 | indent_style = tab 9 | indent_size = 4 10 | tab_width = 4 11 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | main.js 4 | 5 | build 6 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "root": true, 3 | "parser": "@typescript-eslint/parser", 4 | "env": { "node": true }, 5 | "plugins": [ 6 | "@typescript-eslint" 7 | ], 8 | "extends": [ 9 | "eslint:recommended", 10 | "plugin:@typescript-eslint/eslint-recommended", 11 | "plugin:@typescript-eslint/recommended" 12 | ], 13 | "parserOptions": { 14 | "sourceType": "module" 15 | }, 16 | "rules": { 17 | "no-unused-vars": "off", 18 | "@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], 19 | "@typescript-eslint/ban-ts-comment": "off", 20 | "no-prototype-builtins": "off", 21 | "@typescript-eslint/no-empty-function": "off" 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # vscode 2 | .vscode 3 | 4 | # Intellij 5 | *.iml 6 | .idea 7 | 8 | # npm 9 | node_modules 10 | package-lock.json 11 | 12 | # Don't include the compiled main.js file in the repo. 13 | # They should be uploaded to GitHub releases instead. 14 | main.js 15 | 16 | # Exclude sourcemaps 17 | *.map 18 | 19 | # obsidian 20 | data.json 21 | styles.css 22 | build 23 | 24 | # Exclude macOS Finder (System Explorer) View States 25 | .DS_Store 26 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | tag-version-prefix="" -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 AwesomeDog 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Awesome Reader 2 | 3 | Make Obsidian a proper Reader. 4 | 5 | ## Features 6 | 7 | - 💾 Remember reading progress and sync to all devices. You can now continue reading where you left off across all 8 | devices. 9 | - ✒ Create book note from TOC(table of contents). With well organized heading formats. 10 | - ♳ Support multiple ebook formats. Currently, epub and pdf are supported. 11 | 12 | ## How to use 13 | 14 | You may want to toggle on `Detect all file extensions` first in `options -> Files & Links`. 15 | 16 | 1. Drop some ebooks(e.g. epub files) to your vault. Click it and read. 17 | 2. To create book note, click `Open/create book note` from file menu. Note will be in the same folder alongside the 18 | book. 19 | 3. Reading progress is automatically remembered in plugin's folder. And will be sync to all devices if you got "Obsidian 20 | Sync" or similar services. 21 | 22 |  23 | 24 | ## Known issues 25 | 26 | - Reading progress of pdf format is not fully implemented now 27 | 28 | ## Attribution 29 | 30 | Special thanks to caronchen's 31 | marvelous [Obsidian ePub Reader Plugin](https://github.com/caronchen/obsidian-epub-plugin), 32 | some code is from this great work. 33 | -------------------------------------------------------------------------------- /esbuild.config.mjs: -------------------------------------------------------------------------------- 1 | import esbuild from "esbuild"; 2 | import process from "process"; 3 | import builtins from 'builtin-modules' 4 | 5 | const banner = 6 | `/* 7 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD 8 | if you want to view the source, please visit the github repository of this plugin 9 | */ 10 | `; 11 | 12 | const prod = (process.argv[2] === 'production'); 13 | 14 | esbuild.build({ 15 | banner: { 16 | js: banner, 17 | }, 18 | entryPoints: ['src/main.ts'], 19 | bundle: true, 20 | external: [ 21 | 'obsidian', 22 | 'electron', 23 | '@codemirror/autocomplete', 24 | '@codemirror/collab', 25 | '@codemirror/commands', 26 | '@codemirror/language', 27 | '@codemirror/lint', 28 | '@codemirror/search', 29 | '@codemirror/state', 30 | '@codemirror/view', 31 | '@lezer/common', 32 | '@lezer/highlight', 33 | '@lezer/lr', 34 | ...builtins], 35 | format: 'cjs', 36 | watch: !prod, 37 | target: 'es2018', 38 | logLevel: "info", 39 | sourcemap: prod ? false : 'inline', 40 | treeShaking: true, 41 | outfile: 'main.js', 42 | }).catch(() => process.exit(1)); 43 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "awesome-reader", 3 | "name": "Awesome Reader", 4 | "version": "0.1.4", 5 | "minAppVersion": "0.15.0", 6 | "description": "Make Obsidian a proper Reader.", 7 | "author": "AwesomeDog", 8 | "authorUrl": "https://github.com/AwesomeDog", 9 | "isDesktopOnly": false 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-awesome-reader", 3 | "version": "0.1.0", 4 | "description": "Make Obsidian a proper Reader.", 5 | "main": "main.js", 6 | "scripts": { 7 | "clean": "del-cli -f main.js styles.css data.json build", 8 | "rename_css": "node -e \"require('fs').rename('main.css', 'styles.css', function(err) { if (err) console.log(err); console.log('File successfully renamed!') })\"", 9 | "dev": "node esbuild.config.mjs", 10 | "build": "npm run clean && tsc -noEmit -skipLibCheck && node esbuild.config.mjs production && npm run rename_css", 11 | "release": "npm run build && mkdir build && shx cp main.js styles.css manifest.json build", 12 | "version": "node version-bump.mjs && git add manifest.json versions.json" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "MIT", 17 | "devDependencies": { 18 | "@types/node": "^16.11.6", 19 | "@typescript-eslint/eslint-plugin": "5.29.0", 20 | "@typescript-eslint/parser": "5.29.0", 21 | "@types/react": "^18.0.8", 22 | "@types/react-dom": "^18.0.3", 23 | "builtin-modules": "3.3.0", 24 | "esbuild": "0.14.47", 25 | "obsidian": "latest", 26 | "tslib": "2.4.0", 27 | "typescript": "4.7.4" 28 | }, 29 | "dependencies": { 30 | "react": "18.2.0", 31 | "react-dom": "18.2.0", 32 | "react-reader": "^1.0.2", 33 | "del-cli": "^4.0.1", 34 | "shx": "^0.3.4" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /resources/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AwesomeDog/obsidian-awesome-reader/3d6b733d67029d23edcb66af0de1624b5ff785ce/resources/img1.png -------------------------------------------------------------------------------- /src/EpubView.tsx: -------------------------------------------------------------------------------- 1 | import {FileView, Menu, TFile, WorkspaceLeaf} from "obsidian"; 2 | import * as React from 'react'; 3 | import {useState} from 'react'; 4 | import * as ReactDOM from 'react-dom'; 5 | import AwesomeReaderPlugin, {AwesomeReaderPluginSettings} from "./main"; 6 | import {getEpubTocMd, openOrCreateNote} from "./utils"; 7 | import {ReactReader, ReactReaderStyle} from "react-reader"; 8 | 9 | export const EpubReader = ({contents, title, scrolled, tocOffset, initLocation, saveLocation, tocMemo}: { 10 | contents: ArrayBuffer; 11 | title: string; 12 | scrolled: boolean; 13 | tocOffset: number; 14 | initLocation: string | number; 15 | saveLocation: Function; 16 | tocMemo: Function; 17 | }) => { 18 | const [location, setLocation] = useState(initLocation); 19 | const locationChanged = (epubcifi: string | number) => { 20 | setLocation(epubcifi); 21 | saveLocation(epubcifi); 22 | }; 23 | 24 | // @ts-ignore 25 | return