viliusle / miniPaint

online image editor
http://viliusle.github.io/miniPaint/
Other
2.6k stars 606 forks source link

Open_Image Issue #322

Closed Dejin1 closed 1 year ago

Dejin1 commented 2 years ago

I have tried for hours trying programmatically to open an image on load.

I have used multiple sources such as:

https://github.com/viliusle/miniPaint/blob/master/examples/open-edit-save.html

https://github.com/viliusle/miniPaint/issues/44

But It seems when it tries to run this line of code it gives an error : [Uncaught TypeError: Cannot read property 'insert' of undefined at open_image ((index):41)]

I would even be willing donate quite a bit if you could help me with this issue

Also possibly how to call menu buttons such as File > Open > Open URL It would be nice to be able to have a method i could call from index.php for certain 'app' calls.

Any and all help would be much appreciated and id be willing to pay for the speed of service!

viliusle commented 2 years ago

If you are including miniPaintusing iframe:

Make sure this line works and you can access Layers object:

var Layers = document.getElementById('myFrame').contentWindow.Layers;

Iframe must be hosted in same server.

If you are using miniPaint not using iframe

Layers should be global object, but only after page is loaded.


To call menu elements dynamically, you can look at this: https://github.com/viliusle/miniPaint/blob/master/src/js/core/base-search.js#L136 (this is global Search, using F3 shortcut)