fix: add target="_blank" to links

This commit is contained in:
chenos 2021-01-07 09:54:31 +08:00
parent 551f8bad8d
commit 84e4df4086

View File

@ -20,6 +20,15 @@ marked.setOptions({
breaks: true, breaks: true,
}); });
const renderer = new marked.Renderer();
renderer.link = ( href, title, text ) => `<a target="_blank" href="${ href }" title="${ title||'' }">${ text }</a>`;
function markdown(text: string) {
return marked(text, {
renderer,
});
}
const InterfaceTypes = new Map<string, any>(); const InterfaceTypes = new Map<string, any>();
function registerFieldComponent(type, Component) { function registerFieldComponent(type, Component) {
@ -65,12 +74,12 @@ export function TextareaField(props: any) {
return null; return null;
} }
if (viewType !== 'table') { if (viewType !== 'table') {
return <div className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: marked(value)}}/>; return <div className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: markdown(value)}}/>;
} }
if (value.length > 20) { if (value.length > 20) {
return ( return (
<Popover content={( <Popover content={(
<div onClick={(e) => e.stopPropagation()} className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: marked(value)}}/> <div onClick={(e) => e.stopPropagation()} className={'textarea-field-content'} style={{maxWidth: 300}} dangerouslySetInnerHTML={{__html: markdown(value)}}/>
)}>{value.substring(0, 15)}...</Popover> )}>{value.substring(0, 15)}...</Popover>
); );
} }