Write faster in the dev.to editor - adding a WYSIWYG and keyboard shortcuts! [hack 2]
Tags: javascript, showdev, webdev, productivity
Published: 2021-03-29 00:13:34

**This is is just a proof of concept, if there is enough demand I will refine it and improve it but it suits my needs for now, hopefully it will make life easier for you too!**  

## Introducing a "WYSIWYG" for dev.to
If you are new to dev.to and are about to write your first article you may find the editor a little bit confusing.

Liquid Tags, markdown etc. are not particularly friendly if you aren't used to using them.

Even if you are a veteran Markdown user, creating documents in dev.to can be laborious having to type everything by hand.

Well **struggle no longer**, I present to you dev-WYSIWYG! (I know this isn't technically a WYSIWYG but it was easier to call it that!)

![Adding bold text using the WYSIWYG](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fprma76skuvydvp2estt.gif)

It is a bookmarklet (currently pointed at my server but once the bugs are ironed out it will point to github) that gives you bold, italic, headings and more!

Even better, every command has a corresponding keyboard shortcut with <kbd>Ctrl</kbd> + <kbd>Key Name</kbd>

## Keyboard commands:
Simply press <kbd>Ctrl</kbd> + the modifier key shown in the buttons.

For example for a codepen liquid tag (to display an inline codepen) press <kbd>Ctrl</kbd> + <kbd>5</kbd>

Commands are:
 - <kbd>Ctrl</kbd> +<kbd>2</kbd>: heading 2
 - <kbd>Ctrl</kbd> +<kbd>3</kbd>: heading 3
 - <kbd>Ctrl</kbd> +<kbd>4</kbd>: heading 4
 - <kbd>Ctrl</kbd> +<kbd>B</kbd>: bold
 - <kbd>Ctrl</kbd> +<kbd>I</kbd>: italic
 - <kbd>Ctrl</kbd> +<kbd>L</kbd>: link
 - <kbd>Ctrl</kbd> +<kbd>K</kbd>: inline code (backticks)
 - <kbd>Ctrl</kbd> +<kbd>Q</kbd>: block quote
 - <kbd>Ctrl</kbd> +<kbd>R</kbd>: horizontal rule
 - <kbd>Ctrl</kbd> +<kbd>0</kbd>: Code Block (triple backticks)
 - <kbd>Ctrl</kbd> +<kbd>5</kbd>: Inline Codepen
 - <kbd>Ctrl</kbd> +<kbd>6</kbd>: Inline jsFiddle
 - <kbd>Ctrl</kbd> +<kbd>7</kbd>: inline dev.to article link card
 - <kbd>Ctrl</kbd> +<kbd>8</kbd>: inline dev.to user profile card
 - <kbd>Ctrl</kbd> +<kbd>9</kbd>: inline dev.to comment card

If you are used to stackoverflow controls a lot of them are similar so it should be easy to pick up!

## Behaviour
If you have text selected then it will use that text within whatever tags are being inserted.

If you have no text selected then it will enter some default text for you.

For certain items you will get prompts to fill in the key information. Please note that if you have selected some text the prompts may be ignored (I will tidy that up later).

## Give it a try before using it.

The below fiddle allows you to try out the editor first in a fiddle to get used to it and see if it is "good enough" in it's current state for your needs.

{% jsfiddle https://jsfiddle.net/ojb3dcne/4/ result,js,html,css %}

## Using it on dev.to

![Drag the bookmarklet to the bookmarks bar and then press to activate!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hdkz2i3d4i5bwf8u4c2.gif)

Once you have played with the fiddle and you like the editor, simply drag the link in the fiddle that says "dev.to WYSIWYG" to your bookmarks bar.

Then click the link when you are on the dev editor page (https://dev.to/new) and voila you have editor features and keyboard shortcuts!

## Conclusion
Maybe people will hate it, but I already **love** the fact that I can just press <kbd>Ctrl</kbd> + <kbd>B</kbd> to make selected text bold.

There are still a few things to add such as ordered and unordered lists and `<kbd>` wrapping commands as I find those particularly annoying!

Anyway, let me know what you think and if you end up using it! 

**p.s.** I advocate for accessibility all the time, at the moment this is not fully accessible and I am aware of that, once I have finalised the functions etc. I will make the adjustments needed (it is still usable as it is, just awkward).