mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
fix(link): Prevent auto-linking when typing URL inside inline code mark (#4160)
This commit is contained in:
parent
18946b1e35
commit
b24df3aa4c
@ -112,18 +112,27 @@ export function autolink(options: AutolinkOptions): Plugin {
|
||||
|
||||
find(lastWordBeforeSpace)
|
||||
.filter(link => link.isLink)
|
||||
.filter(link => {
|
||||
if (options.validate) {
|
||||
return options.validate(link.value)
|
||||
}
|
||||
return true
|
||||
})
|
||||
// Calculate link position.
|
||||
.map(link => ({
|
||||
...link,
|
||||
from: lastWordAndBlockOffset + link.start + 1,
|
||||
to: lastWordAndBlockOffset + link.end + 1,
|
||||
}))
|
||||
// ignore link inside code mark
|
||||
.filter(link => {
|
||||
return !newState.doc.rangeHasMark(
|
||||
link.from,
|
||||
link.to,
|
||||
newState.schema.marks.code,
|
||||
)
|
||||
})
|
||||
// validate link
|
||||
.filter(link => {
|
||||
if (options.validate) {
|
||||
return options.validate(link.value)
|
||||
}
|
||||
return true
|
||||
})
|
||||
// Add link mark.
|
||||
.forEach(link => {
|
||||
if (getMarksBetween(link.from, link.to, newState.doc).some(item => item.mark.type === options.type)) {
|
||||
|
Loading…
Reference in New Issue
Block a user