Skip to content

Enable import of an applied patch to optionally register Undo actions #771

@NSTroy

Description

@NSTroy

Per this Discord thread: We need a way to allow import of an applied diff to register the changes with the document's UndoManager as if they had been made locally. The purpose is to enable use of Loro's UndoManager in an app that maintains more than one LoroDoc instance for a given document and exchanges Loro diffs to keep those instances synchronized between the components that own them. With the requested capability, we would be able to let the backend component be the designated owner of UndoManager instances, while the frontend component would remain able to make changes on the user's behalf that would be undoable by having the frontend delegate undo/redo requests to our backend.

@zxch3n 's suggestion of enabling this through origin-based logic would suffice for us. If possible, it would be ideal to have API that lets us register a callback/closure that would serve as a "treat diffs from this origin as local? [and therefore create Undo records for them]" predicate. That would offer more flexibility than requiring the origin string to have a particular value, prefix, or suffix.

We'll need to use this from Rust, Swift, and C#.

This appears to be the place in Loro's current implementation that decides to treat an imported diff's changes as non-local. Addressing this request would, I imagine, involve making that logic flexible to treating imported changes as "local" sometimes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions