tui.image-editor icon indicating copy to clipboard operation
tui.image-editor copied to clipboard

Exposing fabricjs canvas object within ImageEditor class

Open BennyG93 opened this issue 3 years ago • 3 comments

Exposing the FabricJS canvas object and the loadFromJSON FabricJS function via the core imageEditor class http://fabricjs.com/docs/fabric.Canvas.html#loadFromJSON

Exporting Canvas example:

import ImageEditor from '@toast-ui/react-image-editor';

var canvasData = imageEditor.getCanvas();
console.log(canvasData);

After storing the whole Canvas object inside a variable, it can then be saved to MongoDB. In theory, you can then fetch this object from MongoDB and it can be restored using the loadFromJSON FabricJS function which is exposed via the imageEditor class.

Example:

import ImageEditor from '@toast-ui/react-image-editor';

const canvasData = someFunction.getCanvasFromMongoDB()
imageEditor.loadCanvas(canvasData);

FYI this is completely experimental and has not been tested. It is only for example.

BennyG93 avatar Oct 21 '21 13:10 BennyG93

@BennyG93 Thank you for suggesting this fantastic feature. It is a very necessary feature for our application. Can I add a tests?

lja1018 avatar Oct 27 '21 01:10 lja1018

@lja1018 Sure you can continue with this, I made this draft as a theoretical proof of concept but I have have not actually tried it in action

BennyG93 avatar Nov 11 '21 14:11 BennyG93

This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks!

stale[bot] avatar Jan 09 '22 00:01 stale[bot]