sharedb-monaco

ShareDB Bindings for the Monaco Editor

Showing:

Popularity

Downloads/wk

13

GitHub Stars

11

Maintenance

Last Commit

8mos ago

Contributors

0

Package

Dependencies

4

Size (min+gzip)

28.6KB

License

MIT

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

sharedb-monaco

Two-way bindings between ShareDB and the Monaco Editor

Developed for the CodeCollab project.

Tested and works well with monaco-react.

Install

Using NPM:

$ npm install sharedb-monaco

Usage

Sample usage of this library in action

import ShareDBMonaco from "sharedb-monaco";
import { editor } from "monaco-editor";

// Get a monaco editor (ICodeEditor) instance
let editor = editor.create(document.getElementById("editor"), {
    value: "print('Hello World!')",
    language: "python"
});

let binding = new ShareDBMonaco(options);

// Attach editor when document is initialised
binding.on("ready", () => {
    binding.add(editor, path);
});

ShareDBMonaco Options

  • opts.id ID of the ShareDB document
  • options.namespace namespace of document within ShareDB, to be equal to that on the server
  • options.wsurl Websocket URL for ShareDB Server API

ShareDBMonaco Instance

Events

  • ready Emitted when ShareDB document has initialised and ShareDBMonaco is ready for an editor to be attached.
  • close Emitted when the close() method is called.

Methods

add(editor, path, viewOnly?): Attaches an editor to the ShareDBMonaco instance

Parameters:

  • editor An instance of the monaco editor (iCodeEditor).
  • path Path on ShareDB JSON object to apply operations to. For example, if your ShareDB document is structured as { foo: "", bar: "" }, set path = "foo" for ShareDBMonaco to apply operations to foo
  • viewOnly (OPTIONAL) Is the editor in viewOnly mode. Operations are treated differently for viewOnly editors.

close(): Closes the ShareDB and WebSocket connections between the server and this ShareDBMonaco instance. Also detaches any listeners on the editor.

License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100