Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a standalone mode extension for ACE?

Tags:

ace-editor

I'd like to extend ace with a mode for a custom language. As far as I can tell, the general process is:

  1. Download the ace source.
  2. Create a new lib/ace/mode/foo.js for your custom language.
  3. run "make build" (or similar) to rebuild ACE.
  4. Use the newly compiled build/src-min-no-conflict (or whatever) ACE distribution in your website.

But I want to just use an existing ACE distribution from their website, combined with my standalone new mode. I don't want to have to rebuild ACE as part of my build process in order to build my new mode. I got close by doing:

ace.config.setModuleUrl("foo-mode", "./foo.js");
session.setMode("foo-mode");

But I quickly ran into requirejs / dependency problems. For instance I couldn't do require("ace/mode/matching_brace_outdent") inside my mode. I temporarily hacked around that by first calling setMode('ace/mode/c_cpp') (which as a byproduct defines the matching_brace_outdent module). But I ran into even worse problems trying to get a custom WorkerClient to work.

Is my only option to build my mode as part of ACE? Or am I missing something?

like image 627
Michael Lehenbauer Avatar asked Nov 03 '22 09:11

Michael Lehenbauer


1 Answers

Try the pre-built release.

https://github.com/ajaxorg/ace-builds/releases

You might need to edit other files (lists of modes etc.) depending on how you wish to present your new language in the UI:

like image 88
Akber Choudhry Avatar answered Jan 04 '23 15:01

Akber Choudhry