Research & Development
A Coder's Textarea

As a developer from way back, I have found that the best approach is to hand-code the markup.

That said, I have also finally moved to the web for much of my work flow: Much of the things that I used to write in a text editor and then upload, and I am now creating directly in the browser.

So, while the rest of the world wants wysiwyg, I want a decent browser based text editor, with a small footprint.

Update: since I first wrote this article, almost three years ago, I am still using this editor — to make this note in fact!

I have switched to Markdown, and now I'm even more convinced that this is the way to go — never more productive...

My hope is to use a textarea augmented with a bit of css and javascript.

Requirements

So what are the features that comprise a professional quality coder's editor? Here are my minimum acceptable requirements:

What's Out There?

A few quick searches provided the following

In a nutshell, it quickly became apparent that I should begin prototyping my textarea editor. In fact, I am writing this page in my first stable version!

Quite some time after writing my own, I discovered BBC's JHC Webitor which stands for Javascript, HTML and CSS Web Editor. Making this note simply because it might be useful in the future.

Rabbit Holes

Seems like I always go down some rabbit holes on every project — Oh, well, that Leads to learning some new things as well as some new page content

Draggable Div

I've done this before, you just set position:absolute on the div you want to move. But, this time I wanted a nice reusable method and I wanted to do it right. Seems to me that means

Not difficult, but a digression nonetheless. See Moveable/draggable, for some of the issues. Bottom line, I have my reusable code which is better than any of the samples!

Getting & setting Selections

Just a frustrating case of code bloat to deal with browser incompatibilities — as I often do now, I ended up ripping out the IE support!

Here is the link, in case you want to use it How to get selected text from textbox control with javascript

Find/Replace

As mentioned above, the sample code I first used was very naive. But on closer examination, I realized the split/join vs regular expression approaches are an interesting conversation

I use regular expressions since I want case sensitivity and whole words as find options. But then the issue of returning the positions of a regex call is also fraught with possibilities.