mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
add optionalSlashSlash to protocol options (#3675)
* add optionalSlashSlash to protocol options * Update documentation * rename optionalSlashSlash to optionalSlashes * regenerate package-lock.json with node v16
This commit is contained in:
parent
82625644be
commit
1ac3070abc
@ -31,6 +31,18 @@ Link.configure({
|
|||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
By default, [linkify](https://linkify.js.org/docs/) adds `//` to the end of a protocol however this behavior can be changed by passing `optionalSlashes` option
|
||||||
|
```js
|
||||||
|
Link.configure({
|
||||||
|
protocols: [
|
||||||
|
{
|
||||||
|
scheme: 'tel',
|
||||||
|
optionalSlashes: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### autolink
|
### autolink
|
||||||
If enabled, it adds links as you type.
|
If enabled, it adds links as you type.
|
||||||
|
|
||||||
|
13
package-lock.json
generated
13
package-lock.json
generated
@ -12838,8 +12838,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/linkifyjs": {
|
"node_modules/linkifyjs": {
|
||||||
"version": "3.0.5",
|
"version": "4.1.0",
|
||||||
"license": "MIT"
|
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-Ffv8VoY3+ixI1b3aZ3O+jM6x17cOsgwfB1Wq7pkytbo1WlyRp6ZO0YDMqiWT/gQPY/CmtiGuKfzDIVqxh1aCTA=="
|
||||||
},
|
},
|
||||||
"node_modules/lint-staged": {
|
"node_modules/lint-staged": {
|
||||||
"version": "13.0.3",
|
"version": "13.0.3",
|
||||||
@ -19712,7 +19713,7 @@
|
|||||||
"version": "2.0.0-beta.218",
|
"version": "2.0.0-beta.218",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"linkifyjs": "^3.0.5"
|
"linkifyjs": "^4.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tiptap/core": "^2.0.0-beta.218",
|
"@tiptap/core": "^2.0.0-beta.218",
|
||||||
@ -24646,7 +24647,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"@tiptap/core": "^2.0.0-beta.218",
|
"@tiptap/core": "^2.0.0-beta.218",
|
||||||
"@tiptap/pm": "^2.0.0-beta.218",
|
"@tiptap/pm": "^2.0.0-beta.218",
|
||||||
"linkifyjs": "^3.0.5"
|
"linkifyjs": "^4.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@tiptap/extension-list-item": {
|
"@tiptap/extension-list-item": {
|
||||||
@ -28977,7 +28978,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"linkifyjs": {
|
"linkifyjs": {
|
||||||
"version": "3.0.5"
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/linkifyjs/-/linkifyjs-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-Ffv8VoY3+ixI1b3aZ3O+jM6x17cOsgwfB1Wq7pkytbo1WlyRp6ZO0YDMqiWT/gQPY/CmtiGuKfzDIVqxh1aCTA=="
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"version": "13.0.3",
|
"version": "13.0.3",
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
"@tiptap/pm": "^2.0.0-beta.218"
|
"@tiptap/pm": "^2.0.0-beta.218"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"linkifyjs": "^3.0.5"
|
"linkifyjs": "^4.1.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -6,6 +6,11 @@ import { autolink } from './helpers/autolink'
|
|||||||
import { clickHandler } from './helpers/clickHandler'
|
import { clickHandler } from './helpers/clickHandler'
|
||||||
import { pasteHandler } from './helpers/pasteHandler'
|
import { pasteHandler } from './helpers/pasteHandler'
|
||||||
|
|
||||||
|
export interface LinkProtocolOptions {
|
||||||
|
scheme: string;
|
||||||
|
optionalSlashes?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface LinkOptions {
|
export interface LinkOptions {
|
||||||
/**
|
/**
|
||||||
* If enabled, it adds links as you type.
|
* If enabled, it adds links as you type.
|
||||||
@ -14,7 +19,7 @@ export interface LinkOptions {
|
|||||||
/**
|
/**
|
||||||
* An array of custom protocols to be registered with linkifyjs.
|
* An array of custom protocols to be registered with linkifyjs.
|
||||||
*/
|
*/
|
||||||
protocols: Array<string>
|
protocols: Array<LinkProtocolOptions | string>
|
||||||
/**
|
/**
|
||||||
* If enabled, links will be opened on click.
|
* If enabled, links will be opened on click.
|
||||||
*/
|
*/
|
||||||
@ -62,7 +67,13 @@ export const Link = Mark.create<LinkOptions>({
|
|||||||
keepOnSplit: false,
|
keepOnSplit: false,
|
||||||
|
|
||||||
onCreate() {
|
onCreate() {
|
||||||
this.options.protocols.forEach(registerCustomProtocol)
|
this.options.protocols.forEach(protocol => {
|
||||||
|
if (typeof protocol === 'string') {
|
||||||
|
registerCustomProtocol(protocol)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
registerCustomProtocol(protocol.scheme, protocol.optionalSlashes)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
onDestroy() {
|
onDestroy() {
|
||||||
|
Loading…
Reference in New Issue
Block a user