Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexherbo2/webextension-editor
Open an external editor to edit text inputs
https://github.com/alexherbo2/webextension-editor
chrome firefox webextension
Last synced: about 2 months ago
JSON representation
Open an external editor to edit text inputs
- Host: GitHub
- URL: https://github.com/alexherbo2/webextension-editor
- Owner: alexherbo2
- License: unlicense
- Created: 2019-11-18T10:21:30.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-21T17:46:11.000Z (over 1 year ago)
- Last Synced: 2024-05-21T04:25:01.484Z (8 months ago)
- Topics: chrome, firefox, webextension
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 4
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING
Awesome Lists containing this project
README
# Editor for [Chrome] and [Firefox] – [WebExtensions]
[Chrome]: https://google.com/chrome/
[Firefox]: https://mozilla.org/firefox/
[WebExtensions]: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensionsOpen an external editor to edit text inputs.
## Dependencies
- [jq]
[jq]: https://stedolan.github.io/jq/
###### Extensions
- [Shell]
[Shell]: https://github.com/alexherbo2/webextension-shell
## Installation
###### Chrome
``` sh
make chrome
```Open the _Extensions_ page by navigating to `chrome://extensions`, enable _Developer mode_ then _Load unpacked_ to select the extension directory: `target/chrome`.
###### Firefox
``` sh
make firefox
```- Open `about:config`, change `xpinstall.signatures.required` to `false`.
- Open `about:addons` ❯ _Extensions_, click _Install add-on from file_ and select the package file: `target/firefox/package.zip`.## Configuration
###### Chrome
Open `chrome://extensions/configureCommands` to configure the keyboard shortcuts.
###### Firefox
Open `about:addons` ❯ _Extensions_ and click _Manage extension shortcuts_ in the menu.
## Usage
Press Control + i to edit the last used text input with your favorite editor.
## Commands
###### `edit`
Edit the last used text input with your favorite editor.
Default: Control + i.## Options
###### `editor`
Sets the editor to be used.
Parameters:
- `file`
- `anchor_line`
- `anchor_column`
- `cursor_line`
- `cursor_column`Default: `xterm -e "$EDITOR" "${file}"`.
**Example** – Open [Kakoune] in [Alacritty]:
``` sh
alacritty --class 'popup' --command \
kak "${file}" -e "
select ${anchor_line}.${anchor_column},${cursor_line}.${cursor_column}
"
```[Kakoune]: https://kakoune.org
[Alacritty]: https://github.com/alacritty/alacritty## Cross-extension messaging
``` javascript
// Environment variables
switch (true) {
case (typeof browser !== 'undefined'):
var PLATFORM = 'firefox'
var EDITOR_EXTENSION_ID = '[email protected]'
break
case (typeof chrome !== 'undefined'):
var PLATFORM = 'chrome'
var EDITOR_EXTENSION_ID = 'oaagifcpibmdpajhjfcdjliekffjcnnk'
break
}// Initialization
const editor = {}
editor.port = chrome.runtime.connect(EDITOR_EXTENSION_ID)
editor.send = (command, ...arguments) => {
editor.port.postMessage({ command, arguments })
}// Usage
editor.send('edit')
```You can find some examples in [Krabby].
[Krabby]: https://krabby.netlify.app
See the [source](src) for a complete reference.