Skip to content

Commit

Permalink
fix(richtext-lexical): add target _blank for new-tab in linkFeature (#…
Browse files Browse the repository at this point in the history
…8571)

FIxes #8569 

Matches the fixes in commit 23df60d
(plugin-form-builder) and e0b201c (v3)

Adds target="_blank" where the link should be in a new tab
  • Loading branch information
GeekPro101 authored Oct 7, 2024
1 parent 034aa68 commit 61e8ce1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/richtext-lexical/src/field/features/Link/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,14 @@ export const LinkFeature = (props: LinkFeatureProps): FeatureProvider => {
})

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

const href: string =
node.fields.linkType === 'custom'
? node.fields.url
: (node.fields.doc?.value as string)

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

0 comments on commit 61e8ce1

Please sign in to comment.