Skip to content

Commit

Permalink
fix(extension/link): 🐛 fix last word value not being passed through w…
Browse files Browse the repository at this point in the history
…hen undefined (#3258)
  • Loading branch information
bdbch authored Sep 30, 2022
1 parent 801b436 commit 69923e2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/extension-link/src/helpers/autolink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ export function autolink(options: AutolinkOptions): Plugin {

if (textBlock && textBeforeWhitespace) {
const wordsBeforeWhitespace = textBeforeWhitespace.split(' ').filter(s => s !== '')

if (wordsBeforeWhitespace.length <= 0) {
return false
}

const lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1]
const lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace)

if (!lastWordBeforeSpace) {
return false
}

find(lastWordBeforeSpace)
.filter(link => link.isLink)
.filter(link => {
Expand Down

1 comment on commit 69923e2

@nqnduy
Copy link

@nqnduy nqnduy commented on 69923e2 Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I installed @tiptap version 2.0.0-beta.199 but the extesion/link is 2.0.0-beta.197. Why?

Please sign in to comment.