A map of capture groups to functions for producing the href of a
link. By default, it is e.g. used to prepend https:// to links
matching on www. so they are not interpreted as relative.
The user can add their own handlers if modifying linkRegExp.
Signed-off-by: Øyvind Rønningstad <ronningstad@gmail.com>
Solves/improves the following:
- Setting a custom linkRegExp messes with the logic for adding
protocol or mailto. Use named capture groups in the regex, and
add a case in the href generation that just uses the match
directly if neither the url nor the email regex matches, which
would mean that the user's custom regex matched instead.
- Make https the default protocol instead of http
- Use a more general regex for matching the protocol.
Signed-off-by: Øyvind Rønningstad <ronningstad@gmail.com>
The fixer node may get removed when merging adjacent inlines, so move
the cleanup to before this. For safety, also properly check for non-null
nodes so we don't crash if it's still elided for some reason.
There seems to be a bug in Chrome where it will sometimes not render
some of the text in the DOM when there are multiple zero-width spaces
around the beginning and ends of inline tags (not sure on the exact
details).
Steps to reproduce (prior to this commit):
1. Turn on bold and underlined text
2. Type something in bold and underlined text
3. Turn off bold and underline
4. Try to type something — it will not show up! That is, until you press
the enter key and we remove the zero-width spaces.
This is a massive refactor to port Squire to TypeScript, fix a bunch of small
bugs and modernise our tooling. The development was done on an internal
repository, so apologies to anyone following externally for the commit dump;
updates from here should come as real commits again.
Co-authored-by: Joe Woods <woods@fastmailteam.com>