-
Notifications
You must be signed in to change notification settings - Fork 4
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 05a0de7
Showing
15 changed files
with
3,761 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,10 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = tab | ||
indent_size = 4 | ||
tab_width = 4 |
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 @@ | ||
npm node_modules | ||
build |
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,23 @@ | ||
{ | ||
"root": true, | ||
"parser": "@typescript-eslint/parser", | ||
"env": { "node": true }, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/eslint-recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parserOptions": { | ||
"sourceType": "module" | ||
}, | ||
"rules": { | ||
"no-unused-vars": "off", | ||
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }], | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"no-prototype-builtins": "off", | ||
"@typescript-eslint/no-empty-function": "off" | ||
} | ||
} |
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 @@ | ||
# vscode | ||
.vscode | ||
|
||
# Intellij | ||
*.iml | ||
.idea | ||
|
||
# npm | ||
node_modules | ||
|
||
# Don't include the compiled main.js file in the repo. | ||
# They should be uploaded to GitHub releases instead. | ||
main.js | ||
|
||
# Exclude sourcemaps | ||
*.map | ||
|
||
# obsidian | ||
data.json | ||
|
||
# Exclude macOS Finder (System Explorer) View States | ||
.DS_Store |
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,17 @@ | ||
# Ninja cursor | ||
|
||
The plugin which enhance cursor visiblity. | ||
|
||
![ninjacursor](https://user-images.githubusercontent.com/45774780/177688736-8dacd265-d75f-4ca2-8201-aa8c0a8b7a84.gif) | ||
|
||
Note : This is the clone implementation of the cool product that I saw on the twitter. But I missed to fav and forgot what is was. I will find that again, and obtain permission. But if you know something, please inform me!!! | ||
|
||
## How to install | ||
|
||
1. Install [Beta Reviewers Auto-update Tester](https://github.com/TfTHacker/obsidian42-brat) | ||
2. Copy this repo's URL ([https://github.com/vrtmrz/ninja-cursor](https://github.com/vrtmrz/ninja-cursor)) | ||
3. Open command pallet, select `BRAT: Add a beta plugin for testing` | ||
4. Paste copied URL into the opened dialog. | ||
5. Press `Add Plugin` button. | ||
|
||
License: MIT. |
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,55 @@ | ||
import esbuild from "esbuild"; | ||
import process from "process"; | ||
import builtins from 'builtin-modules' | ||
|
||
const banner = | ||
`/* | ||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD | ||
if you want to view the source, please visit the github repository of this plugin | ||
*/ | ||
`; | ||
|
||
const prod = (process.argv[2] === 'production'); | ||
|
||
esbuild.build({ | ||
banner: { | ||
js: banner, | ||
}, | ||
entryPoints: ['main.ts'], | ||
bundle: true, | ||
external: [ | ||
'obsidian', | ||
'electron', | ||
'@codemirror/autocomplete', | ||
'@codemirror/closebrackets', | ||
'@codemirror/collab', | ||
'@codemirror/commands', | ||
'@codemirror/comment', | ||
'@codemirror/fold', | ||
'@codemirror/gutter', | ||
'@codemirror/highlight', | ||
'@codemirror/history', | ||
'@codemirror/language', | ||
'@codemirror/lint', | ||
'@codemirror/matchbrackets', | ||
'@codemirror/panel', | ||
'@codemirror/rangeset', | ||
'@codemirror/rectangular-selection', | ||
'@codemirror/search', | ||
'@codemirror/state', | ||
'@codemirror/stream-parser', | ||
'@codemirror/text', | ||
'@codemirror/tooltip', | ||
'@codemirror/view', | ||
'@lezer/common', | ||
'@lezer/highlight', | ||
'@lezer/lr', | ||
...builtins], | ||
format: 'cjs', | ||
watch: !prod, | ||
target: 'es2016', | ||
logLevel: "info", | ||
sourcemap: prod ? false : 'inline', | ||
treeShaking: true, | ||
outfile: 'main.js', | ||
}).catch(() => process.exit(1)); |
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,101 @@ | ||
import { Plugin } from 'obsidian'; | ||
|
||
|
||
let lastPos: DOMRect | null = null; | ||
let styleCount = 0; | ||
export default class NinjaCursorPlugin extends Plugin { | ||
cursorElement: HTMLSpanElement; | ||
|
||
async onload() { | ||
this.cursorElement = document.createElement("span"); | ||
|
||
document.body.appendChild(this.cursorElement); | ||
const root = document.documentElement; | ||
root.style.setProperty("--cursor-x1", `${0}`); | ||
root.style.setProperty("--cursor-y1", `${0}`); | ||
root.style.setProperty("--cursor-x2", `${0}`); | ||
root.style.setProperty("--cursor-y2", `${0}`); | ||
this.cursorElement.addClass("x-cursor"); | ||
|
||
const moveCursor = () => { | ||
const selection = window.getSelection(); | ||
if (!selection) { | ||
console.log("Could not find selection") | ||
return; | ||
} | ||
const range = selection.getRangeAt(0); | ||
let rect = range?.getBoundingClientRect() | ||
if (!rect) { | ||
console.log("Could not find range") | ||
return; | ||
} | ||
if (rect.x == 0 && rect.y == 0) { | ||
const textRange = document.createRange() | ||
textRange.setStart(range.startContainer, range.startOffset) | ||
textRange.setEndAfter(range.startContainer) | ||
let textRect = textRange.getBoundingClientRect() | ||
if (textRect.x == 0 && textRect.y == 0) { | ||
textRange.setStart(range.endContainer, range.endOffset - 1) | ||
textRange.setEnd(range.endContainer, range.endOffset) | ||
const textRectx = textRange.getClientRects(); | ||
const txx = textRectx.item(textRectx.length - 1); | ||
if (!txx) { | ||
console.log("Could not found") | ||
return; | ||
} | ||
textRect = txx; | ||
textRect.x = txx.right; | ||
textRect.y = txx.bottom - txx.height; | ||
} | ||
|
||
if (textRect.x == 0 && textRect.y == 0) { | ||
return; | ||
} | ||
rect = textRect; | ||
} | ||
if (lastPos == null) { | ||
lastPos = rect; | ||
return; | ||
} | ||
if (lastPos.x == rect.x && lastPos.y == rect.y) { | ||
return; | ||
} | ||
styleCount = (styleCount + 1) % 2; | ||
root.style.setProperty("--cursor-height", `${rect.height}px`); | ||
root.style.setProperty("--cursor-x1", `${lastPos.x}px`); | ||
root.style.setProperty("--cursor-y1", `${lastPos.y}px`); | ||
root.style.setProperty("--cursor-x2", `${rect.x}px`); | ||
root.style.setProperty("--cursor-y2", `${rect.y}px`); | ||
this.cursorElement.removeClass("x-cursor0"); | ||
this.cursorElement.removeClass("x-cursor1"); | ||
this.cursorElement.getAnimations().forEach((anim) => anim.cancel()); | ||
|
||
window.requestAnimationFrame((time) => { | ||
window.requestAnimationFrame((time) => { | ||
this.cursorElement.addClass(`x-cursor${styleCount}`); | ||
lastPos = rect; | ||
}) | ||
}) | ||
} | ||
this.registerDomEvent(window, "keydown", (ev) => { | ||
moveCursor(); | ||
|
||
}) | ||
this.registerDomEvent(window, "mousedown", () => { | ||
moveCursor(); | ||
}) | ||
} | ||
|
||
|
||
onunload() { | ||
document.body.removeChild(this.cursorElement); | ||
} | ||
|
||
async loadSettings() { | ||
|
||
} | ||
|
||
async saveSettings() { | ||
|
||
} | ||
} |
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,10 @@ | ||
{ | ||
"id": "ninja-cursor", | ||
"name": "Ninja Cursor", | ||
"version": "0.0.1", | ||
"minAppVersion": "0.12.0", | ||
"description": "The plugin which enhance cursor visiblity.", | ||
"author": "vorotamoroz", | ||
"authorUrl": "https://github.com/vrtmrz/", | ||
"isDesktopOnly": false | ||
} |
Oops, something went wrong.