添加 json view.

This commit is contained in:
lijiahang
2023-10-26 14:57:09 +08:00
parent 03e18cc0e2
commit 6c4e588f92
11 changed files with 110 additions and 21 deletions

View File

@@ -27,6 +27,12 @@ export type RenderLineHighlight = 'all' | 'line' | 'none' | 'gutter'
export interface Options {
// 自适应布局
automaticLayout?: boolean;
// 只读提示
readOnlyMessage?: {
value?: string,
[key: string]: unknown;
};
// 是否折叠
folding?: boolean;
// 折叠方式
@@ -44,7 +50,9 @@ export interface Options {
placeholder?: string;
minimap?: {
// 关闭小地图
enabled?: boolean
enabled?: boolean;
[key: string]: unknown;
};
fontSize?: number;
// 取消代码后面一大段空白
@@ -63,6 +71,9 @@ export interface Options {
export const createDefaultOptions = (): Options => {
return {
automaticLayout: true,
readOnlyMessage: {
value: '当前为只读状态'
},
folding: true,
foldingHighlight: true,
foldingStrategy: 'indentation',

View File

@@ -71,7 +71,8 @@
language: props.language,
readOnly: props.readonly,
theme: props.theme === true ? (appStore.theme === 'dark' ? 'vs-dark' : 'vs') : props.theme,
options: { ...createDefaultOptions(), ...props.options },
...createDefaultOptions(),
...props.options,
};
// 创建编辑器
editor = monaco.editor.create(editorContainer.value, options);
@@ -101,7 +102,7 @@
}
});
// 监听配置
// 监听配置变更
watch(() => props.options, (v) => {
if (editor) {
editor.updateOptions(v);