I'm trying to allow codemirror to autoresize up to a given number of lines or pixel height. After this max-size is reached the widget should add scrollbars.
CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
viewportMargin: 50
});
max-height is not working
.CodeMirror {
border: 1px solid #eee;
height: 100%;
}
http://jsfiddle.net/qzjo4ejh/
Integrating with VuePut the <div> you will attach your CodeMirror to in your Vue template. Create the CodeMirror instance in the mounted lifecycle hook. Use $refs to get a reference to the <div> in the component's template. Listen for changes to your CodeMirror instance by listening to CodeMirror's 'changes' event.
By setting an editor's height style to auto and giving the viewportMargin a value of Infinity , CodeMirror can be made to automatically resize to fit its content.
This could be used to, for example, replace a textarea with a real editor: var myCodeMirror = CodeMirror(function(elt) { myTextArea. parentNode. replaceChild(elt, myTextArea); }, {value: myTextArea.
CodeMirror is a code editor component for the web. It can be used in websites to implement a text input field with support for many editing features, and has a rich programming interface to allow further extension. 9.
You should give .CodeMirror
a height: auto
style, and put the max-height
on .CodeMirror-scroll
. The embedded editor on the project page does this (view source, it's right near the top).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With