diff --git a/css/bootstrap-markdown.min.css b/css/bootstrap-markdown.min.css index 0c22f18..ac71e89 100644 --- a/css/bootstrap-markdown.min.css +++ b/css/bootstrap-markdown.min.css @@ -1 +1 @@ -.md-editor{display:block;border:1px solid #ddd}.md-editor>.md-header,.md-editor .md-footer{display:block;padding:6px 4px;background:#fff}.md-editor>.md-header{margin: 0;}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px}.md-editor>textarea{font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:14px;outline:0;outline:thin dotted \9;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6)} \ No newline at end of file +.md-editor{display:block;border:1px solid #ddd}.md-editor>.md-header,.md-editor .md-footer{display:block;padding:6px 4px;background:#fff}.md-editor>.md-header{margin: 0;}.md-editor>.md-preview{background:#fff;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;min-height:10px;overflow:auto}.md-editor>textarea{font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:14px;outline:0;outline:thin dotted \9;margin:0;display:block;padding:0;width:100%;border:0;border-top:1px dashed #ddd;border-bottom:1px dashed #ddd;border-radius:0;box-shadow:none;background:#eee}.md-editor>textarea:focus{box-shadow:none;background:#fff}.md-editor.active{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,0.6)} \ No newline at end of file diff --git a/js/bootstrap-markdown.js b/js/bootstrap-markdown.js index 4009647..cf797e8 100644 --- a/js/bootstrap-markdown.js +++ b/js/bootstrap-markdown.js @@ -131,7 +131,9 @@ rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows this.$textarea.attr('rows',rowsVal) - this.$textarea.css('resize','none') + if (this.$options.resize) { + this.$textarea.css('resize',this.$options.resize) + } this.$textarea .on('focus', $.proxy(this.focus, this)) @@ -257,16 +259,27 @@ editor.append(editorFooter) } - // Set width/height - $.each(['height','width'],function(k,attr){ - if (options[attr] != 'inherit') { - if (jQuery.isNumeric(options[attr])) { - editor.css(attr,options[attr]+'px') - } else { - editor.addClass(options[attr]) - } + // Set width + if (options.width && options.width !== 'inherit') { + if (jQuery.isNumeric(options.width)) { + editor.css('display', 'table') + textarea.css('width', options.width + 'px') + } else { + editor.addClass(options.width) } - }) + } + + // Set height + if (options.height && options.height !== 'inherit') { + if (jQuery.isNumeric(options.height)) { + var height = options.height + if (editorHeader) height = Math.max(0, height - editorHeader.outerHeight()) + if (editorFooter) height = Math.max(0, height - editorFooter.outerHeight()) + textarea.css('height', height + 'px') + } else { + editor.addClass(options.height) + } + } // Reference this.$editor = editor @@ -334,6 +347,12 @@ container.parent().append(replacementContainer) } + // Set the preview element dimensions + replacementContainer.css({ + width: container.outerWidth() + 'px', + height: container.outerHeight() + 'px' + }) + // Hide the last-active textarea container.hide() @@ -678,6 +697,7 @@ savable:false, width: 'inherit', height: 'inherit', + resize: 'none', iconlibrary: 'glyph', /* Buttons Properties */ diff --git a/less/bootstrap-markdown.less b/less/bootstrap-markdown.less index db8708f..e5bb417 100644 --- a/less/bootstrap-markdown.less +++ b/less/bootstrap-markdown.less @@ -27,6 +27,7 @@ border-top: 1px dashed @table-border-color; border-bottom: 1px dashed @table-border-color; min-height: 10px; + overflow: auto; } > textarea {