[QUESTION] How to dynamically add assets from the server after editor initialization?
Question
Hi! Thanks for the work you've done building this cool library! I am using latest angular and stuck with issue when I open image library in editor and there is no collection. Collection will go from the server. When I add some image then I see whole images set that were saved before, but at first time collection is empty, how can I do this?
this.editor = grapesjs.init({
container: '#wiq-content-editor',
height: '100vh',
components: content,
css: styles,
style: styles,
plugins: ['gjs-preset-webpage'],
storageManager: {
id: 'wiq-content-editor-',
type: 'local',
autosave: false,
autoload: false
},
colorPicker: {
appendTo: 'parent',
offset: {
top: 26,
left: -166
}
},
assetManager: {
storeAfterUpload: true,
upload: this.apiUrl + '/files',
uploadFile: (e) => {
let files = e.target.files;
let formData = new FormData();
formData.append('category', 'content');
Object.keys(files).forEach(fileIndex => {
formData.append('file', files[fileIndex], files[fileIndex].name);
});
this.postFiles(formData);
}
}
});
grapesjs.plugins.add('gjs-preset-webpage', require('grapesjs-preset-webpage').default);
this.assetManager = this.editor.AssetManager;
res.items.forEach(element => {
this.assetManager.add({
type: element.category,
src: element.url,
height: element.height,
width: element.width
});
});
Answers (1)
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 #1059
[Question]: Load html content from a file dynamically
Hi, I need to load content from a html file from server onto editor after or while initializing editor. How this can be implemented? HTML w...
Issue #1747
[Question] How to re-render the whole library dynamically
Hi Artur, I have this checkbox underneath the editor. If you click it, it will load extra custom components. and if you un-click it, those...
Issue #1777
[Question] How to dynamically change the DomComponents ?
Hello , Thank you for this great library , i am working with a newsletter system that get content from the database and generate the latest...
Issue #1583
[Question] Amending urlStore and urlLoad dynamically.
Hi Everyone I'm loving Grapesjs so far - thanks for all your work on it. I'm in the process of trying to set up storage for whole page temp...
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.