voidlabs / mosaico

Mosaico - Responsive Email Template Editor
https://mosaico.io
GNU General Public License v3.0
1.71k stars 504 forks source link

help #441

Closed Gorgona9 closed 6 years ago

Gorgona9 commented 6 years ago

Hello.... I've included mosaico editor in my angularJS app. And now I have a proble. As it should be a part of a page and its output html should join to the rest of data to be send to backend. How can I get the output html? not download but thrown out of the page so I can get it in other angularjs page?

CaptainHypertext commented 6 years ago

@Gorgona9 If I understand your question, this is how you can get the html data from your Mosaico plugins, which you define as part of your initialization:

var plugins = [
    function (viewModel) {

        var saveCmd = {
            name: 'Save Command',
            enabled: ko.observable(true)
        };

        saveCmd.execute = function () {
            saveCmd.enabled(false);

            // Here is the Mosaico data
            var html = viewModel.exportHTML();
            var json_data = viewModel.exportJSON();
            var meta = viewModel.exportMetadata();

            saveCmd.enabled(true);
        };

        viewModel.save = saveCmd;
    }
];
Gorgona9 commented 6 years ago

thank You so much.