Skip to content

Commit

Permalink
feat: expose detached editing configure to wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
zxch3n committed Sep 24, 2024
1 parent 1d64490 commit 3651ce0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions crates/loro-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,36 @@ impl LoroDoc {
Self(Arc::new(doc))
}

/// Enables editing in detached mode, which is disabled by default.
///
/// The doc enter detached mode after calling `detach` or checking out a non-latest version.
///
/// # Important Notes:
///
/// - This mode uses a different PeerID for each checkout.
/// - Ensure no concurrent operations share the same PeerID if set manually.
/// - Importing does not affect the document's state or version; changes are
/// recorded in the [OpLog] only. Call `checkout` to apply changes.
#[wasm_bindgen(js_name = "setDetachedEditing")]
pub fn set_detached_editing(&self, enable: bool) {
self.0.set_detached_editing(enable);
}

/// Whether the editing is enabled in detached mode.
///
/// The doc enter detached mode after calling `detach` or checking out a non-latest version.
///
/// # Important Notes:
///
/// - This mode uses a different PeerID for each checkout.
/// - Ensure no concurrent operations share the same PeerID if set manually.
/// - Importing does not affect the document's state or version; changes are
/// recorded in the [OpLog] only. Call `checkout` to apply changes.
#[wasm_bindgen(js_name = "isDetachedEditingEnabled")]
pub fn is_detached_editing_enabled(&self) -> bool {
self.0.is_detached_editing_enabled()
}

/// Set whether to record the timestamp of each change. Default is `false`.
///
/// If enabled, the Unix timestamp will be recorded for each change automatically.
Expand Down

0 comments on commit 3651ce0

Please sign in to comment.