{#
INPUT:

- cell -- Cell instance

- wrap -- number of columns to wrap

- do_print -- whether to display for printing

- editing -- whether user is editing the cell

- publish - a boolean; whether this is a published cell
#}
<span id="cell_outer_{{ cell.id() }}">
    {% if not do_print and not publish and not cell.worksheet().docbrowser() %}
            <div class="insert_new_cell" id="insert_new_cell_before{{ cell.id() }}">
              <div class="ui-icon ui-icon-circle-plus wksht-icon_button" 
                id="insert_new_compute_cell_before{{ cell.id() }}" 
                title="{{ gettext('Click to insert new compute cell.') }}"></div>
              <div class="ui-icon ui-icon-comment wksht-icon_button" 
                id="insert_new_text_cell_before{{ cell.id() }}"
                 title="{{ gettext('Click to insert new rich-text cell.') }}"></div>
              <div class="legacy_insert_new_cell" id="legacy_new_cell_before{{ cell.id() }}"></div>
            </div>
            <script type="text/javascript">
                $("#insert_new_compute_cell_before{{ cell.id() }}").bind("click",function (e) {
                    insert_new_cell_before({{ '%r'|format(cell.id()) }});
                });
                $("#insert_new_text_cell_before{{ cell.id() }}").bind("click",function (e) {
                   insert_new_text_cell_before({{ '%r'|format(cell.id()) }});
                });
                $("#legacy_new_cell_before{{ cell.id() }}").bind("click",function (e) {
                   if (e.shiftKey){
                      insert_new_text_cell_before({{ '%r'|format(cell.id()) }});
                   } else {
                      insert_new_cell_before({{ '%r'|format(cell.id()) }});
                   }
                });
            </script>
    {% endif %}
    <div class="text_cell" id="cell_text_{{ cell.id() }}">
      {{ cell.plain_text() | safe }}
    </div>
{% if JEDITABLE_TINYMCE and not cell.worksheet().is_published() and not cell.worksheet().docbrowser() and not do_print and not publish %}
    <script type="text/javascript">
       $("#cell_text_{{ cell.id() }}").unbind('dblclick').editable(function (value, settings) {
            evaluate_text_cell_input({{ '%r'|format(cell.id()) }}, value, settings);
            return(value);
        }, {
            tooltip   : "",
            placeholder : "",
         // type   : 'textarea',
            type   : 'mce',
            onblur : 'ignore',
            select : false,
            submit : "{{ gettext('Save changes') }}",
            cancel : "{{ gettext('Cancel changes') }}",
            event  : "dblclick",
            style  : "inherit",
	    data   : {{ cell.plain_text()|repr_str| safe }}
        });
    </script>
{% endif %}

{% if editing and not do_print %}
    <script>
        $("#cell_text_{{ cell.id() }}").trigger('dblclick');
    </script>
{% endif %}
</span>
