FEAT: add click event on blocks
Question
editor.on('block:click', (block) => {
console.log(block)
})
Or Is there any way to listen for click event in block ?
Answers (2)
Well you can actually make use of custom render from blocks to apply custom DOM events.
blockManager.add('some-block-id', {
// ... block definition
render: ({ model, el }) => {
el.addEventListener('click', () => {
console.log('block', model)
})
},
});
<pre>
editor.on('component:selected', (some, argument) => {
console.log(some, argument);
})
</pre>
https://grapesjs.com/docs/api/editor.html#available-eventsRelated Questions and Answers
Continue research with similar issue discussions.
Issue #958
Unable to create a popup by using bootbox or any other way.
Unable to create bootbox popup. Below is my code:- var blockManager = editor.BlockManager; blockManager.add('design', { label: 'Design', co...
Issue #889
[QUESTIONS]: Destroy Editor
is there way to destroy editor, I need to add button on page if user click, open page in editor and on save close editor and remove any ref...
Issue #1386
Is there any "Resize event" for components?
I want to read the resize event when an element is triggered for resizing. My current Code looks like this, editor.on("component:resize", f...
Issue #1708
StyleManager events fire multiple times per change
To reproduce: On a fresh install of GrapesJS, within the demo page (within index.html), add an event listener like so: editor.on('component...
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.