@tiptap/extension-link 3.30.2 → 3.30.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,19 +1,19 @@
1
- import { Mark } from '@tiptap/core';
2
-
1
+ import { Mark } from "@tiptap/core";
2
+ //#region src/link.d.ts
3
3
  interface LinkProtocolOptions {
4
- /**
5
- * The protocol scheme to be registered.
6
- * @default '''
7
- * @example 'ftp'
8
- * @example 'git'
9
- */
10
- scheme: string;
11
- /**
12
- * If enabled, it allows optional slashes after the protocol.
13
- * @default false
14
- * @example true
15
- */
16
- optionalSlashes?: boolean;
4
+ /**
5
+ * The protocol scheme to be registered.
6
+ * @default '''
7
+ * @example 'ftp'
8
+ * @example 'git'
9
+ */
10
+ scheme: string;
11
+ /**
12
+ * If enabled, it allows optional slashes after the protocol.
13
+ * @default false
14
+ * @example true
15
+ */
16
+ optionalSlashes?: boolean;
17
17
  }
18
18
  declare const pasteRegex: RegExp;
19
19
  /**
@@ -21,132 +21,132 @@ declare const pasteRegex: RegExp;
21
21
  */
22
22
  type DeprecatedOpenWhenNotEditable = 'whenNotEditable';
