硬骨素抗体确实具有用于分钟行数的溶液-在Codemirror ?
最小高度为我工作,但不插入空行的高度。
JS
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
gutter: true,
lineWrapping: true
});
CSS
.CodeMirror-scroll {
overflow: auto;
height: auto; overflow: visible;
position: relative;
outline: none;
min-height: 300px; /* the minimum height */
}
也许有一个简单的解决方案来插入空行是什么?
除去min-height: 300px;
并初始化新线作为起始值编辑:
var minLines = 3;
var startingValue = '';
for (var i = 0; i < minLines; i++) {
startingValue += '\n';
}
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
gutter: true,
lineWrapping: true,
value: startingValue
});
目前,CodeMirror的value
选择似乎并不有长达2.21版本的影响。 这可以通过使用很容易被绕过setValue()
初始化后:
///...
// initialize as before, omitting the value option
editor.setValue(startingValue);
注意:确保不设置autoClearEmptyLines: true
,因为它会发生冲突和抵消插入空行。
所以家伙,我得到了解决。 任何理由编辑器没有得到value
从配置选项,所以我后设置的值。 @Eliran感谢,我用你的方法来设置值。
editor.setValue(startingValue);
DEMO
http://jsfiddle.net/vujLv/1/