User:Alex Smotrov/insertTags()

Current
While editing Wikipedia, you can insert some predefined text using either toolbar or Edittools. They both use Javascript function  defined in wikibits.js (svn). This function accepts 3 parameters: tagOpen, tagClose, sampleText.

First, let's try to use this function in Firefox:  sampleText  — and you can start typing, replacing sample text If you already had some text selected, then it's Your text| — note that cursor is at the end and again you can start typing

Unfortunately, for Internet Explorer it's different: sampleText| — now you have to go back and delete sample text manually If you already had some text selected, then it's Your Text or even Your Text (same selection, but invisible, and no cursor) — now you have to press → before typing, otherwise you will replace this selection.

Also there is:
 * annoying feature: the whole window «jumps», making textarea «more visible»
 * curious feature: you can «insert» the text selected anywhere else on the page (not just in textarea)

Note that Opera 9 supports boths IE and Firefox methods. It is unfortunate that Opera is currently fed IE code and therefore is crippled in almost the same way.

Proposed
Proposed insertTags.js is trying to fix these problems for IE (Firefox code is pretty much the same). It is submitted as bugzilla:10526. Please leave your comments/suggestions at the talk page or on the bug page.

Demo

 * 1) Start IE or Opera and go to any Wikipedia edit page
 * 2) See how tags are inserted using buttons on top or links at bottom
 * 3) Paste this into browser address field and press Enter
 * 4) Repeat step 2
 * 1) Repeat step 2

Or you can simply add  → monobook.js

Tested in: Firefox 1.5, IE6/7, Opera 9.2