Skip to content

Commit 588c864

Browse files
authored
fix: help mark dangerouslySetInnerHTML (#289)
1 parent b46696f commit 588c864

File tree

12 files changed

+30
-10
lines changed

12 files changed

+30
-10
lines changed

src/lib/kit/components/Card/Card.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import isString from 'lodash/isString';
66

77
import {COMMON_POPOVER_PLACEMENT, COMMON_TITLE_MAX_WIDTH} from '../../constants/common';
88
import {block} from '../../utils';
9+
import {HTMLContent} from '../HTMLContent';
910

1011
import './Card.scss';
1112

@@ -95,7 +96,7 @@ export const Card: React.FC<CardProps> = ({
9596
placement: COMMON_POPOVER_PLACEMENT,
9697
}}
9798
>
98-
{description}
99+
<HTMLContent html={description} />
99100
</HelpMark>
100101
</div>
101102
) : null}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
3+
interface HTMLContentProps {
4+
html: string;
5+
}
6+
7+
export const HTMLContent: React.FC<HTMLContentProps> = ({html}) => {
8+
return <div dangerouslySetInnerHTML={{__html: html}} />;
9+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './HTMLContent';

src/lib/kit/components/Inputs/TableArrayInput/TableArrayInput.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import {useSearchContext} from '../../../../core/components/Form/hooks';
2626
import {COMMON_POPOVER_PLACEMENT} from '../../../constants/common';
2727
import {block} from '../../../utils';
28+
import {HTMLContent} from '../../HTMLContent';
2829

2930
import './TableArrayInput.scss';
3031

@@ -115,7 +116,7 @@ export const TableArrayInput: ArrayInput = ({spec, name, arrayInput, input}) =>
115116
placement: COMMON_POPOVER_PLACEMENT,
116117
}}
117118
>
118-
{description}
119+
<HTMLContent html={description} />
119120
</HelpMark>
120121
</Flex>
121122
),

src/lib/kit/components/Layouts/Column/Column.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {isArrayItem, isArraySpec, isObjectSpec, withGenerateButton} from '../../
88
import {ErrorWrapper, GenerateRandomValueButton} from '../../../components';
99
import {COMMON_POPOVER_PLACEMENT} from '../../../constants/common';
1010
import {block} from '../../../utils';
11+
import {HTMLContent} from '../../HTMLContent';
1112

1213
import './Column.scss';
1314

@@ -40,7 +41,7 @@ const ColumnBase = <T extends FieldValue, S extends Spec>({
4041
placement: COMMON_POPOVER_PLACEMENT,
4142
}}
4243
>
43-
{spec.viewSpec.layoutDescription}
44+
<HTMLContent html={spec.viewSpec.layoutDescription} />
4445
</HelpMark>
4546
</Text>
4647
</span>

src/lib/kit/components/Layouts/Row/Row.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {isArrayItem, isArraySpec, isObjectSpec, withGenerateButton} from '../../
88
import {ErrorWrapper, GenerateRandomValueButton} from '../../../components';
99
import {COMMON_POPOVER_PLACEMENT} from '../../../constants/common';
1010
import {block} from '../../../utils';
11+
import {HTMLContent} from '../../HTMLContent';
1112

1213
import './Row.scss';
1314

@@ -43,7 +44,7 @@ const RowBase = <T extends FieldValue, S extends Spec>({
4344
placement: COMMON_POPOVER_PLACEMENT,
4445
}}
4546
>
46-
{spec.viewSpec.layoutDescription}
47+
<HTMLContent html={spec.viewSpec.layoutDescription} />
4748
</HelpMark>
4849
</Text>
4950
</span>

src/lib/kit/components/Layouts/Section/Section.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import type {
1515
} from '../../../../core';
1616
import {isArrayItem, isArraySpec, isObjectSpec} from '../../../../core';
1717
import {block} from '../../../utils';
18+
import {HTMLContent} from '../../HTMLContent';
1819
import {RemoveButton} from '../../RemoveButton';
1920

2021
import './Section.scss';
@@ -122,7 +123,7 @@ const SectionBase = <
122123
placement: COMMON_POPOVER_PLACEMENT,
123124
}}
124125
>
125-
{spec.viewSpec.layoutDescription}
126+
<HTMLContent html={spec.viewSpec.layoutDescription} />
126127
</HelpMark>
127128
</Text>
128129
);

src/lib/kit/components/SimpleVerticalAccordeon/SimpleVerticalAccordeon.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Button, HelpMark, Icon, Popover, Text} from '@gravity-ui/uikit';
66

77
import {COMMON_POPOVER_PLACEMENT} from '../../constants/common';
88
import {block} from '../../utils';
9+
import {HTMLContent} from '../HTMLContent';
910

1011
import './SimpleVerticalAccordeon.scss';
1112

@@ -206,7 +207,7 @@ export class SimpleVerticalAccordeon extends React.Component<
206207
placement: COMMON_POPOVER_PLACEMENT,
207208
}}
208209
>
209-
{note}
210+
<HTMLContent html={note} />
210211
</HelpMark>
211212
</Text>
212213
) : null;

src/lib/kit/components/TogglerCard/TogglerCard.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {Card, HelpMark, Text} from '@gravity-ui/uikit';
44

55
import {COMMON_POPOVER_PLACEMENT} from '../../constants/common';
66
import {block} from '../../utils';
7+
import {HTMLContent} from '../HTMLContent';
78

89
import './TogglerCard.scss';
910

@@ -45,7 +46,7 @@ export const TogglerCard: React.FC<TogglerCardProps> = ({
4546
placement: COMMON_POPOVER_PLACEMENT,
4647
}}
4748
>
48-
{description}
49+
<HTMLContent html={description} />
4950
</HelpMark>
5051
) : null}
5152
</div>

src/lib/kit/components/ViewLayouts/ViewColumn/ViewColumn.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {useDynamicFormsCtx} from '../../../../core';
77
import {CopyButton} from '../../../../kit';
88
import {COMMON_POPOVER_PLACEMENT} from '../../../constants/common';
99
import {block, isNotEmptyValue} from '../../../utils';
10+
import {HTMLContent} from '../../HTMLContent';
1011

1112
import './ViewColumn.scss';
1213

@@ -36,7 +37,7 @@ export const ViewColumn = <T extends FormValue, S extends Spec>({
3637
placement: COMMON_POPOVER_PLACEMENT,
3738
}}
3839
>
39-
{spec.viewSpec.layoutDescription}
40+
<HTMLContent html={spec.viewSpec.layoutDescription} />
4041
</HelpMark>
4142
) : null}
4243
</div>

0 commit comments

Comments
 (0)