From 84e4df408621b98e0f0788a0c491f72a18d00c65 Mon Sep 17 00:00:00 2001 From: chenos Date: Thu, 7 Jan 2021 09:54:31 +0800 Subject: [PATCH] fix: add target="_blank" to links --- packages/app/src/components/views/Field/index.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/app/src/components/views/Field/index.tsx b/packages/app/src/components/views/Field/index.tsx index a0a81dd7d..fb326f734 100644 --- a/packages/app/src/components/views/Field/index.tsx +++ b/packages/app/src/components/views/Field/index.tsx @@ -20,6 +20,15 @@ marked.setOptions({ breaks: true, }); +const renderer = new marked.Renderer(); +renderer.link = ( href, title, text ) => `${ text }`; + +function markdown(text: string) { + return marked(text, { + renderer, + }); +} + const InterfaceTypes = new Map(); function registerFieldComponent(type, Component) { @@ -65,12 +74,12 @@ export function TextareaField(props: any) { return null; } if (viewType !== 'table') { - return
; + return
; } if (value.length > 20) { return ( e.stopPropagation()} className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: marked(value)}}/> +
e.stopPropagation()} className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: markdown(value)}}/> )}>{value.substring(0, 15)}... ); }