Skip to content

Commit 8c58f5a

Browse files
committed
refactor: sanitizationConfig object extraction
1 parent 33034b3 commit 8c58f5a

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

apps/example-web/src/App.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ const DEFAULT_LINK_STATE: OnLinkDetected = {
3838
const LINK_REGEX =
3939
/^(?:enriched:\/\/\S+|(?:https?:\/\/)?(?:www\.)?swmansion\.com(?:\/\S*)?)$/i;
4040

41+
const SANITIZATION_CONFIG = {
42+
linkRegex: LINK_REGEX,
43+
};
44+
4145
function App() {
4246
const ref = useRef<EnrichedTextInputInstance>(null);
4347
const [currentHtml, setCurrentHtml] = useState('');
@@ -278,9 +282,7 @@ function App() {
278282
mentionIndicators={['@', '#']}
279283
htmlStyle={WEB_DEFAULT_HTML_STYLE}
280284
linkRegex={LINK_REGEX}
281-
sanitizationConfig={{
282-
linkRegex: LINK_REGEX,
283-
}}
285+
sanitizationConfig={SANITIZATION_CONFIG}
284286
/>
285287
<MentionPopup
286288
variant="user"

apps/example-web/src/components/TextRenderer.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import { WEB_DEFAULT_HTML_STYLE } from '../defaultHtmlStyle';
1313
const LINK_REGEX =
1414
/^(?:enriched:\/\/\S+|(?:https?:\/\/)?(?:www\.)?swmansion\.com(?:\/\S*)?)$/i;
1515

16+
const SANITIZATION_CONFIG = {
17+
linkRegex: LINK_REGEX,
18+
};
19+
1620
interface TextRendererProps {
1721
htmlValue: string;
1822
}
@@ -47,9 +51,7 @@ export function TextRenderer({ htmlValue }: TextRendererProps) {
4751
onBlur={handleTextBlur}
4852
onLinkPress={handleLinkPress}
4953
onMentionPress={handleMentionPress}
50-
sanitizationConfig={{
51-
linkRegex: LINK_REGEX,
52-
}}
54+
sanitizationConfig={SANITIZATION_CONFIG}
5355
>
5456
{htmlValue}
5557
</EnrichedText>

0 commit comments

Comments
 (0)