From d329725cc9616ba17f01bc3484fc0ee632edf6bc Mon Sep 17 00:00:00 2001 From: "s.spirkin" Date: Thu, 23 Jan 2025 15:27:18 +0300 Subject: [PATCH] feat: add disableLinks props for Markdown --- .../desktop/src/main/ts/markdown/Markdown.md | 30 +++++++++++++++++++ .../desktop/src/main/ts/markdown/Markdown.tsx | 22 +++++++++++--- .../mobile/src/main/ts/markdown/Markdown.md | 30 +++++++++++++++++++ .../mobile/src/main/ts/markdown/Markdown.tsx | 22 +++++++++++--- 4 files changed, 96 insertions(+), 8 deletions(-) diff --git a/packages/desktop/src/main/ts/markdown/Markdown.md b/packages/desktop/src/main/ts/markdown/Markdown.md index 0bd84f085..0464368e7 100644 --- a/packages/desktop/src/main/ts/markdown/Markdown.md +++ b/packages/desktop/src/main/ts/markdown/Markdown.md @@ -208,3 +208,33 @@ ``` + +## Отключение ссылок + +```jsx + + + {` +####disableLinks = false + +Киви кошелек: https://qiwi.com + +Игровая витрина: games.qiwi.com + `} + + +``` + +```jsx + + + {` +####disableLinks = true + +Киви кошелек: https://qiwi.com + +Игровая витрина: games.qiwi.com + `} + + +``` diff --git a/packages/desktop/src/main/ts/markdown/Markdown.tsx b/packages/desktop/src/main/ts/markdown/Markdown.tsx index 0aaabac1e..d32f5d2b1 100644 --- a/packages/desktop/src/main/ts/markdown/Markdown.tsx +++ b/packages/desktop/src/main/ts/markdown/Markdown.tsx @@ -6,6 +6,7 @@ import { List } from '../list' import { Heading, Paragraph, Text } from '../typography' export interface MarkdownProps { + disableLinks?: boolean size?: 's' | 'm' | 'l' children: string } @@ -49,13 +50,20 @@ const img: FC = ({ src, alt }) => ( img.displayName = 'img' interface LinkProps extends SizeProps { + disableLinks?: boolean title?: string href?: string } -const a: FC = ({ title, href, size, children }) => ( - -) +const a: FC = ({ disableLinks, title, href, size, children }) => { + if (disableLinks) { + return + } + + return ( + + ) +} a.displayName = 'a' @@ -167,10 +175,15 @@ const overrides: { [tag: string]: FC } = { img, } -export const Markdown: FC = ({ size = 'm', children }) => ( +export const Markdown: FC = ({ + size = 'm', + disableLinks = false, + children +}) => ( ({ ...prev, @@ -179,6 +192,7 @@ export const Markdown: FC = ({ size = 'm', children }) => ( component: overrides[tag], props: { size, + disableLinks }, }, }, diff --git a/packages/mobile/src/main/ts/markdown/Markdown.md b/packages/mobile/src/main/ts/markdown/Markdown.md index e7c9e85b9..f9e4bb761 100644 --- a/packages/mobile/src/main/ts/markdown/Markdown.md +++ b/packages/mobile/src/main/ts/markdown/Markdown.md @@ -203,3 +203,33 @@ ``` + +## Отключение ссылок + +```jsx + + + {` +####disableLinks = false + +Киви кошелек: https://qiwi.com + +Игровая витрина: games.qiwi.com + `} + + +``` + +```jsx + + + {` +####disableLinks = true + +Киви кошелек: https://qiwi.com + +Игровая витрина: games.qiwi.com + `} + + +``` diff --git a/packages/mobile/src/main/ts/markdown/Markdown.tsx b/packages/mobile/src/main/ts/markdown/Markdown.tsx index ae5915f81..cd6c23cca 100644 --- a/packages/mobile/src/main/ts/markdown/Markdown.tsx +++ b/packages/mobile/src/main/ts/markdown/Markdown.tsx @@ -6,6 +6,7 @@ import { List } from '../list' import { Heading, Paragraph, Text } from '../typography' export interface MarkdownProps { + disableLinks?: boolean size?: 's' | 'm' | 'l' children: string } @@ -49,13 +50,20 @@ const img: FC = ({ src, alt }) => ( img.displayName = 'img' interface LinkProps extends SizeProps { + disableLinks?: boolean title?: string href?: string } -const a: FC = ({ title, href, size, children }) => ( - -) +const a: FC = ({ disableLinks, title, href, size, children }) => { + if (disableLinks) { + return + } + + return ( + + ) +} a.displayName = 'a' @@ -158,10 +166,15 @@ const overrides: { [tag: string]: FC } = { img, } -export const Markdown: FC = ({ size = 'm', children }) => ( +export const Markdown: FC = ({ + size = 'm', + disableLinks = false, + children +}) => ( ({ ...prev, @@ -170,6 +183,7 @@ export const Markdown: FC = ({ size = 'm', children }) => ( component: overrides[tag], props: { size, + disableLinks }, }, },