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

Feature: Prevent an action from being added to the undo stack #4283

Closed
Atrus619 opened this issue Apr 7, 2023 · 2 comments
Closed

Feature: Prevent an action from being added to the undo stack #4283

Atrus619 opened this issue Apr 7, 2023 · 2 comments
Labels
enhancement Improvement over existing feature other Feature not covered by the rest of the labels

Comments

@Atrus619
Copy link

Atrus619 commented Apr 7, 2023

I'm working on implementing an image node that is built in multiple steps:

  1. User uploads an image file
  2. Image node is created, without a src attribute and suspends
  3. API call goes to the backend to retrieve a pre-signed URL to upload the image as well as an s3 key where the image will be stored
  4. Image component receives the s3 key and stores it for serialization (the src of the image is not serialized in order to compress it)
  5. Image ends suspension
  6. Later, when the saved editor is opened up again, the s3 key is used again to ask the backend for a pre-signed url to use as the src for the image (suspending while it waits async)

Because this is a multiple step process involving multiple changes to the editor, the action of adding an image to the editor cannot be undone in one ctrl+z. I would like to be able to specify in some way for a set of commands to not be added to the undo stack, or to be added to the undo stack as one batched change

I haven't been able to find any good examples online or in the documentation of how to use the @lexical/history library to do this, it seems this only really supports undoing, redoing, clearing the editor, and sharing history between components.

@Atrus619 Atrus619 added the enhancement Improvement over existing feature label Apr 7, 2023
@zurfyx
Copy link
Member

zurfyx commented Apr 12, 2023

editor.update(..., {tag: 'history-merge'} would this work for you?

@zurfyx zurfyx added the other Feature not covered by the rest of the labels label Apr 12, 2023
@Atrus619
Copy link
Author

this works great - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement over existing feature other Feature not covered by the rest of the labels
Projects
None yet
Development

No branches or pull requests

2 participants