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.
DetailsSubject Repo Branch Lines +/- Allow autolinking inside list items Comment ActionsThe 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.
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.
Comment ActionsChange 240910 had a related patch set uploaded (by Cscott):
Allow autolinking inside list items
Comment ActionsChange 240911 had a related patch set uploaded (by Cscott):
Allow autolinking ISBN/PMID/RFC inside list items
Comment ActionsChange 240910 merged by jenkins-bot:
Allow autolinking inside list items
Comment ActionsChange 240911 merged by jenkins-bot:
Allow autolinking ISBN/PMID/RFC inside list items
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Allow autolinking inside list items | Comment Actions 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. 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. Comment Actions Change 240910 had a related patch set uploaded (by Cscott): Comment Actions Change 240911 had a related patch set uploaded (by Cscott): Comment Actions Change 240910 merged by jenkins-bot: Comment Actions Change 240911 merged by jenkins-bot: |