ToggleLink. When a lose focus Editor, i can't set link
when focus on InputLink, and i click on button for add link, ToggleLink doesn't work
` _confirmLink(e, self) { e.preventDefault(); const {editorState, urlValue} = self.state;
const entityKey = Entity.create('LINK', 'MUTABLE', {url: 'www.yandex.ru'});
self.setState({
editorState: RichUtils.toggleLink(
editorState,
editorState.getSelection(),
entityKey
),
isOpenLink: false,
urlValue: '',
}, () => {
setTimeout(() => self.focus(), 0);
});
}`
this.onURLChange = (e) =>{ this.setState({urlValue: e.target.value}); };
all click a do with e.prevenDefault() and MouseDown
I thinck problem maybe in
const Link = (props) => { console.log('Link') const {url} = Entity.get(props.entityKey).getData(); return ( <a {...props} style={styleMap.link} onClick={console.log('tratata')} href={url}> {props.children} </a> ); };
Okey, my propblem in onChange, because when i set new editorStatez i lose decorator. what me do?
Can you provide a gif or video of the problem? It's not clear to me what exactly isn't working, or why you would lose the decorator when setting state.