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

When creating a link on the last word of a block, the link continue to extend (see gif)

Open codeKonami opened this issue 8 years ago • 3 comments
trafficstars

The gif is quite self explanatory.

Bug

Thanks for the great tool!!

codeKonami avatar Nov 30 '16 16:11 codeKonami

This behavior is the default in draft js. One workaround can be to call toggleLink twice, once with the selection and the next with selection collapsed. Or maybe there's a better way.

brijeshb42 avatar Dec 01 '16 07:12 brijeshb42

Maybe the solution would be to do the same as for the bold and italic.

You create your link, if you continue to write right after link, the link expands. If you select a part of the link, the toolbar shows up the link button is activated. If you click on the link button, you unlink the section you've selected.

With this solution, you can't modify the URL once it has been created. You'll need to select the entire link, unlink it, and click again to create a new link. But I don't think it is too weird.

What do you think ?

codeKonami avatar Dec 01 '16 09:12 codeKonami

But Bold, Italic also continues to be extended if it is at the last. If you make your last word B/I, and then continue writing in same or new line, new characters are also bold.

A solution could be to detect a space and toggle B I U, Link automatically or maybe toggle it anyway.

Current process is nothing but what draft docs state, RichUtils.toggleInlineStyle and RichUtils.toggleLink. But this needs to be modified so that new characters don't carry over the style just like I have modified RETURN presses so that new lines after header blocks are always unstyled.

brijeshb42 avatar Dec 01 '16 10:12 brijeshb42