File tree 3 files changed +11
-4
lines changed
plugins/com.msgbyte.mdpanel/src/group
plugin/PluginStore/DocumentView 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(() => {
54
54
render = { ( dataMap : Record < string , string > ) => {
55
55
return (
56
56
< MainContent >
57
- < Markdown raw = { dataMap [ 'markdown' ] ?? '' } />
57
+ < Markdown raw = { dataMap [ 'markdown' ] ?? '' } allowIframe = { true } />
58
58
</ MainContent >
59
59
) ;
60
60
} }
Original file line number Diff line number Diff line change @@ -13,8 +13,9 @@ const ReactMarkdown = Loadable(() => import('react-markdown'));
13
13
14
14
export const Markdown : React . FC < {
15
15
raw : string ;
16
+ allowIframe ?: boolean ;
16
17
baseUrl ?: string ;
17
- } > = React . memo ( ( { raw, baseUrl } ) => {
18
+ } > = React . memo ( ( { raw, baseUrl, allowIframe } ) => {
18
19
const { t } = useTranslation ( ) ;
19
20
const transformUrl = useCallback (
20
21
( url : string ) => {
@@ -46,21 +47,27 @@ export const Markdown: React.FC<{
46
47
) ,
47
48
svg : ( ) => < div > not support svg</ div > ,
48
49
iframe : ( props ) => {
50
+ if ( ! allowIframe ) {
51
+ return < div > { t ( '不支持iframe' ) } </ div > ;
52
+ }
53
+
49
54
let src = props . src ;
50
55
51
56
if ( ! src ) {
52
57
return < div /> ;
53
58
}
54
59
55
60
if ( ! src . startsWith ( 'http' ) ) {
56
- return < div > only support http source </ div > ;
61
+ return < div > { t ( '只支持http路径' ) } </ div > ;
57
62
}
58
63
59
64
if ( src && src . includes ( '?' ) ) {
60
65
src += '&autoplay=0' ; // make sure media autoplay is false
61
66
}
62
67
return < iframe { ...props } src = { src } /> ;
63
68
} ,
69
+ embed : ( ) => < div > { t ( '不支持embed' ) } </ div > ,
70
+ html : ( ) => < div > { t ( '不支持自定义HTML' ) } </ div > ,
64
71
style : ( ) => < div > { t ( '不支持自定义样式' ) } </ div > ,
65
72
meta : ( ) => < div > { t ( '不支持自定义Meta' ) } </ div > ,
66
73
} ) ,
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export const DocumentMarkdownRender: React.FC<{ url: string }> = React.memo(
24
24
return < Problem text = { String ( error ) } /> ;
25
25
}
26
26
27
- return < Markdown raw = { String ( value ) } baseUrl = { url } /> ;
27
+ return < Markdown raw = { String ( value ) } baseUrl = { url } allowIframe = { true } /> ;
28
28
}
29
29
) ;
30
30
DocumentMarkdownRender . displayName = 'DocumentMarkdownRender' ;
You can’t perform that action at this time.
0 commit comments