Cannot add spaces to extended button component based on text component.
Question
Hello guys,
First of all i would like to express my gratitudes for this amazing tool. I have extended button component based on text component so as to can edit the content of button manually without using traits.
The code for the extended button component is this:
var comps = editor.DomComponents;
var defaultType4 = comps.getType('text');
editor.DomComponents.addType('button', {
model:{
defaults: {
tagName: 'button',
classes: ['.pointer'], //Add click pointer on hover,
},
},
extend: 'text',
isComponent: function (el) {
if (el.tagName === 'BUTTON')
return {type: 'button'};
},
view: defaultType4.view.extend({
events: {
dblclick: 'onActive',
input: 'onInput',
dragstart: 'handleDragStart',
click: function() {
/*Click function */
}
},
})
})
At this point i am capable of edit content of button components manually. Now the problem that i am dealing with is that i can not add space characters inside content of buttons.Can anyone help me ?Answers (1)
Seems like space triggers the click event in Chrome. The solution seems to be to add the preventDefault on keypress https://stackoverflow.com/questions/22104860/chrome-firing-onclick-when-space-typed-in-contenteditable-button
ps. avoid extending the view in that way. By default, when you use extend of some type, it's also extending its view (if you need to extend the view of another component you can use extendView: 'another-component-type',)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #510
Add new class programatically
Hello Artf, I want to edit the styles of components (mostly imported html) without modifying all components with the same class. I tried to...
Issue #486
Custom Component not editable and also after traits update canvas does not update
below is code i used for traits and custom section but after adding component via block, cannot edit text or trait update does not update c...
Issue #2065
Few Questions
First of all, Amazing project thumbs up to everybody involved. I have a couple of questions:How can I iterate over all of the components an...
Issue #3287
QUESTION: Wrapper styling
First of all, congrats @artf for this amazing project 💯 I am currently working on a project and I wanted to ask if I can edit the wrapper...
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.