Help loading FireStore data
Question
It helps with FireStore, since I've managed to save to the Firestore database, now I'd like to know how can I load those values from the database and display them as a template. I am new and I need help, sorry for the bad, this is my code.
The data I use is from an example, so it doesn't matter much if others see it
var editor = grapesjs.init({
height: '100%',
showOffsets: 1,
noticeOnUnload: 0,
storageManager: { type: 'firestore',
id: 'gjs-', // Prefix identifier that will be used on parameters
autosave: false, // Store data automatically
autoload: false, // Autoload stored data on init
stepsBeforeSave: 1, // If autosave enabled, indicates how many changes are necessary before store method is triggered
},
container: '#gjs',
fromElement: true,
plugins: ['grapesjs-firestore'],
pluginsOpts: {
'grapesjs-firestore': {
docId: 'someID',
apiKey: 'AIzaSyDbc1HECiWstp_T8zW-etJEdH84THUlIYg',
authDomain: 'radarsystem-edit-land.firebaseapp.com',
projectId: 'radarsystem-edit-land',
collectionName: 'template',
}
}
});
// Add the button
editor.Panels.addButton('options', [{
id: 'save-db',
className: 'fa fa-floppy-o icon-blank',
command: 'save-db',
attributes: {title: 'Save DB'}
}]);
// Add the command
editor.Commands.add
('save-db', {
run: function(editor, sender)
{
sender && sender.set('active'); // turn off the button
editor.store();
}
});
editor.on('storage:load', function(e) {
console.log('Load template ', e);
});
editor.on('storage:store', function(e) {
console.log('Save template', e);
});
editor.on('storage:error', function(e) {
console.log('Error template ', e);
});
window.editor = editor;
Answers (1)
You can enable autoload: true, or you can load data programmatically by calling editor.load()
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1360
[Question/bug] Need help saving data to Blackbaud database.
I'm trying to embed this into Blackbaud Internet Solutions using a Custom Content Part. Can someone help me figure out how to setup the sto...
Issue #1363
Problem trying to inject new HTML content in the Editor
Hi @artf, I'm now working on doing content in multi-languages inside the editor but I would like to know how can I save in the Dom HTML new...
Issue #1395
Update component for images
I've saved template in the database with all the components like images and all. But after that I've upload new images in the system so tho...
Issue #2118
[Question] Save configuration of dynamic blocks into HTML? (Countdown, Slider)
I am trying to save the template data into the database. Currently I have it working successfully. It posts the Assets, Components, Styles,...
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.