1 // Roo.ux.Showdown.toHtml(Roo.util.Format.htmlEncode(this.getValue())))
9 * @class Roo.bootstrap.Showdown
10 * @extends Roo.bootstrap.TextArea
11 * Bootstrap Showdown editable area
12 * @cfg {string} content
15 * Create a new Showdown
18 Roo.bootstrap.Markdown = function(config){
19 Roo.bootstrap.Markdown.superclass.constructor.call(this, config);
23 Roo.extend(Roo.bootstrap.Markdown, Roo.bootstrap.TextArea, {
27 initEvents : function()
30 Roo.bootstrap.TextArea.prototype.initEvents.call(this);
31 this.markdownEl = this.el.createChild({
32 cls : 'roo-markdown-area'
34 this.inputEl().addClass('d-none');
35 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
36 this.markdownEl.on('click', this.toggleTextEdit, this);
37 this.on('blur', this.toggleTextEdit, this);
38 this.on('specialkey', this.resizeTextArea, this);
41 toggleTextEdit : function()
43 var sh = this.markdownEl.getHeight();
44 this.inputEl().addClass('d-none');
45 this.markdownEl.addClass('d-none');
48 this.inputEl().setHeight(Math.min(500, Math.max(sh,(this.getValue().split("\n").length+1) * 30)));
49 this.inputEl().removeClass('d-none');
50 this.inputEl().focus();
55 this.updateMarkdown();
56 this.markdownEl.removeClass('d-none');
60 updateMarkdown : function()
62 if (this.getValue() == '') {
63 this.markdownEl.dom.innerHTML = String.format('<span class="roo-placeholder">{0}</span>', this.placeholder);
66 this.markdownEl.dom.innerHTML = Roo.Markdown.toHtml(Roo.util.Format.htmlEncode(this.getValue()));
69 resizeTextArea: function () {
72 Roo.log([sh, this.getValue().split("\n").length * 30]);
73 this.inputEl().setHeight(Math.min(500, Math.max(sh, (this.getValue().split("\n").length +1) * 30)));
75 setValue : function(val)
77 Roo.bootstrap.TextArea.prototype.setValue.call(this,val);
79 this.updateMarkdown();