Client API

Controlling the co-editing session.

Codox will load and expose a client side API that enables programmatic control of how and when co-editing sessions should be started and stopped. The client shim automatically creates a globally accessible Codox class.

An instance of the Codox class should be created via new Codox() for each editor instance participating in a co-editing session.

Initialization

init(config)

Initialize an codox instance with app specific configurations. The general structure of the config JSON is as follows:

Key

Value

app

string

docid

string

username

string

apiKey

string

editor

Quill

autoStart (optional)

boolean

A Codox object must be initialized before it can be used. Please refer to individual editor integration instructions on how to specify the values of these parameters.

Starting a session

There is no distinction between starting a new session or joining an existing session from the API standpoint. The Codox client will handle the logic for the two cases in the backdrops.

Method 1

When init(config)is called without specifying a value for autoStart , or if the value ofautoStartis set totrue,the Codox client will immediately start a new session if one doesn't exist, or join an existing session if one exists.

Example:

const editor = new Quill("#editor");
const codox = new Codox();
var config = {
"app" : "quilljs",
"editor" : editor,
"docId" : "document_1",
"username" : "Joe Smith",
"apiKey" : "8a97c7db-5155-4245-9f9d-16e3dfd11ef2",
"autoStart" : true, //the same as not specifying autoStart
};
//start co-editing immediately
codox.init(config);

Method 2

If the config keyautoStartis set to the value false, then the Codox client will only be initialized, and the session bootstrapping process can be delayed till an explicit call to start().

start(config)

Calling start will explicitly start or join a co-editing session. The config parameter is optional and its specification is identical to init(config). If init(config) has already been invoked, calling start() will start/join the session based on the existing config values.

Example:

function init(){
const editor = new Quill("#editor");
const codox = new Codox();
var config = {
"app" : "quilljs",
"editor" : editor,
"docId" : "document_1",
"username" : "Joe Smith",
"apiKey" : "8a97c7db-5155-4245-9f9d-16e3dfd11ef2",
"autoStart" : false, //set to false to delay start/join
};
//initialization only
codox.init(config);
return codox;
}
const codox = init();
codox.start()

Stopping a session

stop()

Explicitly remove the client from a co-editing session. If the client is the last one in a co-editing session, the entire session will be stopped and removed.