Skip to content

alexherbo2/webextension-editor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Editor for Chrome and FirefoxWebExtensions

Open an external editor to edit text inputs.

Dependencies

Extensions

Installation

Chrome
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
make firefox
  • Open about:config, change xpinstall.signatures.required to false.
  • Open about:addonsExtensions, 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:addonsExtensions 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:

alacritty --class 'popup' --command \
  kak "${file}" -e "
    select ${anchor_line}.${anchor_column},${cursor_line}.${cursor_column}
  "

Cross-extension messaging

// Environment variables
switch (true) {
  case (typeof browser !== 'undefined'):
    var PLATFORM = 'firefox'
    var EDITOR_EXTENSION_ID = 'editor@alexherbo2.github.com'
    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.

See the source for a complete reference.

About

Open an external editor to edit text inputs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published