There’s already an API defined, but it has zero documentation, and isn’t exposed in the way that most JS libraries these days expose APIs. I’m a bit out of touch with what the standard practice is for JS module systems like npm/browserify/requirejs but i think these would be worth looking at to determine the best approach.
Currently the closest thing to a formal API definition is in the following file:
experiments/sample/code/objc_bindings/EDJSInterface.h
or it’s C++ equivalent:
experiments/corinthia/src/JSInterface.h
This defines a set of modules, and indicates the methods/parameters/return types. Within the JS code, these are all global variables (e.g. Selection_selectAll in the file Selection.js). In node.js for example, I think you have a module object implicitly defined, and you say module.exports = { … }. So we need to work out a way of doing this that will avoid the need for global variables.
We’ll also need to consider the dependencies between modules, e.g. Selection.js uses DOM.js but not the other way round (to the best of my knowledge). Angular.js has quite a nice dependency injection technique which we could consider for this.
So I think the code should still remain in multiple files, but exposed using such a module system. Then the next main thing is documentation. I’ll make this my next main priority.
Also, I noticed you’d imported the editor files into corinthia-editorlib, but not the related tests. I suggest we keep the two together in the same repository, since they’re so closely tied together.
I actually have very extensive history for the editor library which was never present in the original Corinthia repository that I made publicly available last year, since it began with what at the time was simply a snapshot of the relative parts of the code from UX Write. However I’m now going through the UX Write repository and using some git gymnastics to try and extract the full history of *just* the JS editing code. Once I’ve done this I’ll put it in a new branch in corinthia-editorlib. I think history could be at least of some help for others trying to understand the library, but I agree that proper documentation is needed.