-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit de0da3e
Showing
14 changed files
with
436 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github: deathau | ||
custom: ["https://www.paypal.me/deathau"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
name: Release Obsidian Plugin | ||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- '*' # Push events to matching any tag format, i.e. 1.0, 20.15.10 | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '14.x' # You might need to adjust this value to your own version | ||
# Get the version number and put it in a variable | ||
- name: Get Version | ||
id: version | ||
run: | | ||
echo "::set-output name=tag::$(git describe --abbrev=0)" | ||
# Build the plugin | ||
- name: Build | ||
id: build | ||
run: | | ||
npm install | ||
npm run build --if-present | ||
# Package the required files into a zip | ||
- name: Package | ||
run: | | ||
mkdir ${{ github.event.repository.name }} | ||
cp main.js manifest.json styles.css README.md ${{ github.event.repository.name }} | ||
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} | ||
# Create the release on github | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
VERSION: ${{ github.ref }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
# Upload the packaged release file | ||
- name: Upload zip file | ||
id: upload-zip | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./${{ github.event.repository.name }}.zip | ||
asset_name: ${{ github.event.repository.name }}-${{ steps.version.outputs.tag }}.zip | ||
asset_content_type: application/zip | ||
# Upload the main.js | ||
- name: Upload main.js | ||
id: upload-main | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./main.js | ||
asset_name: main.js | ||
asset_content_type: text/javascript | ||
# Upload the manifest.json | ||
- name: Upload manifest.json | ||
id: upload-manifest | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./manifest.json | ||
asset_name: manifest.json | ||
asset_content_type: application/json | ||
# Upload the style.css | ||
- name: Upload styles.css | ||
id: upload-css | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./styles.css | ||
asset_name: styles.css | ||
asset_content_type: text/css | ||
# TODO: release notes??? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Bump Version | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
type: | ||
description: 'Type of version (`major`, `minor`, `patch`)' | ||
required: true | ||
default: 'patch' | ||
jobs: | ||
bump: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
token: ${{secrets.PAT}} # use a personal acces token so that other actions can trigger | ||
- name: Use Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: '14.x' # You might need to adjust this value to your own version | ||
- name: Update version | ||
id: version | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
npm version ${{ github.event.inputs.type }} | ||
echo "::set-output name=tag::$(git describe --abbrev=0)" | ||
# update the manifest.json with the tag version | ||
- name: Update manifest version | ||
uses: jossef/action-set-json-field@v1 | ||
with: | ||
file: manifest.json | ||
field: version | ||
value: ${{ steps.version.outputs.tag }} | ||
- name: Commit manifest | ||
run: | | ||
git branch --show-current | ||
git add -u | ||
git commit --amend --no-edit | ||
git tag -fa ${{ steps.version.outputs.tag }} -m "${{ steps.version.outputs.tag }}" | ||
# push the commit | ||
- name: Push changes | ||
uses: ad-m/github-push-action@v0.6.0 | ||
with: | ||
github_token: ${{secrets.PAT}} | ||
tags: true | ||
branch: ${{ github.ref }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
package-lock.json | ||
|
||
# build | ||
main.js | ||
styles.css | ||
*.js.map | ||
data.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tag-version-prefix = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Typewriter Scroll Obsidian Plugin | ||
[![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/deathau/cm-typewriter-scroll-obsidian?style=for-the-badge&sort=semver)](https://github.com/deathau/cm-typewriter-scroll-obsidian/releases/latest) | ||
![GitHub All Releases](https://img.shields.io/github/downloads/deathau/cm-typewriter-scroll-obsidian/total?style=for-the-badge) | ||
|
||
A plugin for [Obsidian](https://obsidian.md) to enable typewriter-style scrolling, which keeps the view centered in the editor. | ||
|
||
![Screenshot](https://github.com/deathau/cm-typewriter-scroll-obsidian/raw/main/screenshot.gif) | ||
|
||
### Compatibility | ||
|
||
Custom plugins are only available for Obsidian v0.9.7+. | ||
|
||
The current API of this repo targets Obsidian **v0.9.7**. | ||
|
||
### Notes | ||
This is all very experimental at the moment, so parts might not work, etc. | ||
|
||
## Installation | ||
|
||
### From within Obsidian | ||
From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following: | ||
- Open Settings > Third-party plugin | ||
- Make sure Safe mode is **off** | ||
- Click Browse community plugins | ||
- Search for this plugin | ||
- Click Install | ||
- Once installed, close the community plugins window and activate the newly installed plugin | ||
#### Updates | ||
You can follow the same procedure to update the plugin | ||
|
||
### From GitHub | ||
- Download the Latest Release from the Releases section of the GitHub Repository | ||
- Extract the plugin folder from the zip to your vault's plugins folder: `<vault>/.obsidian/plugins/` | ||
Note: On some machines the `.obsidian` folder may be hidden. On MacOS you should be able to press `Command+Shift+Dot` to show the folder in Finder. | ||
- Reload Obsidian | ||
- If prompted about Safe Mode, you can disable safe mode and enable the plugin. | ||
Otherwise head to Settings, third-party plugins, make sure safe mode is off and | ||
enable the plugin from there. | ||
|
||
## Security | ||
> Third-party plugins can access files on your computer, connect to the internet, and even install additional programs. | ||
The source code of this plugin is available on GitHub for you to audit yourself, but installing plugins into Obsidian is currently a matter of trust. | ||
|
||
I can assure you here that I do nothing to collect your data, send information to the internet or otherwise do anything nefarious with your system. However, be aware that I *could*, and you only have my word that I don't. | ||
|
||
This plugin does contain code copied from [this repository](https://github.com/azu/codemirror-typewriter-scrolling/blob/b0ac076d72c9445c96182de87d974de2e8cc56e2/typewriter-scrolling.js), which I have modified for this plugin. | ||
|
||
## Development | ||
|
||
This project uses Typescript to provide type checking and documentation. | ||
The repo depends on the latest [plugin API](https://github.com/obsidianmd/obsidian-api) in Typescript Definition format, which contains TSDoc comments describing what it does. | ||
|
||
**Note:** The Obsidian API is still in early alpha and is subject to change at any time! | ||
|
||
If you want to contribute to development and/or just customize it with your own | ||
tweaks, you can do the following: | ||
- Clone this repo. | ||
- `npm i` or `yarn` to install dependencies | ||
- `npm run build` to compile. | ||
- Copy `manifest.json`, `main.js` and `styles.css` to a subfolder of your plugins | ||
folder (e.g, `<vault>/.obsidian/plugins/<plugin-name>/`) | ||
- Reload obsidian to see changes | ||
|
||
Alternately, you can clone the repo directly into your plugins folder and once | ||
dependencies are installed use `npm run dev` to start compilation in watch mode. | ||
You may have to reload obsidian (`ctrl+R`) to see changes. | ||
|
||
## Pricing | ||
Huh? This is an open-source plugin I made *for fun*. It's completely free. | ||
However, if you absolutely *have* to send me money because you like it that | ||
much, feel free to throw some coins in my hat via the following: | ||
|
||
[![GitHub Sponsors](https://img.shields.io/github/sponsors/deathau?style=social)](https://github.com/sponsors/deathau) | ||
[![Paypal](https://img.shields.io/badge/paypal-deathau-yellow?style=social&logo=paypal)](https://paypal.me/deathau) | ||
|
||
# Version History | ||
## 0.0.1 | ||
Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import './styles.scss' | ||
import './typewriter-scrolling' | ||
import { Plugin, MarkdownView } from 'obsidian'; | ||
|
||
export default class CMTypewriterScrollPlugin extends Plugin { | ||
|
||
settings: any; | ||
async onInit() { | ||
|
||
} | ||
|
||
async onload() { | ||
this.settings = await this.loadData() || { enabled: true } as any; | ||
if (this.settings.enabled) { | ||
(this.app.workspace as any).layoutReady ? this.enable() : this.app.workspace.on('layout-ready', this.enable); | ||
} | ||
|
||
// add the toggle on/off command | ||
this.addCommand({ | ||
id: 'toggle-typewriter-sroll', | ||
name: 'Toggle On/Off', | ||
callback: () => { | ||
// disable or enable as necessary | ||
this.settings.enabled ? this.disable() : this.enable(); | ||
} | ||
}); | ||
} | ||
|
||
onunload() { | ||
this.disable(); | ||
} | ||
|
||
disable = () => { | ||
document.body.classList.remove('plugin-cm-typewriter-scroll'); | ||
|
||
this.app.off("codemirror", this.addTypewriterScroll); | ||
|
||
this.app.workspace.getLeavesOfType("markdown").forEach((leaf) => { | ||
if (leaf.view instanceof MarkdownView) { | ||
this.addTypewriterScroll(leaf.view.sourceMode.cmEditor, false); | ||
} | ||
}) | ||
|
||
this.settings.enabled = false; | ||
this.saveData(this.settings); | ||
} | ||
|
||
enable = () => { | ||
document.body.classList.add('plugin-cm-typewriter-scroll'); | ||
|
||
this.app.on("codemirror", this.addTypewriterScroll); | ||
|
||
this.app.workspace.getLeavesOfType("markdown").forEach((leaf) => { | ||
if (leaf.view instanceof MarkdownView) { | ||
this.addTypewriterScroll(leaf.view.sourceMode.cmEditor); | ||
} | ||
}) | ||
|
||
this.settings.enabled = true; | ||
this.saveData(this.settings); | ||
} | ||
|
||
// @ts-ignore | ||
addTypewriterScroll = (cm: CodeMirror.Editor, enable: boolean = true) => { | ||
cm.setOption("typewriterScrolling", enable); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "cm-typewriter-scroll-obsidian", | ||
"name": "Typewriter Scroll", | ||
"author": "death_au", | ||
"description": "Typewriter-style scrolling which keeps the view centered in the editor.", | ||
"isDesktopOnly": false, | ||
"version": "0.0.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "cm-typewriter-scroll-obsidian", | ||
"version": "0.0.0", | ||
"description": "Typewriter-style scrolling which keeps the view centered in the editor.", | ||
"main": "main.js", | ||
"scripts": { | ||
"instal-deps": "npm install", | ||
"dev": "rollup --config rollup.config.js -w", | ||
"build": "rollup --config rollup.config.js" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^15.1.0", | ||
"@rollup/plugin-node-resolve": "^9.0.0", | ||
"@rollup/plugin-typescript": "^6.0.0", | ||
"@types/node": "^14.14.6", | ||
"obsidian": "obsidianmd/obsidian-api#master", | ||
"rollup": "^2.32.1", | ||
"rollup-plugin-scss": "^2.6.1", | ||
"sass": "^1.28.0", | ||
"tslib": "^2.0.3", | ||
"typescript": "^4.0.3" | ||
}, | ||
"dependencies": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import typescript from '@rollup/plugin-typescript'; | ||
import {nodeResolve} from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import scss from 'rollup-plugin-scss'; | ||
|
||
export default { | ||
input: 'main.ts', | ||
output: { | ||
dir: '.', | ||
sourcemap: 'inline', | ||
format: 'cjs', | ||
exports: 'default' | ||
}, | ||
external: ['obsidian'], | ||
plugins: [ | ||
typescript(), | ||
nodeResolve({browser: true}), | ||
commonjs(), | ||
scss({ output: 'styles.css', sass: require('sass') }) | ||
] | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
body.plugin-cm-typewriter-scroll { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": ".", | ||
"inlineSourceMap": true, | ||
"inlineSources": true, | ||
"module": "ESNext", | ||
"target": "es5", | ||
"allowJs": true, | ||
"noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"importHelpers": true, | ||
"lib": [ | ||
"dom", | ||
"es5", | ||
"scripthost", | ||
"es2015" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts" | ||
] | ||
} |
Oops, something went wrong.