Search code examples
javascripthtmletherpad

How is the caret emulated in Etherpad?


How is the blinking caret emulated in Etherpad? (See a live version at ietherpad.com) The way I would do it, is to create a div and position it absolutely where the caret should be. Then, display and remove it in regular intervals. However they seem to do it differently.

The text of a row is in

<div id="magicdomid2" class="">...</div>

I can't see anything changing around the div. How is it done?


Solution

  • It isn't emulated. In modern browsers, Etherpad creates an iframe containing a document with the tag:

    <body contenteditable="true">
    

    Which tells the browser to allow editing of the contained HTML document. The carat is one of the effects of including that attribute.