[QUESTION] Custom component - how to set editable to true
See original GitHub issueHi, I’ve created a custom component type, but I am having some trouble making it editable. The component is a “span” with component type “tag”. it will contain only text, but I want it to extend the default, not the text component. Any idea how can I make it editable, even if it is not “text”.
comps.addType('tag', {
model: {
defaults: {
type: 'tag',
tagName: 'span',
editable: true,
droppable: false,
attributes: {
'data-gjs-type': 'tag',
},
textable: 1,
traits: [{
type: 'select',
label: 'Tag',
name: 'selected-tag',
options: tagTypes,
}],
},
isComponent: function(el) {
let result;
if (el.tagName == 'SPAN' && el.getAttribute("data-gjs-type") === "tag") {
result = {
type: 'tag',
};
}
return result;
}
}, ...
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
React custom component containing editable ...
We are using custom React components and they are working well. However, I would like to implement a custom component that behaves like...
Read more >How do I add the ability to edit text within a react component?
Your Task component needs a keyPress handler to set isEditing to false when enter is pressed: const handleKeyPress = (e) => { if...
Read more >contenteditable - HTML: HyperText Markup Language | MDN
Chrome Edge
contenteditable Full support. ChromeYes. Toggle history Full suppo...
contenteditable="caret". Experimental Full support. ChromeYes. Toggle history Full suppo...
contenteditable="events". Experimental Full support. ChromeYes. Toggle history...
Read more >Create Editable HTML in React
There is an HTML attribute you can pass to any HTML tags which makes it editable. If you set contenteditable=true for nearly any...
Read more >Make a Custom Data Type Editable
Accessibility of Editable Custom Types · Add the attribute data-inputable="true" to the input component in the edit template. · Set standardCellLayout: true for ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you! I have done something similar, but yours is not so complicated. I’ve had other events attached to onActive, so I couldn’t use it. Now I detached them and I will do as you suggest. About the
data-gjs-type
- I need it because the content I am creating is stored and when reloaded the components have to be recognized in order for their settings/traits to be loaded and especially this custom type component I’ve added. There is also a possibility to change the content via traits, which complicates things a bit too 😃 P.S.: @artf You have done a great work by far!I think you’re looking for something like this
ps: there is no need to check/handle for
data-gjs-type
, the editor does it already for you. If you don’t import HTML and need to recognize yourtag
custom component you can skipisComponent