Store the html and inline css in Editor.Store()
Question
I am trying to store the html and inline css , can you please in how to pass it to editor.store() function. @artf
editor.Commands.add`
('save-db',
{
run: function(editor, sender)
{
sender && sender.set('active'); // turn off the button
var html = editor.runCommand('gjs-get-inlined-html');
editor.store();
alert('Draft');
console.log(html);
editor.on('storage:store', function(e) {
console.log('Stored ', e);
});
}
});
Answers (3)
@mekamleshk editor.store() function gets the html, components, css, html and styles and passes it to storage:store event and you can access it like you have above
im sorry if i have miss understood what your asking but it looks like your trying to add a save button
the save button
editor.Panels.addButton('options', [{
id: 'save',
className: 'fa fa-floppy-o icon-blank',
command: function (editor, sender) {
if (sender)
sender.set('active', false);
editor.store();
},
attributes: {title: 'save to database'}
}]);
the store event
editor.on('storage:store', function (e) {
console.log('STORE ', e);
console.log('HTML', e.html);
console.log('CSS', e.css);
});
you can use grapejs's build in remote storage feature if you want to post these values to a backend
in the grapejs init you will want something like this
storageManager: {
type: 'remote',
urlStore: 'http://mywebsite.com/store/website',
contentTypeJson: true,
},
this will post a json string to the backend
Please recheck my code i have updated it. @sonnylloyd @artf I want to store inline html
var html = editor.runCommand('gjs-get-inlined-html');
into mysql database using
editor.store() function
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1487
Load from Database
I've got an issue with loading the lory-slider from my mysql db. When i load it back in, the functionality is gone, i cant slide left or ri...
Issue #1836
How to add !important in all the generated apis
Hello @artf, While i am going to edit some html from editor with the help of css then i need to add !important into all the css which is ch...
Issue #740
How to remove class from html
Hi @artf, We are updating the <i> tag class but it adds new class to this but previous class is not remove.please let us know how to remove...
Issue #930
[Question] Update resizer after asset changed
Hi! I trying to change default assets manager with ours custom manager. On double click the selected image is replaced with a new one with...
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.