Installation

How to use @otjs packages in your project.


β€œLife is really simple, but we insist on making it complicated.” ― Confucius

πŸ’‘

All installation script in this document are using pnpm as package manager. Kindly check the compatible commands and options, in case you are using any other package manager and/or runtime.

πŸš€ Quickstart

More often than not all you need is to synchronise your coding workspaces. For that, @otjs comes with two out of the box packages, namely - @otjs/firebase-ace and @otjs/firebase-monaco for Ace and Monaco editor respectively.

pnpm add @otjs/firebase-ace

or

pnpm add @otjs/firebase-monaco

πŸ”‘ Usage

Given these packages come batteries included, they only require few configuration, and all set to synchronise.

  • For @otjs/firebase-ace:
import { FireAceEditor } from "@otjs/firebase-ace";

const fireAce = new FireAceEditor({
  databaseRef:            // Database Reference in Firebase Realtime DB
  editor:                 // Ace Editor instance
  announcementDuration:   // Duration to hide Cursor tooltip (optional)
  userId:                 // Unique Identifier for current user
  userColor:              // Unique Color Code for current user
  userName:               // Human readable Name or Short Name (optional)
});
  • For @otjs/firebase-monaco:
import { FireMonacoEditor } from "@otjs/firebase-monaco";

const fireMonaco = new FireMonacoEditor({
  databaseRef:            // Database Reference in Firebase Realtime DB
  editor:                 // Monaco Editor instance
  announcementDuration:   // Duration to hide Cursor tooltip (optional)
  userId:                 // Unique Identifier for current user
  userColor:              // Unique Color Code for current user
  userName:               // Human readable Name or Short Name (optional)
});

⭐ Examples

Packages and their working examples with descriptions
ExampleSandbox (WIP)PlaygroundDescription

Ace + Firebase

@otjs/firebase-ace

Complete working example with Ace Editor and Firebase Database using @otjs/firebase-ace.

Monaco + Firebase

@otjs/firebase-monaco

Complete working example with Monaco Editor and Firebase Database using @otjs/firebase-monaco.

πŸ“¦ Packages

There are multiple packages published under @otjs namespace and each have a shared responsibility in building the whole system.

@otjs/ace

Editor Adapter for Ace Editor by Cloud9.

Go

@otjs/firebase-ace

Plaintext Editor with in-built binding for Firebase and Ace Editor.

Go

@otjs/firebase-monaco

Plaintext Editor with in-built binding for Firebase and Monaco Editor.

Go

@otjs/firebase-plaintext

Database Adapter for Firebase by Google Cloud.

Go

@otjs/monaco

Editor Adapter for Monaco Editor by Microsoft.

Go

@otjs/plaintext

Text Operation feature sets for Transformations.

Go

@otjs/plaintext-editor

Client (Editor) implementation for Plaintext Synchronisation.

Go

@otjs/state-machine

Database Synchronisation Toolkit.

Go