DomComponents model content
Hi, thanks for your answer last time about executing a modal or an alert when dropping a specific blockmanager now my problem is i set a specific content too my model so like this when i'm gonna drop the block it will create some html in my zone and also execute an alert but when i place a specific content in my model it always start with a div and i don't want to use div see the code bellow in this link thanks aggain : https://codeshare.io/5QOWOQ
You can see the problem in the code generated in this screenshot "https://image.noelshack.com/fichiers/2017/37/1/1505147551-capture-d-ecran-2017-09-11-a-18-31-42.png" as you can see my code in my content start from a div and end from a div :x
Can we edit direct the code in the export code modal , like enable it with changing something in the code ? That will be really good
You're extending the default model and placing INSIDE the content of the table but the wrapper it's still a div component, so it's a correct behavior. You might want to do this:
model: defaultModel.extend({
defaults: Object.assign({}, defaultModel.prototype.defaults, {
tagName: 'table', // <- change the container tagname
attributes: {
cellpadding: 0,
...
},
content: `<tr>...</tr>`
}),
}),
Can we edit direct the code in the export code modal
Yes, but you have to create a custom command which shows the exported HTML in a modal and let you import it back, check how I've done the importer in newsletter preset https://github.com/artf/grapesjs-preset-newsletter/blob/master/src/openImportCommand.js
Really thanks :+1: i got another question how to clear also css when i use editor.DomComponents.clear(); its always clear only the html part , and not the css part, also i wanted to know to get the css part with editor like editor.getCss maybe and modify it :o like editor.setComponent(finalHtml) example
Question 2 : Do you know how can i allow dropzone, cause i done in my index.html "assetmanager" like : dropzone: 1 and nothing happen when i'm dragging some picture from my desktop i want just to get the big menu and modify it to create my own library of picture with search bar :p
For CSS you have to check here https://github.com/artf/grapesjs/wiki/API-Css-Composer
If you want to clear all CSS: editor.CssComposer.getAll().reset()
Adding rules via CssComposer it's a little bit harder so I'd suggest just editor.addComponents('<style>...</style>') / editor.setStyle('.cls{color: red}');
You can get the CSS string with editor.getCss() and its structure with editor.getStyle() (all rules)
For the asset manager please check here https://github.com/artf/grapesjs/wiki/Assets
Man your the best , thanks again , when i will finish my project i will show you how you change my life at work :)
haha please do it, it'd be awesome 😁
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.