Skip to content

Initialization

codox.init(config)

Once a codox instance has been created, you should initialize thecodox instance with app specific configurations. The general structure of the config JSON is as follows:

KeyValue
app(required)string
docId(required)string
apiKey(required)string
user(required)object
editor(required)object
autoStart(optional)boolean
avatar(optional)object
showUI(optional)boolean
showCursor(optional)boolean
cursorAlwaysOn(optional)boolean
showPointer(optional)boolean
pointers(optional)object
hooks(optional)object
username(deprecated)string

Description

app

string

The static string value 'froala', 'quill', or 'tinymce'

docId

string

A unique identifier for the document. In a content management service, this could for example be the resource identifier for the document.

The uniqueness of the identifier is essential to avoid collisions between one co-editing session and another. In particular, if you are running multiple subdomains for user subscriptions, make sure the docId is “namespaced” and unique across all the subdomains .

apiKey

string

The API key for the integration. You can obtain a key from your account dashboard.

user

Object

This user field allows you to attach app specific meta-data to the user.

KeyValue
name(optional)string
email(optional)string
avatar(optional)url
id(optional)string
color(optional)string

The value of the avatarfield is a link to an image resource. If avatar has a value specified, it will override the default solid background avatar implementation.

The value of color can be any valid css color property value (e.g., 'red', '#00ff00', 'rgb(0, 0, 255)') .

The ‘user’ object will be emitted on ‘users_update’ event.

editor

Object

A reference to an editor instance for which the co-editing session should start in. For Froala and Quill integrations, assign editor the reference to the editor object. For TinyMCE, the plugin will pass in the editor object reference automatically.

Each codox instance is bound to a single editor instance. If the editor is destroyed and recreated as part of some UI framework lifecycle events, then a new codox object should be created with the new editor instance.

autoStart (optional)

boolean

Set to true to start co-editing immediately on call toinit(config). Set to false to initialize but delay the start to co-editing (see the codox.start() client API).

Default to true.

avatars (optional)

object

This is an optional configuration parameter that determines the position of the avatars relative to the editor window.

KeyValue
left(optional)boolean
vertical(optional)boolean

The avatars are placed horizontally by the top-right corner of the editor window by default.

left and verticalboth default to false

showUI (optional)

boolean

Set to true to show avatars for online users. Set to false to hide the avatars.

Defaults to true.

showCursor (optional)

boolean

Set to true, to display cursor positions and selections for remote co-editing users. Set to false to hide cursor positions and selections.

Defaults to true.

cursorAlwaysOn (optional)

boolean

Set to true to always show remote users’ caret with username.

Defaults to false

showPointer (optional)

boolean

Set true, to display pointer positions and click events of remote co-editing users. Set false to hide pointers.

Defaults false.

pointers (optional)

object

This is an optional parameter that controls the rendering of remote pointers. Static string values: ‘arrow’, ‘hand’, ‘pointer’, ‘pointerSolid’.

KeyValue
shape(optional)string

hooks`` (optional)

object

A collection of callback functions. See hooks section for details.

username (optional)

string

The name of the user joining the co-editing session. For a content management service, this should be set for each logged-in user based on their credentials. This name will be displayed during real-time co-editing sessions.

username is deprecated and will be removed in the next major release (v2). Please use the user meta-data field.

Please refer to individual editor integration instructions on how to specify the values of these parameters.