draft-js icon indicating copy to clipboard operation
draft-js copied to clipboard

ToggleLink. When a lose focus Editor, i can't set link

Open Zulfia73 opened this issue 10 years ago • 3 comments

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

Zulfia73 avatar May 31 '16 13:05 Zulfia73

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> ); };

Zulfia73 avatar May 31 '16 13:05 Zulfia73

Okey, my propblem in onChange, because when i set new editorStatez i lose decorator. what me do?

Zulfia73 avatar Jun 01 '16 06:06 Zulfia73

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.

hellendag avatar Jun 01 '16 16:06 hellendag