⚓ T113535 Autolink doesn't take place when you finish a list item
- ️Wed Sep 23 2015
Autolink doesn't take place when you finish a list item
Closed, ResolvedPublic1 Estimated Story Points
Autolink doesn't take place when you finish a list item
Closed, ResolvedPublic1 Estimated Story Points
If you type a URL or ISBN and press enter in a paragraph, the autolink code will be invoked when you press enter.
However, if you are in a list item (for example: at the bottom here ) and press enter, autolinking doesn't happen.
I think this is because autolinking stops as soon as it hits a "non plain text" element, like the </li><li>. IIRC there's a bit of a special case to make </p><p> work, but apparently something slightly different is needed for lists.
Event Timeline
cscott raised the priority of this task from to Needs Triage.
In VE, lists always contain paragraphs (or another content containing node, e.g. heading) as list items are non-content branch nodes.
The problem is the auto-link sequence is look for LinkRegex+Whitespace, which a newline isn't (it's a </paragraph> element). Fixing is not as simple as detecting LinkRegex+</paragraph> because that is also true before you press Enter, and while you still typing the link. Conceptually you probably want to special case the user pressing enter somehow.
The special case that makes it work for paragraphs is https://github.com/wikimedia/VisualEditor/blob/master/src/ui/ve.ui.SequenceRegistry.js#L58 It's possible we can just extend that hack to handle lists, too. But I agree that manually triggering the sequence registry when enter is pressed (*before* the new list item/paragraph is inserted) would be a better fix (and the hack about could then be removed). You'd have to be careful about the undo stack. Usually the sequence is "insert space", then "autolink", so that "undo" undoes the autolink first, then the "insert space". If we trigger the sequence registry before the insertion, then the first undo would undo the "enter", and you'd have to press undo a second time to undo the autolink. That inconsistency could be confusing.
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits