Skip to content

Commit d45aa64

Browse files
committed
feat: code refactoring
1 parent c3a2996 commit d45aa64

File tree

36 files changed

+1443
-14024
lines changed

36 files changed

+1443
-14024
lines changed

.dumi/overrides.less

+17
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,27 @@
33
font-weight: lighter;
44
}
55

6+
.dumi-default-navbar {
7+
font-weight: normal;
8+
}
9+
10+
.dumi-default-sidebar-group {
11+
font-weight: normal;
12+
}
13+
14+
.dumi-default-sidebar {
15+
width: 200px;
16+
}
17+
618
.dumi-default-doc-layout > main {
719
padding: 0;
20+
max-width: 80%;
821
}
922

1023
.dumi-default-hero {
1124
height: 800px;
1225
}
26+
27+
.dumi-default-features {
28+
margin: 0 auto 30px;
29+
}

docs/index.md

+4-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ hero:
88
- text: Github
99
link: https://github.com/lin-mt/json-schema-editor-arco
1010
features:
11-
- title: 高颜值
12-
emoji: 🌹
11+
- emoji: 🌹
1312
description: 基于 Arco Design 构建
14-
- title: 可视化
15-
emoji: 🧐
13+
- emoji: 🧐
1614
description: 可视化编辑 Json Schema
17-
- title: Mock
18-
emoji: 🎭
19-
description: 支持多种数据格式的 Mock
15+
- emoji: 🚀
16+
description: JSON Schema Draft 07 标准
2017
---

package.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,10 @@
5555
]
5656
},
5757
"dependencies": {
58-
"@arco-design/web-react": "^2.45.1",
59-
"@monaco-editor/react": "^4.4.6",
60-
"@types/lodash": "^4.14.191",
61-
"lodash": "^4.17.21",
62-
"mobx": "^6.8.0",
63-
"mobx-react": "^7.6.0"
58+
"@arco-design/web-react": "^2.64.1",
59+
"@monaco-editor/react": "^4.6.0",
60+
"@types/lodash": "^4.17.13",
61+
"lodash": "^4.17.21"
6462
},
6563
"devDependencies": {
6664
"@commitlint/cli": "^17.1.2",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import Editor, { OnChange } from '@monaco-editor/react';
2+
import React, { ReactElement } from 'react';
3+
import { xcodeDefault } from './themes';
4+
5+
interface QuietEditorProp {
6+
width?: string | number;
7+
height?: string | number;
8+
value?: string;
9+
language?: string;
10+
readOnly?: boolean;
11+
lineNumbers?: 'on' | 'off' | 'relative' | 'interval';
12+
folding?: boolean;
13+
renderLineHighlight?: 'all' | 'line' | 'none' | 'gutter';
14+
onChange?: OnChange;
15+
handleEditorDidMount?: (editor: any, monaco: any) => void;
16+
}
17+
18+
const MonacoEditor = (props: QuietEditorProp): ReactElement => {
19+
const {
20+
width,
21+
lineNumbers = 'on',
22+
height,
23+
value,
24+
folding = true,
25+
language,
26+
readOnly = false,
27+
renderLineHighlight = 'all',
28+
onChange,
29+
} = props;
30+
31+
function editorWillMount(monaco: any) {
32+
monaco.editor.defineTheme('x-code-default', xcodeDefault);
33+
}
34+
35+
return (
36+
<div
37+
style={{
38+
border: `1px solid rgb(var(--color-border))`,
39+
width: width ? width : '100%',
40+
}}
41+
>
42+
<Editor
43+
height={height}
44+
width={width}
45+
value={value}
46+
language={language}
47+
onChange={onChange}
48+
onMount={props.handleEditorDidMount}
49+
beforeMount={editorWillMount}
50+
theme="x-code-default"
51+
options={{
52+
// 只读
53+
readOnly,
54+
// 关闭行数显示
55+
lineNumbers,
56+
// 关闭选中行的渲染
57+
renderLineHighlight,
58+
// 是否折叠
59+
folding,
60+
smoothScrolling: true,
61+
// 编辑器中字体大小
62+
fontSize: 13,
63+
// 是否可以滚动到最后一行,可以往上滚动超出内容范围
64+
scrollBeyondLastLine: false,
65+
// 左边空出来的宽度
66+
// lineDecorationsWidth: 3,
67+
// lineNumbersMinChars: 6,
68+
// 滚动条样式
69+
scrollbar: {
70+
// verticalScrollbarSize: 9,
71+
// horizontalScrollbarSize: 9,
72+
},
73+
// 小地图
74+
minimap: {
75+
enabled: false,
76+
},
77+
}}
78+
/>
79+
</div>
80+
);
81+
};
82+
83+
export default MonacoEditor;

0 commit comments

Comments
 (0)