|
@@ -18,6 +18,10 @@ import * as monaco from "monaco-editor";
|
|
|
import { editor } from "monaco-editor/esm/vs/editor/editor.api";
|
|
|
import { configureMonacoYaml } from "monaco-yaml";
|
|
|
|
|
|
+import { type JSONSchema7 } from "json-schema";
|
|
|
+import metaSchema from "meta-json-schema/schemas/meta-json-schema.json";
|
|
|
+import mergeSchema from "meta-json-schema/schemas/clash-verge-merge-json-schema.json";
|
|
|
+
|
|
|
interface Props {
|
|
|
uid: string;
|
|
|
open: boolean;
|
|
@@ -33,12 +37,14 @@ configureMonacoYaml(monaco, {
|
|
|
enableSchemaRequest: true,
|
|
|
schemas: [
|
|
|
{
|
|
|
- uri: "https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/meta-json-schema.json",
|
|
|
+ uri: "http://example.com/meta-json-schema.json",
|
|
|
fileMatch: ["**/*.clash.yaml"],
|
|
|
+ schema: metaSchema as JSONSchema7,
|
|
|
},
|
|
|
{
|
|
|
- uri: "https://fastly.jsdelivr.net/gh/dongchengjie/meta-json-schema@main/schemas/clash-verge-merge-json-schema.json",
|
|
|
+ uri: "http://example.com/clash-verge-merge-json-schema.json",
|
|
|
fileMatch: ["**/*.merge.yaml"],
|
|
|
+ schema: mergeSchema as JSONSchema7,
|
|
|
},
|
|
|
],
|
|
|
});
|
|
@@ -65,8 +71,10 @@ export const EditorViewer = (props: Props) => {
|
|
|
instanceRef.current = editor.create(editorRef.current, {
|
|
|
model: model,
|
|
|
language: language,
|
|
|
+ tabSize: ["yaml", "javascript"].includes(language) ? 2 : 4, // 根据语言类型设置缩进
|
|
|
theme: themeMode === "light" ? "vs" : "vs-dark",
|
|
|
minimap: { enabled: dom.clientWidth >= 1000 }, // 超过一定宽度显示minimap滚动条
|
|
|
+ mouseWheelZoom: true, // Ctrl+滚轮调节缩放
|
|
|
quickSuggestions: {
|
|
|
strings: true, // 字符串类型的建议
|
|
|
comments: true, // 注释类型的建议
|
|
@@ -102,7 +110,7 @@ export const EditorViewer = (props: Props) => {
|
|
|
<DialogTitle>{t("Edit File")}</DialogTitle>
|
|
|
|
|
|
<DialogContent
|
|
|
- sx={{ width: "95%", height: "100vh", pb: 1, userSelect: "text" }}
|
|
|
+ sx={{ width: "94%", height: "100vh", pb: 1, userSelect: "text" }}
|
|
|
>
|
|
|
<div style={{ width: "100%", height: "100%" }} ref={editorRef} />
|
|
|
</DialogContent>
|