Skip to content
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

api:undomanager.undo()/redo() #672

Open
sunnyawake5 opened this issue Mar 1, 2025 · 1 comment
Open

api:undomanager.undo()/redo() #672

sunnyawake5 opened this issue Mar 1, 2025 · 1 comment

Comments

@sunnyawake5
Copy link

can undomanager.undo()/redo() return the stack item which may attach some user specified info for example custom caret position?

@zxch3n
Copy link
Member

zxch3n commented Mar 2, 2025

Yes, you can specify a custom value and cursor information in the returned value of onPush, which will be present in the arguments of onPop.

export type UndoConfig = {
    mergeInterval?: number,
    maxUndoSteps?: number,
    excludeOriginPrefixes?: string[],
    onPush?: (isUndo: boolean, counterRange: { start: number, end: number }, event?: LoroEventBatch) => { value: Value, cursors: Cursor[] },
    onPop?: (isUndo: boolean, value: { value: Value, cursors: Cursor[] }, counterRange: { start: number, end: number }) => void
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants