Skip to content

Commit 4f3d00e

Browse files
committed
Adjust footnote icon
1 parent 838b6c5 commit 4f3d00e

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

packages/module/src/MarkdownContent/MarkdownContent.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,20 @@ export const MarkdownContent: FunctionComponent<MarkdownContentProps> = ({
257257
remarkRehypeOptions={{
258258
// removes sr-only class from footnote labels applied by default
259259
footnoteLabelProperties: { className: [''] },
260+
// omit default ↩ text; backref icon is rendered in LinkMessage
261+
footnoteBackContent: (_referenceIndex, rereferenceIndex) => {
262+
if (rereferenceIndex > 1) {
263+
return [
264+
{
265+
type: 'element',
266+
tagName: 'sup',
267+
properties: {},
268+
children: [{ type: 'text', value: String(rereferenceIndex) }]
269+
}
270+
];
271+
}
272+
return [];
273+
},
260274
...reactMarkdownProps?.remarkRehypeOptions
261275
}}
262276
disallowedElements={disallowedElements}

packages/module/src/Message/LinkMessage/LinkMessage.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
// ============================================================================
44

55
import { Button, ButtonProps } from '@patternfly/react-core';
6-
import { ExternalLinkSquareAltIcon } from '@patternfly/react-icons';
6+
import { RhMicronsExternalLinkIcon, RhUiBackwardsIcon } from '@patternfly/react-icons';
77
import { ExtraProps } from 'react-markdown';
88
import { css } from '@patternfly/react-styles';
99

10+
const isFootnoteBackref = (className?: string) => className?.includes('data-footnote-backref');
11+
1012
export interface LinkMessageProps {
1113
/** Flag indicating that the content should retain message styles when using Markdown. */
1214
shouldRetainStyles?: boolean;
@@ -26,7 +28,7 @@ const LinkMessage = ({
2628
component="a"
2729
variant="link"
2830
href={href}
29-
icon={<ExternalLinkSquareAltIcon />}
31+
icon={<RhMicronsExternalLinkIcon />}
3032
iconPosition="end"
3133
isInline
3234
target={target}
@@ -40,6 +42,23 @@ const LinkMessage = ({
4042
);
4143
}
4244

45+
if (isFootnoteBackref(props.className)) {
46+
return (
47+
<Button
48+
isInline
49+
component="a"
50+
href={href}
51+
variant="link"
52+
id={id}
53+
icon={<RhUiBackwardsIcon />}
54+
{...props}
55+
className={css(shouldRetainStyles && 'pf-m-markdown', props?.className)}
56+
>
57+
{children}
58+
</Button>
59+
);
60+
}
61+
4362
return (
4463
// need to explicitly call this out or id doesn't seem to get passed - required for footnotes
4564
<Button

0 commit comments

Comments
 (0)