@kong-ui-public/monaco-editor 0.3.1-pr.2622.ca1f578c8.0 → 0.4.0
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/dist/runtime/monaco-editor.es.js +307 -0
- package/dist/runtime/monaco-editor.umd.js +1 -0
- package/dist/runtime/style.css +1 -0
- package/dist/types/src/components/MonacoEditor.vue.d.ts +52 -0
- package/dist/types/src/components/MonacoEditor.vue.d.ts.map +1 -0
- package/dist/types/src/components/MonacoEditorStatusOverlay.vue.d.ts +19 -0
- package/dist/types/src/components/MonacoEditorStatusOverlay.vue.d.ts.map +1 -0
- package/dist/types/src/composables/useI18n.d.ts +9 -0
- package/dist/types/src/composables/useI18n.d.ts.map +1 -0
- package/dist/types/src/composables/useMonacoEditor.d.ts +25 -0
- package/dist/types/src/composables/useMonacoEditor.d.ts.map +1 -0
- package/dist/types/src/constants/index.d.ts +3 -0
- package/dist/types/src/constants/index.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/tests/setup.d.ts +2 -0
- package/dist/types/src/tests/setup.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +69 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/vite-plugin/index.d.ts +56 -0
- package/dist/types/vite-plugin/index.d.ts.map +1 -0
- package/dist/types/vite-plugin/index.spec.d.ts +2 -0
- package/dist/types/vite-plugin/index.spec.d.ts.map +1 -0
- package/dist/vite-plugin/index.cjs +127 -0
- package/dist/vite-plugin/index.js +128 -0
- package/package.json +12 -6
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { toValue as C, reactive as U, onMounted as D, onActivated as P, onBeforeUnmount as V, watch as K, defineComponent as N, resolveComponent as A, createBlock as S, openBlock as y, createSlots as $, withCtx as b, resolveDynamicComponent as z, mergeModels as H, useModel as G, useTemplateRef as j, computed as M, createElementBlock as q, normalizeClass as J, unref as c, createElementVNode as Q, renderSlot as I, createVNode as T, Transition as k, createCommentVNode as w } from "vue";
|
|
2
|
+
import { ProgressIcon as Y, CodeblockIcon as Z } from "@kong/icons";
|
|
3
|
+
import * as _ from "monaco-editor";
|
|
4
|
+
import { createI18n as X, i18nTComponent as ee } from "@kong-ui-public/i18n";
|
|
5
|
+
const te = "'JetBrains Mono', Consolas, monospace", oe = "12px", ne = "500", ae = "20px", re = Object.freeze({
|
|
6
|
+
autoClosingQuotes: "always",
|
|
7
|
+
automaticLayout: !0,
|
|
8
|
+
// Auto resize layout
|
|
9
|
+
bracketPairColorization: {
|
|
10
|
+
enabled: !0
|
|
11
|
+
},
|
|
12
|
+
hideCursorInOverviewRuler: !0,
|
|
13
|
+
// hide the cursor position in the minimap TODO: maybe hide it on first line or change it colour
|
|
14
|
+
fontFamily: te,
|
|
15
|
+
fontSize: Number(oe.replace("px", "")),
|
|
16
|
+
fontWeight: ne,
|
|
17
|
+
lineHeight: Number(ae.replace("px", "")),
|
|
18
|
+
formatOnPaste: !0,
|
|
19
|
+
formatOnType: !0,
|
|
20
|
+
// Add to enable automatic formatting as the user types.
|
|
21
|
+
lineNumbersMinChars: 3,
|
|
22
|
+
minimap: {
|
|
23
|
+
enabled: !1
|
|
24
|
+
},
|
|
25
|
+
stickyScroll: {
|
|
26
|
+
enabled: !0
|
|
27
|
+
},
|
|
28
|
+
suggest: {
|
|
29
|
+
showWords: !1
|
|
30
|
+
// Prevent showing word suggestions that exist in the document
|
|
31
|
+
},
|
|
32
|
+
quickSuggestions: !0,
|
|
33
|
+
// Enable quick suggestions
|
|
34
|
+
suggestOnTriggerCharacters: !0,
|
|
35
|
+
// Allow suggestions on trigger characters
|
|
36
|
+
wordBasedSuggestions: "off",
|
|
37
|
+
overviewRulerLanes: 0,
|
|
38
|
+
renderWhitespace: "boundary",
|
|
39
|
+
scrollBeyondLastLine: !1,
|
|
40
|
+
roundedSelection: !1,
|
|
41
|
+
wordWrapColumn: 120,
|
|
42
|
+
colorDecorators: !0,
|
|
43
|
+
folding: !0,
|
|
44
|
+
// Enable code folding for MDC block components
|
|
45
|
+
fixedOverflowWidgets: !0,
|
|
46
|
+
// Ensure suggestion widgets can overflow container
|
|
47
|
+
tabSize: 2,
|
|
48
|
+
detectIndentation: !1,
|
|
49
|
+
// Important as to not override tabSize
|
|
50
|
+
insertSpaces: !0,
|
|
51
|
+
// Since the formatter utilizes spaces, we set to true to insert spaces when pressing Tab
|
|
52
|
+
trimAutoWhitespace: !0,
|
|
53
|
+
wordWrap: "bounded",
|
|
54
|
+
find: {
|
|
55
|
+
addExtraSpaceOnTop: !1
|
|
56
|
+
// we need this set to false to get the correct absolute position, otherwise when the search box opens the content shifts
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
60
|
+
const F = () => {
|
|
61
|
+
};
|
|
62
|
+
function ie(o, t) {
|
|
63
|
+
function e(...n) {
|
|
64
|
+
return new Promise((r, i) => {
|
|
65
|
+
Promise.resolve(o(() => t.apply(this, n), {
|
|
66
|
+
fn: t,
|
|
67
|
+
thisArg: this,
|
|
68
|
+
args: n
|
|
69
|
+
})).then(r).catch(i);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return e;
|
|
73
|
+
}
|
|
74
|
+
function se(o, t = {}) {
|
|
75
|
+
let e, n, r = F;
|
|
76
|
+
const i = (l) => {
|
|
77
|
+
clearTimeout(l), r(), r = F;
|
|
78
|
+
};
|
|
79
|
+
let s;
|
|
80
|
+
return (l) => {
|
|
81
|
+
const p = C(o), d = C(t.maxWait);
|
|
82
|
+
return e && i(e), p <= 0 || d !== void 0 && d <= 0 ? (n && (i(n), n = void 0), Promise.resolve(l())) : new Promise((v, a) => {
|
|
83
|
+
r = t.rejectOnCancel ? a : v, s = l, d && !n && (n = setTimeout(() => {
|
|
84
|
+
e && i(e), n = void 0, v(s());
|
|
85
|
+
}, d)), e = setTimeout(() => {
|
|
86
|
+
n && i(n), n = void 0, v(l());
|
|
87
|
+
}, p);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// @__NO_SIDE_EFFECTS__
|
|
92
|
+
function le(o, t = 200, e = {}) {
|
|
93
|
+
return ie(se(t, e), o);
|
|
94
|
+
}
|
|
95
|
+
function de(o) {
|
|
96
|
+
var t;
|
|
97
|
+
const e = C(o);
|
|
98
|
+
return (t = e == null ? void 0 : e.$el) !== null && t !== void 0 ? t : e;
|
|
99
|
+
}
|
|
100
|
+
let g;
|
|
101
|
+
const x = /* @__PURE__ */ new Map();
|
|
102
|
+
function ce(o) {
|
|
103
|
+
return g || (g = _), o && !x.get(o) && (x.set(o, !0), _.languages.getLanguages().some((t) => t.id === o) || _.languages.register({ id: o })), g;
|
|
104
|
+
}
|
|
105
|
+
function ue(o, t) {
|
|
106
|
+
let e, n = !1;
|
|
107
|
+
const r = U({
|
|
108
|
+
editorStatus: "loading",
|
|
109
|
+
searchBoxIsRevealed: !1,
|
|
110
|
+
hasContent: !1,
|
|
111
|
+
theme: t.theme || "light"
|
|
112
|
+
}), i = (a) => {
|
|
113
|
+
!n || !e || e.setValue(a);
|
|
114
|
+
}, s = (a) => e == null ? void 0 : e.updateOptions({ readOnly: a }), u = () => e == null ? void 0 : e.focus(), l = (a) => {
|
|
115
|
+
try {
|
|
116
|
+
if (!e || !a) return;
|
|
117
|
+
e.focus(), e.trigger("keyboard", a, null);
|
|
118
|
+
} catch (f) {
|
|
119
|
+
console.error(`useMonacoEditor: Failed to trigger command: ${a}`, f);
|
|
120
|
+
}
|
|
121
|
+
}, p = () => {
|
|
122
|
+
var a;
|
|
123
|
+
try {
|
|
124
|
+
if (!e) return;
|
|
125
|
+
if (r.searchBoxIsRevealed)
|
|
126
|
+
return (a = e.getContribution("editor.contrib.findController")) == null ? void 0 : a.closeFindWidget();
|
|
127
|
+
l("actions.find");
|
|
128
|
+
} catch (f) {
|
|
129
|
+
console.error("useMonacoEditor: Failed to close findController.", f);
|
|
130
|
+
}
|
|
131
|
+
}, d = /* @__PURE__ */ le(() => g == null ? void 0 : g.editor.remeasureFonts(), 200);
|
|
132
|
+
return (() => {
|
|
133
|
+
const a = ce(t.language), f = a.Uri.parse(`inmemory://model/${t.language}-${crypto.randomUUID()}`), B = a.editor.createModel(t.code.value, t.language, f);
|
|
134
|
+
K(() => C(o), (L) => {
|
|
135
|
+
var O;
|
|
136
|
+
const E = de(L);
|
|
137
|
+
if (!(E instanceof HTMLElement)) {
|
|
138
|
+
n = !1;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (!n) {
|
|
142
|
+
e = a.editor.create(E, {
|
|
143
|
+
...re,
|
|
144
|
+
readOnly: t.readOnly || !1,
|
|
145
|
+
language: t.language,
|
|
146
|
+
theme: r.theme,
|
|
147
|
+
model: B,
|
|
148
|
+
...t.monacoOptions
|
|
149
|
+
}), n = !0, r.editorStatus = "ready", r.hasContent = !!t.code.value, e.onDidChangeModelContent(() => {
|
|
150
|
+
var h;
|
|
151
|
+
const m = e.getValue();
|
|
152
|
+
r.hasContent = !!m.length, (h = t.onChanged) == null || h.call(t, m);
|
|
153
|
+
}), (O = t.onCreated) == null || O.call(t), d();
|
|
154
|
+
try {
|
|
155
|
+
const m = e.getContribution("editor.contrib.findController");
|
|
156
|
+
if (m) {
|
|
157
|
+
const h = m.getState();
|
|
158
|
+
h.onFindReplaceStateChange(() => {
|
|
159
|
+
r.searchBoxIsRevealed = h.isRevealed;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
} catch (m) {
|
|
163
|
+
console.error("useMonacoEditor: Failed to get the state of findController", m);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
immediate: !0,
|
|
168
|
+
flush: "post"
|
|
169
|
+
});
|
|
170
|
+
})(), D(d), P(d), V(() => {
|
|
171
|
+
if (!e) return;
|
|
172
|
+
const a = e.getModel();
|
|
173
|
+
e.dispose(), a && a.dispose();
|
|
174
|
+
}), {
|
|
175
|
+
editor: e,
|
|
176
|
+
editorStates: r,
|
|
177
|
+
setContent: i,
|
|
178
|
+
setReadOnly: s,
|
|
179
|
+
focus: u,
|
|
180
|
+
remeasureFonts: d,
|
|
181
|
+
toggleSearchWidget: p,
|
|
182
|
+
triggerKeyboardCommand: l
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
const me = {
|
|
186
|
+
messages: {
|
|
187
|
+
empty_message: "The editor is currently empty. Start typing to add content.",
|
|
188
|
+
empty_title: "No content available",
|
|
189
|
+
loading_message: "Please wait while the {type} content is loaded.",
|
|
190
|
+
loading_title: "{type} editor"
|
|
191
|
+
}
|
|
192
|
+
}, ge = {
|
|
193
|
+
editor: me
|
|
194
|
+
};
|
|
195
|
+
function fe() {
|
|
196
|
+
const o = X("en-us", ge);
|
|
197
|
+
return {
|
|
198
|
+
i18n: o,
|
|
199
|
+
i18nT: ee(o)
|
|
200
|
+
// Translation component <i18n-t>
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const he = /* @__PURE__ */ N({
|
|
204
|
+
__name: "MonacoEditorStatusOverlay",
|
|
205
|
+
props: {
|
|
206
|
+
title: {},
|
|
207
|
+
message: {},
|
|
208
|
+
icon: {}
|
|
209
|
+
},
|
|
210
|
+
setup(o) {
|
|
211
|
+
return (t, e) => {
|
|
212
|
+
const n = A("KEmptyState");
|
|
213
|
+
return y(), S(n, {
|
|
214
|
+
class: "monaco-editor-status-overlay",
|
|
215
|
+
message: o.message,
|
|
216
|
+
title: o.title
|
|
217
|
+
}, $({ _: 2 }, [
|
|
218
|
+
o.icon ? {
|
|
219
|
+
name: "icon",
|
|
220
|
+
fn: b(() => [
|
|
221
|
+
(y(), S(z(o.icon), { decorative: "" }))
|
|
222
|
+
]),
|
|
223
|
+
key: "0"
|
|
224
|
+
} : void 0
|
|
225
|
+
]), 1032, ["message", "title"]);
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
}), R = (o, t) => {
|
|
229
|
+
const e = o.__vccOpts || o;
|
|
230
|
+
for (const [n, r] of t)
|
|
231
|
+
e[n] = r;
|
|
232
|
+
return e;
|
|
233
|
+
}, W = /* @__PURE__ */ R(he, [["__scopeId", "data-v-062eadb5"]]), ye = /* @__PURE__ */ N({
|
|
234
|
+
__name: "MonacoEditor",
|
|
235
|
+
props: /* @__PURE__ */ H({
|
|
236
|
+
theme: { default: "light" },
|
|
237
|
+
language: { default: "markdown" },
|
|
238
|
+
options: { default: () => {
|
|
239
|
+
} }
|
|
240
|
+
}, {
|
|
241
|
+
modelValue: {
|
|
242
|
+
type: String,
|
|
243
|
+
required: !0
|
|
244
|
+
},
|
|
245
|
+
modelModifiers: {}
|
|
246
|
+
}),
|
|
247
|
+
emits: ["update:modelValue"],
|
|
248
|
+
setup(o) {
|
|
249
|
+
const t = G(o, "modelValue"), { i18n: e } = fe(), n = j("editorRef"), r = M(() => o.theme === "dark" ? "dark" : "light"), i = M(() => s.editorStates.editorStatus === "ready" && !s.editorStates.hasContent), s = ue(n, {
|
|
250
|
+
language: o.language,
|
|
251
|
+
code: t,
|
|
252
|
+
theme: r.value,
|
|
253
|
+
monacoOptions: o.options,
|
|
254
|
+
onChanged: (u) => {
|
|
255
|
+
t.value = u;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return (u, l) => (y(), q("div", {
|
|
259
|
+
class: J(["monaco-editor-container", [
|
|
260
|
+
r.value,
|
|
261
|
+
{ loading: c(s).editorStates.editorStatus === "loading" }
|
|
262
|
+
]]),
|
|
263
|
+
"data-testid": "monaco-editor-container"
|
|
264
|
+
}, [
|
|
265
|
+
Q("div", {
|
|
266
|
+
ref_key: "editorRef",
|
|
267
|
+
ref: n,
|
|
268
|
+
class: "monaco-editor-target",
|
|
269
|
+
"data-testid": "monaco-editor-target"
|
|
270
|
+
}, null, 512),
|
|
271
|
+
I(u.$slots, "state-loading", {
|
|
272
|
+
isLoading: c(s).editorStates.editorStatus === "loading"
|
|
273
|
+
}, () => [
|
|
274
|
+
T(k, { name: "fade" }, {
|
|
275
|
+
default: b(() => [
|
|
276
|
+
c(s).editorStates.editorStatus === "loading" ? (y(), S(W, {
|
|
277
|
+
key: 0,
|
|
278
|
+
"data-testid": "monaco-editor-status-overlay-loading",
|
|
279
|
+
icon: c(Y),
|
|
280
|
+
message: c(e).t("editor.messages.loading_message", { type: o.language }),
|
|
281
|
+
title: c(e).t("editor.messages.loading_title", { type: o.language })
|
|
282
|
+
}, null, 8, ["icon", "message", "title"])) : w("", !0)
|
|
283
|
+
]),
|
|
284
|
+
_: 1
|
|
285
|
+
})
|
|
286
|
+
], !0),
|
|
287
|
+
I(u.$slots, "state-empty", { isEmpty: i.value }, () => [
|
|
288
|
+
T(k, { name: "fade" }, {
|
|
289
|
+
default: b(() => [
|
|
290
|
+
i.value ? (y(), S(W, {
|
|
291
|
+
key: 0,
|
|
292
|
+
"data-testid": "monaco-editor-status-overlay-empty",
|
|
293
|
+
icon: c(Z),
|
|
294
|
+
message: c(e).t("editor.messages.empty_message"),
|
|
295
|
+
title: c(e).t("editor.messages.empty_title")
|
|
296
|
+
}, null, 8, ["icon", "message", "title"])) : w("", !0)
|
|
297
|
+
]),
|
|
298
|
+
_: 1
|
|
299
|
+
})
|
|
300
|
+
], !0)
|
|
301
|
+
], 2));
|
|
302
|
+
}
|
|
303
|
+
}), Se = /* @__PURE__ */ R(ye, [["__scopeId", "data-v-8e67eb98"]]);
|
|
304
|
+
export {
|
|
305
|
+
Se as MonacoEditor,
|
|
306
|
+
ue as useMonacoEditor
|
|
307
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(s,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("monaco-editor"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","monaco-editor","@kong-ui-public/i18n"],e):(s=typeof globalThis<"u"?globalThis:s||self,e(s["kong-ui-public-monaco-editor"]={},s.Vue,s.KongIcons,s.monaco,s["kong-ui-public-i18n"]))})(this,function(s,e,S,F,b){"use strict";function N(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const C=N(F),x=Object.freeze({autoClosingQuotes:"always",automaticLayout:!0,bracketPairColorization:{enabled:!0},hideCursorInOverviewRuler:!0,fontFamily:"'JetBrains Mono', Consolas, monospace",fontSize:Number("12px".replace("px","")),fontWeight:"500",lineHeight:Number("20px".replace("px","")),formatOnPaste:!0,formatOnType:!0,lineNumbersMinChars:3,minimap:{enabled:!1},stickyScroll:{enabled:!0},suggest:{showWords:!1},quickSuggestions:!0,suggestOnTriggerCharacters:!0,wordBasedSuggestions:"off",overviewRulerLanes:0,renderWhitespace:"boundary",scrollBeyondLastLine:!1,roundedSelection:!1,wordWrapColumn:120,colorDecorators:!0,folding:!0,fixedOverflowWidgets:!0,tabSize:2,detectIndentation:!1,insertSpaces:!0,trimAutoWhitespace:!0,wordWrap:"bounded",find:{addExtraSpaceOnTop:!1}});typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const O=()=>{};function B(o,n){function t(...r){return new Promise((i,c)=>{Promise.resolve(o(()=>n.apply(this,r),{fn:n,thisArg:this,args:r})).then(i).catch(c)})}return t}function U(o,n={}){let t,r,i=O;const c=d=>{clearTimeout(d),i(),i=O};let l;return d=>{const y=e.toValue(o),u=e.toValue(n.maxWait);return t&&c(t),y<=0||u!==void 0&&u<=0?(r&&(c(r),r=void 0),Promise.resolve(d())):new Promise((_,a)=>{i=n.rejectOnCancel?a:_,l=d,u&&!r&&(r=setTimeout(()=>{t&&c(t),r=void 0,_(l())},u)),t=setTimeout(()=>{r&&c(r),r=void 0,_(d())},y)})}}function V(o,n=200,t={}){return B(U(n,t),o)}function W(o){var n;const t=e.toValue(o);return(n=t==null?void 0:t.$el)!==null&&n!==void 0?n:t}let g;const E=new Map;function D(o){return g||(g=C),o&&!E.get(o)&&(E.set(o,!0),C.languages.getLanguages().some(n=>n.id===o)||C.languages.register({id:o})),g}function I(o,n){let t,r=!1;const i=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:n.theme||"light"}),c=a=>{!r||!t||t.setValue(a)},l=a=>t==null?void 0:t.updateOptions({readOnly:a}),m=()=>t==null?void 0:t.focus(),d=a=>{try{if(!t||!a)return;t.focus(),t.trigger("keyboard",a,null)}catch(p){console.error(`useMonacoEditor: Failed to trigger command: ${a}`,p)}},y=()=>{var a;try{if(!t)return;if(i.searchBoxIsRevealed)return(a=t.getContribution("editor.contrib.findController"))==null?void 0:a.closeFindWidget();d("actions.find")}catch(p){console.error("useMonacoEditor: Failed to close findController.",p)}},u=V(()=>g==null?void 0:g.editor.remeasureFonts(),200);return(()=>{const a=D(n.language),p=a.Uri.parse(`inmemory://model/${n.language}-${crypto.randomUUID()}`),j=a.editor.createModel(n.code.value,n.language,p);e.watch(()=>e.toValue(o),H=>{var w;const M=W(H);if(!(M instanceof HTMLElement)){r=!1;return}if(!r){t=a.editor.create(M,{...x,readOnly:n.readOnly||!1,language:n.language,theme:i.theme,model:j,...n.monacoOptions}),r=!0,i.editorStatus="ready",i.hasContent=!!n.code.value,t.onDidChangeModelContent(()=>{var h;const f=t.getValue();i.hasContent=!!f.length,(h=n.onChanged)==null||h.call(n,f)}),(w=n.onCreated)==null||w.call(n),u();try{const f=t.getContribution("editor.contrib.findController");if(f){const h=f.getState();h.onFindReplaceStateChange(()=>{i.searchBoxIsRevealed=h.isRevealed})}}catch(f){console.error("useMonacoEditor: Failed to get the state of findController",f)}}},{immediate:!0,flush:"post"})})(),e.onMounted(u),e.onActivated(u),e.onBeforeUnmount(()=>{if(!t)return;const a=t.getModel();t.dispose(),a&&a.dispose()}),{editor:t,editorStates:i,setContent:c,setReadOnly:l,focus:m,remeasureFonts:u,toggleSearchWidget:y,triggerKeyboardCommand:d}}const R={editor:{messages:{empty_message:"The editor is currently empty. Start typing to add content.",empty_title:"No content available",loading_message:"Please wait while the {type} content is loaded.",loading_title:"{type} editor"}}};function K(){const o=b.createI18n("en-us",R);return{i18n:o,i18nT:b.i18nTComponent(o)}}const L=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(o){return(n,t)=>{const r=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(r,{class:"monaco-editor-status-overlay",message:o.message,title:o.title},e.createSlots({_:2},[o.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),T=(o,n)=>{const t=o.__vccOpts||o;for(const[r,i]of n)t[r]=i;return t},k=T(L,[["__scopeId","data-v-062eadb5"]]),P=T(e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({theme:{default:"light"},language:{default:"markdown"},options:{default:()=>{}}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const n=e.useModel(o,"modelValue"),{i18n:t}=K(),r=e.useTemplateRef("editorRef"),i=e.computed(()=>o.theme==="dark"?"dark":"light"),c=e.computed(()=>l.editorStates.editorStatus==="ready"&&!l.editorStates.hasContent),l=I(r,{language:o.language,code:n,theme:i.value,monacoOptions:o.options,onChanged:m=>{n.value=m}});return(m,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[i.value,{loading:e.unref(l).editorStates.editorStatus==="loading"}]]),"data-testid":"monaco-editor-container"},[e.createElementVNode("div",{ref_key:"editorRef",ref:r,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),e.renderSlot(m.$slots,"state-loading",{isLoading:e.unref(l).editorStates.editorStatus==="loading"},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.unref(l).editorStates.editorStatus==="loading"?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(S.ProgressIcon),message:e.unref(t).t("editor.messages.loading_message",{type:o.language}),title:e.unref(t).t("editor.messages.loading_title",{type:o.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0),e.renderSlot(m.$slots,"state-empty",{isEmpty:c.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[c.value?(e.openBlock(),e.createBlock(k,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(S.CodeblockIcon),message:e.unref(t).t("editor.messages.empty_message"),title:e.unref(t).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0)],2))}}),[["__scopeId","data-v-8e67eb98"]]);s.MonacoEditor=P,s.useMonacoEditor=I,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.monaco-editor-status-overlay[data-v-062eadb5]{background:transparent;left:50%;pointer-events:none;position:absolute;top:50%;transform:translate(-50%,-50%)}.monaco-editor-status-overlay[data-v-062eadb5] .empty-state-content{align-items:center;display:flex;flex-direction:column}.monaco-editor-status-overlay[data-v-062eadb5] .empty-state-content .empty-state-icon,.monaco-editor-status-overlay[data-v-062eadb5] .empty-state-content .empty-state-title,.monaco-editor-status-overlay[data-v-062eadb5] .empty-state-content .empty-state-message{color:#afb7c5;color:var(--kui-color-text-neutral-weak, #afb7c5)}.monaco-editor-status-overlay[data-v-062eadb5] .empty-state-content .empty-state-title{text-transform:capitalize}.monaco-editor-container[data-v-8e67eb98]{background:#fff;background:var(--kui-color-background, #ffffff);display:flex;flex-direction:column;height:100%;overflow:hidden;position:relative;width:100%}.monaco-editor-container.loading[data-v-8e67eb98]{pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-container.loading .monaco-editor-target[data-v-8e67eb98]{filter:blur(2px);opacity:0;pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-target[data-v-8e67eb98]{height:100%;overflow:hidden;position:relative;transition:all .2s ease-in-out;transition:all var(--kui-animation-duration-20, .2s) ease-in-out;width:100%}.monaco-editor-target[data-v-8e67eb98] .monaco-editor{position:absolute;--vscode-editor-background: var(--kui-color-background, #ffffff);--vscode-editorGutter-background: var(--kui-color-background, #ffffff);--vscode-editorLineNumber-activeForeground: var(--kui-color-text-primary, #0044f4);--vscode-editorSuggestWidget-background: var(--kui-color-background, #ffffff);--vscode-editorSuggestWidget-border: var(--kui-color-border, #e0e4ea);--vscode-editorSuggestWidget-highlightForeground: var(--kui-color-text-decorative-purple, #6f28ff);--vscode-editorSuggestWidget-focusHighlightForeground: var(--kui-color-text-decorative-purple, #6f28ff);--vscode-menu-background: var(--kui-color-background, #ffffff);--vscode-menu-border: var(--kui-color-border, #e0e4ea);--vscode-menu-separatorBackground: var(--kui-color-border, #e0e4ea);--vscode-focusBorder: var(--kui-color-text-neutral, #6c7489);--vscode-input-background: var(--kui-color-background, #ffffff);--vscode-sash-hoverBorder: var(--kui-color-border-primary, #0044f4)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .sticky-widget{z-index:2}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-details-container{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-details-container .suggest-details{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important;overflow-x:hidden;overflow-y:auto}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-details-container .suggest-details .type{word-break:break-word!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important;min-height:30px!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget.shows-details{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important;min-height:30px!important;overflow-x:hidden;overflow-y:auto;scrollbar-width:thin}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .tree,.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-scrollable-element,.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list,.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-rows{border-radius:8px!important;border-radius:var(--kui-border-radius-40, 8px)!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-rows{overflow-x:hidden;overflow-y:auto}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row{padding:0 6px;padding:var(--kui-space-0, 0px) var(--kui-space-30, 6px)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row.focused{background:#e0e4ea;background:var(--kui-color-background-neutral-weaker, #e0e4ea)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row.focused .monaco-icon-label,.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row.focused .suggest-icon{color:#232633!important;color:var(--kui-color-text-neutral-strongest, #232633)!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row.focused .details-label{color:#232633;color:var(--kui-color-text-neutral-strongest, #232633)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row .highlight{font-weight:600;font-weight:var(--kui-font-weight-semibold, 600)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row:first-child.focused{border-top-left-radius:6px;border-top-left-radius:var(--kui-border-radius-30, 6px)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row .suggest-icon:not(.codicon-symbol-property){color:#0044f4;color:var(--kui-color-text-primary, #0044f4)}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .suggest-widget .monaco-list-row .monaco-icon-label{color:#6c7489!important;color:var(--kui-color-text-neutral, #6c7489)!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .codicon-suggest-more-info{transform:translateY(2px)!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .find-widget{background:#fff;background:var(--kui-color-background, #ffffff);border-bottom:1px solid #e0e4ea;border-bottom:var(--kui-border-width-10, 1px) solid var(--kui-color-border-neutral-weaker, #e0e4ea);border-radius:0;border-radius:var(--kui-border-radius-0, 0px);right:0!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .find-widget .monaco-sash{background-color:#e0e4ea;background-color:var(--kui-color-background-neutral-weaker, #e0e4ea);width:1px!important}.monaco-editor-target[data-v-8e67eb98] .monaco-editor .find-widget .monaco-inputbox{background-color:#fff!important;background-color:var(--kui-color-background, #ffffff)!important;border:1px solid #e0e4ea!important;border:var(--kui-border-width-10, 1px) solid var(--kui-color-border-neutral-weaker, #e0e4ea)!important;border-radius:6px;border-radius:var(--kui-border-radius-30, 6px);padding:0 2px;padding:var(--kui-space-0, 0px) var(--kui-space-10, 2px)}.fade-enter-active[data-v-8e67eb98],.fade-leave-active[data-v-8e67eb98]{transition:opacity .2s ease;transition:opacity var(--kui-animation-duration-20, .2s) ease}.fade-enter-from[data-v-8e67eb98],.fade-leave-to[data-v-8e67eb98]{opacity:0}.fade-enter-to[data-v-8e67eb98],.fade-leave-from[data-v-8e67eb98]{opacity:1}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { editor } from 'monaco-editor';
|
|
2
|
+
import type { EditorThemes } from '../types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/**
|
|
5
|
+
* The theme of the Monaco Editor instance.
|
|
6
|
+
* @default 'light'
|
|
7
|
+
*/
|
|
8
|
+
theme?: EditorThemes;
|
|
9
|
+
/**
|
|
10
|
+
* The programming language for syntax highlighting.
|
|
11
|
+
* @default 'markdown'
|
|
12
|
+
*/
|
|
13
|
+
language?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional Monaco Editor options to customize the editor further.
|
|
16
|
+
* @default undefined
|
|
17
|
+
*/
|
|
18
|
+
options?: Partial<editor.IStandaloneEditorConstructionOptions> | undefined;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The model content for the Monaco Editor.
|
|
22
|
+
*/
|
|
23
|
+
declare const model: import("vue").ModelRef<string, string, string, string>;
|
|
24
|
+
type __VLS_PublicProps = __VLS_Props & {
|
|
25
|
+
/**
|
|
26
|
+
* The model content for the Monaco Editor.
|
|
27
|
+
*/
|
|
28
|
+
modelValue: typeof model['value'];
|
|
29
|
+
};
|
|
30
|
+
declare var __VLS_1: {
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
}, __VLS_12: {
|
|
33
|
+
isEmpty: boolean;
|
|
34
|
+
};
|
|
35
|
+
type __VLS_Slots = {} & {
|
|
36
|
+
'state-loading'?: (props: typeof __VLS_1) => any;
|
|
37
|
+
} & {
|
|
38
|
+
'state-empty'?: (props: typeof __VLS_12) => any;
|
|
39
|
+
};
|
|
40
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
41
|
+
"update:modelValue": (value: string) => any;
|
|
42
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
43
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
44
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
45
|
+
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
46
|
+
export default _default;
|
|
47
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
48
|
+
new (): {
|
|
49
|
+
$slots: S;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=MonacoEditor.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoEditor.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/MonacoEditor.vue"],"names":[],"mappings":"AAkTA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,KAAK,WAAW,GAAG;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;MAGE;IACF,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,GAAG,SAAS,CAAA;CAC3E,CAAC;AAOF;;GAEG;AACH,QAAA,MAAM,KAAK,wDAGT,CAAA;AA4BF,KAAK,iBAAiB,GAAG,WAAW,GAAG;IACvC;;OAEG;IACH,UAAU,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAiJF,QAAA,IAAI,OAAO;;CAAU,EAAE,QAAQ;;CAAY,CAAE;AAC7C,KAAK,WAAW,GAAG,EAAE,GACnB;IAAE,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,OAAO,KAAK,GAAG,CAAA;CAAE,GACpD;IAAE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,QAAQ,KAAK,GAAG,CAAA;CAAE,CAAC;AA2BtD,QAAA,MAAM,eAAe;;;;kFAKnB,CAAC;wBACkB,eAAe,CAAC,OAAO,eAAe,EAAE,WAAW,CAAC;AAAzE,wBAA0E;AAE1E,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/**
|
|
4
|
+
* The title to display in the empty state.
|
|
5
|
+
*/
|
|
6
|
+
title: string;
|
|
7
|
+
/**
|
|
8
|
+
* The message to display in the empty state.
|
|
9
|
+
*/
|
|
10
|
+
message: string;
|
|
11
|
+
/**
|
|
12
|
+
* The icon component to display in the empty state.
|
|
13
|
+
* @default undefined
|
|
14
|
+
*/
|
|
15
|
+
icon?: Component;
|
|
16
|
+
};
|
|
17
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
|
+
export default _default;
|
|
19
|
+
//# sourceMappingURL=MonacoEditorStatusOverlay.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MonacoEditorStatusOverlay.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/MonacoEditorStatusOverlay.vue"],"names":[],"mappings":"AAkEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,KAAK,WAAW,GAAG;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAA;CACjB,CAAC;;AA6EF,wBAIG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createI18n, i18nTComponent } from '@kong-ui-public/i18n';
|
|
2
|
+
import english from '../locales/en.json';
|
|
3
|
+
interface UseI18nReturn {
|
|
4
|
+
i18n: ReturnType<typeof createI18n<typeof english>>;
|
|
5
|
+
i18nT: ReturnType<typeof i18nTComponent<typeof english>>;
|
|
6
|
+
}
|
|
7
|
+
export default function useI18n(): UseI18nReturn;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=useI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useI18n.d.ts","sourceRoot":"","sources":["../../../../src/composables/useI18n.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACjE,OAAO,OAAO,MAAM,oBAAoB,CAAA;AAExC,UAAU,aAAa;IACrB,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,OAAO,OAAO,CAAC,CAAC,CAAA;IACnD,KAAK,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC,CAAA;CACzD;AAED,MAAM,CAAC,OAAO,UAAU,OAAO,IAAI,aAAa,CAO/C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as monaco from 'monaco-editor';
|
|
2
|
+
import type { MaybeComputedElementRef, MaybeElement } from '@vueuse/core';
|
|
3
|
+
import type { UseMonacoEditorOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Composable for integrating the Monaco Editor into Vue components.
|
|
6
|
+
* @param {MaybeComputedElementRef} target - The target DOM element or Vue component ref where the editor will be mounted.
|
|
7
|
+
* @param {UseMonacoEditorOptions} options - Configuration options for the Monaco editor.
|
|
8
|
+
* @returns {object} An object containing the editor instance and utility methods.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useMonacoEditor<T extends MaybeElement>(target: MaybeComputedElementRef<T>, options: UseMonacoEditorOptions): {
|
|
11
|
+
editor: monaco.editor.IStandaloneCodeEditor | undefined;
|
|
12
|
+
editorStates: {
|
|
13
|
+
editorStatus: import("..").EditorStatus;
|
|
14
|
+
searchBoxIsRevealed: boolean;
|
|
15
|
+
hasContent: boolean;
|
|
16
|
+
theme: import("..").EditorThemes;
|
|
17
|
+
};
|
|
18
|
+
setContent: (content: string) => void;
|
|
19
|
+
setReadOnly: (readOnly: boolean) => void;
|
|
20
|
+
focus: () => void;
|
|
21
|
+
remeasureFonts: import("@vueuse/core").UseDebounceFnReturn<() => void | undefined>;
|
|
22
|
+
toggleSearchWidget: () => void;
|
|
23
|
+
triggerKeyboardCommand: (id: string) => void;
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useMonacoEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,UAAU,CAAA;AA+B1E;;;;;EAKE;AACF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB;;;;;;;;0BAqBF,MAAM,KAAG,IAAI;4BAOX,OAAO,KAAG,IAAI;iBAG3B,IAAI;;8BAkBS,IAAI;iCAXC,MAAM,KAAG,IAAI;EAmIlD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAG3C,eAAO,MAAM,sBAAsB,gEA0CjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,+BAA+B,CAAA;AAExD,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,cAAc,SAAS,CAAA;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../../src/tests/setup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { editor } from 'monaco-editor';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Options for the Monaco editor composable
|
|
5
|
+
*/
|
|
6
|
+
export interface UseMonacoEditorOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The initial content of the editor
|
|
9
|
+
*/
|
|
10
|
+
code: Ref<string>;
|
|
11
|
+
/**
|
|
12
|
+
* The programming language for syntax highlighting
|
|
13
|
+
*/
|
|
14
|
+
language: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the editor is read-only
|
|
17
|
+
*/
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The theme of the editor
|
|
21
|
+
*/
|
|
22
|
+
theme?: EditorThemes;
|
|
23
|
+
/**
|
|
24
|
+
* Callback function triggered when the content changes
|
|
25
|
+
*/
|
|
26
|
+
onChanged?: (content: string) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Callback function triggered when the editor is created
|
|
29
|
+
*/
|
|
30
|
+
onCreated?: () => void;
|
|
31
|
+
/**
|
|
32
|
+
* Additional actions to be added to the editor
|
|
33
|
+
*/
|
|
34
|
+
actions?: any;
|
|
35
|
+
/**
|
|
36
|
+
* Additional Monaco editor settings
|
|
37
|
+
* @see https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html
|
|
38
|
+
*/
|
|
39
|
+
monacoOptions?: Partial<editor.IStandaloneEditorConstructionOptions>;
|
|
40
|
+
}
|
|
41
|
+
/** The themes available for the Monaco editor */
|
|
42
|
+
export type EditorThemes = 'light' | 'dark';
|
|
43
|
+
/** The status of the Monaco editor */
|
|
44
|
+
export type EditorStatus = 'loading' | 'ready';
|
|
45
|
+
export interface MonacoEditorStates {
|
|
46
|
+
/**
|
|
47
|
+
* The current status of the editor instance.
|
|
48
|
+
* @type {'loading' | 'ready'}
|
|
49
|
+
* @default 'loading'
|
|
50
|
+
*/
|
|
51
|
+
editorStatus: EditorStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Indicates whether the search box is currently visible.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
searchBoxIsRevealed: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the editor currently contains any content.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
hasContent: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The current theme of the editor.
|
|
64
|
+
* @type {'light' | 'dark'}
|
|
65
|
+
* @default 'light'
|
|
66
|
+
*/
|
|
67
|
+
theme: EditorThemes;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAE9B;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC;;OAEG;IACH,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;MAEE;IACF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;OAEG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IACpB;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;IACtB;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAA;IACb;;;MAGE;IACF,aAAa,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,CAAA;CACrE;AAED,iDAAiD;AACjD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,CAAA;AAE3C,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,OAAO,CAAA;AAG9C,MAAM,WAAW,kBAAkB;IACjC;;;;QAII;IACJ,YAAY,EAAE,YAAY,CAAA;IAE1B;;;QAGI;IACJ,mBAAmB,EAAE,OAAO,CAAA;IAE5B;;;QAGI;IACJ,UAAU,EAAE,OAAO,CAAA;IAEnB;;;;QAII;IACJ,KAAK,EAAE,YAAY,CAAA;CACpB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
import type { EditorFeature, EditorLanguage, NegatedEditorFeature, IFeatureDefinition } from 'monaco-editor/esm/metadata.js';
|
|
3
|
+
type Options = {
|
|
4
|
+
/**
|
|
5
|
+
* Include only a subset of the languages supported.
|
|
6
|
+
*
|
|
7
|
+
* @type {EditorLanguage[]}
|
|
8
|
+
* @defaultValue All languages shipped with monaco-editor
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* // Only include JavaScript and JSON support
|
|
12
|
+
* languages: ['javascript', 'json']
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
languages?: EditorLanguage[];
|
|
16
|
+
/**
|
|
17
|
+
* Custom languages (outside of the ones shipped with the `monaco-editor`).
|
|
18
|
+
* Use this to add support for languages not included in monaco-editor by default.
|
|
19
|
+
*
|
|
20
|
+
* @type {IFeatureDefinition[]}
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* // Add yaml support from `monaco-yaml`
|
|
24
|
+
* customLanguages: [
|
|
25
|
+
* {
|
|
26
|
+
* label: 'yaml',
|
|
27
|
+
* entry: 'monaco-yaml',
|
|
28
|
+
* worker: {
|
|
29
|
+
* id: 'monaco-yaml/yamlWorker',
|
|
30
|
+
* entry: 'monaco-yaml/yaml.worker',
|
|
31
|
+
* },
|
|
32
|
+
* },
|
|
33
|
+
* ]
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
customLanguages?: IFeatureDefinition[];
|
|
37
|
+
/**
|
|
38
|
+
* Include only a subset of the editor features.
|
|
39
|
+
* Prefix a feature with `!` to exclude it instead.
|
|
40
|
+
*
|
|
41
|
+
* @type {Array<EditorFeature | NegatedEditorFeature>}
|
|
42
|
+
* @defaultValue All features shipped with monaco-editor
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* // Exclude context menu and find features
|
|
46
|
+
* features: ['!contextmenu', '!find']
|
|
47
|
+
*
|
|
48
|
+
* // Or only include specific features
|
|
49
|
+
* features: ['coreCommands', 'coreActions']
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
features?: Array<EditorFeature | NegatedEditorFeature>;
|
|
53
|
+
};
|
|
54
|
+
export default function (options?: Options): Plugin;
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../vite-plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAClC,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EACnB,MAAM,+BAA+B,CAAA;AAGtC,KAAK,OAAO,GAAG;IACb;;;;;;;;;;OAUG;IACH,SAAS,CAAC,EAAE,cAAc,EAAE,CAAA;IAE5B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,eAAe,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAEtC;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,oBAAoB,CAAC,CAAA;CACvD,CAAA;AAsGD,MAAM,CAAC,OAAO,WAAU,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAqEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../vite-plugin/index.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const metadata_js = require("monaco-editor/esm/metadata.js");
|
|
3
|
+
const WORKER_ALIASES = {
|
|
4
|
+
javascript: "typescript",
|
|
5
|
+
less: "css",
|
|
6
|
+
scss: "css",
|
|
7
|
+
handlebars: "html",
|
|
8
|
+
razor: "html"
|
|
9
|
+
};
|
|
10
|
+
const VIRTUAL_MODULE_ID = "\0virtual:monaco-editor";
|
|
11
|
+
function generateImports(entries) {
|
|
12
|
+
const entryArray = Array.isArray(entries) ? entries : [entries];
|
|
13
|
+
return entryArray.map((entry) => `import 'monaco-editor/esm/${entry}'`);
|
|
14
|
+
}
|
|
15
|
+
function resolveFeatures(requestedFeatures, allFeatureIds) {
|
|
16
|
+
if (!requestedFeatures) {
|
|
17
|
+
return allFeatureIds;
|
|
18
|
+
}
|
|
19
|
+
const excludedFeatures = requestedFeatures.filter((f) => f.startsWith("!")).map((f) => f.slice(1));
|
|
20
|
+
if (excludedFeatures.length) {
|
|
21
|
+
return allFeatureIds.filter((f) => !excludedFeatures.includes(f));
|
|
22
|
+
}
|
|
23
|
+
return requestedFeatures;
|
|
24
|
+
}
|
|
25
|
+
function generateWorkerCode(languageIds, languagesDict, customLanguages) {
|
|
26
|
+
const importedWorkers = /* @__PURE__ */ new Set();
|
|
27
|
+
const imports = [];
|
|
28
|
+
const workerMapEntries = [];
|
|
29
|
+
imports.push("import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'");
|
|
30
|
+
languageIds.forEach((langId) => {
|
|
31
|
+
var _a;
|
|
32
|
+
const actualLang = WORKER_ALIASES[langId] || langId;
|
|
33
|
+
const lang = languagesDict[actualLang];
|
|
34
|
+
const workerEntry = (_a = lang == null ? void 0 : lang.worker) == null ? void 0 : _a.entry;
|
|
35
|
+
if (!workerEntry) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const workerVar = `${actualLang}Worker`;
|
|
39
|
+
if (!importedWorkers.has(workerVar)) {
|
|
40
|
+
imports.push(
|
|
41
|
+
`import ${workerVar} from 'monaco-editor/esm/${workerEntry}?worker'`
|
|
42
|
+
);
|
|
43
|
+
importedWorkers.add(workerVar);
|
|
44
|
+
}
|
|
45
|
+
workerMapEntries.push(` ${langId}: ${workerVar},`);
|
|
46
|
+
});
|
|
47
|
+
if (customLanguages) {
|
|
48
|
+
customLanguages.filter(({ worker }) => worker == null ? void 0 : worker.entry).forEach(({ label, worker }) => {
|
|
49
|
+
const workerVar = `${label}Worker`;
|
|
50
|
+
imports.push(`import ${workerVar} from '${worker.entry}?worker'`);
|
|
51
|
+
workerMapEntries.push(` ${label}: ${workerVar},`);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return [
|
|
55
|
+
...imports,
|
|
56
|
+
"",
|
|
57
|
+
"const workerMap = {",
|
|
58
|
+
...workerMapEntries,
|
|
59
|
+
"}",
|
|
60
|
+
"",
|
|
61
|
+
"self.MonacoEnvironment = {",
|
|
62
|
+
" getWorker(_, label) {",
|
|
63
|
+
" const Worker = workerMap[label] || EditorWorker",
|
|
64
|
+
" return new Worker()",
|
|
65
|
+
" },",
|
|
66
|
+
"}"
|
|
67
|
+
];
|
|
68
|
+
}
|
|
69
|
+
function index(options) {
|
|
70
|
+
return {
|
|
71
|
+
name: "vite-plugin-monaco",
|
|
72
|
+
enforce: "pre",
|
|
73
|
+
resolveId(id) {
|
|
74
|
+
if (id === "monaco-editor") {
|
|
75
|
+
return VIRTUAL_MODULE_ID;
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
load(id) {
|
|
79
|
+
if (id !== VIRTUAL_MODULE_ID) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const languagesDict = Object.fromEntries(
|
|
83
|
+
metadata_js.languages.map((lang) => [lang.label, lang])
|
|
84
|
+
);
|
|
85
|
+
const featuresDict = Object.fromEntries(
|
|
86
|
+
metadata_js.features.map((feat) => [feat.label, feat])
|
|
87
|
+
);
|
|
88
|
+
const featuresIds = resolveFeatures(
|
|
89
|
+
options == null ? void 0 : options.features,
|
|
90
|
+
Object.keys(featuresDict)
|
|
91
|
+
);
|
|
92
|
+
const featureImports = featuresIds.flatMap((featureId) => {
|
|
93
|
+
const feature = featuresDict[featureId];
|
|
94
|
+
if (!(feature == null ? void 0 : feature.entry)) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
return generateImports(feature.entry);
|
|
98
|
+
});
|
|
99
|
+
const languageIds = (options == null ? void 0 : options.languages) || Object.keys(languagesDict);
|
|
100
|
+
const languageImports = languageIds.flatMap((langId) => {
|
|
101
|
+
const lang = languagesDict[langId];
|
|
102
|
+
if (!(lang == null ? void 0 : lang.entry)) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
return generateImports(lang.entry);
|
|
106
|
+
});
|
|
107
|
+
const customLanguageImports = ((options == null ? void 0 : options.customLanguages) || []).map(
|
|
108
|
+
({ entry }) => `import '${entry}'`
|
|
109
|
+
);
|
|
110
|
+
const workerCode = generateWorkerCode(
|
|
111
|
+
languageIds,
|
|
112
|
+
languagesDict,
|
|
113
|
+
options == null ? void 0 : options.customLanguages
|
|
114
|
+
);
|
|
115
|
+
return [
|
|
116
|
+
"import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'",
|
|
117
|
+
...featureImports,
|
|
118
|
+
...languageImports,
|
|
119
|
+
...customLanguageImports,
|
|
120
|
+
...workerCode,
|
|
121
|
+
"export * from 'monaco-editor/esm/vs/editor/editor.api'",
|
|
122
|
+
"export default monaco"
|
|
123
|
+
].join("\n");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
module.exports = index;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { languages, features } from "monaco-editor/esm/metadata.js";
|
|
2
|
+
const WORKER_ALIASES = {
|
|
3
|
+
javascript: "typescript",
|
|
4
|
+
less: "css",
|
|
5
|
+
scss: "css",
|
|
6
|
+
handlebars: "html",
|
|
7
|
+
razor: "html"
|
|
8
|
+
};
|
|
9
|
+
const VIRTUAL_MODULE_ID = "\0virtual:monaco-editor";
|
|
10
|
+
function generateImports(entries) {
|
|
11
|
+
const entryArray = Array.isArray(entries) ? entries : [entries];
|
|
12
|
+
return entryArray.map((entry) => `import 'monaco-editor/esm/${entry}'`);
|
|
13
|
+
}
|
|
14
|
+
function resolveFeatures(requestedFeatures, allFeatureIds) {
|
|
15
|
+
if (!requestedFeatures) {
|
|
16
|
+
return allFeatureIds;
|
|
17
|
+
}
|
|
18
|
+
const excludedFeatures = requestedFeatures.filter((f) => f.startsWith("!")).map((f) => f.slice(1));
|
|
19
|
+
if (excludedFeatures.length) {
|
|
20
|
+
return allFeatureIds.filter((f) => !excludedFeatures.includes(f));
|
|
21
|
+
}
|
|
22
|
+
return requestedFeatures;
|
|
23
|
+
}
|
|
24
|
+
function generateWorkerCode(languageIds, languagesDict, customLanguages) {
|
|
25
|
+
const importedWorkers = /* @__PURE__ */ new Set();
|
|
26
|
+
const imports = [];
|
|
27
|
+
const workerMapEntries = [];
|
|
28
|
+
imports.push("import EditorWorker from 'monaco-editor/esm/vs/editor/editor.worker?worker'");
|
|
29
|
+
languageIds.forEach((langId) => {
|
|
30
|
+
var _a;
|
|
31
|
+
const actualLang = WORKER_ALIASES[langId] || langId;
|
|
32
|
+
const lang = languagesDict[actualLang];
|
|
33
|
+
const workerEntry = (_a = lang == null ? void 0 : lang.worker) == null ? void 0 : _a.entry;
|
|
34
|
+
if (!workerEntry) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const workerVar = `${actualLang}Worker`;
|
|
38
|
+
if (!importedWorkers.has(workerVar)) {
|
|
39
|
+
imports.push(
|
|
40
|
+
`import ${workerVar} from 'monaco-editor/esm/${workerEntry}?worker'`
|
|
41
|
+
);
|
|
42
|
+
importedWorkers.add(workerVar);
|
|
43
|
+
}
|
|
44
|
+
workerMapEntries.push(` ${langId}: ${workerVar},`);
|
|
45
|
+
});
|
|
46
|
+
if (customLanguages) {
|
|
47
|
+
customLanguages.filter(({ worker }) => worker == null ? void 0 : worker.entry).forEach(({ label, worker }) => {
|
|
48
|
+
const workerVar = `${label}Worker`;
|
|
49
|
+
imports.push(`import ${workerVar} from '${worker.entry}?worker'`);
|
|
50
|
+
workerMapEntries.push(` ${label}: ${workerVar},`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return [
|
|
54
|
+
...imports,
|
|
55
|
+
"",
|
|
56
|
+
"const workerMap = {",
|
|
57
|
+
...workerMapEntries,
|
|
58
|
+
"}",
|
|
59
|
+
"",
|
|
60
|
+
"self.MonacoEnvironment = {",
|
|
61
|
+
" getWorker(_, label) {",
|
|
62
|
+
" const Worker = workerMap[label] || EditorWorker",
|
|
63
|
+
" return new Worker()",
|
|
64
|
+
" },",
|
|
65
|
+
"}"
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
function index(options) {
|
|
69
|
+
return {
|
|
70
|
+
name: "vite-plugin-monaco",
|
|
71
|
+
enforce: "pre",
|
|
72
|
+
resolveId(id) {
|
|
73
|
+
if (id === "monaco-editor") {
|
|
74
|
+
return VIRTUAL_MODULE_ID;
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
load(id) {
|
|
78
|
+
if (id !== VIRTUAL_MODULE_ID) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const languagesDict = Object.fromEntries(
|
|
82
|
+
languages.map((lang) => [lang.label, lang])
|
|
83
|
+
);
|
|
84
|
+
const featuresDict = Object.fromEntries(
|
|
85
|
+
features.map((feat) => [feat.label, feat])
|
|
86
|
+
);
|
|
87
|
+
const featuresIds = resolveFeatures(
|
|
88
|
+
options == null ? void 0 : options.features,
|
|
89
|
+
Object.keys(featuresDict)
|
|
90
|
+
);
|
|
91
|
+
const featureImports = featuresIds.flatMap((featureId) => {
|
|
92
|
+
const feature = featuresDict[featureId];
|
|
93
|
+
if (!(feature == null ? void 0 : feature.entry)) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
return generateImports(feature.entry);
|
|
97
|
+
});
|
|
98
|
+
const languageIds = (options == null ? void 0 : options.languages) || Object.keys(languagesDict);
|
|
99
|
+
const languageImports = languageIds.flatMap((langId) => {
|
|
100
|
+
const lang = languagesDict[langId];
|
|
101
|
+
if (!(lang == null ? void 0 : lang.entry)) {
|
|
102
|
+
return [];
|
|
103
|
+
}
|
|
104
|
+
return generateImports(lang.entry);
|
|
105
|
+
});
|
|
106
|
+
const customLanguageImports = ((options == null ? void 0 : options.customLanguages) || []).map(
|
|
107
|
+
({ entry }) => `import '${entry}'`
|
|
108
|
+
);
|
|
109
|
+
const workerCode = generateWorkerCode(
|
|
110
|
+
languageIds,
|
|
111
|
+
languagesDict,
|
|
112
|
+
options == null ? void 0 : options.customLanguages
|
|
113
|
+
);
|
|
114
|
+
return [
|
|
115
|
+
"import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'",
|
|
116
|
+
...featureImports,
|
|
117
|
+
...languageImports,
|
|
118
|
+
...customLanguageImports,
|
|
119
|
+
...workerCode,
|
|
120
|
+
"export * from 'monaco-editor/esm/vs/editor/editor.api'",
|
|
121
|
+
"export default monaco"
|
|
122
|
+
].join("\n");
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
index as default
|
|
128
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong-ui-public/monaco-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/monaco-editor.umd.js",
|
|
6
6
|
"module": "./dist/monaco-editor.es.js",
|
|
@@ -10,10 +10,15 @@
|
|
|
10
10
|
],
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"import": "./dist/monaco-editor.es.js",
|
|
14
|
-
"require": "./dist/monaco-editor.umd.js",
|
|
13
|
+
"import": "./dist/runtime/monaco-editor.es.js",
|
|
14
|
+
"require": "./dist/runtime/monaco-editor.umd.js",
|
|
15
15
|
"types": "./dist/types/index.d.ts"
|
|
16
16
|
},
|
|
17
|
+
"./vite-plugin": {
|
|
18
|
+
"import": "./dist/vite-plugin/index.js",
|
|
19
|
+
"require": "./dist/vite-plugin/index.cjs",
|
|
20
|
+
"types": "./dist/types/vite-plugin/index.d.ts"
|
|
21
|
+
},
|
|
17
22
|
"./package.json": "./package.json",
|
|
18
23
|
"./dist/*": "./dist/*"
|
|
19
24
|
},
|
|
@@ -35,8 +40,8 @@
|
|
|
35
40
|
"extends": "../../../package.json"
|
|
36
41
|
},
|
|
37
42
|
"distSizeChecker": {
|
|
38
|
-
"warningLimit": "
|
|
39
|
-
"errorLimit": "
|
|
43
|
+
"warningLimit": "200KB",
|
|
44
|
+
"errorLimit": "300KB"
|
|
40
45
|
},
|
|
41
46
|
"peerDependencies": {
|
|
42
47
|
"@kong/kongponents": ">=9.42.0 <10.0.0",
|
|
@@ -56,8 +61,9 @@
|
|
|
56
61
|
},
|
|
57
62
|
"scripts": {
|
|
58
63
|
"dev": "cross-env USE_SANDBOX=true vite",
|
|
59
|
-
"build": "run
|
|
64
|
+
"build": "pnpm run typecheck && run-p build:package build:plugin build:types",
|
|
60
65
|
"build:package": "vite build -m production",
|
|
66
|
+
"build:plugin": "vite build --config './vite-plugin/vite.config.ts'",
|
|
61
67
|
"build:analyzer": "BUILD_VISUALIZER='core/monaco-editor' vite build -m production",
|
|
62
68
|
"build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
|
|
63
69
|
"build:sandbox": "cross-env USE_SANDBOX=true vite build -m production",
|