简体   繁体   中英

How to remove line at the bottom of textarea while using CodeMirror text editor?

I have a textarea in my html code, and I also use CodeMirror text edior to apply that textarea. But that textarea results in many lines that I don't need at the buttom.

在此处输入图片说明

So, how to set up configuration to remove those unwanted lines at the buttom of my textarea.

This is my code:

<body>

                <textarea id="myEditor">
                    var myTextArea= document.getElementById('myEditor');
                    var myCodeMirror = CodeMirror.fromTextArea(myTextArea);
                </textarea>

                <script>
                    var myTextArea = document.getElementById('myEditor');
                    var myCodeMirror = CodeMirror.fromTextArea(myTextArea, {
                        theme: "lesser-dark",
                        lineNumbers: true,
                        mode: 'text/html',
                        tabMode: 'indent',
                        onChange: function(){
                            clearTimeout(delay);
                            delay = setTimeout(updatePreview, 300);
                        }
                    });
                </script>
        </body>

Weave: http://kodeweave.sourceforge.net/editor/#da9875c8610f88c9e479d8d271e6ba9a

If I understand your question correctly (relative to your picture). You have two lines of code, but your editor says you have 3, and you want to have it show two correct?

This is because you have a new line at the bottom of your textarea. You could easily fix this in html before your CodeMirror instance is created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM