customLinkPrefixes isn't plumbed throughout library
Is there an existing issue for this?
- [X] I have searched the existing issues
Flutter Quill version
9.3.1
Steps to reproduce
When customLinkPrefixes are set in QuillEditorConfigurations...
- They aren't honored in the _LinkDialog from the toolbar.
- this can be reproduced by (1) setting them in the config, (2) trying to use them in the dialog.
- They aren't honored during insert by AutoFormatMultipleLinksRule
- this can be reproduced by trying to insert text when using the rule.
Expected results
Expect that custom Link Prefixes are honored for the above fields.
I would be happy to help with writing a PR for the fix, but I think the library maintainers should suggest a path for the fix. The library mostly uses Regex to detect links, but the customLinkPrefixes is just a list of strings of the prefixes. Additionally, some parts of the library that interact with links aren't configured via the QuillEditorConfigurations. I'm not experienced with the library's architecture enough to make them without input.
Actual results
Custom Link Prefixes are ignored for the above fields.
Code sample
n/a this can be validated using the repo's provided examples, with this one config added.
Screenshots or Video
No response
Logs
No response
Does this isse still persists? I will close it. Please, reopen if it does.
@mikecodega Can you confirm if this still an issue?
Hey, this issue doesn't seem to be resolved. What changes were made?
It looks like it's still not possible to use the built-in link insertion modal from the toolbar to insert a link with a custom prefix.
For example, I tried "scheme://" as a prefix, and then adding a link such as "scheme://XXXX", and the only thing it'd accept is "http://XXXX" or "https://XXXX"
I can confirm that customLinkPrefixes is not honored, it's not passed at all in the actual link detection rule.
I think the fix might not be too heavy, we should pass this parameter to AutoFormatMultipleLinksRule and generate more link patterns for link detection, because currently quill editor enforces only one pattern:
static const _oneLineLinkPattern =
r'^https?:\/\/[\w\-]+(\.[\w\-]+)*(:\d+)?([\/\?#].*)?$';
static const _detectLinkPattern =
r'https?:\/\/[\w\-]+(\.[\w\-]+)*(:\d+)?([\/\?#][^\s]*)?';
Something like this might work (it's only pseudo-code though):
customLinkPrefixes.forEach((customPrefix) {
final pattern = '^${customPrefix}?:\/\/[\w\-]+(\.[\w\-]+)*(:\d+)?([\/\?#].*)?$';
// Check if the custom pattern matches
if(matches)
// proceed with match on next steps
else
// continue in for loop
});
It would really be great if someone could fix this. Even simple email links like "mailto:[email protected]" are not accepted in the input dialog after adding customLinkPrefixes: const ['mailto:', 'tel:'] in the "QuillEditorConfigurations"
I'll check it out after merge some of the open PRs that i have. Thanks for the code example.
@CatHood0
I will take over, I noticed you've been trying to do too much recently. Related #1164
I will take over, I noticed you've been trying to do too much recently.
Thank you so much 🙇🏻♂️!
For example, I tried "scheme://" as a prefix, and then adding a link such as "scheme://XXXX", and the only thing it'd accept is "http://XXXX" or "https://XXXX"
Yes, it isn't clear; see the related lines.
I have fixed it in my local branch.