smugmug/yui-gallery — pull request #25 by bwg (2013-06-25 20:18:47+00:00)
Title: Keep that range around.  You never know when you'll need it.

creating a link requires the user to type in a url for the link. when this happens, the currently selected range is lost.

use the editor `blur` handler to keep the internal `_selectedRange` around and then restore it on `focus`. Now we can just `focus()` the editor before executing the `createlink` command.

thought:
would it be prudent to just `focus()` on any `command()` call? currently the loss of focus issue is workable by setting the attribute `unselectable="on"` for IE and using the css rule `user-select: none;` for webkit/gecko on elements that would cause the editor to lose focus (drop down menus, links, buttons in some browsers)