[Bug]: How to use components
Question
Using GrapesJS 0.15.10 I cant get the components to work the way I intent. Its probable me, so if its a question, feel free to adjust the title of the issue. (its a follow up of https://github.com/artf/grapesjs/issues/2195)
I've made a pen (hope thats ok, didnt see the fiddle templates) for my example: https://codepen.io/jogai/pen/yLNJgLZ?editors=1011
I see the same behavior in chrome & firefox.
Expected to have a row with text that is not selectable/draggable/highlightable but instead the row has text that is draggable into the other component.
Expected attributes of the component:
data-gjs-selectable="false" data-gjs-highlightable="false" data-gjs-hoverable="false"
But instead the attributes are:
data-gjs-type="cell" draggable="true" data-highlightable="1"
data-gjs-type is fine, the others have a wrong value, hoverable is missing entirely, one is missing data-gjs completely, and one is missing the -gjs- part.
Answers (3)
Hi @Jogai you must also specify the data-gjs-draggable on the <td>:
<table width="770" cellpadding="0" cellspacing="0" style="background-color:#CAD;">
<tr style="display:block;padding:15px;">
<td data-gjs-draggable="false" data-gjs-selectable="false" data-gjs-highlightable="false">
Component text 1
</td>
</tr>
<tr style="display:block;padding:15px;">
<td data-gjs-draggable="false" data-gjs-selectable="false" data-gjs-highlightable="false">
Component text 2
</td>
</tr>
</table>
Cheers!
Thanks. At least thats an improvement, but still the other properties are not taken into account, and if you try tro drag it (since the drag arrows still show up) it throws an error and then the whole editor is in a broken state. I updated the example.
Updated the example. Its sort of a followup on https://github.com/artf/grapesjs/issues/2195
My assumption is wrong that draggable needs data-gjs- prefix, because the html part without using component doesnt have that either. Still the child td is not seen as part of the component.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3119
[QUESTION] How to create custom block made of grapesjs components?
Hi, i want to have custom blocks made of grapesjs components. I found solution how to add components: https://github.com/artf/grapesjs/issu...
Issue #1341
[Question] How to work with Custom Components
Hello, I have some questions and issues about and with the grapes editorProblem 1 In a component, which class is there extended? Is it real...
Issue #1908
[question] Cannot read property 'indexOf' of undefined
I found a previous result here: https://github.com/artf/grapesjs/issues/1772 however I can still not get it to work, using the most basic s...
Issue #2664
[Bug] getComponents method doesn't return tree of components
I'm trying to implement multiple pages as per discussion in that issue - https://github.com/artf/grapesjs/issues/1331 But when I trying to...
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.