Replies: 15 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. |
Beta Was this translation helpful? Give 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. |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
On mosaico.io website you currently don't have other options. |
Beta Was this translation helpful? Give feedback.
-
@punnawat @bago @bwl21 |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@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 |
Beta Was this translation helpful? Give feedback.
-
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). |
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
@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. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
simple is the best. many thanks for your post |
Beta Was this translation helpful? Give feedback.
-
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 :) |
Beta Was this translation helpful? Give feedback.
-
I made a php backend for save the templates models for my application and think that can be usefully for the community.
|
Beta Was this translation helpful? Give feedback.
-
I needed a fast solution, to get the edits from the old to the new computer (only the data in localStorage was needed). On the mosaico page on the old machine, i opened chrome dev tools, and pasted this code into the console:
The result is an object with the data, which I copied with right click. I inserted the object into sublime text, to save it as a .txt file. which i send to the new computer. On the new computer, i copied the content from the text file. Opened the mosaico page (installed it before) on chrome, i opened chrome dev tools. deleted all entries from local storage (line by line). On the console i typed "let storedData = " and pasted the contend of the file and pressed enter, to assign the data to the variable storedData. The I pasted this code to write the data to the local storage of the new computer.
|
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions