From ab469aa07d63f22be9a8bae9d4e9873e2c697f11 Mon Sep 17 00:00:00 2001 From: Bowen Liang Date: Mon, 30 Dec 2024 22:27:25 +0800 Subject: [PATCH] feat: support opening new tab in markdown button (#12213) --- .../base/markdown-blocks/button.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/app/components/base/markdown-blocks/button.tsx b/web/app/components/base/markdown-blocks/button.tsx index 56647b3bbeeea5..77e3cc15954900 100644 --- a/web/app/components/base/markdown-blocks/button.tsx +++ b/web/app/components/base/markdown-blocks/button.tsx @@ -6,13 +6,30 @@ const MarkdownButton = ({ node }: any) => { const { onSend } = useChatContext() const variant = node.properties.dataVariant const message = node.properties.dataMessage + const link = node.properties.dataLink const size = node.properties.dataSize + function is_valid_url(url: string): boolean { + try { + const parsed_url = new URL(url) + return ['http:', 'https:'].includes(parsed_url.protocol) + } + catch { + return false + } + } + return