简体   繁体   English

使用CodeMirror文本编辑器时,如何删除textarea底部的行?

[英]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. 我的html代码中有一个textarea,并且我也使用CodeMirror文本edior来应用该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 编织: 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? 您有两行代码,但是编辑器说您有3行,并且您想让它显示正确的两行吗?

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. 在创建CodeMirror实例之前,您可以在html中轻松修复此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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