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

Is there a way to exclude some object saving in history? #55

Open
Saqib92 opened this issue Dec 19, 2023 · 2 comments
Open

Is there a way to exclude some object saving in history? #55

Saqib92 opened this issue Dec 19, 2023 · 2 comments

Comments

@Saqib92
Copy link

Saqib92 commented Dec 19, 2023

I have background image and then i add some objects on canavs, and start doing undo it also undo the backgound image. but want to keep background image. so is there any option to exclude an object saving into history?

@DTHRT
Copy link

DTHRT commented Apr 11, 2024

Hey, you can make this feature by yourself by extending fabric-history 🔥.
So what you need to do:

  1. Copy the library code from here: https://raw.githubusercontent.com/lyzerk/fabric-history/master/src/index.js;
  2. Paste it into your project (in my case: I created CustomFabricClass.js with this code and imported it the React component where I'm using it);
  3. Make your feature by modyfing code which you pasted ⭐

This library just adds special methods to fabric.Canvas. Since you want to filter object saving - you can implement it by modyfing fabric.Canvas.prototype._historySaveAction

Hope it helps 😁

@Shivamc489
Copy link
Contributor

as @DTHRT directed, I did the same and it worked for me.
Big thanks man 🙏
I have raised #58 which aims to solve this.

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

3 participants