为什么 ace 编辑器加载所有文本突出显示以及如何删除它? [英] Why does ace editor load with all text highlighted and how to remove it?

查看:20
本文介绍了为什么 ace 编辑器加载所有文本突出显示以及如何删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码如下:

$scope.aceIDEs='var hw = new function() {\n console.log("Hello world!");\n}'$scope.loadAceJSExample = 函数(_editor){_editor.setValue($scope.aceIDEs);_editor.getSession().setUseWorker(false);_editor.setHighlightActiveLine(true);};

还有:

<div>ui-ace="{onLoad : loadAceJSExample,onChange : aceJSExampleChanged,useWrapMode : 真,主题:'github',showGutter:真的,模式:'javascript'}"/>

我尝试调用 _editor.getSession().removeMarker();但没有帮助

每次我刷新它看起来像这样,一旦我点击它就会恢复正常:

解决方案

使用 _editor.session.setValue($scope.aceIDEs); 也会重置 undomanager.或者,您可以使用 _editor.setValue($scope.aceIDEs, cursorPos);.其中 cursorPos=-1 将光标放在开头,cursorPos=1 放在结尾.或者在设置值后调用_editor.clearSelection().

My code looks like :

$scope.aceIDEs='var hw = new function() {\n  console.log("Hello world!");\n}'

$scope.loadAceJSExample = function (_editor) {
_editor.setValue($scope.aceIDEs);
_editor.getSession().setUseWorker(false);
_editor.setHighlightActiveLine(true);
};

And:

<div class="container fade-in" style='padding: 4em;'>
<div>
      ui-ace="{onLoad : loadAceJSExample,
      onChange : aceJSExampleChanged,
      useWrapMode : true,
      theme : 'github',
      showGutter: true,
      mode: 'javascript'

    }" />

I tried calling _editor.getSession().removeMarker(); but did not help

Every time i refresh it looks like this,once i click in it returns to normal:

解决方案

Use _editor.session.setValue($scope.aceIDEs); which also resets undomanager. Alternatively you can use _editor.setValue($scope.aceIDEs, cursorPos);. where cursorPos=-1 puts cursor at start and cursorPos=1 at the end. Or call _editor.clearSelection() after setting value.

这篇关于为什么 ace 编辑器加载所有文本突出显示以及如何删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