forked from Gitlink/forgeplus-react
37 lines
979 B
JavaScript
37 lines
979 B
JavaScript
import React from 'react';
|
|
import Editor from 'react-monaco-editor';
|
|
|
|
function Editors({value,onChange,theme,height,visible,width="100%",Numbers="on"}){
|
|
const editor_options = {
|
|
lineNumbers: Numbers,
|
|
wordWrap: true, //强制换行
|
|
selectOnLineNumbers: true,
|
|
lineHeight: 24,
|
|
renderLineHighlight: "line",
|
|
revealHorizontalRightPadding: 5,
|
|
placeholder:"请输入内容",
|
|
readOnly: visible,
|
|
cursorStyle: visible ? "underline-thin" : "line",
|
|
folding: true,
|
|
foldingStrategy: "indentation", // 代码可分小段折叠
|
|
automaticLayout: true, // 自适应布局
|
|
minimap: {
|
|
// 不要小地图
|
|
enabled: false,
|
|
},
|
|
}
|
|
return(
|
|
<Editor
|
|
height={height}
|
|
width={width}
|
|
language={"yaml"}
|
|
theme={theme}
|
|
placeholder="请输入内容"
|
|
value={value}
|
|
options={editor_options}
|
|
onChange={(value)=>onChange(value)}
|
|
disabled={true}
|
|
></Editor>
|
|
)
|
|
}
|
|
export default Editors; |