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

feat: Canvas data serialization #294

Open
junghwan-park opened this issue Jan 10, 2020 · 9 comments
Open

feat: Canvas data serialization #294

junghwan-park opened this issue Jan 10, 2020 · 9 comments
Labels
Feature New features to implement
Milestone

Comments

@junghwan-park
Copy link
Member

  • Save ImageEditor's state to JSON format
    • object
      • backgroundImage
      • drawings
      • texts
      • shapes
      • icons
    • filter
    • undo/redo stack

issue-ref: #244

@junghwan-park junghwan-park added the Feature New features to implement label Jan 10, 2020
@junghwan-park junghwan-park added this to the v4.0.0 milestone Jan 10, 2020
@jaltekruse
Copy link

Hi @junghwan-park,

My next big use case for fabric and the tui-editor requires a feature like this. I am curious if you have stared work on this feature at all? I am happy to work together with you on this and contribute to the project.

For a little context on my use case and for an example of my work, I am currently using your component for my open source math site, it allows teachers to give feedback on images of student work.

https://freemathapp.org/

The next feature I would like to add is a drawing/graphing component built on fabric and the tui-editor to allow students to submit math drawings they create digitally in the site, rather than relying on images attached from elsewhere or captured from their webcam. For this feature though I want the documents to be further editable, so I don't want to ship the feature where it would just flatten the student work down to a jpeg or PNG.

@jaltekruse
Copy link

@junghwan-park I have been working on this, and it appears that using the native fabric JS JSON serialization works for most of the types of shapes/objects in the editor. There is an issue reading back in objects that override the "type" property of a fabric object. So the use of a special 'circle' type instead of just leaving it as an ellipse did cause an issue, but removing that customization allowed most things to work.

Would you consider removing this customization and just letting it stay as an ellipse?

Is there important state in the image editor that isn't covered by a toJSON on the fabric canvas?

@no-1ne
Copy link

no-1ne commented Mar 25, 2021

For replay it is doable by taking .tojson snapshots along with respective timestamps, and then replaying them (based on timestamp, by loading respective loadFromJSON )

@no-1ne
Copy link

no-1ne commented Mar 25, 2021

Currently is there an API on how do we get the fabric instance so that we can get the tojson data?

@lja1018
Copy link
Contributor

lja1018 commented Mar 26, 2021

@jaltekruse
Excuse me for not having answered your letter sooner. You can take advantage of fabric canvas' toJson, but you should also consider serializing data on the undo/redo stack.

@startupgurukul
Currently, APIs to get fabric instance are not supported.

@no-1ne
Copy link

no-1ne commented Mar 26, 2021

Thank you for the reply, if the fabric instance isn't exposed, how do you recommend getting the current json snapshot

@BennyG93
Copy link

Hi, is there any update on this feature? It would be great for coming back to a design at a later date to continue editing (similar to canva)

Thanks!

@Hardik-2019
Copy link

I would love to work on this issue. Please let me know how can I contribute. Can you please assign this issue to me @junghwan-park

@lja1018
Copy link
Contributor

lja1018 commented Oct 25, 2021

@Hardik-2019
I think it can be implemented through #667.

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

No branches or pull requests

6 participants