23
23
  interface LinkOptions {
24
+ /**
25
+ * If enabled, the extension will automatically add links as you type.
26
+ * @default true
27
+ * @example false
28
+ */
29
+ autolink: boolean;
30
+ /**
31
+ * An array of custom protocols to be registered with linkifyjs.
32
+ * @default []
33
+ * @example ['ftp', 'git']
34
+ */
35
+ protocols: Array<LinkProtocolOptions | string>;
36
+ /**
37
+ * Default protocol to use when no protocol is specified.
38
+ * @default 'http'
39
+ */
40
+ defaultProtocol: string;
41
+ /**
42
+ * If enabled, links will be opened on click.
43
+ * @default true
44
+ * @example false
45
+ */
46
+ openOnClick: boolean | DeprecatedOpenWhenNotEditable;
47
+ /**
48
+ * If enabled, the link will be selected when clicked.
49
+ * @default false
50
+ * @example true
51
+ */
52
+ enableClickSelection: boolean;
53
+ /**
54
+ * Adds a link to the current selection if the pasted content only contains an url.
55
+ * @default true
56
+ * @example false
57
+ */
58
+ linkOnPaste: boolean;
59
+ /**
60
+ * If enabled, typing or pasting the Markdown link syntax, e.g. `[Tiptap](https://tiptap.dev)`
61
+ * or `[Tiptap](https://tiptap.dev "Rich text editor")`, converts it into a link.
62
+ * @default false
63
+ * @example true
64
+ */
65
+ markdownLinks: boolean;
66
+ /**
67
+ * HTML attributes to add to the link element.
68
+ * @default {}
69
+ * @example { class: 'foo' }
70
+ */
71
+ HTMLAttributes: Record<string, any>;
72
+ /**
73
+ * @deprecated Use the `shouldAutoLink` option instead.
74
+ * A validation function that modifies link verification for the auto linker.
75
+ * @param url - The url to be validated.
76
+ * @returns - True if the url is valid, false otherwise.
77
+ */
78
+ validate: (url: string) => boolean;
79
+ /**
80
+ * A validation function which is used for configuring link verification for preventing XSS attacks.
81
+ * Only modify this if you know what you're doing.
82
+ *
83
+ * @returns {boolean} `true` if the URL is valid, `false` otherwise.
84
+ *
85
+ * @example
86
+ * isAllowedUri: (url, { defaultValidate, protocols, defaultProtocol }) => {
87
+ * return url.startsWith('./') || defaultValidate(url)
88
+ * }
89
+ */
90
+ isAllowedUri: (
91
+ /**
92
+ * The URL to be validated.
93
+ */
94
+ url: string, ctx: {
24
95
  /**
25
- * If enabled, the extension will automatically add links as you type.
26
- * @default true
27
- * @example false
96
+ * The default validation function.
28
97
  */
29
- autolink: boolean;
98
+ defaultValidate: (url: string) => boolean;
30
99
  /**
31
- * An array of custom protocols to be registered with linkifyjs.
32
- * @default []
33
- * @example ['ftp', 'git']
100
+ * An array of allowed protocols for the URL (e.g., "http", "https"). As defined in the `protocols` option.
34
101
  */
35
102
  protocols: Array<LinkProtocolOptions | string>;
36
103
  /**
37
- * Default protocol to use when no protocol is specified.
38
- * @default 'http'
104
+ * A string that represents the default protocol (e.g., 'http'). As defined in the `defaultProtocol` option.
39
105
  */
40
106
  defaultProtocol: string;
41
- /**
42
- * If enabled, links will be opened on click.
43
- * @default true
44
- * @example false
45
- */
46
- openOnClick: boolean | DeprecatedOpenWhenNotEditable;
47
- /**
48
- * If enabled, the link will be selected when clicked.
49
- * @default false
50
- * @example true
51
- */
52
- enableClickSelection: boolean;
53
- /**
54
- * Adds a link to the current selection if the pasted content only contains an url.
55
- * @default true
56
- * @example false
57
- */
58
- linkOnPaste: boolean;
59
- /**
60
- * If enabled, typing or pasting the Markdown link syntax, e.g. `[Tiptap](https://tiptap.dev)`
61
- * or `[Tiptap](https://tiptap.dev "Rich text editor")`, converts it into a link.
62
- * @default false
63
- * @example true
64
- */
65
- markdownLinks: boolean;
66
- /**
67
- * HTML attributes to add to the link element.
68
- * @default {}
69
- * @example { class: 'foo' }
70
- */
71
- HTMLAttributes: Record<string, any>;
72
- /**
73
- * @deprecated Use the `shouldAutoLink` option instead.
74
- * A validation function that modifies link verification for the auto linker.
75
- * @param url - The url to be validated.
76
- * @returns - True if the url is valid, false otherwise.
77
- */
78
- validate: (url: string) => boolean;
79
- /**
80
- * A validation function which is used for configuring link verification for preventing XSS attacks.
81
- * Only modify this if you know what you're doing.
82
- *
83
- * @returns {boolean} `true` if the URL is valid, `false` otherwise.
84
- *
85
- * @example
86
- * isAllowedUri: (url, { defaultValidate, protocols, defaultProtocol }) => {
87
- * return url.startsWith('./') || defaultValidate(url)
88
- * }
89
- */
90
- isAllowedUri: (
91
- /**
92
- * The URL to be validated.
93
- */
94
- url: string, ctx: {
95
- /**
96
- * The default validation function.
97
- */
98
- defaultValidate: (url: string) => boolean;
99
- /**
100
- * An array of allowed protocols for the URL (e.g., "http", "https"). As defined in the `protocols` option.
101
- */
102
- protocols: Array<LinkProtocolOptions | string>;
103
- /**
104
- * A string that represents the default protocol (e.g., 'http'). As defined in the `defaultProtocol` option.
105
- */
106
- defaultProtocol: string;
107
- }) => boolean;
108
- /**
109
- * Determines whether a valid link should be automatically linked in the content.
110
- *
111
- * @param {string} url - The URL that has already been validated.
112
- * @returns {boolean} - True if the link should be auto-linked; false if it should not be auto-linked.
113
- */
114
- shouldAutoLink: (url: string) => boolean;
107
+ }) => boolean;
108
+ /**
109
+ * Determines whether a valid link should be automatically linked in the content.
110
+ *
111
+ * @param {string} url - The URL that has already been validated.
112
+ * @returns {boolean} - True if the link should be auto-linked; false if it should not be auto-linked.
113
+ */
114
+ shouldAutoLink: (url: string) => boolean;
115
115
  }
