Singapore
DocsGitHub

A code editor for the browser that keeps every version.

Singapore is a modular code editor component. Each edit makes a new version of a persistent piece table, and anchors follow text through edits. Parsing, highlighting and language servers run in workers.

import {  anchorAfter,  createPieceTableSnapshot,  deleteFromPieceTable,  insertIntoPieceTable,  materializePieceTableFullText as text,  resolveAnchor,} from '@singapore-editor/textbuffer'// Every edit returns a new version. Old versions stay readable.const first = createPieceTableSnapshot('hello')const second = insertIntoPieceTable(first, 5, ' world')const branch = insertIntoPieceTable(first, 0, 'say ')text(first) // 'hello'text(second) // 'hello world'text(branch) // 'say hello'// An anchor follows its text through later edits.const world = anchorAfter(second, 6)const third = deleteFromPieceTable(second, 0, 6)resolveAnchor(third, world) // { offset: 0, liveness: 'live' }
This is a Singapore editor, configured for TypeScript. Edit this.

Install

npm install @singapore-editor/core

Then follow the quick start. Every docs page opens in the same editor you are installing.

Start here

Limits

The public API is still changing. Rows have fixed height, syntax colours cannot use bold or italic, and mobile and touch are outside the current target. There is no published editor-level benchmark against Monaco or CodeMirror yet.