Closed espipj closed 4 weeks ago
It looks like the problem is that the default isUrl
helper returns false for a correctly formatted tel:
URL. If you could patch that helper to add tel:
as a special case, that should resolve the issue, I think.
Changing isUrl
to return true for anything that can be parsed with new URL(...)
probably isn't what we want, since this would result in false positives when pasting strings containing colons. new URL('hello:world') // parses successfully
Hey! That was what was done fore mailto:
here: https://github.com/udecode/plate/pull/2444/files#diff-62c6d5e72c540099f6f0662214376ae7aba81cd9fe0b1f591a7b0b6e534c7a0aR8
I personally don't think a patch of a package should mark the issue as resolved, in fact it seems like a proper bug more people may face...
On Thu, 10 Oct 2024, 17:54 Ziad Beyens, @.***> wrote:
Closed #3230 https://github.com/udecode/plate/issues/3230 as completed.
— Reply to this email directly, view it on GitHub https://github.com/udecode/plate/issues/3230#event-14594617780, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCFC6VYAAQ62BLYOZXPI4LZ22WKRAVCNFSM6AAAAABIPJSP6OVHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJUGU4TINRRG43TQMA . You are receiving this because you authored the thread.Message ID: @.***>
@espipj By patching the helper, 12joan@ did not mean to patch the package. Here's how you can override isUrl
, which I do as well, in my implementation of PlateJS:
plugins: [
LinkPlugin.configure({
options: {
isUrl: (text: string) => // define a function to check if string should be a URL. You can use linkify-it NPM package,
getUrlHref: (text: string) => define a function to return the fully formatted link, e.g. mailto:xyz@xyz.com or tel:9991919191, again Linkify-it can be used for this,
},
}),
]
While we can certainly add this use case to LinkPlugin
, users are still enabled to implement it themselves without much hassle. More info on link plugin: https://platejs.org/docs/link
@espipj By patching the helper, 12joan@ did not mean to patch the package. Here's how you can override
isUrl
, which I do as well, in my implementation of PlateJS:
I actually meant that @espipj could make a PR with a patch changeset to fix this bug in isUrl
That would indeed be nice as a built-in case, I'll turn this issue into a feature request.
Description
As of now
tel:
links doesn't work either but they're are included under default "allowedSchemas" here so sanitizeUrl will never run.Related PR: https://github.com/udecode/plate/pull/2444
Steps to Reproduce
Create a link in the editor using "tel:123456"
Expected Behavior
Link gets created if "tel" is under "allowedSchemas" (there by default)
Environment
Bounty
Click here to add a bounty via Algora.
Funding