Comments (18)
@sebastianha @andrepeitz @piyalmaduranga
You can check now the new Component doc. Feedbacks are welcome :)
For any bugs open a new issue
from grapesjs.
Thanks for the hint, didn't see that!
But for all other things a component type API would be nice :)
from grapesjs.
Hi @piyalmaduranga
those in the image are what I call Blocks, and a Block contains Components.
var blockManager = editor.BlockManager;
// Add new block
blockManager.add('my-block-id', {
label: 'Simple block',
content: '<div class="my-block">This string will be parsed and turned into a Component</div>',
});
// Edit
blockManager.get('my-block-id').set({
label: 'Updated simple block',
attributes: {title: 'My title'}
});
// Add a block as a Component
blockManager.add('my-map-block', {
label: 'Simple map block',
attributes: {
class:'fa fa-map-o'
},
content: {
// Built-in 'map' component
type: 'map',
style: { height: '350px'},
// Once inserted it can't be removed (just an example)
removable: false
}
});
how can I add modal pop up after drop component to our template?
If you want to add custom behavior to your Components (eg. pop up a modal when inserted into the canvas, do something when is double clicked, etc.) you need to define a new Component type but I've not yet added those API to GrapesJS but are coming soon.
from grapesjs.
Hi @artf
I tried load the script inside editor,
blockManager.add('advert-id', {
label: 'advert',
content: '<div id="advertDiv"><script src ="https://www.sample.net/invocationcode"></div>',
});
When I add component into template.It is not generate script tag.I want to get work script that I inserted.
block content is : <div id="advertDiv"><script src ="https://www.sample.net/invocationcode"></div>
It included script tag. but result not show script tag statement. Only show <div id ="advertDiv"></div>
missing my external script
Can I add external javascript block into template?
from grapesjs.
@piyalmaduranga I'm still in progress to make templates work properly with javascript so for this reason I simply throw away all script
tags, I can eventually add a new config property to let it import but not sure about the consequence
from grapesjs.
HI @artf
i added block using block manager it was like <script>block content</script> then i save my edited template and i tried edit this template again , in this time run script that i added it show image with tag and <script> tag also
my problem was i want to remove html tag in div i defined of my template how can i do it?
from grapesjs.
@piyalmaduranga can you show me maybe some screenshot about your problem, I don't get it. You were able to import correctly the <script>
with Block but not with the already saved template?!?
from grapesjs.
If you want to add custom behavior to your Components (eg. pop up a modal when inserted into the canvas, do something when is double clicked, etc.) you need to define a new Component type but I've not yet added those API to GrapesJS but are coming soon.
Do you have any updates on this? I would need this feature, too.
from grapesjs.
I would need the feature to define a new complex Component with custom behavior too and would really appreciate the implementation.
from grapesjs.
@sebastianha @andrepeitz working on it. I'll ping you back when it's ready.
In the meantime, can you explain me your cases?
from grapesjs.
Hi,
for example I wanted to use the image component but as I store my images in a way that the file names get prefixed with md5 sum etc, the current component is not ideal for me as it shows the full path name in the list (this is very ugly for the user).
I wanted to show only parts of the file name or a different key of the returned object of the asset manager. I am also thinking about organizing my images in folders. Also I wanted to remove the ability to add images via URL, so only upload and the list should be available.
At the end I planned to add my own custom image component type for this (and also for learning how to write them).
BTW: Thanks for the great editor and keep continuing your work!
from grapesjs.
I would like to use it for formulars where I can send the data via AJAX request to my backend.
from grapesjs.
@sebastianha For the asset manager you don't need another component. You can pass custom names for image assets in this way:
var editor = grapesjs.init({
...
assetManager: {
assets: [
{src: '.../cc4360/fff/image.jpg',} // Here you'll get image.jpg as asset label
{src: '.../cc4360/fff/image2.jpg', name: 'Custom name'}
]
}
...
});
Also I wanted to remove the ability to add images via URL, so only upload and the list should be available.
Just hide it with CSS :)
from grapesjs.
Thank you very much, I will try it and let you know!
from grapesjs.
Looks very good from my side! Thank you very much, I really appreciate that!
from grapesjs.
Which are the properties available for the content property of the block?
content: { ??? }
from grapesjs.
@Gerald-AuZ
eg. HTML string
content: '<div>...</div>'
or GrapesJS's Component object
content: {
tagName: 'section'
attributes: {...}
components: [{..}, {...}, ...]
}
from grapesjs.
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.
from grapesjs.
Related Issues (20)
- BUG: component.get('traits').clone() is no longer available. HOT 1
- BUG: Outlines persist in preview mode HOT 2
- BUG: CSS properties default values HOT 2
- BUG: Editing button text no longer works on 0.21.9 HOT 1
- BUG: How to add a addtional custom block manager like tab or section like block manager and style manager ,and add some blocks it to it? HOT 1
- BUG: typping error in dist/index.d.ts
- BUG: Filtering Blocks does not work as described in Docs HOT 2
- BUG: Unnecessary Canvas style HOT 3
- Interested in Collaboration?
- BUG: Double Entry in Layers if Component is moved directly after add HOT 1
- BUG:
- event works also on component mount HOT 1
- BUG: Uncaught TypeError: __webpack_require__.r is not a function at ./node_modules/grapesjs/dist/grapes.mjs (grapes.mjs:1:1) at __webpack_require__ (bootstrap:789:1) at fn (bootstrap:150:1) at ./src/Demo/Templates/TextEditor.js (Templates.js:31:1) at __webpack_require__ (bootstrap:789:1) at fn (bootstrap:150:1) at ./src/Demo/Templates/Templates.js (Templates.css:45:1) at __webpack_require__ (bootstrap:789:1) at fn (bootstrap:150:1) HOT 2
- When rendering <tr> tags inside <template> tags, tags are trimmed off and only string content is remained.
- Icons and Shapes options HOT 1
- BUG: ID isn't updating after change
- BUG: on fullscreen, color picker is hidden HOT 2
- BUG: Cannot edit component content even with editable property set to true HOT 1
- Installation of Grapesjs and yarn on Ubuntu 24.04 LTS HOT 1
- BUG: Broken link on Asset Manager
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grapesjs.