@fast-crud/editor-code 1.25.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +79 -0
- package/.prettierrc +5 -0
- package/CHANGELOG.md +945 -0
- package/dist/d/editor/components/fs-editor-code/validators.d.ts +10 -0
- package/dist/d/editor/components/fs-editor-code/worker/index.d.ts +9 -0
- package/dist/d/editor/components/fs-editor-code/worker/yaml.worker.d.ts +1 -0
- package/dist/d/editor/components/fs-editor-code/workers.d.ts +9 -0
- package/dist/d/editor/exports.d.ts +3 -0
- package/dist/d/editor/index.d.ts +4 -0
- package/dist/d/editor/index.umd.d.ts +4 -0
- package/dist/d/editor/type/index.d.ts +4 -0
- package/dist/d/editor/type/types.d.ts +12 -0
- package/dist/d/index.d.ts +1 -0
- package/dist/d/index.umd.d.ts +1 -0
- package/dist/editor-code.mjs +9 -0
- package/dist/editor-code.mjs.map +1 -0
- package/dist/editor-code.umd.js +2 -0
- package/dist/editor-code.umd.js.map +1 -0
- package/dist/index-4cfdb04c.mjs +132 -0
- package/dist/index-4cfdb04c.mjs.map +1 -0
- package/dist/index-c2ddaf47.mjs +97 -0
- package/dist/index-c2ddaf47.mjs.map +1 -0
- package/dist/style.css +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +84 -0
- package/src/editor/components/fs-editor-code/async-import.ts +19 -0
- package/src/editor/components/fs-editor-code/index.vue +240 -0
- package/src/editor/components/fs-editor-code/validators.ts +37 -0
- package/src/editor/components/fs-editor-code/worker/index.ts +64 -0
- package/src/editor/components/fs-editor-code/worker/yaml.worker.ts +1 -0
- package/src/editor/components/fs-editor-code/workers.ts +45 -0
- package/src/editor/exports.ts +3 -0
- package/src/editor/index.umd.ts +17 -0
- package/src/editor/type/types.ts +7 -0
- package/src/index.umd.ts +1 -0
- package/src/style.css +1 -0
- package/tsconfig.json +49 -0
- package/vite.config.js +125 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "monaco-yaml/yaml.worker.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./editor";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./editor/index.umd";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-code.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(a,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("vue"),require("monaco-editor"),require("lodash-es"),require("@fast-crud/fast-crud")):typeof define=="function"&&define.amd?define(["exports","vue","monaco-editor","lodash-es","@fast-crud/fast-crud"],i):(a=typeof globalThis<"u"?globalThis:a||self,i(a.FsExtends={},a.Vue,a.monaco,a._,a.FastCrud))})(this,function(a,i,_,f,p){"use strict";function v(t){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(o,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return o.default=t,Object.freeze(o)}const c=v(_);async function b(){return await import("js-yaml")}async function j(){await import("monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution")}async function V(){await import("monaco-editor/esm/vs/language/json/monaco.contribution")}async function k(){await import("monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution")}async function E(){return await import("monaco-yaml")}const g=[];function C(t,o){g.push({worker:o,match:e=>{if(typeof t=="string")return t===e;for(const r of t)if(r==="*"||r===e)return!0;return!1}})}function y(){window.MonacoEnvironment||(window.MonacoEnvironment={getWorker(t,o){for(const e of g)if(e.match(o))return new e.worker}})}const M=i.defineComponent({__name:"index",props:{language:{},modelValue:{},config:{},schema:{},debounce:{},init:{},readonly:{type:Boolean},disabled:{type:Boolean},id:{}},emits:["update:modelValue","change","ready"],setup(t,{emit:o}){const e=t;y();const r=i.ref();let u=null;function d(){u&&u.dispose()}i.onUnmounted(()=>{d()});const m=o,D=f.debounce(n=>{m("update:modelValue",n)},e.debounce||500);async function W(n){d();const s=c.editor.create(r.value,{automaticLayout:!0,value:e.modelValue,language:n.language,theme:"vs-dark",minimap:{enabled:!1},readOnly:e.readonly||e.disabled,hover:{enabled:!0},...n.config});return s.onDidChangeModelContent(w=>{const l=s.getValue();e.modelValue!==l&&(m("change",l),D(l))}),u=s,n.instance=s,m("ready",n),s}async function B(n){await k(),c.languages.register({id:"javascript"})}async function Y(n){await V(),c.languages.register({id:"json"});const s=[];n.schema&&s.push({uri:"http://myserver/foo-schema.json",fileMatch:["*"],schema:{...n.schema}}),c.languages.json.jsonDefaults.setDiagnosticsOptions({validate:!0,enableSchemaRequest:!1,schemas:s})}async function x(n){await j();const{configureMonacoYaml:s}=await E();c.languages.register({id:"yaml"});let w=`fs-editor-code-yaml-${e.id||""}.yaml`;const l=[];n.schema&&l.push({fileMatch:["*"],schema:{...n.schema},uri:`http://myserver/${w}`}),s(c,{schemas:l,format:!0,hover:!0,completion:!0,validate:!0,isKubernetes:!1,enableSchemaRequest:!1})}async function h(){d();const n={monaco:c,language:e.language||"javascript",config:f.cloneDeep(e.config||{}),initialValue:e.modelValue||"",schema:e.schema};n.language==="javascript"?await B():n.language==="yaml"?await x(n):n.language==="json"&&await Y(n),await W(n)}return i.onMounted(async()=>{await h(),i.watch(()=>({language:e.language,config:e.config}),n=>{h()})}),i.watch(()=>e.modelValue,n=>{u&&u.getValue()!==n&&u.setValue(n)}),(n,s)=>(i.openBlock(),i.createElementBlock("div",{ref_key:"monacoRef",ref:r,class:"fs-editor-code"},null,512))}}),P="",O=Object.freeze(Object.defineProperty({__proto__:null,default:M},Symbol.toStringTag,{value:"Module"}));function S(){return{"editor-code":{form:{component:{name:"fs-editor-code"},col:{span:24}}}}}const R={install(t,o){const e=S(),{addTypes:r}=p.useTypes();r(e)}},T={jsonRule:{validator:async(t,o)=>{if(o)try{JSON.parse(o)}catch(e){throw console.error(e),new Error("json格式错误:"+e.message)}},message:"json格式错误"},yamlRule:{validator:async(t,o)=>{if(o)try{const e=await b();e.load(o,{schema:e.JSON_SCHEMA})}catch(e){throw console.error(e),new Error("yaml格式错误:"+e.message)}},message:"yaml格式错误"}},F=Object.assign({"./components/fs-editor-code/index.vue":O}),J={install(t){p.utils.vite.installSyncComponents(t,F,null,/^.*\/([^\/]+)\/.*.vue$/,null)}},q={install(t,o){t.use(R,o),t.use(J)}};a.FsEditorCode=q,a.FsEditorCodeValidators=T,a.initWorkers=y,a.registerWorker=C,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
|
2
|
+
//# sourceMappingURL=editor-code.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-code.umd.js","sources":["../../src/editor/components/fs-editor-code/async-import.ts","../../src/editor/components/fs-editor-code/workers.ts","../src/editor/components/fs-editor-code/index.vue","../../src/editor/type/types.ts","../../src/editor/type/index.ts","../../src/editor/components/fs-editor-code/validators.ts","../../src/editor/index.umd.ts"],"sourcesContent":[null,null,"<template>\n <div ref=\"monacoRef\" class=\"fs-editor-code\"></div>\n</template>\n\n<script lang=\"ts\" setup>\nimport * as monaco from \"monaco-editor\";\n// import * as monaco from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { onMounted, onUnmounted, ref, watch } from \"vue\";\nimport { cloneDeep, debounce as lodashDebounce } from \"lodash-es\";\nimport {\n importJavascriptContribution,\n importJsonContribution,\n importMonacoYaml,\n importYamlContribution\n} from \"./async-import\";\nimport { initWorkers } from \"./workers\";\n/**\n * config:\n * value: '', // 编辑器初始文本\n * language: 'javascript', // 语言\n * theme: 'vs', // 主题\n * readOnly: false, // 是否只读\n * minimap: { enabled: false }, // 是否启用小地图\n * fontSize: 14, // 字体大小\n * tabSize: 2, // tab缩进长度\n * automaticLayout: true, // 自动布局\n * lineNumbers: 'off', // 是否启用行号\n * contextmenu: true, // 是否启用上下文菜单\n * folding: true, // 是否启用代码折叠\n * foldingStrategy: 'auto', // 代码折叠策略\n * wordWrap: 'on', // 自动换行设置\n * wrappingIndent: 'indent', // 换行缩进\n * formatOnPaste: true, // 粘贴时是否自动格式化\n * formatOnType: true, // 输入时是否自动格式化\n * dragAndDrop: true, // 是否允许拖放\n * cursorStyle: 'line', // 光标样式\n * cursorBlinking: 'blink', // 光标闪烁方式\n * scrollbar: {\n * vertical: 'auto', // 垂直滚动条的显示方式\n * horizontal: 'auto', // 水平滚动条的显示方式\n * verticalScrollbarSize: 2, // 垂直滚动条的宽\n * horizontalScrollbarSize: 2, // 水平滚动条的高度\n * }\n */\nconst props = defineProps<{\n language?: string;\n modelValue?: string;\n config?: any;\n schema?: any;\n debounce?: number;\n init?: any;\n readonly?: boolean;\n disabled?: boolean;\n id?: string;\n}>();\n\nexport type EditorCodeCtx = {\n // monaco对象\n monaco: any;\n //语言\n language: string;\n //配置\n config: any;\n //editor实例对象\n instance?: any;\n\n schema?: any;\n\n initialValue?: any;\n};\ninitWorkers();\nconst monacoRef = ref();\n\nlet instanceRef: any = null;\n\nfunction disposeEditor() {\n if (instanceRef) {\n instanceRef.dispose(); //使用完成销毁实例\n }\n}\n\nonUnmounted(() => {\n disposeEditor();\n});\n\nconst emits = defineEmits([\"update:modelValue\", \"change\", \"ready\"]);\n\nconst emitValue = lodashDebounce((value: any) => {\n emits(\"update:modelValue\", value);\n}, props.debounce || 500);\n\nasync function createEditor(ctx: EditorCodeCtx) {\n disposeEditor();\n const instance = monaco.editor.create(monacoRef.value, {\n automaticLayout: true,\n value: props.modelValue,\n language: ctx.language,\n theme: \"vs-dark\",\n minimap: { enabled: false },\n readOnly: props.readonly || props.disabled,\n hover: {\n enabled: true\n },\n ...ctx.config\n });\n\n // @event `change`\n instance.onDidChangeModelContent((event) => {\n const value = instance.getValue();\n if (props.modelValue !== value) {\n emits(\"change\", value);\n emitValue(value);\n }\n });\n\n instanceRef = instance;\n ctx.instance = instance;\n emits(\"ready\", ctx);\n return instance;\n}\n\nasync function initJavascript(ctx: EditorCodeCtx) {\n await importJavascriptContribution();\n monaco.languages.register({ id: \"javascript\" });\n}\n\nasync function initJson(ctx: EditorCodeCtx) {\n await importJsonContribution();\n monaco.languages.register({ id: \"json\" });\n\n const schemas = [];\n if (ctx.schema) {\n schemas.push({\n uri: \"http://myserver/foo-schema.json\", // id of the first schema\n fileMatch: [\"*\"], // associate with our model\n schema: {\n ...ctx.schema\n }\n });\n }\n\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n validate: true,\n enableSchemaRequest: false,\n schemas\n });\n}\n\nasync function initYaml(ctx: EditorCodeCtx) {\n await importYamlContribution();\n const { configureMonacoYaml } = await importMonacoYaml();\n monaco.languages.register({ id: \"yaml\" });\n let id = `fs-editor-code-yaml-${props.id || \"\"}.yaml`;\n const schemas = [];\n if (ctx.schema) {\n schemas.push({\n fileMatch: [\"*\"], // associate with our model\n schema: {\n ...ctx.schema\n },\n uri: `http://myserver/${id}`\n });\n }\n configureMonacoYaml(monaco, {\n schemas,\n format: true,\n hover: true,\n completion: true,\n validate: true,\n isKubernetes: false,\n enableSchemaRequest: false\n });\n\n // const uri = monaco.Uri.parse(id);\n // const oldModel = monaco.editor.getModel(uri);\n // if (oldModel) {\n // oldModel.dispose();\n // }\n // ctx.config.model = monaco.editor.createModel(props.modelValue, null, uri);\n}\n\nasync function doInit() {\n disposeEditor();\n const ctx: EditorCodeCtx = {\n monaco,\n language: props.language || \"javascript\",\n config: cloneDeep(props.config || {}),\n initialValue: props.modelValue || \"\",\n schema: props.schema\n };\n if (ctx.language === \"javascript\") {\n await initJavascript(ctx);\n } else if (ctx.language === \"yaml\") {\n await initYaml(ctx);\n } else if (ctx.language === \"json\") {\n await initJson(ctx);\n }\n\n await createEditor(ctx);\n}\n\nonMounted(async () => {\n await doInit();\n watch(\n () => {\n return {\n language: props.language,\n config: props.config\n };\n },\n (value: any) => {\n doInit();\n }\n );\n});\n\nwatch(\n () => {\n return props.modelValue;\n },\n (value: any) => {\n if (instanceRef && instanceRef.getValue() !== value) {\n instanceRef.setValue(value);\n }\n }\n);\n</script>\n\n<style lang=\"less\">\n.fs-editor-code {\n min-height: 100px;\n width: 100%;\n border: 1px solid #eee;\n border-radius: 5px;\n}\n\n.monaco-editor .hover-content {\n z-index: 10000 !important;\n}\n</style>\n",null,null,null,null],"names":["importJsYaml","importYamlContribution","importJsonContribution","importJavascriptContribution","importMonacoYaml","WorkerBucket","registerWorker","labels","worker","label","labelItem","initWorkers","_","workerLoader","props","__props","monacoRef","ref","instanceRef","disposeEditor","onUnmounted","emits","__emit","emitValue","lodashDebounce","value","createEditor","ctx","instance","monaco","event","initJavascript","initJson","schemas","initYaml","configureMonacoYaml","id","doInit","cloneDeep","onMounted","watch","_createElementBlock","types","FsExtendsModelType","app","options","newTypes","addTypes","useTypes","FsEditorCodeValidators","rule","yaml","modules","FsExtendsComponents","utils","FsEditorCode"],"mappings":"urBAAA,eAAsBA,GAAY,CACzB,OAAA,KAAM,QAAO,SAAS,CAC/B,CAEA,eAAsBC,GAAsB,CAC1C,KAAM,QAAO,6DAA6D,CAC5E,CAEA,eAAsBC,GAAsB,CAC1C,KAAM,QAAO,wDAAwD,CACvE,CAEA,eAAsBC,GAA4B,CAChD,KAAM,QAAO,yEAAyE,CACxF,CAEA,eAAsBC,GAAgB,CAC7B,OAAA,KAAM,QAAO,aAAa,CACnC,CCdA,MAAMC,EAA6B,CAAA,EAInB,SAAAC,EAAeC,EAA2BC,EAAW,CACnEH,EAAa,KAAK,CAChB,OAAAG,EACA,MAAQC,GAAiB,CACnB,GAAA,OAAOF,GAAW,SACpB,OAAOA,IAAWE,EAEpB,UAAWC,KAAaH,EAItB,GAHIG,IAAc,KAGdA,IAAcD,EACT,MAAA,GAGJ,MAAA,EACT,CAAA,CACD,CACH,UAEgBE,GAAW,CACrB,OAAO,oBAKX,OAAO,kBAAoB,CAEzB,UAAUC,EAAGH,EAAK,CAChB,UAAWI,KAAgBR,EACrB,GAAAQ,EAAa,MAAMJ,CAAK,EACnB,OAAA,IAAII,EAAa,MAG9B,CAAA,EAEJ,0OCA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AkB,EAAE,IAAK,CAAE,KAAM,GAAM,CACnE,CAAA,CAEL,CCHe,MAAAC,EAAA,CACb,QAAQC,EAAUC,EAAY,CAC5B,MAAMC,EAAWJ,IACX,CAAE,SAAAK,GAAaC,EAAAA,WACrBD,EAASD,CAAQ,CACnB,GCyBWG,EAAyB,CACpC,SAhCe,CACf,UAAW,MAAOC,EAAWzB,IAAc,CAEzC,GAAIA,EACE,GAAA,CACF,KAAK,MAAMA,CAAK,QACT,EAAQ,CACf,cAAQ,MAAM,CAAC,EACT,IAAI,MAAM,YAAc,EAAE,OAAO,CACxC,CAEL,EACA,QAAS,YAqBT,SAlBe,CACf,UAAW,MAAOyB,EAAWzB,IAAc,CAEzC,GAAIA,EACE,GAAA,CACI,MAAA0B,EAAO,MAAMnD,IACnBmD,EAAK,KAAK1B,EAAO,CAAE,OAAQ0B,EAAK,YAAa,QACtC,EAAQ,CACf,cAAQ,MAAM,CAAC,EACT,IAAI,MAAM,YAAc,EAAE,OAAO,CACxC,CAEL,EACA,QAAS,aC1BLC,6DACAC,EAAsB,CAC1B,QAAQT,EAAQ,CACdU,QAAM,KAAK,sBAAsBV,EAAKQ,EAAS,KAAM,yBAA0B,IAAI,CACrF,GAGWG,EAAe,CAC1B,QAAQX,EAAUC,EAAY,CACxBD,EAAA,IAAID,EAAoBE,CAAO,EACnCD,EAAI,IAAIS,CAAmB,CAC7B"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { defineComponent as b, ref as _, onUnmounted as V, onMounted as w, watch as m, openBlock as j, createElementBlock as C } from "vue";
|
|
2
|
+
import * as t from "monaco-editor";
|
|
3
|
+
import { debounce as M, cloneDeep as k } from "lodash-es";
|
|
4
|
+
import { i as R, a as B, b as D, c as J, d as Y } from "./index-c2ddaf47.mjs";
|
|
5
|
+
import "@fast-crud/fast-crud";
|
|
6
|
+
const S = /* @__PURE__ */ b({
|
|
7
|
+
__name: "index",
|
|
8
|
+
props: {
|
|
9
|
+
language: {},
|
|
10
|
+
modelValue: {},
|
|
11
|
+
config: {},
|
|
12
|
+
schema: {},
|
|
13
|
+
debounce: {},
|
|
14
|
+
init: {},
|
|
15
|
+
readonly: { type: Boolean },
|
|
16
|
+
disabled: { type: Boolean },
|
|
17
|
+
id: {}
|
|
18
|
+
},
|
|
19
|
+
emits: ["update:modelValue", "change", "ready"],
|
|
20
|
+
setup(d, { emit: f }) {
|
|
21
|
+
const a = d;
|
|
22
|
+
R();
|
|
23
|
+
const c = _();
|
|
24
|
+
let o = null;
|
|
25
|
+
function s() {
|
|
26
|
+
o && o.dispose();
|
|
27
|
+
}
|
|
28
|
+
V(() => {
|
|
29
|
+
s();
|
|
30
|
+
});
|
|
31
|
+
const l = f, g = M((e) => {
|
|
32
|
+
l("update:modelValue", e);
|
|
33
|
+
}, a.debounce || 500);
|
|
34
|
+
async function p(e) {
|
|
35
|
+
s();
|
|
36
|
+
const n = t.editor.create(c.value, {
|
|
37
|
+
automaticLayout: !0,
|
|
38
|
+
value: a.modelValue,
|
|
39
|
+
language: e.language,
|
|
40
|
+
theme: "vs-dark",
|
|
41
|
+
minimap: { enabled: !1 },
|
|
42
|
+
readOnly: a.readonly || a.disabled,
|
|
43
|
+
hover: {
|
|
44
|
+
enabled: !0
|
|
45
|
+
},
|
|
46
|
+
...e.config
|
|
47
|
+
});
|
|
48
|
+
return n.onDidChangeModelContent((u) => {
|
|
49
|
+
const i = n.getValue();
|
|
50
|
+
a.modelValue !== i && (l("change", i), g(i));
|
|
51
|
+
}), o = n, e.instance = n, l("ready", e), n;
|
|
52
|
+
}
|
|
53
|
+
async function h(e) {
|
|
54
|
+
await B(), t.languages.register({ id: "javascript" });
|
|
55
|
+
}
|
|
56
|
+
async function y(e) {
|
|
57
|
+
await D(), t.languages.register({ id: "json" });
|
|
58
|
+
const n = [];
|
|
59
|
+
e.schema && n.push({
|
|
60
|
+
uri: "http://myserver/foo-schema.json",
|
|
61
|
+
// id of the first schema
|
|
62
|
+
fileMatch: ["*"],
|
|
63
|
+
// associate with our model
|
|
64
|
+
schema: {
|
|
65
|
+
...e.schema
|
|
66
|
+
}
|
|
67
|
+
}), t.languages.json.jsonDefaults.setDiagnosticsOptions({
|
|
68
|
+
validate: !0,
|
|
69
|
+
enableSchemaRequest: !1,
|
|
70
|
+
schemas: n
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async function v(e) {
|
|
74
|
+
await J();
|
|
75
|
+
const { configureMonacoYaml: n } = await Y();
|
|
76
|
+
t.languages.register({ id: "yaml" });
|
|
77
|
+
let u = `fs-editor-code-yaml-${a.id || ""}.yaml`;
|
|
78
|
+
const i = [];
|
|
79
|
+
e.schema && i.push({
|
|
80
|
+
fileMatch: ["*"],
|
|
81
|
+
// associate with our model
|
|
82
|
+
schema: {
|
|
83
|
+
...e.schema
|
|
84
|
+
},
|
|
85
|
+
uri: `http://myserver/${u}`
|
|
86
|
+
}), n(t, {
|
|
87
|
+
schemas: i,
|
|
88
|
+
format: !0,
|
|
89
|
+
hover: !0,
|
|
90
|
+
completion: !0,
|
|
91
|
+
validate: !0,
|
|
92
|
+
isKubernetes: !1,
|
|
93
|
+
enableSchemaRequest: !1
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async function r() {
|
|
97
|
+
s();
|
|
98
|
+
const e = {
|
|
99
|
+
monaco: t,
|
|
100
|
+
language: a.language || "javascript",
|
|
101
|
+
config: k(a.config || {}),
|
|
102
|
+
initialValue: a.modelValue || "",
|
|
103
|
+
schema: a.schema
|
|
104
|
+
};
|
|
105
|
+
e.language === "javascript" ? await h() : e.language === "yaml" ? await v(e) : e.language === "json" && await y(e), await p(e);
|
|
106
|
+
}
|
|
107
|
+
return w(async () => {
|
|
108
|
+
await r(), m(
|
|
109
|
+
() => ({
|
|
110
|
+
language: a.language,
|
|
111
|
+
config: a.config
|
|
112
|
+
}),
|
|
113
|
+
(e) => {
|
|
114
|
+
r();
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
}), m(
|
|
118
|
+
() => a.modelValue,
|
|
119
|
+
(e) => {
|
|
120
|
+
o && o.getValue() !== e && o.setValue(e);
|
|
121
|
+
}
|
|
122
|
+
), (e, n) => (j(), C("div", {
|
|
123
|
+
ref_key: "monacoRef",
|
|
124
|
+
ref: c,
|
|
125
|
+
class: "fs-editor-code"
|
|
126
|
+
}, null, 512));
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
export {
|
|
130
|
+
S as default
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=index-4cfdb04c.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-4cfdb04c.mjs","sources":["../src/editor/components/fs-editor-code/index.vue"],"sourcesContent":["<template>\n <div ref=\"monacoRef\" class=\"fs-editor-code\"></div>\n</template>\n\n<script lang=\"ts\" setup>\nimport * as monaco from \"monaco-editor\";\n// import * as monaco from \"monaco-editor/esm/vs/editor/editor.api\";\nimport { onMounted, onUnmounted, ref, watch } from \"vue\";\nimport { cloneDeep, debounce as lodashDebounce } from \"lodash-es\";\nimport {\n importJavascriptContribution,\n importJsonContribution,\n importMonacoYaml,\n importYamlContribution\n} from \"./async-import\";\nimport { initWorkers } from \"./workers\";\n/**\n * config:\n * value: '', // 编辑器初始文本\n * language: 'javascript', // 语言\n * theme: 'vs', // 主题\n * readOnly: false, // 是否只读\n * minimap: { enabled: false }, // 是否启用小地图\n * fontSize: 14, // 字体大小\n * tabSize: 2, // tab缩进长度\n * automaticLayout: true, // 自动布局\n * lineNumbers: 'off', // 是否启用行号\n * contextmenu: true, // 是否启用上下文菜单\n * folding: true, // 是否启用代码折叠\n * foldingStrategy: 'auto', // 代码折叠策略\n * wordWrap: 'on', // 自动换行设置\n * wrappingIndent: 'indent', // 换行缩进\n * formatOnPaste: true, // 粘贴时是否自动格式化\n * formatOnType: true, // 输入时是否自动格式化\n * dragAndDrop: true, // 是否允许拖放\n * cursorStyle: 'line', // 光标样式\n * cursorBlinking: 'blink', // 光标闪烁方式\n * scrollbar: {\n * vertical: 'auto', // 垂直滚动条的显示方式\n * horizontal: 'auto', // 水平滚动条的显示方式\n * verticalScrollbarSize: 2, // 垂直滚动条的宽\n * horizontalScrollbarSize: 2, // 水平滚动条的高度\n * }\n */\nconst props = defineProps<{\n language?: string;\n modelValue?: string;\n config?: any;\n schema?: any;\n debounce?: number;\n init?: any;\n readonly?: boolean;\n disabled?: boolean;\n id?: string;\n}>();\n\nexport type EditorCodeCtx = {\n // monaco对象\n monaco: any;\n //语言\n language: string;\n //配置\n config: any;\n //editor实例对象\n instance?: any;\n\n schema?: any;\n\n initialValue?: any;\n};\ninitWorkers();\nconst monacoRef = ref();\n\nlet instanceRef: any = null;\n\nfunction disposeEditor() {\n if (instanceRef) {\n instanceRef.dispose(); //使用完成销毁实例\n }\n}\n\nonUnmounted(() => {\n disposeEditor();\n});\n\nconst emits = defineEmits([\"update:modelValue\", \"change\", \"ready\"]);\n\nconst emitValue = lodashDebounce((value: any) => {\n emits(\"update:modelValue\", value);\n}, props.debounce || 500);\n\nasync function createEditor(ctx: EditorCodeCtx) {\n disposeEditor();\n const instance = monaco.editor.create(monacoRef.value, {\n automaticLayout: true,\n value: props.modelValue,\n language: ctx.language,\n theme: \"vs-dark\",\n minimap: { enabled: false },\n readOnly: props.readonly || props.disabled,\n hover: {\n enabled: true\n },\n ...ctx.config\n });\n\n // @event `change`\n instance.onDidChangeModelContent((event) => {\n const value = instance.getValue();\n if (props.modelValue !== value) {\n emits(\"change\", value);\n emitValue(value);\n }\n });\n\n instanceRef = instance;\n ctx.instance = instance;\n emits(\"ready\", ctx);\n return instance;\n}\n\nasync function initJavascript(ctx: EditorCodeCtx) {\n await importJavascriptContribution();\n monaco.languages.register({ id: \"javascript\" });\n}\n\nasync function initJson(ctx: EditorCodeCtx) {\n await importJsonContribution();\n monaco.languages.register({ id: \"json\" });\n\n const schemas = [];\n if (ctx.schema) {\n schemas.push({\n uri: \"http://myserver/foo-schema.json\", // id of the first schema\n fileMatch: [\"*\"], // associate with our model\n schema: {\n ...ctx.schema\n }\n });\n }\n\n monaco.languages.json.jsonDefaults.setDiagnosticsOptions({\n validate: true,\n enableSchemaRequest: false,\n schemas\n });\n}\n\nasync function initYaml(ctx: EditorCodeCtx) {\n await importYamlContribution();\n const { configureMonacoYaml } = await importMonacoYaml();\n monaco.languages.register({ id: \"yaml\" });\n let id = `fs-editor-code-yaml-${props.id || \"\"}.yaml`;\n const schemas = [];\n if (ctx.schema) {\n schemas.push({\n fileMatch: [\"*\"], // associate with our model\n schema: {\n ...ctx.schema\n },\n uri: `http://myserver/${id}`\n });\n }\n configureMonacoYaml(monaco, {\n schemas,\n format: true,\n hover: true,\n completion: true,\n validate: true,\n isKubernetes: false,\n enableSchemaRequest: false\n });\n\n // const uri = monaco.Uri.parse(id);\n // const oldModel = monaco.editor.getModel(uri);\n // if (oldModel) {\n // oldModel.dispose();\n // }\n // ctx.config.model = monaco.editor.createModel(props.modelValue, null, uri);\n}\n\nasync function doInit() {\n disposeEditor();\n const ctx: EditorCodeCtx = {\n monaco,\n language: props.language || \"javascript\",\n config: cloneDeep(props.config || {}),\n initialValue: props.modelValue || \"\",\n schema: props.schema\n };\n if (ctx.language === \"javascript\") {\n await initJavascript(ctx);\n } else if (ctx.language === \"yaml\") {\n await initYaml(ctx);\n } else if (ctx.language === \"json\") {\n await initJson(ctx);\n }\n\n await createEditor(ctx);\n}\n\nonMounted(async () => {\n await doInit();\n watch(\n () => {\n return {\n language: props.language,\n config: props.config\n };\n },\n (value: any) => {\n doInit();\n }\n );\n});\n\nwatch(\n () => {\n return props.modelValue;\n },\n (value: any) => {\n if (instanceRef && instanceRef.getValue() !== value) {\n instanceRef.setValue(value);\n }\n }\n);\n</script>\n\n<style lang=\"less\">\n.fs-editor-code {\n min-height: 100px;\n width: 100%;\n border: 1px solid #eee;\n border-radius: 5px;\n}\n\n.monaco-editor .hover-content {\n z-index: 10000 !important;\n}\n</style>\n"],"names":["props","__props","initWorkers","monacoRef","ref","instanceRef","disposeEditor","onUnmounted","emits","__emit","emitValue","lodashDebounce","value","createEditor","ctx","instance","monaco","event","initJavascript","importJavascriptContribution","initJson","importJsonContribution","schemas","initYaml","importYamlContribution","configureMonacoYaml","importMonacoYaml","id","doInit","cloneDeep","onMounted","watch","_createElementBlock"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4CA,UAAMA,IAAQC;AA0BF,IAAAC;AACZ,UAAMC,IAAYC;AAElB,QAAIC,IAAmB;AAEvB,aAASC,IAAgB;AACvB,MAAID,KACFA,EAAY,QAAQ;AAAA,IAExB;AAEA,IAAAE,EAAY,MAAM;AACF,MAAAD;IAAA,CACf;AAED,UAAME,IAAQC,GAERC,IAAYC,EAAe,CAACC,MAAe;AAC/C,MAAAJ,EAAM,qBAAqBI,CAAK;AAAA,IAAA,GAC/BZ,EAAM,YAAY,GAAG;AAExB,mBAAea,EAAaC,GAAoB;AAChC,MAAAR;AACd,YAAMS,IAAWC,EAAO,OAAO,OAAOb,EAAU,OAAO;AAAA,QACrD,iBAAiB;AAAA,QACjB,OAAOH,EAAM;AAAA,QACb,UAAUc,EAAI;AAAA,QACd,OAAO;AAAA,QACP,SAAS,EAAE,SAAS,GAAM;AAAA,QAC1B,UAAUd,EAAM,YAAYA,EAAM;AAAA,QAClC,OAAO;AAAA,UACL,SAAS;AAAA,QACX;AAAA,QACA,GAAGc,EAAI;AAAA,MAAA,CACR;AAGQ,aAAAC,EAAA,wBAAwB,CAACE,MAAU;AACpC,cAAAL,IAAQG,EAAS;AACnB,QAAAf,EAAM,eAAeY,MACvBJ,EAAM,UAAUI,CAAK,GACrBF,EAAUE,CAAK;AAAA,MACjB,CACD,GAEaP,IAAAU,GACdD,EAAI,WAAWC,GACfP,EAAM,SAASM,CAAG,GACXC;AAAA,IACT;AAEA,mBAAeG,EAAeJ,GAAoB;AAChD,YAAMK,EAA6B,GACnCH,EAAO,UAAU,SAAS,EAAE,IAAI,aAAc,CAAA;AAAA,IAChD;AAEA,mBAAeI,EAASN,GAAoB;AAC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nB,MAAMI,EAAkB,IACfJ,EAAI,aAAa,SAC1B,MAAMS,EAAST,CAAG,IACTA,EAAI,aAAa,UAC1B,MAAMM,EAASN,CAAG,GAGpB,MAAMD,EAAaC,CAAG;AAAA,IACxB;AAEA,WAAAgB,EAAU,YAAY;AACpB,YAAMF,EAAO,GACbG;AAAA,QACE,OACS;AAAA,UACL,UAAU/B,EAAM;AAAA,UAChB,QAAQA,EAAM;AAAA,QAAA;AAAA,QAGlB,CAACY,MAAe;AACP,UAAAgB;QACT;AAAA,MAAA;AAAA,IACF,CACD,GAEDG;AAAA,MACE,MACS/B,EAAM;AAAA,MAEf,CAACY,MAAe;AACd,QAAIP,KAAeA,EAAY,SAAS,MAAMO,KAC5CP,EAAY,SAASO,CAAK;AAAA,MAE9B;AAAA,IAAA,mBA/NAoB,EAAkD,OAAA;AAAA,eAAzC;AAAA,MAAJ,KAAI7B;AAAA,MAAY,OAAM;AAAA,IAAA;;;"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useTypes as e, utils as i } from "@fast-crud/fast-crud";
|
|
2
|
+
function a() {
|
|
3
|
+
return {
|
|
4
|
+
"editor-code": {
|
|
5
|
+
form: { component: { name: "fs-editor-code" }, col: { span: 24 } }
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const c = {
|
|
10
|
+
install(t, n) {
|
|
11
|
+
const o = a(), { addTypes: r } = e();
|
|
12
|
+
r(o);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
async function m() {
|
|
16
|
+
return await import("js-yaml");
|
|
17
|
+
}
|
|
18
|
+
async function y() {
|
|
19
|
+
await import("monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution");
|
|
20
|
+
}
|
|
21
|
+
async function w() {
|
|
22
|
+
await import("monaco-editor/esm/vs/language/json/monaco.contribution");
|
|
23
|
+
}
|
|
24
|
+
async function g() {
|
|
25
|
+
await import("monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution");
|
|
26
|
+
}
|
|
27
|
+
async function E() {
|
|
28
|
+
return await import("monaco-yaml");
|
|
29
|
+
}
|
|
30
|
+
const u = {
|
|
31
|
+
validator: async (t, n) => {
|
|
32
|
+
if (n)
|
|
33
|
+
try {
|
|
34
|
+
JSON.parse(n);
|
|
35
|
+
} catch (o) {
|
|
36
|
+
throw console.error(o), new Error("json格式错误:" + o.message);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
message: "json格式错误"
|
|
40
|
+
}, l = {
|
|
41
|
+
validator: async (t, n) => {
|
|
42
|
+
if (n)
|
|
43
|
+
try {
|
|
44
|
+
const o = await m();
|
|
45
|
+
o.load(n, { schema: o.JSON_SCHEMA });
|
|
46
|
+
} catch (o) {
|
|
47
|
+
throw console.error(o), new Error("yaml格式错误:" + o.message);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
message: "yaml格式错误"
|
|
51
|
+
}, h = {
|
|
52
|
+
jsonRule: u,
|
|
53
|
+
yamlRule: l
|
|
54
|
+
}, s = [];
|
|
55
|
+
function C(t, n) {
|
|
56
|
+
s.push({
|
|
57
|
+
worker: n,
|
|
58
|
+
match: (o) => {
|
|
59
|
+
if (typeof t == "string")
|
|
60
|
+
return t === o;
|
|
61
|
+
for (const r of t)
|
|
62
|
+
if (r === "*" || r === o)
|
|
63
|
+
return !0;
|
|
64
|
+
return !1;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function k() {
|
|
69
|
+
window.MonacoEnvironment || (window.MonacoEnvironment = {
|
|
70
|
+
//@ts-ignore
|
|
71
|
+
getWorker(t, n) {
|
|
72
|
+
for (const o of s)
|
|
73
|
+
if (o.match(n))
|
|
74
|
+
return new o.worker();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const p = /* @__PURE__ */ Object.assign({ "./components/fs-editor-code/index.vue": () => import("./index-4cfdb04c.mjs") }), f = {
|
|
79
|
+
install(t) {
|
|
80
|
+
i.vite.installAsyncComponents(t, p, null, /^.*\/([^\/]+)\/.*.vue$/, null);
|
|
81
|
+
}
|
|
82
|
+
}, v = {
|
|
83
|
+
install(t, n) {
|
|
84
|
+
t.use(c, n), t.use(f);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
v as F,
|
|
89
|
+
g as a,
|
|
90
|
+
w as b,
|
|
91
|
+
y as c,
|
|
92
|
+
E as d,
|
|
93
|
+
h as e,
|
|
94
|
+
k as i,
|
|
95
|
+
C as r
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=index-c2ddaf47.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-c2ddaf47.mjs","sources":["../../src/editor/type/types.ts","../../src/editor/type/index.ts","../../src/editor/components/fs-editor-code/async-import.ts","../../src/editor/components/fs-editor-code/validators.ts","../../src/editor/components/fs-editor-code/workers.ts","../../src/editor/index.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["types","EcologyType","app","options","newTypes","addTypes","useTypes","importJsYaml","importYamlContribution","importJsonContribution","importJavascriptContribution","importMonacoYaml","jsonRule","rule","value","e","yamlRule","yaml","FsEditorCodeValidators","WorkerBucket","registerWorker","labels","worker","label","labelItem","initWorkers","_","workerLoader","asyncModules","FsExtendsComponents","utils","FsEditorCode"],"mappings":";AAAc,SAAAA,IAAA;AACL,SAAA;AAAA,IACL,eAAe;AAAA,MACb,MAAM,EAAE,WAAW,EAAE,MAAM,iBAAkB,GAAE,KAAK,EAAE,MAAM,KAAM;AAAA,IACnE;AAAA,EAAA;AAEL;ACHA,MAAeC,IAAA;AAAA,EACb,QAAQC,GAAUC,GAAY;AAC5B,UAAMC,IAAWJ,KACX,EAAE,UAAAK,MAAaC;AACrB,IAAAD,EAASD,CAAQ;AAAA,EACnB;;ACRF,eAAsBG,IAAY;AACzB,SAAA,MAAM,OAAO,SAAS;AAC/B;AAEA,eAAsBC,IAAsB;AAC1C,QAAM,OAAO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AA;AAEJ;ACxCA,MAAMC,sHACAC,IAAsB;AAAA,EAC1B,QAAQ3B,GAAQ;AACd,IAAA4B,EAAM,KAAK,uBAAuB5B,GAAK0B,GAAc,MAAM,0BAA0B,IAAI;AAAA,EAC3F;GAGWG,IAAe;AAAA,EAC1B,QAAQ7B,GAAUC,GAAY;AACxB,IAAAD,EAAA,IAAID,GAAaE,CAAO,GAC5BD,EAAI,IAAI2B,CAAmB;AAAA,EAC7B;;"}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.fs-editor-code{min-height:100px;width:100%;border:1px solid #eee;border-radius:5px}.monaco-editor .hover-content{z-index:10000!important}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src/index";
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require("./src");
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fast-crud/editor-code",
|
|
3
|
+
"version": "1.25.13",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"module": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"main": "./dist/fast-editor-code.umd.js",
|
|
10
|
+
"module": "./dist/fast-editor-code.mjs",
|
|
11
|
+
"types": "./dist/d/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build:all": "npm run build:type && npm run build && npm run copy:index",
|
|
15
|
+
"build": " npm run tsc && npm run build:umd && npm run build:es",
|
|
16
|
+
"build:es": "vite build",
|
|
17
|
+
"build:type": "vite build --mode type && npm run copy:type",
|
|
18
|
+
"build:umd": "vite build --mode umd",
|
|
19
|
+
"copy:type": "copyfiles -f ./dist/extends-uploader.es.js ./dist/index.type.js",
|
|
20
|
+
"copy:index": "copyfiles -f ./src/index.vite.es.js ./dist/",
|
|
21
|
+
"lint-fix": "eslint --fix --ext .js --ext .jsx --ext .vue src/",
|
|
22
|
+
"tsc": "vue-tsc --noEmit --skipLibCheck",
|
|
23
|
+
"afterPubPush": ""
|
|
24
|
+
},
|
|
25
|
+
"author": "Greper",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"js-yaml": "^4.1.0",
|
|
29
|
+
"lodash-es": "^4.17.21",
|
|
30
|
+
"monaco-editor": "^0.52.2",
|
|
31
|
+
"monaco-yaml": "^5.3.1"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@fast-crud/fast-crud": "^1.25.13",
|
|
35
|
+
"@ls-lint/ls-lint": "^2.0.1",
|
|
36
|
+
"@rollup/plugin-commonjs": "^25.0.3",
|
|
37
|
+
"@rollup/plugin-strip": "^3.0.2",
|
|
38
|
+
"@rollup/plugin-typescript": "^11.1.2",
|
|
39
|
+
"@types/chai": "^4.3.5",
|
|
40
|
+
"@types/file-saver": "^2.0.5",
|
|
41
|
+
"@types/humanize-duration": "^3.27.1",
|
|
42
|
+
"@types/lodash-es": "^4.17.8",
|
|
43
|
+
"@types/mocha": "^10.0.1",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.2.1",
|
|
45
|
+
"@typescript-eslint/parser": "^6.2.1",
|
|
46
|
+
"@vitejs/plugin-legacy": "^4.1.1",
|
|
47
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
|
48
|
+
"@vitejs/plugin-vue-jsx": "^3.0.1",
|
|
49
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
50
|
+
"autoprefixer": "^10.4.14",
|
|
51
|
+
"chai": "^4.3.7",
|
|
52
|
+
"copyfiles": "^2.4.1",
|
|
53
|
+
"eslint": "^8.46.0",
|
|
54
|
+
"eslint-config-prettier": "^8.10.0",
|
|
55
|
+
"eslint-plugin-import": "^2.28.0",
|
|
56
|
+
"eslint-plugin-node": "^11.1.0",
|
|
57
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
58
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
59
|
+
"eslint-plugin-vue": "^9.16.1",
|
|
60
|
+
"esno": "^0.17.0",
|
|
61
|
+
"less": "^4.1.3",
|
|
62
|
+
"less-loader": "^11.1.3",
|
|
63
|
+
"libphonenumber-js": "^1.10.49",
|
|
64
|
+
"lint-staged": "^13.2.3",
|
|
65
|
+
"postcss": "^8.4.27",
|
|
66
|
+
"prettier": "^3.0.1",
|
|
67
|
+
"pretty-quick": "^3.1.3",
|
|
68
|
+
"rimraf": "^5.0.1",
|
|
69
|
+
"rollup-plugin-visualizer": "^5.9.2",
|
|
70
|
+
"stylelint": "^15.10.2",
|
|
71
|
+
"stylelint-config-prettier": "^9.0.5",
|
|
72
|
+
"stylelint-order": "^6.0.3",
|
|
73
|
+
"terser": "^5.19.2",
|
|
74
|
+
"ts-node": "^10.9.1",
|
|
75
|
+
"typescript": "5.1.6",
|
|
76
|
+
"unplugin-vue-define-options": "^1.3.14",
|
|
77
|
+
"vite": "^4.4.8",
|
|
78
|
+
"vite-plugin-compression": "^0.5.1",
|
|
79
|
+
"vue": "^3.3.4",
|
|
80
|
+
"vue-eslint-parser": "^9.3.1",
|
|
81
|
+
"vue-tsc": "^1.8.8"
|
|
82
|
+
},
|
|
83
|
+
"gitHead": "206b7891c092dfe9e9ca8272e484b0198abf57fc"
|
|
84
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export async function importJsYaml() {
|
|
2
|
+
return await import("js-yaml");
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export async function importYamlContribution() {
|
|
6
|
+
await import("monaco-editor/esm/vs/basic-languages/yaml/yaml.contribution");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export async function importJsonContribution() {
|
|
10
|
+
await import("monaco-editor/esm/vs/language/json/monaco.contribution");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export async function importJavascriptContribution() {
|
|
14
|
+
await import("monaco-editor/esm/vs/basic-languages/javascript/javascript.contribution");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function importMonacoYaml() {
|
|
18
|
+
return await import("monaco-yaml");
|
|
19
|
+
}
|