Merge pull request #335 from jorilallo/issue-321

Fixes: Link paste behavior
This commit is contained in:
Jori Lallo
2017-10-21 18:55:14 -07:00
committed by GitHub

View File

@@ -111,16 +111,15 @@ class LinkToolbar extends Component {
save = (href: string) => {
href = href.trim();
const transform = this.props.state.transform();
transform.unwrapInline('link');
const { state } = this.props;
const transform = state.transform();
if (href) {
const data = { href };
transform.wrapInline({ type: 'link', data });
if (state.selection.isExpanded) {
transform.unwrapInline('link');
if (href) transform.wrapInline({ type: 'link', data: { href } });
}
const state = transform.apply();
this.props.onChange(state);
this.props.onChange(transform.apply());
this.props.onBlur();
};