diff --git a/packages/design/components/MonacoEditor/Editor.tsx b/packages/design/components/MonacoEditor/Editor.tsx index c66d331..7a63820 100644 --- a/packages/design/components/MonacoEditor/Editor.tsx +++ b/packages/design/components/MonacoEditor/Editor.tsx @@ -15,17 +15,19 @@ const FILENAME = 'index.tsx'; const MonacoEditor = (props: MocacoEditorProps) => { const { compilerWorker } = useWorkers(); - const [value, onChange] = useControlled(props, { - valuePropName: 'value', - changeName: 'onChange', - defaultValuePropName: 'defaultValue', - }); + // const [value, onChange] = useControlled(props, { + // valuePropName: 'value', + // changeName: 'onChange', + // defaultValuePropName: 'defaultValue', + // }); const { height = 400, defaultLanguage = CodeType.ts, path = FILENAME, theme = ThemeType['Visual Studio Dark'], modules, + onChange, + defaultValue, ...rest } = props; @@ -39,7 +41,7 @@ const MonacoEditor = (props: MocacoEditorProps) => { type: MessageChangeType.Compile, data: { filename: path, - code: value, + code: defaultValue, modules, }, }); @@ -64,11 +66,11 @@ const MonacoEditor = (props: MocacoEditorProps) => { height={height} path={path} defaultLanguage={defaultLanguage} - defaultValue={value} + defaultValue={defaultValue} theme={theme} onChange={handleEditorChange} onMount={handleEditorDidMount} - {...omit(rest, ['value', 'onChange'])} + {...rest} // beforeMount={handleEditorWillMount} // onValidate={handleEditorValidation} /> diff --git a/packages/design/components/MonacoEditor/MultipleEditor.tsx b/packages/design/components/MonacoEditor/MultipleEditor.tsx index a427aec..59a4e2c 100644 --- a/packages/design/components/MonacoEditor/MultipleEditor.tsx +++ b/packages/design/components/MonacoEditor/MultipleEditor.tsx @@ -35,8 +35,9 @@ const items = [ }`, }, ]; -// todo: 1.多文件引入(scss、tsx),引入scss -// 2.代码优化; +// todo: 1. 编译文件的独立性。现在修改css实际走的是tsx的编译 +// 2.引入scss +// 3.代码优化; const MultipleEditor = () => { const [tabsValue, setTabsValue] = useLocalStorage('tabs', { defaultValue: items, @@ -52,7 +53,7 @@ const MultipleEditor = () => { modules={tabsValue} path={String(item.label)} defaultLanguage={item.language} - value={item.value} + defaultValue={item.value} onChange={(value) => { const prevTabValue = tabsValue; const activeTab = _find(prevTabValue, item.key);