udecode / plate

Rich-text editor with shadcn
https://platejs.org
Other
10.49k stars 645 forks source link

Tel link doesn't work Link Plugin #3230

Open espipj opened 3 months ago

espipj commented 3 months ago

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

Fund with Polar

12joan commented 3 months 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

espipj commented 3 months ago

Hey! That was what was done fore mailto:here: https://github.com/udecode/plate/pull/2444/files#diff-62c6d5e72c540099f6f0662214376ae7aba81cd9fe0b1f591a7b0b6e534c7a0aR8