From e3331f1331a0cc8d7db5ca7f87d380b949360e90 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Fri, 8 Nov 2024 11:01:00 +0100 Subject: [PATCH] chore: update docs to be accurate --- src/content/editor/extensions/marks/link.mdx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/content/editor/extensions/marks/link.mdx b/src/content/editor/extensions/marks/link.mdx index b5552a0..fd0245b 100644 --- a/src/content/editor/extensions/marks/link.mdx +++ b/src/content/editor/extensions/marks/link.mdx @@ -101,7 +101,8 @@ Link.configure({ }) ``` -### default protocol +### defaultProtocol + The default protocol used by `linkOnPaste` and `autolink` when no protocol is defined. By default, the href generated for example.com is http://example.com and this option allows that protocol to be customized. @@ -144,7 +145,7 @@ Link.configure({ }) ``` -### validate +### isAllowedUri A function that allows customization of link validation, modifying the default verification logic. This function accepts the URL and a context object with additional properties. @@ -161,12 +162,16 @@ A function that allows customization of link validation, modifying the default v This function enables you to enforce rules on allowed protocols or domains when autolinking URLs. ```js -// Validate URLs to only accept specific protocols +// Validate URLs to only accept non-relative URLs Link.configure({ - validate: (url, ctx) => ctx.defaultValidate(url) && !url.startsWith('./'), + isAllowedUri: (url, ctx) => ctx.defaultValidate(url) && !url.startsWith('./'), }) ``` +### validate (deprecated) + +This function has been deprecated in favor of the more descriptive `shouldAutoLink` function. If provided, the `validate` function will replace the `shouldAutoLink` function. + ### shouldAutoLink Defines whether a valid link should be automatically linked within the editor content.