[Question] How to extract html/css code in view code automatically?
Question
I need the function to copy the html/css code in the view code component automatically. Is there a predefined function? or I must implement this directly?
Answers (3)
Hi @poirin ,
I have some solution, last week i have this problem too i try to save current HTML & CSS without manual copying.
And below is my code .
Add custom panel eg. left top button (save button).
/**
* Create save button
* @type {String}
*/
panelManager.addPanel({
id: 'customPanel',
visible : true,
buttons : [{
id : 'smile',
className : 'fa fa-save',
attributes : { title: 'Update Promo' },
command : 'customCommand'
}],
});

And then create save function
/**
* Create save function
*/
commands.add('customCommand', {
run: function(editor, sender){
storageManager.load(['css', 'html'], function(res) {
// your custom event
// Note: res variable will return code of css & html
})
}
});
Good luck 👍
If you're talking about storing your templates int DB or any other remote endpoint you can setup the built-in RemoteStorage, take a look here #778
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.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #822
[QUESTION] How to get the html and css code in view code tool?
or how to get all the html code and css so that I could save it in my database. Or there is already a functionality in the documentation? y...
Issue #1888
[Question] Add custom html inside canvas
Hi there, I'm using grapes to export a custom json with all the information i need, instead of HTML and CSS. For doing that I'm parsing the...
Issue #865
[QUESTION] How can I set default tagName
Hi ! I want to set tagName tr for all components(or specific component in use). Is there any predefined function to set tagName ?
Issue #1609
Grapesjs, How to extract html/css code in view code into console log?
WARNING READ and FOLLOW next 5 steps, then REMOVE them before posting the issueFollow CONTRIBUTING Guidelines https://github.com/artf/grape...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.