@@ -5,12 +5,12 @@ import { REPORT_NAME } from '@alipay/alex-core';
55import { createEditor } from './createEditor' ;
66import { Root } from '../core/Root' ;
77import { RootProps , LandingProps } from '../core/types' ;
8- import { themeStorage } from '../core/utils' ;
98import { useConstant } from '../core/hooks' ;
109import { IConfig , IAppInstance } from './types' ;
1110import { EditorProps } from '../core/editor/types' ;
1211import { Container } from '../core/editor/container' ;
1312import { HIDE_EDITOR_TAB_CLASS_NAME } from '../core/constants' ;
13+ import styles from '../core/style.module.less' ;
1414
1515interface IRenderProps extends IConfig {
1616 onLoad ?( app : IAppInstance ) : void ;
@@ -22,18 +22,17 @@ export type IEditorRenderProps = IRenderProps & EditorProps;
2222export const renderEditor = ( domElement : HTMLElement , props : IEditorRenderProps ) => {
2323 const { onLoad, Landing, ...opts } = props ;
2424 const app = createEditor ( opts ) ;
25- const themeType = themeStorage . get ( ) ;
26- ReactDOM . render ( < Root status = "loading" theme = { themeType } Landing = { Landing } /> , domElement ) ;
25+ const className = `alex-editor ${
26+ opts . runtimeConfig . hideEditorTab ? styles [ 'hide-editor-tab' ] : ''
27+ } `;
28+
29+ ReactDOM . render ( < Root status = "loading" Landing = { Landing } className = { className } /> , domElement ) ;
2730
2831 app
2932 . start ( ( appElement ) => {
3033 return new Promise ( ( resolve ) => {
3134 ReactDOM . render (
32- < Root
33- status = "success"
34- theme = { themeType }
35- className = { opts . runtimeConfig . hideEditorTab ? HIDE_EDITOR_TAB_CLASS_NAME : '' }
36- >
35+ < Root status = "success" className = { className } >
3736 { appElement }
3837 </ Root > ,
3938 domElement ,
@@ -46,7 +45,11 @@ export const renderEditor = (domElement: HTMLElement, props: IEditorRenderProps)
4645 } )
4746 . catch ( ( err : Error ) => {
4847 ReactDOM . render (
49- < Root status = "error" error = { err ?. message || localize ( 'error.unknown' ) } theme = { themeType } /> ,
48+ < Root
49+ status = "error"
50+ error = { err ?. message || localize ( 'error.unknown' ) }
51+ className = { className }
52+ /> ,
5053 domElement
5154 ) ;
5255
@@ -66,7 +69,6 @@ export const renderEditor = (domElement: HTMLElement, props: IEditorRenderProps)
6669
6770export const EditorRenderer : React . FC < IEditorRenderProps > = ( { onLoad, Landing, ...opts } ) => {
6871 const app = useConstant ( ( ) => createEditor ( opts ) ) ;
69- const themeType = useConstant ( ( ) => themeStorage . get ( ) ) ;
7072 const appElementRef = useRef < React . ReactElement | null > ( null ) ;
7173
7274 const [ state , setState ] = useState < {
@@ -106,13 +108,13 @@ export const EditorRenderer: React.FC<IEditorRenderProps> = ({ onLoad, Landing,
106108 } , [ ] ) ;
107109
108110 const rootClassName = useMemo (
109- ( ) => ( opts . runtimeConfig . hideEditorTab ? HIDE_EDITOR_TAB_CLASS_NAME : '' ) ,
111+ ( ) => ( opts . runtimeConfig . hideEditorTab ? styles [ 'hide-editor-tab' ] : '' ) ,
110112 [ opts . runtimeConfig . hideEditorTab ]
111113 ) ;
112114
113115 return (
114116 < Container value = { { documentModel : opts . documentModel } } >
115- < Root { ...state } theme = { themeType } Landing = { Landing } className = { rootClassName } >
117+ < Root { ...state } Landing = { Landing } className = { `alex-editor ${ rootClassName } ` } >
116118 { appElementRef . current }
117119 </ Root >
118120 </ Container >
0 commit comments