Example

You are selecting at , surrounded by

Let's play the game

<a href="javascript:;" id="button-cursor">set cursor</a>
<a href="javascript:;" id="button-text">change text</a>
<a href="javascript:;" id="button-prepend">prepend text</a>
<a href="javascript:;" id="button-append">append text</a>
<a href="javascript:;" id="button-line">current line</a>
seajs.use(['$', 'lepture/selection/0.9.0/selection'], function($, selection) {
    var sel = selection(document.getElementById('editor'));
    $('#editor').on('click select keyup', function() {
        $('#speaker-text').text(sel.text());
        $('#speaker-cursor').text(sel.cursor());
        $('#speaker-surround').text(sel.surround());
    });

    $('#button-cursor').click(function() {
        sel.cursor(10, 19);
        // equal sel.cursor([10, 19])
    });
    $('#button-text').click(function() {
        sel.text('hello world');
        // sel.text('hello world', 'left')
        // sel.text('hello world', 'right')
    });
    $('#button-prepend').click(function() {
        sel.prepend('hello prepend', 'right');
    });
    $('#button-append').click(function() {
        sel.prepend('hello append', 'left');
    });
    $('#button-line').click(function() {
        alert(sel.line());
    });
});