-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
📝 Provide a description of the improvement
The improvement I'd like to propose is adding the ability to customize which URL protocols the Link plugin considers safe so that URLs using them are properly linked in the Link Balloon and take the user to the intended destination upon clicking.
How the feature works now and what you'd like to change?
Currently, the Link Balloon relies a SAFE_URL regex to determine if a link, upon click, should take the user to the set URL, or to #
const SAFE_URL = /^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i;Because the list of "safe" protocols are baked into the SAFE_URL regex, URLs using uncommon protocols such as tel, cannot be linked.
In order to address this, there could be an option added to the link configuration that might look something like this:
<CKEditor
config={{
link: {
safeUrlProtocols: 'https?|ftps?|mailto|tel' // or alternatively ['http', 'ftp', 'mailto', 'tel']
}
}}
/>With this approach, the regex currently used to determine if a URL is safe might be replaced with a function that receives safeUrlProtocols to dynamically build and return a regex.
📃 Other details
- Browser: All
- OS: All
- CKEditor version: All
- Installed CKEditor plugins: Link, AutoLink
If you'd like to see this improvement implemented, add a 👍 reaction to this post.