-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
1,443 additions
and
14,024 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
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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import Editor, { OnChange } from '@monaco-editor/react'; | ||
import React, { ReactElement } from 'react'; | ||
import { xcodeDefault } from './themes'; | ||
|
||
interface QuietEditorProp { | ||
width?: string | number; | ||
height?: string | number; | ||
value?: string; | ||
language?: string; | ||
readOnly?: boolean; | ||
lineNumbers?: 'on' | 'off' | 'relative' | 'interval'; | ||
folding?: boolean; | ||
renderLineHighlight?: 'all' | 'line' | 'none' | 'gutter'; | ||
onChange?: OnChange; | ||
handleEditorDidMount?: (editor: any, monaco: any) => void; | ||
} | ||
|
||
const MonacoEditor = (props: QuietEditorProp): ReactElement => { | ||
const { | ||
width, | ||
lineNumbers = 'on', | ||
height, | ||
value, | ||
folding = true, | ||
language, | ||
readOnly = false, | ||
renderLineHighlight = 'all', | ||
onChange, | ||
} = props; | ||
|
||
function editorWillMount(monaco: any) { | ||
monaco.editor.defineTheme('x-code-default', xcodeDefault); | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ | ||
border: `1px solid rgb(var(--color-border))`, | ||
width: width ? width : '100%', | ||
}} | ||
> | ||
<Editor | ||
height={height} | ||
width={width} | ||
value={value} | ||
language={language} | ||
onChange={onChange} | ||
onMount={props.handleEditorDidMount} | ||
beforeMount={editorWillMount} | ||
theme="x-code-default" | ||
options={{ | ||
// 只读 | ||
readOnly, | ||
// 关闭行数显示 | ||
lineNumbers, | ||
// 关闭选中行的渲染 | ||
renderLineHighlight, | ||
// 是否折叠 | ||
folding, | ||
smoothScrolling: true, | ||
// 编辑器中字体大小 | ||
fontSize: 13, | ||
// 是否可以滚动到最后一行,可以往上滚动超出内容范围 | ||
scrollBeyondLastLine: false, | ||
// 左边空出来的宽度 | ||
// lineDecorationsWidth: 3, | ||
// lineNumbersMinChars: 6, | ||
// 滚动条样式 | ||
scrollbar: { | ||
// verticalScrollbarSize: 9, | ||
// horizontalScrollbarSize: 9, | ||
}, | ||
// 小地图 | ||
minimap: { | ||
enabled: false, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default MonacoEditor; |
File renamed without changes.
Oops, something went wrong.