var cell_types = cell_types || {};

(function(){
    cell_types["mathjs"] = {
        button_html: "+",
        on_create: function(element, content){
            var extension_content = subqsa(
                element,
                ".extension-content"
            )[0];
            
            element.classList.add("mathjs-cell-type");
            
            var cell_state = "less-detail"
            
            element.classList.add("less-detail");
                        
            // Render content
            var ext_content = render("mathjs-cell-type");
            extension_content.appendChild(ext_content);
            
            var textarea = subqsa(element, "textarea")[0];
            
            textarea.value = content.value;

            autosize(textarea);
            
            // Enable toggle detail button
            var toggle_button = subqsa(element, ".toggle-detail")[0];
            
            toggle_button.addEventListener("click", switch_state);

            // Manage cell state (more / less details)
            function switch_state(){
                if(cell_state == "less-detail"){
                    cell_state = "more-detail";
                    element.classList.remove("less-detail");
                    element.classList.add("more-detail");
                    toggle_button.innerText = "Show less details";
                } else {
                    cell_state = "less-detail";
                    element.classList.add("less-detail");
                    element.classList.remove("more-detail");
                    toggle_button.innerText = "Show more details";
                }
            }

        },
        get_value: function(element){
            var textarea = subqsa(element, "textarea")[0];
            return textarea.value;
        }
    };
})();

@@ -688,32 +688,33 @@
 %22textarea%22)%5B0%5D;%0A
+%0A
             %0A   
@@ -701,32 +701,54 @@
 %5D;%0A%0A            
+// Set initial content
 %0A            tex
@@ -777,16 +777,167 @@
 value;%0A%0A
+            // Adjust number of rows%0A            textarea.rows = content.value.split(%22%5Cn%22).length;%0A%0A            // Enable auto resizer (external lib.)%0A
         

Fix initial textarea row count