-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add disableValidation and monacoEditorOptions props
- Loading branch information
1 parent
63efd9e
commit 237fff4
Showing
3 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,11 @@ loader.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/[email protected]/ | |
|
||
interface IProps { | ||
modelInfos: ModelInfoType[]; | ||
disableValidation?: boolean; | ||
monacoEditorOptions?: BaseMonaco.editor.IStandaloneEditorConstructionOptions; | ||
} | ||
|
||
function App({ modelInfos }: IProps) { | ||
function App({ modelInfos, disableValidation = false, monacoEditorOptions = {} }: IProps) { | ||
const { | ||
stateRef, dispatch, actions, id, | ||
} = useEditor(); | ||
|
@@ -46,7 +48,9 @@ function App({ modelInfos }: IProps) { | |
actions.updateCodeParserLoading(false); | ||
|
||
registerCommandsAndActions(monaco, editor, dispatch, stateRef.current); | ||
registerListeners(editor, editorApiRef.current, stateRef.current); | ||
// TODO 目前监听仅有处理语法校验问题,后续状态控制需要特殊处理 | ||
// eslint-disable-next-line no-unused-expressions | ||
!disableValidation && registerListeners(editor, editorApiRef.current, stateRef.current); | ||
} | ||
|
||
function handleEditorBeforeMount(monaco: Monaco) { | ||
|
@@ -113,6 +117,8 @@ function App({ modelInfos }: IProps) { | |
minimap: { | ||
enabled: false, | ||
}, | ||
fontSize: 14, | ||
...monacoEditorOptions, | ||
}} | ||
/> | ||
); | ||
|