ace-editor

How to get the ace editor to adjust to its parent div

限于喜欢 提交于 2019-11-30 00:50:47
问题 I have the ace div inside another div and I would like the ace editor to adjust it's width and height to the parent div. I call editor.resize() but nothing happens. <!DOCTYPE html> <html lang="en" style="height: 100%"> <head> <title>ACE in Action</title> <style type="text/css" media="screen"> #editor { top: 0; right: 0; bottom: 0; left: 0; height: 100px; } </style> </head> <body style="height: 100%"> <div style="background-color: red; height: 100%; width: 100%;"> <div id="editor">function foo

How do I get value from ACE editor?

我们两清 提交于 2019-11-29 22:02:57
I am using ACE editor for the first time. I have the below questions related to it. How do I find the instance of ACE editor on the page? I don't want to maintain a global variable which will hold the editor instance. I need to find its instance on demand. How to get and set its value? I am open for suggestions for any better editor than ACE editor which will support almost all types of language/markup/css etc and highly integrated with jQuery . Mrchief Per their API : Markup: <div id="aceEditor" style="height: 500px; width: 500px">some text</div> Finding an instance: var editor = ace.edit(

How can I highlight multiple lines with Ace?

吃可爱长大的小学妹 提交于 2019-11-29 21:16:11
问题 The old method mentioned in similar questions here is the following: var editor = ace.edit("editor"); var Range = ace.require('ace/range').Range; editor.setReadOnly(true); editor.setTheme("ace/theme/github"); editor.getSession().setMode("ace/mode/javascript"); editor.getSession().addMarker(new Range(1, 0, 15, 0), "ace_active_line", "background"); Unfortunately it doesn't work, as you can see here: http://jsbin.com/acotuv/1/edit Any suggestions? 回答1: seems like signature of the addMarker

Can Ace Editor support multiple code editors in one page?

社会主义新天地 提交于 2019-11-29 18:56:53
问题 I'm looking to implement a web app that features "coding-competition"-styled interface with 2 different code editors in a single screen. One will be read only and the other will be active and would allow the user to edit. I'm currently using Ace Editor and i find it awesome and simple to use. However, here's my question. I seem to be getting an error upon trying to implement 2 different editors in a single page. Uncaught RangeError: Maximum call stack size exceeded Is the variable "editor" in

How to specify a list of custom tokens to list for autocompletion in Ace Editor?

五迷三道 提交于 2019-11-29 18:13:34
After following the setup for autocompletion with Ace Editor , I have it working with react-ace . However, I need some custom tokens to be available in the built-in autocomplete list. The repository for react-ace has these properties defined as enableBasicAutocompletion: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]), enableLiveAutocompletion: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]), but what is this array ? I have tried setting enableBasicAutocompletion={ ['custom'] } , and enableBasicAutocompletion={ [ (...args) => console.log(args) ] } but both fails with an error

When I try to create a Range object in ace.js, an “Illegal Constructor” error is thrown

淺唱寂寞╮ 提交于 2019-11-29 09:13:54
问题 I am trying to create a Range object for the ace.js editor in my code, but it's not working. It is failing in a way I can't figure out. In the Ace documentation, this constructor is: new Range(Number startRow, Number startColumn, Number endRow, Number endColumn) But when I try this in my code: new Range(0, 0, 0, 1) It raises an Uncaught TypeError: Illegal constructor error. What is causing this behavior, and why doesn't it match the documentation? 回答1: Range is a native type is most browsers

Ace Editor: Lock or Readonly Code Segment

痴心易碎 提交于 2019-11-29 06:15:50
问题 Using the Ace Code Editor can I lock or make readonly a segment of code but still allow other lines of code to be written or edited during a session? 回答1: Here is the start of a solution: $(function() { var editor = ace.edit("editor1") , session = editor.getSession() , Range = require("ace/range").Range , range = new Range(1, 4, 1, 10) , markerId = session.addMarker(range, "readonly-highlight"); session.setMode("ace/mode/javascript"); editor.keyBinding.addKeyboardHandler({ handleKeyboard :

How to specify a list of custom tokens to list for autocompletion in Ace Editor?

时光怂恿深爱的人放手 提交于 2019-11-28 12:35:05
问题 After following the setup for autocompletion with Ace Editor, I have it working with react-ace. However, I need some custom tokens to be available in the built-in autocomplete list. The repository for react-ace has these properties defined as enableBasicAutocompletion: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]), enableLiveAutocompletion: PropTypes.oneOfType([PropTypes.bool, PropTypes.array]), but what is this array ? I have tried setting enableBasicAutocompletion={ ['custom'] } ,

How do I use beautify in Ace Editor?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-28 10:01:54
I've found the beautify extension in Ace editor but I don't see any examples of how to use it. Here's what I have so far: var beautiful = ace.require("ace/ext/beautify"); beautiful.beautify(); but I get the error: Result of expression 'e' [undefined] is not an object. It looks like this works: var beautify = ace.require("ace/ext/beautify"); // get reference to extension var editor = ace.edit("editor"); // get reference to editor beautify.beautify(editor.session); It requires that you pass in the Ace Editor session as the first parameter. In my original question I did not pass in any variables

With the ACE Editor, how can I unbind an event?

*爱你&永不变心* 提交于 2019-11-28 07:13:06
问题 https://github.com/ajaxorg/ace/wiki/Embedding---API editor.session.on('change', callback); is how you bind an event to "change". But how do I unbind it? 回答1: Use removeListener to remove a specific callback. editor.session.removeListener('change', callback); or a shorter version editor.session.off('change', callback); Use removeAllListeners to remove all callbacks. editor.session.removeAllListeners('change'); 来源: https://stackoverflow.com/questions/6157435/with-the-ace-editor-how-can-i-unbind