Skip to content

Real-time collaborative text editing for R and Shiny applications, built on Automerge CRDT.

Installation

pak::pak("shikokuchuo/autoedit")

Overview

autoedit provides two approaches to collaborative editing:

Textarea Editor
Interface Standard Shiny textarea CodeMirror 6 code editor
Sync In-process via Shiny WebSocket to external server
Use case Multi-session Shiny apps Cross-application collaboration
Dependencies automerge automerge, autosync

Textarea

A Shiny module that syncs across browser sessions using Shiny’s reactive system. No external server required - the Shiny process manages document state directly.

library(shiny)
library(autoedit)

ui <- fluidPage(
  textarea_ui("editor", label = "Collaborative notes")
)

server <- function(input, output, session) {
  text <- textarea_server("editor", initial_text = "Start typing...")
  observe(print(text()))
}

shinyApp(ui, server)

Open in multiple browser windows for real-time collaboration.

Editor

A CodeMirror 6 code editor widget that syncs via WebSocket to any automerge-repo compatible server. Suitable for collaboration across different applications or persistent documents.

library(autoedit)

# Connect to a sync server
editor("ws://localhost:3030", "document-id")

# Or use the public Automerge sync server
editor("wss://sync.automerge.org", "your-document-id")

Shiny Example

library(shiny)
library(automerge)
library(autosync)
library(autoedit)

server <- amsync_server(port = 3030, host = "127.0.0.1")
server$start()

doc_id <- create_document(server)
doc <- get_document(server, doc_id)
am_put(doc, AM_ROOT, "text", am_text(""))
am_commit(doc, "init")

ui <- fluidPage(editor_output("editor"))

shiny_server <- function(input, output, session) {
  output$editor <- editor_render(editor(server$url, doc_id))
}

onStop(function() server$stop())
shinyApp(ui, shiny_server)

Development

To rebuild the bundled JavaScript widget:

cd inst/build
npm install
npm run build
  • automerge - R bindings for Automerge CRDT
  • autosync - R sync server for Automerge documents