Skip to content

Commit

Permalink
fix(richtext-lexical): link html converter: serialize newTab to targe…
Browse files Browse the repository at this point in the history
…t="_blank" (#6350)

Co-authored-by: Leo <[email protected]>
  • Loading branch information
linobino1 and Leo authored May 29, 2024
1 parent a8000f6 commit e0b201c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps,
})

const rel: string = node.fields.newTab ? ' rel="noopener noreferrer"' : ''
const target: string = node.fields.newTab ? ' target="_blank"' : ''

let href: string = node.fields.url
if (node.fields.linkType === 'internal') {
Expand All @@ -135,7 +136,7 @@ export const LinkFeature: FeatureProviderProviderServer<LinkFeatureServerProps,
: node.fields.doc?.value?.id
}

return `<a href="${href}"${rel}>${childrenText}</a>`
return `<a href="${href}"${target}${rel}>${childrenText}</a>`
},
nodeTypes: [AutoLinkNode.getType()],
},
Expand Down

0 comments on commit e0b201c

Please sign in to comment.