diff --git a/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.tsx b/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.tsx index bdc1385496..c3c03220dd 100644 --- a/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.tsx +++ b/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.tsx @@ -8,6 +8,7 @@ import { getTranslation } from '@payloadcms/translations' import { CloseMenuIcon, EditIcon, + ExternalLinkIcon, formatDrawerSlug, useConfig, useEditDepth, @@ -26,6 +27,7 @@ import { } from 'lexical' import React, { useCallback, useEffect, useRef, useState } from 'react' +import type { LinkNode } from '../../../../nodes/LinkNode.js' import type { LinkFields } from '../../../../nodes/types.js' import type { LinkPayload } from '../types.js' @@ -40,6 +42,9 @@ import { TOGGLE_LINK_WITH_MODAL_COMMAND } from './commands.js' export function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.ReactNode { const [editor] = useLexicalComposerContext() + // TO-DO: There are several states that should not be state, because they + // are derived from linkNode (linkUrl, linkLabel, stateData, isLink, isAutoLink...) + const [linkNode, setLinkNode] = useState() const editorRef = useRef(null) const [linkUrl, setLinkUrl] = useState(null) @@ -116,6 +121,7 @@ export function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.R setNotLink() return } + setLinkNode(focusLinkParent) const fields = focusLinkParent.getFields() @@ -328,10 +334,14 @@ export function LinkEditor({ anchorElem }: { anchorElem: HTMLElement }): React.R
{linkUrl && linkUrl.length > 0 ? ( + {linkNode?.__fields.newTab ? : null} {linkLabel != null && linkLabel.length > 0 ? linkLabel : linkUrl} ) : linkLabel != null && linkLabel.length > 0 ? ( - {linkLabel} + <> + {linkNode?.__fields.newTab ? : null} + {linkLabel} + ) : null} {editor.isEditable() && ( diff --git a/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/index.scss b/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/index.scss index e3fa861dfc..84354229f2 100644 --- a/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/index.scss +++ b/packages/richtext-lexical/src/features/link/client/plugins/floatingLinkEditor/index.scss @@ -33,6 +33,10 @@ position: relative; font-family: var(--font-body); + .icon--externalLink { + margin-right: 5px; + } + &__label-pure { color: var(--theme-elevation-1000); margin-right: 15px; diff --git a/packages/ui/src/exports/client/index.ts b/packages/ui/src/exports/client/index.ts index 1b0638d62d..3a28fe350d 100644 --- a/packages/ui/src/exports/client/index.ts +++ b/packages/ui/src/exports/client/index.ts @@ -190,6 +190,7 @@ export { Account } from '../../graphics/Account/index.js' export { PayloadIcon } from '../../graphics/Icon/index.js' export { DefaultBlockImage } from '../../graphics/DefaultBlockImage/index.js' +export { ExternalLinkIcon } from '../../graphics/ExternalLink/index.js' export { File } from '../../graphics/File/index.js' // icons diff --git a/packages/ui/src/graphics/ExternalLink/index.scss b/packages/ui/src/graphics/ExternalLink/index.scss new file mode 100644 index 0000000000..f48770d84f --- /dev/null +++ b/packages/ui/src/graphics/ExternalLink/index.scss @@ -0,0 +1,14 @@ +@import '../../scss/styles'; + +@layer payload-default { + .icon--externalLink { + height: $baseline; + width: $baseline; + shape-rendering: auto; + + .stroke { + fill: none; + stroke: currentColor; + } + } +} diff --git a/packages/ui/src/graphics/ExternalLink/index.tsx b/packages/ui/src/graphics/ExternalLink/index.tsx index 81e28e2035..1a9e10099d 100644 --- a/packages/ui/src/graphics/ExternalLink/index.tsx +++ b/packages/ui/src/graphics/ExternalLink/index.tsx @@ -1,23 +1,21 @@ import React from 'react' +import './index.scss' + export const ExternalLinkIcon: React.FC<{ className?: string }> = (props) => { const { className } = props return ( )