Skip to content

feat: add new UndoManager APIs #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions Sources/Loro/LoroFFI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9435,6 +9435,26 @@ public protocol UndoManagerProtocol : AnyObject {
*/
func canUndo() -> Bool

/**
* Ends the current group, calling UndoManager::undo() after this will
* undo all changes that occurred during the group.
*/
func groupEnd()

/**
* Will start a new group of changes, all subsequent changes will be merged
* into a new item on the undo stack. If we receive remote changes, we determine
* wether or not they are conflicting. If the remote changes are conflicting
* we split the undo item and close the group. If there are no conflict
* in changed container ids we continue the group merge.
*/
func groupStart() throws

/**
* Get the peer id of the undo manager
*/
func peer() -> UInt64

/**
* Record a new checkpoint.
*/
Expand Down Expand Up @@ -9574,6 +9594,39 @@ open func canUndo() -> Bool {
uniffi_loro_ffi_fn_method_undomanager_can_undo(self.uniffiClonePointer(),$0
)
})
}

/**
* Ends the current group, calling UndoManager::undo() after this will
* undo all changes that occurred during the group.
*/
open func groupEnd() {try! rustCall() {
uniffi_loro_ffi_fn_method_undomanager_group_end(self.uniffiClonePointer(),$0
)
}
}

/**
* Will start a new group of changes, all subsequent changes will be merged
* into a new item on the undo stack. If we receive remote changes, we determine
* wether or not they are conflicting. If the remote changes are conflicting
* we split the undo item and close the group. If there are no conflict
* in changed container ids we continue the group merge.
*/
open func groupStart()throws {try rustCallWithError(FfiConverterTypeLoroError.lift) {
uniffi_loro_ffi_fn_method_undomanager_group_start(self.uniffiClonePointer(),$0
)
}
}

/**
* Get the peer id of the undo manager
*/
open func peer() -> UInt64 {
return try! FfiConverterUInt64.lift(try! rustCall() {
uniffi_loro_ffi_fn_method_undomanager_peer(self.uniffiClonePointer(),$0
)
})
}

/**
Expand Down Expand Up @@ -16983,6 +17036,15 @@ private var initializationResult: InitializationResult = {
if (uniffi_loro_ffi_checksum_method_undomanager_can_undo() != 42348) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_ffi_checksum_method_undomanager_group_end() != 37541) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_ffi_checksum_method_undomanager_group_start() != 64372) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_ffi_checksum_method_undomanager_peer() != 45180) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_loro_ffi_checksum_method_undomanager_record_new_checkpoint() != 12209) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
8 changes: 4 additions & 4 deletions loro-swift/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion loro-swift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ name = "uniffi-bindgen"
path = "src/uniffi-bindgen.rs"

[dependencies]
loro-ffi = { version = "1.5.9" }
loro-ffi = { version = "1.5.10" }
uniffi = { version = "0.28.3" }

[build-dependencies]
Expand Down
Loading