Detecting new line in codemirror

橙三吉。 提交于 2019-12-06 14:50:14

Catching the enter key is built into the api.

  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    lineNumbers: true,
    lineWrapping:'true',
      extraKeys:{
        Enter: function(){
            alert('enter pressed');
        }
    }
  });

I'm not currently aware of any api that allows you to capture a 'wrap' event.

You could get the CodeMirror-scrollbar-inner height, and if it size increases, and it's not an onpaste event you know the line wrapped or enter was pressed :)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!