它对FireStore有所帮助,因为我已经设法保存到Firestore数据库,现在我想知道如何从数据库中加载这些值并将其显示为模板。我是新手,需要帮助,很抱歉,这是我的代码。
我使用的数据来自示例,因此其他人看到它并不重要
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;