Skip to content

Instantly share code, notes, and snippets.

@epramono
Created October 16, 2014 16:14
Show Gist options
  • Save epramono/4e63a1be039edbf1a0dd to your computer and use it in GitHub Desktop.
Save epramono/4e63a1be039edbf1a0dd to your computer and use it in GitHub Desktop.
A JavaScript keyboard extension to encode selected text in Drafts 4.
var input = getSelectedText();
var output = "";
if (input) {
output = encodeURIComponent(input);
var range = getSelectedRange();
setSelectedText (output);
setSelectedRange (range[0], output.length);
} else {
input = getText();
output = encodeURIComponent(input);
setText(output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment