-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sculpt0r/feat/keyboard-shortcuts
[WIP]build(deps): instal chrome extension types
- Loading branch information
Showing
9 changed files
with
185 additions
and
47 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 |
---|---|---|
@@ -1,27 +1,34 @@ | ||
[![CI - test](https://github.com/sculpt0r/vim-browser-extension/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/sculpt0r/vim-browser-extension/actions/workflows/test.yml) | ||
|
||
# vim-browser-extension | ||
Browser extension to allow vim keys for text editing. | ||
|
||
Browser extension which allows Vim keys for text editing inside `textarea` HTML elements. | ||
It uses only pure DOM API. | ||
|
||
# why it is different than other vim plugins | ||
Other famous plugins use vim keys to navigate in browser/web page. This plugin allows to use vim keys in text editing inputs! | ||
|
||
Other famous plugins use vim keys to navigate in the browser/web page. This plugin allows to use vim keys in text editing inputs! | ||
|
||
# enable vim keys | ||
Plugins functionality can be toggled with a special key combination: | ||
- `alt` + `v` on windows / linux | ||
- `right option` + `left cmd` on macOS | ||
|
||
It is because sometimes you may don't want to `vim-typer` interfere with another vim-like plugin. | ||
Plugin functionality can be toggled with a special key combination: | ||
|
||
- `alt` + `v` on windows / linux | ||
- `Command` + `Control` + `v` on macOS | ||
|
||
It is because sometimes you may not want to `vim-typer` interfere with another vim-like plugin. | ||
|
||
Please look at the indicator. When it becomes green: the plugin functions are available. | ||
|
||
# supported keys | ||
|
||
Currently, `vim-typer` supports: | ||
- `h`,`j`,`k`,`l` | ||
- `e` | ||
- `w` has early support | ||
- more are planned | ||
|
||
- `h`,`j`,`k`,`l` | ||
- `e` | ||
- `w` has early support | ||
- more are planned | ||
|
||
# Development | ||
|
||
work with `src` and `tests` folder. Everything is bundled to the `src_js` directory with rollup `npx rollup --config` | ||
work with `src` and `tests` folder. Everything is bundled to the `src_js` directory with `npm run build` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Empty file.
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
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
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,25 @@ | ||
chrome.commands.onCommand.addListener(async function (command) { | ||
switch (command) { | ||
case "toggle-vim-mode": | ||
const id = (await getCurrentTab()).id; | ||
|
||
if (typeof id === "undefined") { | ||
console.log("Cannot find active tab..."); | ||
break; | ||
} | ||
chrome.tabs.sendMessage(id, { msg: "please toggle plugin" }); | ||
break; | ||
default: | ||
console.log(`Command ${command} not found`); | ||
} | ||
}); | ||
|
||
/** | ||
* https://developer.chrome.com/docs/extensions/reference/api/tabs#get_the_current_tab | ||
*/ | ||
async function getCurrentTab() { | ||
let queryOptions = { active: true, lastFocusedWindow: true }; | ||
// `tab` will either be a `tabs.Tab` instance or `undefined`. | ||
let [tab] = await chrome.tabs.query(queryOptions); | ||
return tab; | ||
} |
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 |
---|---|---|
@@ -1,20 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" | ||
content="IE=edge"> | ||
<meta name="viewport" | ||
content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<textarea style="width: 75%; height: 450px">abc | ||
<textarea style="width: 75%; height: 250px">abc | ||
de f | ||
ghj | ||
oko loko | ||
okoloko | ||
</textarea> | ||
<textarea style="width: 75%; height: 450px"></textarea> | ||
<br> | ||
Contenteditable: <div contenteditable="true">aaa</div> | ||
<textarea style="width: 75%; height: 250px"></textarea> | ||
<br> | ||
Contenteditable: <div contenteditable="true">aaa</div> | ||
</body> | ||
|
||
</html> |