-
Notifications
You must be signed in to change notification settings - Fork 504
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
How to import saved html back to editor #18
Comments
You have to save and load the "sources" too. In the app initialization code you can see how it starts the editor from a given metadata+json model: You can see that methods also adds the localstorage plugin to the editor (the localstorage plugin is the one that will let you save in the localstorage). Have a look at localstorage save implementation: So, you will have att your own plugin to deal with "saves" instead of the localstorage plugin and then you will have to invoke the application main "start" method passing metadata, json content, and your plugin instance. So, you should be able to do all of this without altering mosaico code, but only "using it". We probably should add some facilities to make this "basic usage" simpler, but we're collecting use-cases first. We need feedback. |
I think saved HTML cannot be brought back to the editor by reading the saved HTML file unless the data from the editor is saved in the HTML -file. You could do this in a <script id="aclvalues" type="application/JSON"> ... </script> element within the exported HTML. Alternatively: download a email.json - file in parallel to email.html, also implement a drop method which restores from email.json. |
Hi, |
On mosaico.io website you currently don't have other options. |
Mosaico is not able to load the saved html. THe output HTML is an "export format" and it loses critical informations when you export in this format, and you can't open a generic html in mosaico. Mosaico documents are JSON metadata+content and you can save and load them using "viewModel" (viewModel.exportMetadata() viewModel.exportJSON() ) methods or "Mosaico.init" arguments. |
@bago , I used the mosaico editor to create the template and save it in database to edit it again later. so after creating the template, I downloaded it using the download link provided in mosaico editor, it provided the html format which i saved in database. now i want to load this content in mosaico editor to edit it but i didn't find a way to load the saved html source in mosaico editor.Can you please help me out . I searched on internet and found that mosaico editor saves the created template in json format using two fields. and for both of the fields, mosaico editor provides json format which can be saved in database as a saved template data and in case of edit the saved template , both (metadata and content) are loaded in mosaico editor which loads and shows the saved template in editor. but I need to save the template data in html format which i have done it now just want to load that saved template(html source) in mosaico editor again soI searched through the internet but didn't find a way to load that html data in mosaico editor. can you please help me out |
The output HTML is not a "saving", it is just an output. You can't load it back in mosaico. No way (it seems I already wrote this 3 times just in this issue). If you want to save and load you have to store the metadata+content JSON. So, just find a place where to store that JSON and then you will be able to load them back. You can find other issues with suggestions about what to do with metadata/content. Do you want to do this with "HTML only"? Well.. it is a lot harder, but you can store someway "hidden" in the output html (maybe an html comment) the 2 JSON and then write a tool to extract that data from the comment so you "virtually" load it back (you don't really load the HTML, but you load the data that generated that html). |
Thanks for your feedback. But In our application, After creating the template using the mosaico editor, I need to put that template from mosaico editor in another Editor(CK Editor) . that's why i created the template using the mosaico editor first and after downloading the template in html format , i transferred that html in CK editor to show the template there. now if i want to transfer that HTML source from CK editor to mosaico editor again, How it can be achieved. Any suggestion Or code will be helpful to me. |
@bago @punnawat @bwl21 "xmlhttprequest cannot load ........" "No access control allow origin header is present on the requested resource Can you please help me out ? Any kind of suggestion would be helpful for me. |
simple is the best. many thanks for your post |
Thanks Umar-sid; that's a really good idea. I've expanded on your concept and have written the following two JS functions:
The storeData() response feedback requires SweetAlert but is only for development. The URLs are specific to my app, so if you don't understand what these need to be for your use-case then this solution is not for you. I call storeData() after any template creation, edit, deletion or rename action. When returning to the index page after an edit and save, I work out if a database update is required like this:
These are the two methods used to store/access the data in the database. Again, if you don't understand where they belong in the bigger picture, or how to adapt it for your needs, then this solution is not for you.
This is my single-record database table:
At this stage I haven't thoroughly tested the above, but will try to remember to edit it if needed. I'm no expert on this stuff, so if anyone can improve it, please be my guest :) |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I design an email template and saved it into html code to my database (as click download button). When I would like to edit it. How to load saved template to the editor again.
The text was updated successfully, but these errors were encountered: