Creates a real-time collaborative text editor using CodeMirror 6 and Automerge CRDT, synchronized via WebSocket to an automerge-repo compatible sync server.
Details
The widget connects to the specified sync server and synchronizes a CodeMirror 6 editor with an Automerge document. Multiple users can edit the same document simultaneously with automatic conflict resolution.
The Automerge document must have a "text" field of type Automerge text
(created with automerge::am_text()).
In Shiny applications, the current editor content is available as an
input value at input$<outputId>_content.
Examples
if (FALSE) { # \dontrun{
# Connect to the public Automerge sync server
editor("wss://sync.automerge.org", "your-document-id")
# Or use with an autosync server
server <- autosync::amsync_server(port = 3030)
server$start()
doc_id <- autosync::create_document(server)
doc <- autosync::get_document(server, doc_id)
automerge::am_put(doc, automerge::AM_ROOT, "text", automerge::am_text(""))
automerge::am_commit(doc, "init")
editor(server$url, doc_id)
} # }