• Stars
    star
    197
  • Rank 197,722 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Adds collaborative editing capabilities to the Monaco Editor

Monaco Collaborative Extensions

Build Status

Enhances the Monaco Editor by adding the ability to render cues about what remote users are doing in the system.

demo graphic

Installation

Install package with NPM and add it to your development dependencies:

npm install --save-dev @convergencelabs/monaco-collab-ext

Demo

Go here to see a live demo of multiple cursors, multiple selections, and remote scrollbars (Visit on multiple browsers, or even better, point a friend to it too). This uses Convergence to handle the synchronization of data and user actions.

Usage

RemoteCursorManager

The RemoteCursorManager allows you to easily render the cursors of other users working in the same document. The cursor position can be represented as either a single linear index or as a 2-dimensional position in the form of {lineNumber: 0, column: 10}.

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const remoteCursorManager = new MonacoCollabExt.RemoteCursorManager({
  editor: editor,
  tooltips: true,
  tooltipDuration: 2
});

const cursor = remoteCursorManager.addCursor("jDoe", "blue", "John Doe");

// Set the position of the cursor.
cursor.setOffset(4);

// Hide the cursor
cursor.hide();

// Show the cursor
cursor.show();

// Remove the cursor.
cursor.dispose();

RemoteSelectionManager

The RemoteSelectionManager allows you to easily render the selection of other users working in the same document.

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const remoteSelectionManager = new MonacoCollabExt.RemoteSelectionManager({editor: editor});

const selection = remoteSelectionManager.addSelection("jDoe", "blue");

// Set the range of the selection using zero-based offsets.
selection.setOffsets(45, 55);

// Hide the selection
selection.hide();

// Show the selection
selection.show();

// Remove the selection.
selection.dispose();

EditorContentManager

The EditorContentManager simplifies dealing with local and remote changes to the editor.

const editor = monaco.editor.create(document.getElementById("editor"), {
  value: "function helloWorld = () => { console.log('hello world!')",
  theme: "vs-dark'",
  language: 'javascript'
});

const contentManager = new MonacoCollabExt.EditorContentManager({
  editor: editor,
  onInsert(index, text) {
    console.log("Insert", index, text);
  },
  onReplace(index, length, text) {
    console.log("Replace", index, length, text);
  },
  onDelete(index, length) {
    console.log("Delete", index, length);
  }
});

// Insert text into the editor at offset 5.
contentManager.insert(5, "some text");

// Replace the text in the editor at range 5 - 10.
contentManager.replace(5, 10, "some text");

// Delete the text in the editor at range 5 - 10.
contentManager.delete(5, 10);

// Release resources when done
contentManager.dispose();

More Repositories

1

ace-collab-ext

Enhances the Ace Editor with real time collaboration user experience.
TypeScript
89
star
2

convergence-server

The Convergence Server
Scala
87
star
3

convergence-client-javascript

The Convergence JavaScript Client
TypeScript
49
star
4

convergence-project

The project used for Convergence Project Management and Issue Reporting
41
star
5

html-text-collab-ext

Utilities that enable real time collaboration in HTML TextAreas
TypeScript
40
star
6

javascript-examples

Examples for the Convergence Real-time Collaboration Engine
JavaScript
38
star
7

code-editor-demo

A mock up of a code editor built using React, Ace, Flux, and Convergence
JavaScript
16
star
8

codemirror-collab-ext

Collaborative Extensions for CodeMirror
TypeScript
14
star
9

convergence-proto

The Convergence Client-Server Protocol
Scala
13
star
10

convergence-admin-console

The Convergence Admin Console
TypeScript
13
star
11

convergence-docker-compose

Deployment scripts and documentation for Convergence https://convergence.io
HTML
13
star
12

mxgraph-adapter

An adapter between mxGraph and Convergence
TypeScript
6
star
13

typedoc-plugin-custom-modules

A typedoc plugin for customizing the definition and grouping of modules
TypeScript
6
star
14

mxgraph-demo

A demonstration of collaborative diagram editing using mxGraph and Convergence
JavaScript
6
star
15

jointjs-utils

Utilities to make using JointJS with Convergence easy.
TypeScript
5
star
16

js-dev-guide

Convergence Developers Guide
HTML
4
star
17

convergence-omnibus-container

The Omnibus (All-In-One) container distribution of Convergence
Dockerfile
4
star
18

model-getting-started

A basic example demonstrating the model API.
JavaScript
4
star
19

dom-utils

Utilities to bind a Convergence Model to the DOM.
TypeScript
4
star
20

convergence-cluster-seed

The Convergence Cluster Seed
Scala
2
star
21

color-assigner

A utility to help assign a set of colors to unique resources.
TypeScript
2
star
22

throttle-utils

Utilities to help rate limit event processesing
JavaScript
2
star
23

input-element-bindings

Helper utilities to bind Convergence data to HTML Input Elements.
TypeScript
2
star
24

todomvc

The famous TodoMVC app written using React, MobX, and Convergence
TypeScript
2
star
25

geo-sketch-demo

A GeoSpatial collaboraiton demo using React, MobX, and ArcGIS
TypeScript
1
star
26

convergence-jwt-util

A JWT Generator for Convergence.
JavaScript
1
star
27

typedoc-theme

A customization of the default typedoc theme. See http://docs.convergence.io/js-api/
Handlebars
1
star
28

string-change-detector

JavaScript
1
star
29

textarea-tutorial

The code associated with out Textarea Tutorial
JavaScript
1
star
30

convergence-admin-console-container

The container build of the Convergence Admin Console
Shell
1
star