GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.38k stars 4.06k forks source link

How load new html template into editor #56

Closed desilvaNSP closed 7 years ago

desilvaNSP commented 7 years ago

I have loaded html template into editor initialy

<div id="gjs">
<!-- html content-->
</div>

script


    var editor = grapesjs.init({
        container: '#gjs',
        fromElement: true,
        plugins: ['gjs-plugin-export'],
        pluginsOpts: {
            'gjs-plugin-export': {
                btnLabel: 'EXPORT',
                preHtml: '<!doctype><html><head><link rel="stylesheet" href="./css/style.css"></head><body>'
            }
        }
    });

how I update editor content with new template by replacing existing template. Is there any quick method for that in grapejs. I use select option to load html template.I want to dyanamically apply html template into this editor content.

Thanks in advance.

we need documentation for this library..this is awesome web editor.

artf commented 7 years ago

Sure, you can update the entire content with setComponents

editor.setComponents('<div class="test">Hello</div><style>.test{color:red}</style>');

or just only the style

editor.setStyle('.test{color:blue}');
lock[bot] commented 5 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.