Skip to content

How to loadDesign from mySQL? #79

@mprince2k18

Description

@mprince2k18

I am using unlayer editor in my laravel project. I want to load my existing HTML markup into the editor. But it's not working with loadDesign and loadTemplate function. Here is my code.

<script>

class EmailEditor {
    constructor(id) {
        unlayer.init({
        id: id,
        displayMode: "web",
        appearance: {
            theme: 'dark',
        }
        });
    }

    loadDesign(design) {
        unlayer.loadDesign(design);
    }

    saveDesign(callback) {
        unlayer.saveDesign(callback);
    }
    exportHtml(callback) {
        unlayer.exportHtml(callback);
    }
}

    const editor = new EmailEditor('editor-container');

    const saveHTMLBtn = document.getElementById('update_html_btn');

    saveHTMLBtn.addEventListener('click',e => {
    editor.exportHtml(
        d => {
            // Ajax

            var body = d.html;

            $.post('{{ route('api.page.content.create') }}', 
            {_token:'{{ csrf_token() }}', 
            page_id: '{{ $content->id }}', 
            title: '{{ $content->title }}',
            body: body
        },  
            function(data){
                console.log(data);
            });

          }
        );
    });

</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions