So I'm trying to embed ACE in a Windows 8 JavaScript app that I'm working on and I've run into a bunch of troubles. Here is my code used to turn my <pre id="ace-editor">
element into an Ace editor.
WinJS.Utilities.ready(function ()
{
var editor = ace.edit('ace-editor');
editor.setTheme('ace/theme/monokai');
editor.getSession().setMode('ace/mode/javascript');
editor.getSession().setTabSize(4);
editor.getSession().setUseSoftTabs(false);
editor.setShowPrintMargin(false);
});
Firstly, there's a duplicate cursor appearing, with a bit of position and blinking time offset. Please have a look at the image below.
Secondly, once I've created the editor, I have to call every method twice so I can change an attribute on my editor object. E.g., look at the snippet below:
editor.setTheme('ace/theme/clouds');
editor.setTheme('ace/theme/clouds');
That is what I need to do to change the theme. Calling the setTheme()
method once won't do it.
Now, I'm new to Windows Store development but after a bit of messing around, I can get the cursor to go away if I remove the core UI stylesheet added by default. Same goes for the core JS files. If I remove those, the double firing problem goes away. Has anyone here got a solution or a clue as to why this is happening? I am using the nonconflict version of Ace, but I've tried the other one, too. And I suppose this sounds more of a WinJS problem than Ace, but if anyone here can help me, that'd be great.
Thanks!
Update:
For the duplicate cursor, it seems that ACE doesn't properly detect the Windows Store app environment because it doesn't use the string "Microsoft Internet Explorer" in its user agent. Instead, it's "MSAppHost/1.0" or something. So I've changed my ace.js
and now I detect for both. Here's the updated code:
(navigator.appName=="Microsoft Internet Explorer"||navigator.appName.indexOf("MSAppHost")>=0)
Thanks, user1743328!