116
116
  declare module '@tiptap/core' {
117
- interface Commands<ReturnType> {
118
- link: {
119
- /**
120
- * Set a link mark
121
- * @param attributes The link attributes
122
- * @example editor.commands.setLink({ href: 'https://tiptap.dev' })
123
- */
124
- setLink: (attributes: {
125
- href: string;
126
- target?: string | null;
127
- rel?: string | null;
128
- class?: string | null;
129
- title?: string | null;
130
- }) => ReturnType;
131
- /**
132
- * Toggle a link mark
133
- * @param attributes The link attributes
134
- * @example editor.commands.toggleLink({ href: 'https://tiptap.dev' })
135
- */
136
- toggleLink: (attributes?: {
137
- href: string;
138
- target?: string | null;
139
- rel?: string | null;
140
- class?: string | null;
141
- title?: string | null;
142
- }) => ReturnType;
143
- /**
144
- * Unset a link mark
145
- * @example editor.commands.unsetLink()
146
- */
147
- unsetLink: () => ReturnType;
148
- };
149
- }
117
+ interface Commands<ReturnType> {
118
+ link: {
119
+ /**
120
+ * Set a link mark
121
+ * @param attributes The link attributes
122
+ * @example editor.commands.setLink({ href: 'https://tiptap.dev' })
123
+ */
124
+ setLink: (attributes: {
125
+ href: string;
126
+ target?: string | null;
127
+ rel?: string | null;
128
+ class?: string | null;
129
+ title?: string | null;
130
+ }) => ReturnType;
131
+ /**
132
+ * Toggle a link mark
133
+ * @param attributes The link attributes
134
+ * @example editor.commands.toggleLink({ href: 'https://tiptap.dev' })
135
+ */
136
+ toggleLink: (attributes?: {
137
+ href: string;
138
+ target?: string | null;
139
+ rel?: string | null;
140
+ class?: string | null;
141
+ title?: string | null;
142
+ }) => ReturnType;
143
+ /**
144
+ * Unset a link mark
145
+ * @example editor.commands.unsetLink()
146
+ */
147
+ unsetLink: () => ReturnType;
148
+ };
149
+ }
150
150
  }
151
151
  declare function isAllowedUri(uri: string | undefined, protocols?: LinkOptions['protocols']): true | RegExpMatchArray | null;
152
152
  /**
@@ -154,5 +154,6 @@ declare function isAllowedUri(uri: string | undefined, protocols?: LinkOptions['
154
154
  * @see https://www.tiptap.dev/api/marks/link
155
155
  */
156
156
  declare const Link: Mark<LinkOptions, any>;
157
-
158
- export { Link, type LinkOptions, type LinkProtocolOptions, Link as default, isAllowedUri, pasteRegex };
157
+ //#endregion
158
+ export { Link, Link as default, LinkOptions, LinkProtocolOptions, isAllowedUri, pasteRegex };
159
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/link.ts"],"mappings":";;UAWiB;;;;;;;EAOf;;;;;;EAOA;;cAGW,YAAU;;;;KAMlB;UAEY;;;;;;EAMf;;;;;;EAOA,WAAW,MAAM;;;;;EAMjB;;;;;;EAMA,uBAAuB;;;;;;EAMvB;;;;;;EAMA;;;;;;;EAQA;;;;;;EAOA,gBAAgB;;;;;;;EAQhB,WAAW;;;;;;;;;;;;EAaX,eAIE;;;;EAAA,aACA;;;;IAIE,kBAAkB;;;;IAIlB,WAAW,MAAM;;;;IAIjB;;;;;;;;EAUJ,iBAAiB;;;YAIP,SAAS;IACjB;;;;;;MAME,UAAU;QACR;QACA;QACA;QACA;QACA;YACI;;;;;;MAMN,aAAa;QACX;QACA;QACA;QACA;QACA;YACI;;;;;MAKN,iBAAiB;;;;iBAKP,aAAa,yBAAyB,YAAY,kCAAwB;;;;;cA2C7E,MAAI,KAAA"}