File tree Expand file tree Collapse file tree 3 files changed +11
-4
lines changed
plugins/com.msgbyte.mdpanel/src/group
plugin/PluginStore/DocumentView Expand file tree Collapse file tree 3 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ const MarkdownPanel: React.FC = React.memo(() => {
5454 render = { ( dataMap : Record < string , string > ) => {
5555 return (
5656 < MainContent >
57- < Markdown raw = { dataMap [ 'markdown' ] ?? '' } />
57+ < Markdown raw = { dataMap [ 'markdown' ] ?? '' } allowIframe = { true } />
5858 </ MainContent >
5959 ) ;
6060 } }
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ const ReactMarkdown = Loadable(() => import('react-markdown'));
1313
1414export const Markdown : React . FC < {
1515 raw : string ;
16+ allowIframe ?: boolean ;
1617 baseUrl ?: string ;
17- } > = React . memo ( ( { raw, baseUrl } ) => {
18+ } > = React . memo ( ( { raw, baseUrl, allowIframe } ) => {
1819 const { t } = useTranslation ( ) ;
1920 const transformUrl = useCallback (
2021 ( url : string ) => {
@@ -46,21 +47,27 @@ export const Markdown: React.FC<{
4647 ) ,
4748 svg : ( ) => < div > not support svg</ div > ,
4849 iframe : ( props ) => {
50+ if ( ! allowIframe ) {
51+ return < div > { t ( '不支持iframe' ) } </ div > ;
52+ }
53+
4954 let src = props . src ;
5055
5156 if ( ! src ) {
5257 return < div /> ;
5358 }
5459
5560 if ( ! src . startsWith ( 'http' ) ) {
56- return < div > only support http source </ div > ;
61+ return < div > { t ( '只支持http路径' ) } </ div > ;
5762 }
5863
5964 if ( src && src . includes ( '?' ) ) {
6065 src += '&autoplay=0' ; // make sure media autoplay is false
6166 }
6267 return < iframe { ...props } src = { src } /> ;
6368 } ,
69+ embed : ( ) => < div > { t ( '不支持embed' ) } </ div > ,
70+ html : ( ) => < div > { t ( '不支持自定义HTML' ) } </ div > ,
6471 style : ( ) => < div > { t ( '不支持自定义样式' ) } </ div > ,
6572 meta : ( ) => < div > { t ( '不支持自定义Meta' ) } </ div > ,
6673 } ) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export const DocumentMarkdownRender: React.FC<{ url: string }> = React.memo(
2424 return < Problem text = { String ( error ) } /> ;
2525 }
2626
27- return < Markdown raw = { String ( value ) } baseUrl = { url } /> ;
27+ return < Markdown raw = { String ( value ) } baseUrl = { url } allowIframe = { true } /> ;
2828 }
2929) ;
3030DocumentMarkdownRender . displayName = 'DocumentMarkdownRender' ;
You can’t perform that action at this time.
0 commit comments