Make sure that you have installed:
- NodeJS (v8.10.0)
- npm (v3.5.2)
- Install
ace-collab
as a dependency usingnpm
:
npm install ace-collab
- Import
Editor
fromace-collab
:
import Editor from 'ace-collab'
- Initialize new
Editor
instance:
const editorConfig = {
anchorDOM: document.querySelector('#editor'),
mode: 'ace/mode/csharp',
theme: 'ace/theme/monokai',
}
const editor = new Editor(editorConfig)
- Initialize new collab session by using
init
method:
const serverConfig = {
docId: '', // Provide empty if want to create new session, provide value if want to join existing one
host: '127.0.0.1',
port: '3333',
username: 'John Doe',
ssl: false,
}
const readOnly = false // if set to true, only admin will be able to modify the code
editor.init(serverConfig, readOnly);
- Import and run
startServer
function fromace-collab
:
import startServer from 'ace-collab/lib/server'
const serverConfig = {
allowedOrigins: [], // Provide empty if want to allow entrance for every host, provide string values if want to allow only few
host: '0.0.0.0',
port: 3333,
}
startServer(serverConfig)