calternal-collab
Yrs XML bridge for the editor’s ProseMirror schema.
The shared XML fragment is named default, matching TipTap Collaboration.
Element attributes are JSON values, as y-prosemirror writes them. Text marks
are formatting attributes on Y.XmlText, rather than nested XML elements.
History plans in history reuse this bridge and return normal Yjs updates
for the collaboration event path to apply (DESIGN §§60–61, #975).
External writes merge against the last-synced base in one transaction
(DESIGN §9). Shared edits apply once; retained conflict copies have unique
file anchors and replay-stable identities (#634, DESIGN §33).
Source: crates/calternal-collab/src/lib.rs
Modules
Section titled “Modules”| Module | Summary |
|---|---|
history |
Live document history contract (DESIGN §61, #975 Phase 2). |
markdown |
Markdown dialect bridge for editor content. |
canvas |
Whole-element Canvas events for the server’s Yrs document (DESIGN §60, #976). |
repeats |
Read-only detector for Note bodies damaged by the room epoch bug (see crate::stored): a tab that merged its old document into a rebuilt room saved the whole body twice, and each later restart doubled it again. |
session |
Public Note links cannot submit room updates (DESIGN §54, #981). |
BridgeError
Section titled “BridgeError”pub enum BridgeErrorNo doc comment.
Variants
InvalidNode(&'static str)InvalidJson
Implements: Debug, std::fmt::Display, std::error::Error
Source: crates/calternal-collab/src/lib.rs:29
Functions
Section titled “Functions”apply_external_blocks
Section titled “apply_external_blocks”pub fn apply_external_blocks(doc: &Doc, old: &Value, new: &Value) -> Result<(), BridgeError>Apply changed top-level blocks as one external-origin transaction. Unchanged Yrs elements keep their identity, so collaborators’ edits to other blocks survive. If both sources changed the same block, retain the live block and insert the external block beside it. The next Markdown write versions both.
Source: crates/calternal-collab/src/lib.rs:296
apply_named_blocks
Section titled “apply_named_blocks”pub fn apply_named_blocks( doc: &Doc, old: &Value, new: &Value, origin: &str,) -> Result<(), BridgeError>Apply a named collaborator’s edit in one Yrs transaction. The caller keeps one invocation per agent turn to provide one undo boundary.
This is a three-way merge of top-level blocks: old is the base both
sides started from, new is the external side and the live Yrs fragment
is the other side. See plan_block_edits for the algorithm. Every edit
is placed in live coordinates and applied from the end of the fragment to
its start, so no edit moves the index of an edit that is not applied yet
(#89: indices computed against old put later inserts at wrong places).
Source: crates/calternal-collab/src/lib.rs:309
from_prosemirror
Section titled “from_prosemirror”pub fn from_prosemirror(pm: &Value) -> Result<Doc, BridgeError>Insert a validated ProseMirror tree into a fresh Yrs document.
Source: crates/calternal-collab/src/lib.rs:50
to_prosemirror
Section titled “to_prosemirror”pub fn to_prosemirror(doc: &Doc) -> Result<Value, BridgeError>Read the live Yrs fragment as schema-shaped ProseMirror JSON.
Source: crates/calternal-collab/src/lib.rs:158
Constants
Section titled “Constants”FRAGMENT
Section titled “FRAGMENT”pub const FRAGMENT: &strName used by TipTap Collaboration when no fragment override is supplied.