@kong-ui-public/monaco-editor 0.8.1-pr.2799.4a7245eab.0 → 0.8.1-pr.2808.079ab5d08.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.

Potentially problematic release.


This version of @kong-ui-public/monaco-editor might be problematic. Click here for more details.

package/README.md CHANGED
@@ -97,27 +97,65 @@ The theme of the Monaco Editor instance.
97
97
 
98
98
  The programming language for syntax highlighting. Supports all languages available in [Shiki](https://shiki.matsu.io/languages).
99
99
 
100
+ #### `options`
101
+
102
+ - type: `Partial<editor.IStandaloneEditorConstructionOptions>`
103
+ - required: `false`
104
+ - default: `undefined`
105
+
106
+ Additional Monaco Editor options to customize the editor further. See [Monaco Editor API](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) for available options.
107
+
100
108
  #### `loading`
101
109
 
102
110
  - type: `boolean`
103
111
  - required: `false`
104
112
  - default: `false`
105
113
 
106
- Whether the editor is in a loading state. When true, displays a loading overlay.
114
+ Indicates that the editor is waiting for external data in addition to its own internal initialization.
107
115
 
108
- #### `options`
116
+ > [!WARNING]
117
+ > This prop does not control the Monaco Editor's initialization lifecycle.
109
118
 
110
- - type: `Partial<editor.IStandaloneEditorConstructionOptions>`
119
+ The editor manages its own internal loading state while Monaco and syntax highlighting are being initialized.
120
+ The loading prop is additive, it allows consumers to keep the loading overlay visible if additional async work (such as fetching content) is still in progress after the editor itself is ready.
121
+
122
+ The loading overlay is shown when either:
123
+ - The editor is still initializing internally, or
124
+ - The loading prop is set to true
125
+
126
+ #### `showLoadingState`
127
+
128
+ - type: `boolean`
111
129
  - required: `false`
112
- - default: `undefined`
130
+ - default: `true`
113
131
 
114
- Additional Monaco Editor options to customize the editor further. See [Monaco Editor API](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html) for available options.
132
+ Controls whether the loading state overlay is rendered.
133
+
134
+ > [!NOTE]
135
+ > This does not affect editor initialization. When set to false, the editor will still initialize and emit ready, but no loading UI will be displayed.
136
+
137
+ Useful for constrained layouts where the loading overlay would be visually disruptive.
138
+
139
+ #### `showEmptyState`
140
+
141
+ - type: `boolean`
142
+ - required: `false`
143
+ - default: `true`
144
+
145
+ Controls whether the empty state overlay is rendered when the editor has no content.
146
+
147
+ > [!NOTE]
148
+ > This does not affect editor initialization. When set to false, the editor will still initialize and emit ready, but no empty state UI will be displayed even if the content is empty.
149
+
150
+ Useful for embedded or compact layouts where the empty state overlay is unnecessary.
115
151
 
116
152
  ### Events
117
153
 
118
154
  #### `ready`
119
155
 
120
- Emitted when the Monaco editor instance is initialized and ready for use.
156
+ Emitted when the Monaco editor instance has finished initializing and is ready for interaction.
157
+
158
+ This event reflects only the editor's internal readiness, not any external loading state controlled by the loading prop.
121
159
 
122
160
  **Payload:**
123
161
 
@@ -1,10 +1,10 @@
1
- import { toValue as b, ref as A, shallowRef as K, reactive as H, watch as I, onMounted as $, onActivated as z, onBeforeUnmount as G, onWatcherCleanup as q, defineComponent as D, resolveComponent as J, createBlock as M, openBlock as C, createSlots as Q, withCtx as x, resolveDynamicComponent as Y, mergeModels as F, useModel as Z, useTemplateRef as X, computed as T, createElementBlock as ee, normalizeClass as te, createElementVNode as oe, renderSlot as R, createVNode as w, Transition as L, createCommentVNode as W, unref as h } from "vue";
2
- import { ProgressIcon as ae, CodeblockIcon as ne } from "@kong/icons";
3
- import * as g from "monaco-editor";
4
- import { shikiToMonaco as re } from "@shikijs/monaco";
5
- import { getSingletonHighlighter as se, bundledLanguages as ie, bundledThemes as le } from "shiki";
6
- import { createI18n as ce, i18nTComponent as ue } from "@kong-ui-public/i18n";
7
- const de = "'JetBrains Mono', Consolas, monospace", me = "12px", ge = "500", fe = "20px", ve = Object.freeze({
1
+ import { toValue as O, ref as X, shallowRef as Y, reactive as Z, watch as D, onMounted as ee, onActivated as te, onBeforeUnmount as oe, onWatcherCleanup as ae, defineComponent as H, resolveComponent as ne, createBlock as _, openBlock as E, createSlots as re, withCtx as L, resolveDynamicComponent as se, mergeModels as W, useModel as ie, useTemplateRef as le, computed as I, createElementBlock as ce, normalizeClass as de, createElementVNode as ue, renderSlot as B, createCommentVNode as k, createVNode as N, Transition as U, unref as v } from "vue";
2
+ import { ProgressIcon as ge, CodeblockIcon as me } from "@kong/icons";
3
+ import * as m from "monaco-editor";
4
+ import { shikiToMonaco as fe } from "@shikijs/monaco";
5
+ import { getSingletonHighlighter as pe, bundledLanguages as he, bundledThemes as ve } from "shiki";
6
+ import { createI18n as ye, i18nTComponent as Se } from "@kong-ui-public/i18n";
7
+ const be = "'JetBrains Mono', Consolas, monospace", Ee = "12px", Ce = "500", we = "20px", Me = Object.freeze({
8
8
  autoClosingQuotes: "always",
9
9
  automaticLayout: !0,
10
10
  // Auto resize layout
@@ -13,10 +13,10 @@ const de = "'JetBrains Mono', Consolas, monospace", me = "12px", ge = "500", fe
13
13
  },
14
14
  hideCursorInOverviewRuler: !0,
15
15
  // hide the cursor position in the minimap TODO: maybe hide it on first line or change it colour
16
- fontFamily: de,
17
- fontSize: Number(me.replace("px", "")),
18
- fontWeight: ge,
19
- lineHeight: Number(fe.replace("px", "")),
16
+ fontFamily: be,
17
+ fontSize: Number(Ee.replace("px", "")),
18
+ fontWeight: Ce,
19
+ lineHeight: Number(we.replace("px", "")),
20
20
  formatOnPaste: !0,
21
21
  formatOnType: !0,
22
22
  // Add to enable automatic formatting as the user types.
@@ -59,141 +59,227 @@ const de = "'JetBrains Mono', Consolas, monospace", me = "12px", ge = "500", fe
59
59
  }
60
60
  });
61
61
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
62
- const N = () => {
62
+ const P = () => {
63
63
  };
64
- function he(o, t) {
64
+ function ke(o, t) {
65
65
  function e(...a) {
66
- return new Promise((r, s) => {
66
+ return new Promise((i, r) => {
67
67
  Promise.resolve(o(() => t.apply(this, a), {
68
68
  fn: t,
69
69
  thisArg: this,
70
70
  args: a
71
- })).then(r).catch(s);
71
+ })).then(i).catch(r);
72
72
  });
73
73
  }
74
74
  return e;
75
75
  }
76
- function pe(o, t = {}) {
77
- let e, a, r = N;
78
- const s = (d) => {
79
- clearTimeout(d), r(), r = N;
76
+ function Oe(o, t = {}) {
77
+ let e, a, i = P;
78
+ const r = (s) => {
79
+ clearTimeout(s), i(), i = P;
80
80
  };
81
- let i;
82
- return (d) => {
83
- const f = b(o), m = b(t.maxWait);
84
- return e && s(e), f <= 0 || m !== void 0 && m <= 0 ? (a && (s(a), a = void 0), Promise.resolve(d())) : new Promise((l, v) => {
85
- r = t.rejectOnCancel ? v : l, i = d, m && !a && (a = setTimeout(() => {
86
- e && s(e), a = void 0, l(i());
87
- }, m)), e = setTimeout(() => {
88
- a && s(a), a = void 0, l(d());
89
- }, f);
81
+ let l;
82
+ return (s) => {
83
+ const p = O(o), g = O(t.maxWait);
84
+ return e && r(e), p <= 0 || g !== void 0 && g <= 0 ? (a && (r(a), a = void 0), Promise.resolve(s())) : new Promise((c, h) => {
85
+ i = t.rejectOnCancel ? h : c, l = s, g && !a && (a = setTimeout(() => {
86
+ e && r(e), a = void 0, c(l());
87
+ }, g)), e = setTimeout(() => {
88
+ a && r(a), a = void 0, c(s());
89
+ }, p);
90
90
  });
91
91
  };
92
92
  }
93
93
  // @__NO_SIDE_EFFECTS__
94
- function ye(o, t = 200, e = {}) {
95
- return he(pe(t, e), o);
94
+ function _e(o, t = 200, e = {}) {
95
+ return ke(Oe(t, e), o);
96
96
  }
97
- function U(o) {
97
+ function V(o) {
98
98
  var t;
99
- const e = b(o);
99
+ const e = O(o);
100
100
  return (t = e == null ? void 0 : e.$el) !== null && t !== void 0 ? t : e;
101
101
  }
102
- const P = A(!1);
103
- let y = null;
104
- async function Ce() {
105
- return y || (y = (async () => {
102
+ const F = "[monaco-editor] [lifecycle]", y = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new WeakMap();
103
+ function Te(o) {
104
+ let t = y.get(o.source);
105
+ if (!t) {
106
+ let e;
107
+ switch (o.type) {
108
+ case "editor":
109
+ e = o.source.onDidDispose(() => K(o.source));
110
+ break;
111
+ case "model":
112
+ e = o.source.onWillDispose(() => K(o.source));
113
+ break;
114
+ default:
115
+ throw new Error(`${F} Unknown scope: ${o}`);
116
+ }
117
+ t = {
118
+ disposables: /* @__PURE__ */ new Set(),
119
+ scopeListener: e
120
+ }, y.set(o.source, t);
121
+ }
122
+ return t;
123
+ }
124
+ function G(o) {
125
+ const t = y.get(o);
126
+ t && (t.scopeListener.dispose(), y.delete(o));
127
+ }
128
+ function $(o, t) {
129
+ Te(t).disposables.add(o);
130
+ }
131
+ function A(o, t) {
132
+ const e = y.get(t.source);
133
+ e && (e.disposables.delete(o), e.disposables.size === 0 && G(t.source));
134
+ }
135
+ function Ie(o) {
136
+ const t = [];
137
+ if (o.forEach((e) => {
138
+ try {
139
+ e.dispose();
140
+ } catch (a) {
141
+ t.push(a);
142
+ }
143
+ }), t.length)
144
+ throw new AggregateError(
145
+ t,
146
+ `${F} One or more disposables threw while being disposed.`
147
+ );
148
+ }
149
+ function xe(o, t) {
150
+ var l, f;
151
+ let e = o, a = S.get(e);
152
+ if (!a) {
153
+ const s = x.get(o);
154
+ s && (e = s, a = S.get(s));
155
+ }
156
+ if (a)
157
+ return ((l = a.scope) == null ? void 0 : l.type) === (t == null ? void 0 : t.type) && ((f = a.scope) == null ? void 0 : f.source) === (t == null ? void 0 : t.source) || (a.scope && A(a.decorated, a.scope), t ? ($(a.decorated, t), a.scope = t) : a.scope = void 0), a.decorated;
158
+ const i = e.dispose, r = {
159
+ dispose: () => {
160
+ const s = S.get(e);
161
+ if (s)
162
+ return s.scope && A(r, s.scope), S.delete(e), x.delete(r), i.call(e);
163
+ }
164
+ };
165
+ return S.set(e, { decorated: r, scope: t }), x.set(r, e), t && $(r, t), r;
166
+ }
167
+ function j(o, t) {
168
+ return xe(t, { type: "editor", source: o });
169
+ }
170
+ function K(o) {
171
+ const t = y.get(o);
172
+ if (!t) return;
173
+ const e = Array.from(t.disposables);
174
+ try {
175
+ Ie(e);
176
+ } catch (a) {
177
+ console.warn(`${F} Encountered errors while disposing scoped disposables:`, a, ", Source:", o);
178
+ }
179
+ G(o);
180
+ }
181
+ const q = X(!1);
182
+ let b = null;
183
+ async function De() {
184
+ return b || (b = (async () => {
106
185
  var o, t;
107
186
  try {
108
- const e = ((o = g.json) == null ? void 0 : o.jsonDefaults) || ((t = g.languages.json) == null ? void 0 : t.jsonDefaults);
187
+ const e = ((o = m.json) == null ? void 0 : o.jsonDefaults) || ((t = m.languages.json) == null ? void 0 : t.jsonDefaults);
109
188
  e == null || e.setModeConfiguration({ tokens: !1 });
110
- const a = await se(
189
+ const a = await pe(
111
190
  {
112
- themes: Object.values(le),
113
- langs: Object.values(ie)
191
+ themes: Object.values(ve),
192
+ langs: Object.values(he)
114
193
  }
115
194
  );
116
- a.getLoadedLanguages().forEach((r) => {
117
- g.languages.register({ id: r });
118
- }), re(a, g), P.value = !0;
195
+ a.getLoadedLanguages().forEach((i) => {
196
+ m.languages.register({ id: i });
197
+ }), fe(a, m), q.value = !0;
119
198
  } catch (e) {
120
- throw y = null, e;
199
+ throw b = null, e;
121
200
  }
122
- })(), y);
201
+ })(), b);
123
202
  }
124
- function Se(o, t) {
125
- const e = K();
126
- let a, r = !1, s = !1;
127
- const i = H({
203
+ function Le(o, t) {
204
+ const e = Y();
205
+ let a, i = !1, r = !1;
206
+ const l = Z({
128
207
  editorStatus: "loading",
129
208
  searchBoxIsRevealed: !1,
130
209
  hasContent: !1,
131
210
  theme: t.theme || "light"
132
- }), p = (n) => {
133
- !r || !e.value || e.value.setValue(n);
134
- }, d = (n) => {
135
- var c;
136
- return (c = e.value) == null ? void 0 : c.updateOptions({ readOnly: n });
137
- }, f = () => {
211
+ }), f = (n) => {
212
+ !i || !e.value || e.value.setValue(n);
213
+ }, s = (n) => {
214
+ var d;
215
+ return (d = e.value) == null ? void 0 : d.updateOptions({ readOnly: n });
216
+ }, p = () => {
138
217
  var n;
139
218
  return (n = e.value) == null ? void 0 : n.focus();
140
- }, m = (n) => {
141
- var E;
142
- const c = (E = e.value) == null ? void 0 : E.getModel();
143
- c && g.editor.setModelLanguage(c, n);
144
- }, l = (n) => {
219
+ }, g = (n) => {
220
+ var w;
221
+ const d = (w = e.value) == null ? void 0 : w.getModel();
222
+ d && m.editor.setModelLanguage(d, n);
223
+ }, c = (n) => {
145
224
  try {
146
225
  if (!e.value || !n) return;
147
226
  e.value.focus(), e.value.trigger("keyboard", n, null);
148
- } catch (c) {
149
- console.error(`useMonacoEditor: Failed to trigger command: ${n}`, c);
227
+ } catch (d) {
228
+ console.error(`useMonacoEditor: Failed to trigger command: ${n}`, d);
150
229
  }
151
- }, v = () => {
230
+ }, h = () => {
152
231
  var n;
153
232
  try {
154
233
  if (!e.value) return;
155
- if (i.searchBoxIsRevealed)
234
+ if (l.searchBoxIsRevealed)
156
235
  return (n = e.value.getContribution("editor.contrib.findController")) == null ? void 0 : n.closeFindWidget();
157
- l("actions.find");
158
- } catch (c) {
159
- console.error("useMonacoEditor: Failed to close findController.", c);
236
+ c("actions.find");
237
+ } catch (d) {
238
+ console.error("useMonacoEditor: Failed to close findController.", d);
160
239
  }
161
- }, S = /* @__PURE__ */ ye(() => g.editor.remeasureFonts(), 200);
240
+ }, C = /* @__PURE__ */ _e(() => m.editor.remeasureFonts(), 200);
162
241
  return (() => {
163
- Ce(), I([P, () => b(o)], ([n, c], [, E]) => {
164
- var k;
165
- const O = U(c), V = U(E);
166
- if (!(O instanceof HTMLElement) || !n) {
167
- r = !1;
242
+ De(), D([q, () => O(o)], ([n, d], [, w]) => {
243
+ var R;
244
+ const T = V(d), Q = V(w);
245
+ if (!(T instanceof HTMLElement) || !n) {
246
+ i = !1;
168
247
  return;
169
248
  }
170
- if (!(r && V === O)) {
249
+ if (!(i && Q === T)) {
171
250
  if (!a) {
172
- const u = g.Uri.parse(`inmemory://model/${t.language}-${crypto.randomUUID()}`);
173
- a = g.editor.createModel(t.code.value, t.language, u);
251
+ const u = m.Uri.parse(`inmemory://model/${t.language}-${crypto.randomUUID()}`);
252
+ a = m.editor.createModel(t.code.value, t.language, u);
174
253
  }
175
- e.value = g.editor.create(O, {
176
- ...ve,
254
+ e.value = m.editor.create(T, {
255
+ ...Me,
177
256
  readOnly: t.readOnly || !1,
178
257
  language: t.language,
179
- theme: i.theme === "light" ? "catppuccin-latte" : "catppuccin-mocha",
258
+ theme: l.theme === "light" ? "catppuccin-latte" : "catppuccin-mocha",
180
259
  model: a,
181
260
  editContext: !1,
182
261
  ...t.monacoOptions
183
- }), r = !0, i.editorStatus = "ready", i.hasContent = !!t.code.value, e.value.onDidChangeModelContent(() => {
184
- if (s) return;
185
- const u = e.value.getValue();
186
- i.hasContent = !!u.length, t.code.value = u;
187
- }), (k = t.onReady) == null || k.call(t, e.value), S();
262
+ }), i = !0, l.editorStatus = "ready", l.hasContent = !!t.code.value, j(
263
+ e.value,
264
+ e.value.onDidChangeModelContent(() => {
265
+ if (r) return;
266
+ const u = e.value.getValue();
267
+ l.hasContent = !!u.length, t.code.value = u;
268
+ })
269
+ ), (R = t.onReady) == null || R.call(t, e.value), C();
188
270
  try {
189
- const u = e.value.getContribution("editor.contrib.findController"), _ = u == null ? void 0 : u.getState();
190
- _ == null || _.onFindReplaceStateChange(() => {
191
- i.searchBoxIsRevealed = _.isRevealed;
192
- });
271
+ const u = e.value.getContribution("editor.contrib.findController"), M = u == null ? void 0 : u.getState();
272
+ j(
273
+ e.value,
274
+ M == null ? void 0 : M.onFindReplaceStateChange(() => {
275
+ l.searchBoxIsRevealed = M.isRevealed;
276
+ })
277
+ // This returns a disposable
278
+ );
193
279
  } catch (u) {
194
280
  console.error("useMonacoEditor: Failed to get the state of findController", u);
195
281
  }
196
- q(() => {
282
+ ae(() => {
197
283
  var u;
198
284
  (u = e.value) == null || u.dispose();
199
285
  });
@@ -202,50 +288,50 @@ function Se(o, t) {
202
288
  immediate: !0,
203
289
  flush: "post"
204
290
  });
205
- })(), I(t.code, (n) => {
206
- if (!e.value || !a || !r) return;
207
- const c = a.getValue();
208
- n !== c && (s = !0, e.value.executeEdits("external", [
291
+ })(), D(t.code, (n) => {
292
+ if (!e.value || !a || !i) return;
293
+ const d = a.getValue();
294
+ n !== d && (r = !0, e.value.executeEdits("external", [
209
295
  {
210
296
  range: a.getFullModelRange(),
211
297
  text: n
212
298
  }
213
- ]), e.value.pushUndoStop(), i.hasContent = !!n.length, s = !1);
214
- }), $(S), z(S), G(() => {
299
+ ]), e.value.pushUndoStop(), l.hasContent = !!n.length, r = !1);
300
+ }), ee(C), te(C), oe(() => {
215
301
  if (!e.value) return;
216
302
  const n = e.value.getModel();
217
303
  e.value.dispose(), n && n.dispose();
218
304
  }), {
219
305
  editor: e,
220
- editorStates: i,
221
- setContent: p,
222
- setReadOnly: d,
223
- focus: f,
224
- setLanguage: m,
225
- remeasureFonts: S,
226
- toggleSearchWidget: v,
227
- triggerKeyboardCommand: l
306
+ editorStates: l,
307
+ setContent: f,
308
+ setReadOnly: s,
309
+ focus: p,
310
+ setLanguage: g,
311
+ remeasureFonts: C,
312
+ toggleSearchWidget: h,
313
+ triggerKeyboardCommand: c
228
314
  };
229
315
  }
230
- const Ee = {
316
+ const Fe = {
231
317
  messages: {
232
318
  empty_message: "The editor is currently empty. Start typing to add content.",
233
319
  empty_title: "No content available",
234
320
  loading_message: "Please wait while the {type} content is loaded.",
235
321
  loading_title: "{type} editor"
236
322
  }
237
- }, _e = {
238
- editor: Ee
323
+ }, Re = {
324
+ editor: Fe
239
325
  };
240
- function be() {
241
- const o = ce("en-us", _e);
326
+ function We() {
327
+ const o = ye("en-us", Re);
242
328
  return {
243
329
  i18n: o,
244
- i18nT: ue(o)
330
+ i18nT: Se(o)
245
331
  // Translation component <i18n-t>
246
332
  };
247
333
  }
248
- const Me = /* @__PURE__ */ D({
334
+ const Be = /* @__PURE__ */ H({
249
335
  __name: "MonacoEditorStatusOverlay",
250
336
  props: {
251
337
  title: {},
@@ -254,35 +340,37 @@ const Me = /* @__PURE__ */ D({
254
340
  },
255
341
  setup(o) {
256
342
  return (t, e) => {
257
- const a = J("KEmptyState");
258
- return C(), M(a, {
343
+ const a = ne("KEmptyState");
344
+ return E(), _(a, {
259
345
  class: "monaco-editor-status-overlay",
260
346
  message: o.message,
261
347
  title: o.title
262
- }, Q({ _: 2 }, [
348
+ }, re({ _: 2 }, [
263
349
  o.icon ? {
264
350
  name: "icon",
265
- fn: x(() => [
266
- (C(), M(Y(o.icon), { decorative: "" }))
351
+ fn: L(() => [
352
+ (E(), _(se(o.icon), { decorative: "" }))
267
353
  ]),
268
354
  key: "0"
269
355
  } : void 0
270
356
  ]), 1032, ["message", "title"]);
271
357
  };
272
358
  }
273
- }), j = (o, t) => {
359
+ }), J = (o, t) => {
274
360
  const e = o.__vccOpts || o;
275
- for (const [a, r] of t)
276
- e[a] = r;
361
+ for (const [a, i] of t)
362
+ e[a] = i;
277
363
  return e;
278
- }, B = /* @__PURE__ */ j(Me, [["__scopeId", "data-v-062eadb5"]]), Oe = /* @__PURE__ */ D({
364
+ }, z = /* @__PURE__ */ J(Be, [["__scopeId", "data-v-062eadb5"]]), Ne = /* @__PURE__ */ H({
279
365
  __name: "MonacoEditor",
280
- props: /* @__PURE__ */ F({
366
+ props: /* @__PURE__ */ W({
281
367
  theme: { default: "light" },
282
368
  language: { default: "markdown" },
283
369
  loading: { type: Boolean, default: !1 },
284
370
  options: { default: () => {
285
- } }
371
+ } },
372
+ showLoadingState: { type: Boolean, default: !0 },
373
+ showEmptyState: { type: Boolean, default: !0 }
286
374
  }, {
287
375
  modelValue: {
288
376
  type: String,
@@ -290,66 +378,72 @@ const Me = /* @__PURE__ */ D({
290
378
  },
291
379
  modelModifiers: {}
292
380
  }),
293
- emits: /* @__PURE__ */ F(["ready"], ["update:modelValue"]),
381
+ emits: /* @__PURE__ */ W(["ready"], ["update:modelValue"]),
294
382
  setup(o, { expose: t, emit: e }) {
295
- const a = e, r = Z(o, "modelValue"), { i18n: s } = be(), i = X("editorRef"), p = T(() => o.theme === "dark" ? "dark" : "light"), d = T(() => m.editorStates.editorStatus === "loading" || o.loading), f = T(() => m.editorStates.editorStatus === "ready" && !m.editorStates.hasContent), m = Se(i, {
383
+ const a = e, i = ie(o, "modelValue"), { i18n: r } = We(), l = le("editorRef"), f = I(() => o.theme === "dark" ? "dark" : "light"), s = I(() => o.loading || g.editorStates.editorStatus === "loading"), p = I(() => !s.value && g.editorStates.editorStatus === "ready" && !g.editorStates.hasContent), g = Le(l, {
296
384
  language: o.language,
297
- code: r,
298
- theme: p.value,
385
+ code: i,
386
+ theme: f.value,
299
387
  monacoOptions: o.options,
300
- onReady: (l) => {
301
- a("ready", l);
388
+ onReady: (c) => {
389
+ a("ready", c);
302
390
  }
303
391
  });
304
392
  return t({
305
- monacoEditor: m
306
- }), I(() => o.language, (l, v) => {
307
- l !== v && m.setLanguage(l);
308
- }), (l, v) => (C(), ee("div", {
309
- class: te(["monaco-editor-container", [
310
- p.value,
311
- { loading: d.value }
393
+ monacoEditor: g
394
+ }), D(() => o.language, (c, h) => {
395
+ c !== h && g.setLanguage(c);
396
+ }), (c, h) => (E(), ce("div", {
397
+ class: de(["monaco-editor-container", [
398
+ f.value,
399
+ { loading: s.value }
312
400
  ]]),
313
401
  "data-testid": "monaco-editor-container"
314
402
  }, [
315
- oe("div", {
403
+ ue("div", {
316
404
  ref_key: "editorRef",
317
- ref: i,
405
+ ref: l,
318
406
  class: "monaco-editor-target",
319
407
  "data-testid": "monaco-editor-target"
320
408
  }, null, 512),
321
- R(l.$slots, "state-loading", { isLoading: d.value }, () => [
322
- w(L, { name: "fade" }, {
323
- default: x(() => [
324
- d.value ? (C(), M(B, {
409
+ o.showLoadingState ? B(c.$slots, "state-loading", {
410
+ key: 0,
411
+ isLoading: s.value
412
+ }, () => [
413
+ N(U, { name: "fade" }, {
414
+ default: L(() => [
415
+ s.value ? (E(), _(z, {
325
416
  key: 0,
326
417
  "data-testid": "monaco-editor-status-overlay-loading",
327
- icon: h(ae),
328
- message: h(s).t("editor.messages.loading_message", { type: o.language }),
329
- title: h(s).t("editor.messages.loading_title", { type: o.language })
330
- }, null, 8, ["icon", "message", "title"])) : W("", !0)
418
+ icon: v(ge),
419
+ message: v(r).t("editor.messages.loading_message", { type: o.language }),
420
+ title: v(r).t("editor.messages.loading_title", { type: o.language })
421
+ }, null, 8, ["icon", "message", "title"])) : k("", !0)
331
422
  ]),
332
423
  _: 1
333
424
  })
334
- ], !0),
335
- R(l.$slots, "state-empty", { isEmpty: f.value }, () => [
336
- w(L, { name: "fade" }, {
337
- default: x(() => [
338
- f.value && !d.value ? (C(), M(B, {
425
+ ], !0) : k("", !0),
426
+ o.showEmptyState ? B(c.$slots, "state-empty", {
427
+ key: 1,
428
+ isEmpty: p.value
429
+ }, () => [
430
+ N(U, { name: "fade" }, {
431
+ default: L(() => [
432
+ p.value ? (E(), _(z, {
339
433
  key: 0,
340
434
  "data-testid": "monaco-editor-status-overlay-empty",
341
- icon: h(ne),
342
- message: h(s).t("editor.messages.empty_message"),
343
- title: h(s).t("editor.messages.empty_title")
344
- }, null, 8, ["icon", "message", "title"])) : W("", !0)
435
+ icon: v(me),
436
+ message: v(r).t("editor.messages.empty_message"),
437
+ title: v(r).t("editor.messages.empty_title")
438
+ }, null, 8, ["icon", "message", "title"])) : k("", !0)
345
439
  ]),
346
440
  _: 1
347
441
  })
348
- ], !0)
442
+ ], !0) : k("", !0)
349
443
  ], 2));
350
444
  }
351
- }), we = /* @__PURE__ */ j(Oe, [["__scopeId", "data-v-e2083635"]]);
445
+ }), Ke = /* @__PURE__ */ J(Ne, [["__scopeId", "data-v-89d4c84e"]]);
352
446
  export {
353
- we as MonacoEditor,
354
- Se as useMonacoEditor
447
+ Ke as MonacoEditor,
448
+ Le as useMonacoEditor
355
449
  };
@@ -1 +1 @@
1
- (function(d,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@kong/icons"),require("monaco-editor"),require("@shikijs/monaco"),require("shiki"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","monaco-editor","@shikijs/monaco","shiki","@kong-ui-public/i18n"],e):(d=typeof globalThis<"u"?globalThis:d||self,e(d["kong-ui-public-monaco-editor"]={},d.Vue,d.KongIcons,d.monaco,d.monaco$1,d.shiki,d["kong-ui-public-i18n"]))})(this,function(d,e,k,L,R,O,I){"use strict";function U(o){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(n,t,a.get?a:{enumerable:!0,get:()=>o[t]})}}return n.default=o,Object.freeze(n)}const p=U(L),j=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 T=()=>{};function W(o,n){function t(...a){return new Promise((i,s)=>{Promise.resolve(o(()=>n.apply(this,a),{fn:n,thisArg:this,args:a})).then(i).catch(s)})}return t}function D(o,n={}){let t,a,i=T;const s=g=>{clearTimeout(g),i(),i=T};let l;return g=>{const h=e.toValue(o),f=e.toValue(n.maxWait);return t&&s(t),h<=0||f!==void 0&&f<=0?(a&&(s(a),a=void 0),Promise.resolve(g())):new Promise((c,y)=>{i=n.rejectOnCancel?y:c,l=g,f&&!a&&(a=setTimeout(()=>{t&&s(t),a=void 0,c(l())},f)),t=setTimeout(()=>{a&&s(a),a=void 0,c(g())},h)})}}function V(o,n=200,t={}){return W(D(n,t),o)}function x(o){var n;const t=e.toValue(o);return(n=t==null?void 0:t.$el)!==null&&n!==void 0?n:t}const v=e.ref(!1);let _=null;async function P(){return _||(_=(async()=>{var o,n;try{const t=((o=p.json)==null?void 0:o.jsonDefaults)||((n=p.languages.json)==null?void 0:n.jsonDefaults);t==null||t.setModeConfiguration({tokens:!1});const a=await O.getSingletonHighlighter({themes:Object.values(O.bundledThemes),langs:Object.values(O.bundledLanguages)});a.getLoadedLanguages().forEach(i=>{p.languages.register({id:i})}),R.shikiToMonaco(a,p),v.value=!0}catch(t){throw _=null,t}})(),_)}function w(o,n){const t=e.shallowRef();let a,i=!1,s=!1;const l=e.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:n.theme||"light"}),C=r=>{!i||!t.value||t.value.setValue(r)},g=r=>{var u;return(u=t.value)==null?void 0:u.updateOptions({readOnly:r})},h=()=>{var r;return(r=t.value)==null?void 0:r.focus()},f=r=>{var E;const u=(E=t.value)==null?void 0:E.getModel();u&&p.editor.setModelLanguage(u,r)},c=r=>{try{if(!t.value||!r)return;t.value.focus(),t.value.trigger("keyboard",r,null)}catch(u){console.error(`useMonacoEditor: Failed to trigger command: ${r}`,u)}},y=()=>{var r;try{if(!t.value)return;if(l.searchBoxIsRevealed)return(r=t.value.getContribution("editor.contrib.findController"))==null?void 0:r.closeFindWidget();c("actions.find")}catch(u){console.error("useMonacoEditor: Failed to close findController.",u)}},S=V(()=>p.editor.remeasureFonts(),200);return(()=>{P(),e.watch([v,()=>e.toValue(o)],([r,u],[,E])=>{var B;const b=x(u),$=x(E);if(!(b instanceof HTMLElement)||!r){i=!1;return}if(!(i&&$===b)){if(!a){const m=p.Uri.parse(`inmemory://model/${n.language}-${crypto.randomUUID()}`);a=p.editor.createModel(n.code.value,n.language,m)}t.value=p.editor.create(b,{...j,readOnly:n.readOnly||!1,language:n.language,theme:l.theme==="light"?"catppuccin-latte":"catppuccin-mocha",model:a,editContext:!1,...n.monacoOptions}),i=!0,l.editorStatus="ready",l.hasContent=!!n.code.value,t.value.onDidChangeModelContent(()=>{if(s)return;const m=t.value.getValue();l.hasContent=!!m.length,n.code.value=m}),(B=n.onReady)==null||B.call(n,t.value),S();try{const m=t.value.getContribution("editor.contrib.findController"),M=m==null?void 0:m.getState();M==null||M.onFindReplaceStateChange(()=>{l.searchBoxIsRevealed=M.isRevealed})}catch(m){console.error("useMonacoEditor: Failed to get the state of findController",m)}e.onWatcherCleanup(()=>{var m;(m=t.value)==null||m.dispose()})}},{immediate:!0,flush:"post"})})(),e.watch(n.code,r=>{if(!t.value||!a||!i)return;const u=a.getValue();r!==u&&(s=!0,t.value.executeEdits("external",[{range:a.getFullModelRange(),text:r}]),t.value.pushUndoStop(),l.hasContent=!!r.length,s=!1)}),e.onMounted(S),e.onActivated(S),e.onBeforeUnmount(()=>{if(!t.value)return;const r=t.value.getModel();t.value.dispose(),r&&r.dispose()}),{editor:t,editorStates:l,setContent:C,setReadOnly:g,focus:h,setLanguage:f,remeasureFonts:S,toggleSearchWidget:y,triggerKeyboardCommand:c}}const K={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 H(){const o=I.createI18n("en-us",K);return{i18n:o,i18nT:I.i18nTComponent(o)}}const q=e.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(o){return(n,t)=>{const a=e.resolveComponent("KEmptyState");return e.openBlock(),e.createBlock(a,{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"])}}}),F=(o,n)=>{const t=o.__vccOpts||o;for(const[a,i]of n)t[a]=i;return t},N=F(q,[["__scopeId","data-v-062eadb5"]]),A=F(e.defineComponent({__name:"MonacoEditor",props:e.mergeModels({theme:{default:"light"},language:{default:"markdown"},loading:{type:Boolean,default:!1},options:{default:()=>{}}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:e.mergeModels(["ready"],["update:modelValue"]),setup(o,{expose:n,emit:t}){const a=t,i=e.useModel(o,"modelValue"),{i18n:s}=H(),l=e.useTemplateRef("editorRef"),C=e.computed(()=>o.theme==="dark"?"dark":"light"),g=e.computed(()=>f.editorStates.editorStatus==="loading"||o.loading),h=e.computed(()=>f.editorStates.editorStatus==="ready"&&!f.editorStates.hasContent),f=w(l,{language:o.language,code:i,theme:C.value,monacoOptions:o.options,onReady:c=>{a("ready",c)}});return n({monacoEditor:f}),e.watch(()=>o.language,(c,y)=>{c!==y&&f.setLanguage(c)}),(c,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["monaco-editor-container",[C.value,{loading:g.value}]]),"data-testid":"monaco-editor-container"},[e.createElementVNode("div",{ref_key:"editorRef",ref:l,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),e.renderSlot(c.$slots,"state-loading",{isLoading:g.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[g.value?(e.openBlock(),e.createBlock(N,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:e.unref(k.ProgressIcon),message:e.unref(s).t("editor.messages.loading_message",{type:o.language}),title:e.unref(s).t("editor.messages.loading_title",{type:o.language})},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0),e.renderSlot(c.$slots,"state-empty",{isEmpty:h.value},()=>[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[h.value&&!g.value?(e.openBlock(),e.createBlock(N,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:e.unref(k.CodeblockIcon),message:e.unref(s).t("editor.messages.empty_message"),title:e.unref(s).t("editor.messages.empty_title")},null,8,["icon","message","title"])):e.createCommentVNode("",!0)]),_:1})],!0)],2))}}),[["__scopeId","data-v-e2083635"]]);d.MonacoEditor=A,d.useMonacoEditor=w,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
1
+ (function(u,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue"),require("@kong/icons"),require("monaco-editor"),require("@shikijs/monaco"),require("shiki"),require("@kong-ui-public/i18n")):typeof define=="function"&&define.amd?define(["exports","vue","@kong/icons","monaco-editor","@shikijs/monaco","shiki","@kong-ui-public/i18n"],n):(u=typeof globalThis<"u"?globalThis:u||self,n(u["kong-ui-public-monaco-editor"]={},u.Vue,u.KongIcons,u.monaco,u.monaco$1,u.shiki,u["kong-ui-public-i18n"]))})(this,function(u,n,D,$,A,w,x){"use strict";function H(o){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const e in o)if(e!=="default"){const a=Object.getOwnPropertyDescriptor(o,e);Object.defineProperty(t,e,a.get?a:{enumerable:!0,get:()=>o[e]})}}return t.default=o,Object.freeze(t)}const p=H($),q=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 v=()=>{};function z(o,t){function e(...a){return new Promise((l,i)=>{Promise.resolve(o(()=>t.apply(this,a),{fn:t,thisArg:this,args:a})).then(l).catch(i)})}return e}function G(o,t={}){let e,a,l=v;const i=s=>{clearTimeout(s),l(),l=v};let c;return s=>{const y=n.toValue(o),m=n.toValue(t.maxWait);return e&&i(e),y<=0||m!==void 0&&m<=0?(a&&(i(a),a=void 0),Promise.resolve(s())):new Promise((d,b)=>{l=t.rejectOnCancel?b:d,c=s,m&&!a&&(a=setTimeout(()=>{e&&i(e),a=void 0,d(c())},m)),e=setTimeout(()=>{a&&i(a),a=void 0,d(s())},y)})}}function Y(o,t=200,e={}){return z(G(t,e),o)}function F(o){var t;const e=n.toValue(o);return(t=e==null?void 0:e.$el)!==null&&t!==void 0?t:e}const O="[monaco-editor] [lifecycle]",S=new WeakMap,k=new Map,I=new WeakMap;function Z(o){let t=S.get(o.source);if(!t){let e;switch(o.type){case"editor":e=o.source.onDidDispose(()=>R(o.source));break;case"model":e=o.source.onWillDispose(()=>R(o.source));break;default:throw new Error(`${O} Unknown scope: ${o}`)}t={disposables:new Set,scopeListener:e},S.set(o.source,t)}return t}function L(o){const t=S.get(o);t&&(t.scopeListener.dispose(),S.delete(o))}function N(o,t){Z(t).disposables.add(o)}function B(o,t){const e=S.get(t.source);e&&(e.disposables.delete(o),e.disposables.size===0&&L(t.source))}function J(o){const t=[];if(o.forEach(e=>{try{e.dispose()}catch(a){t.push(a)}}),t.length)throw new AggregateError(t,`${O} One or more disposables threw while being disposed.`)}function Q(o,t){var c,h;let e=o,a=k.get(e);if(!a){const s=I.get(o);s&&(e=s,a=k.get(s))}if(a)return((c=a.scope)==null?void 0:c.type)===(t==null?void 0:t.type)&&((h=a.scope)==null?void 0:h.source)===(t==null?void 0:t.source)||(a.scope&&B(a.decorated,a.scope),t?(N(a.decorated,t),a.scope=t):a.scope=void 0),a.decorated;const l=e.dispose,i={dispose:()=>{const s=k.get(e);if(s)return s.scope&&B(i,s.scope),k.delete(e),I.delete(i),l.call(e)}};return k.set(e,{decorated:i,scope:t}),I.set(i,e),t&&N(i,t),i}function W(o,t){return Q(t,{type:"editor",source:o})}function R(o){const t=S.get(o);if(!t)return;const e=Array.from(t.disposables);try{J(e)}catch(a){console.warn(`${O} Encountered errors while disposing scoped disposables:`,a,", Source:",o)}L(o)}const U=n.ref(!1);let E=null;async function X(){return E||(E=(async()=>{var o,t;try{const e=((o=p.json)==null?void 0:o.jsonDefaults)||((t=p.languages.json)==null?void 0:t.jsonDefaults);e==null||e.setModeConfiguration({tokens:!1});const a=await w.getSingletonHighlighter({themes:Object.values(w.bundledThemes),langs:Object.values(w.bundledLanguages)});a.getLoadedLanguages().forEach(l=>{p.languages.register({id:l})}),A.shikiToMonaco(a,p),U.value=!0}catch(e){throw E=null,e}})(),E)}function V(o,t){const e=n.shallowRef();let a,l=!1,i=!1;const c=n.reactive({editorStatus:"loading",searchBoxIsRevealed:!1,hasContent:!1,theme:t.theme||"light"}),h=r=>{!l||!e.value||e.value.setValue(r)},s=r=>{var f;return(f=e.value)==null?void 0:f.updateOptions({readOnly:r})},y=()=>{var r;return(r=e.value)==null?void 0:r.focus()},m=r=>{var C;const f=(C=e.value)==null?void 0:C.getModel();f&&p.editor.setModelLanguage(f,r)},d=r=>{try{if(!e.value||!r)return;e.value.focus(),e.value.trigger("keyboard",r,null)}catch(f){console.error(`useMonacoEditor: Failed to trigger command: ${r}`,f)}},b=()=>{var r;try{if(!e.value)return;if(c.searchBoxIsRevealed)return(r=e.value.getContribution("editor.contrib.findController"))==null?void 0:r.closeFindWidget();d("actions.find")}catch(f){console.error("useMonacoEditor: Failed to close findController.",f)}},_=Y(()=>p.editor.remeasureFonts(),200);return(()=>{X(),n.watch([U,()=>n.toValue(o)],([r,f],[,C])=>{var K;const T=F(f),ae=F(C);if(!(T instanceof HTMLElement)||!r){l=!1;return}if(!(l&&ae===T)){if(!a){const g=p.Uri.parse(`inmemory://model/${t.language}-${crypto.randomUUID()}`);a=p.editor.createModel(t.code.value,t.language,g)}e.value=p.editor.create(T,{...q,readOnly:t.readOnly||!1,language:t.language,theme:c.theme==="light"?"catppuccin-latte":"catppuccin-mocha",model:a,editContext:!1,...t.monacoOptions}),l=!0,c.editorStatus="ready",c.hasContent=!!t.code.value,W(e.value,e.value.onDidChangeModelContent(()=>{if(i)return;const g=e.value.getValue();c.hasContent=!!g.length,t.code.value=g})),(K=t.onReady)==null||K.call(t,e.value),_();try{const g=e.value.getContribution("editor.contrib.findController"),M=g==null?void 0:g.getState();W(e.value,M==null?void 0:M.onFindReplaceStateChange(()=>{c.searchBoxIsRevealed=M.isRevealed}))}catch(g){console.error("useMonacoEditor: Failed to get the state of findController",g)}n.onWatcherCleanup(()=>{var g;(g=e.value)==null||g.dispose()})}},{immediate:!0,flush:"post"})})(),n.watch(t.code,r=>{if(!e.value||!a||!l)return;const f=a.getValue();r!==f&&(i=!0,e.value.executeEdits("external",[{range:a.getFullModelRange(),text:r}]),e.value.pushUndoStop(),c.hasContent=!!r.length,i=!1)}),n.onMounted(_),n.onActivated(_),n.onBeforeUnmount(()=>{if(!e.value)return;const r=e.value.getModel();e.value.dispose(),r&&r.dispose()}),{editor:e,editorStates:c,setContent:h,setReadOnly:s,focus:y,setLanguage:m,remeasureFonts:_,toggleSearchWidget:b,triggerKeyboardCommand:d}}const ee={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 te(){const o=x.createI18n("en-us",ee);return{i18n:o,i18nT:x.i18nTComponent(o)}}const oe=n.defineComponent({__name:"MonacoEditorStatusOverlay",props:{title:{},message:{},icon:{}},setup(o){return(t,e)=>{const a=n.resolveComponent("KEmptyState");return n.openBlock(),n.createBlock(a,{class:"monaco-editor-status-overlay",message:o.message,title:o.title},n.createSlots({_:2},[o.icon?{name:"icon",fn:n.withCtx(()=>[(n.openBlock(),n.createBlock(n.resolveDynamicComponent(o.icon),{decorative:""}))]),key:"0"}:void 0]),1032,["message","title"])}}}),j=(o,t)=>{const e=o.__vccOpts||o;for(const[a,l]of t)e[a]=l;return e},P=j(oe,[["__scopeId","data-v-062eadb5"]]),ne=j(n.defineComponent({__name:"MonacoEditor",props:n.mergeModels({theme:{default:"light"},language:{default:"markdown"},loading:{type:Boolean,default:!1},options:{default:()=>{}},showLoadingState:{type:Boolean,default:!0},showEmptyState:{type:Boolean,default:!0}},{modelValue:{type:String,required:!0},modelModifiers:{}}),emits:n.mergeModels(["ready"],["update:modelValue"]),setup(o,{expose:t,emit:e}){const a=e,l=n.useModel(o,"modelValue"),{i18n:i}=te(),c=n.useTemplateRef("editorRef"),h=n.computed(()=>o.theme==="dark"?"dark":"light"),s=n.computed(()=>o.loading||m.editorStates.editorStatus==="loading"),y=n.computed(()=>!s.value&&m.editorStates.editorStatus==="ready"&&!m.editorStates.hasContent),m=V(c,{language:o.language,code:l,theme:h.value,monacoOptions:o.options,onReady:d=>{a("ready",d)}});return t({monacoEditor:m}),n.watch(()=>o.language,(d,b)=>{d!==b&&m.setLanguage(d)}),(d,b)=>(n.openBlock(),n.createElementBlock("div",{class:n.normalizeClass(["monaco-editor-container",[h.value,{loading:s.value}]]),"data-testid":"monaco-editor-container"},[n.createElementVNode("div",{ref_key:"editorRef",ref:c,class:"monaco-editor-target","data-testid":"monaco-editor-target"},null,512),o.showLoadingState?n.renderSlot(d.$slots,"state-loading",{key:0,isLoading:s.value},()=>[n.createVNode(n.Transition,{name:"fade"},{default:n.withCtx(()=>[s.value?(n.openBlock(),n.createBlock(P,{key:0,"data-testid":"monaco-editor-status-overlay-loading",icon:n.unref(D.ProgressIcon),message:n.unref(i).t("editor.messages.loading_message",{type:o.language}),title:n.unref(i).t("editor.messages.loading_title",{type:o.language})},null,8,["icon","message","title"])):n.createCommentVNode("",!0)]),_:1})],!0):n.createCommentVNode("",!0),o.showEmptyState?n.renderSlot(d.$slots,"state-empty",{key:1,isEmpty:y.value},()=>[n.createVNode(n.Transition,{name:"fade"},{default:n.withCtx(()=>[y.value?(n.openBlock(),n.createBlock(P,{key:0,"data-testid":"monaco-editor-status-overlay-empty",icon:n.unref(D.CodeblockIcon),message:n.unref(i).t("editor.messages.empty_message"),title:n.unref(i).t("editor.messages.empty_title")},null,8,["icon","message","title"])):n.createCommentVNode("",!0)]),_:1})],!0):n.createCommentVNode("",!0)],2))}}),[["__scopeId","data-v-89d4c84e"]]);u.MonacoEditor=ne,u.useMonacoEditor=V,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
@@ -1 +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-e2083635]{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-e2083635]{pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-container.loading .monaco-editor-target[data-v-e2083635]{filter:blur(2px);opacity:0;pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-target[data-v-e2083635]{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-e2083635] .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-e2083635] .monaco-editor .sticky-widget{z-index:2}.monaco-editor-target[data-v-e2083635] .monaco-editor .suggest-details-container{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important}.monaco-editor-target[data-v-e2083635] .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-e2083635] .monaco-editor .suggest-details-container .suggest-details .type{overflow-wrap:break-word!important}.monaco-editor-target[data-v-e2083635] .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-e2083635] .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-e2083635] .monaco-editor .suggest-widget .tree,.monaco-editor-target[data-v-e2083635] .monaco-editor .suggest-widget .monaco-scrollable-element,.monaco-editor-target[data-v-e2083635] .monaco-editor .suggest-widget .monaco-list,.monaco-editor-target[data-v-e2083635] .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-e2083635] .monaco-editor .suggest-widget .monaco-list-rows{overflow-x:hidden;overflow-y:auto}.monaco-editor-target[data-v-e2083635] .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-e2083635] .monaco-editor .suggest-widget .monaco-list-row.focused{background:#e0e4ea;background:var(--kui-color-background-neutral-weaker, #e0e4ea)}.monaco-editor-target[data-v-e2083635] .monaco-editor .suggest-widget .monaco-list-row.focused .monaco-icon-label,.monaco-editor-target[data-v-e2083635] .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-e2083635] .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-e2083635] .monaco-editor .suggest-widget .monaco-list-row .highlight{font-weight:600;font-weight:var(--kui-font-weight-semibold, 600)}.monaco-editor-target[data-v-e2083635] .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-e2083635] .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-e2083635] .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-e2083635] .monaco-editor .codicon-suggest-more-info{transform:translateY(2px)!important}.monaco-editor-target[data-v-e2083635] .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-e2083635] .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-e2083635] .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-e2083635],.fade-leave-active[data-v-e2083635]{transition:opacity .2s ease;transition:opacity var(--kui-animation-duration-20, .2s) ease}.fade-enter-from[data-v-e2083635],.fade-leave-to[data-v-e2083635]{opacity:0}.fade-enter-to[data-v-e2083635],.fade-leave-from[data-v-e2083635]{opacity: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-89d4c84e]{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-89d4c84e]{pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-container.loading .monaco-editor-target[data-v-89d4c84e]{opacity:0;pointer-events:none;-webkit-user-select:none;user-select:none}.monaco-editor-target[data-v-89d4c84e]{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-89d4c84e] .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-89d4c84e] .monaco-editor .sticky-widget{z-index:2}.monaco-editor-target[data-v-89d4c84e] .monaco-editor .suggest-details-container{border-radius:10px!important;border-radius:var(--kui-border-radius-50, 10px)!important}.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .monaco-editor .suggest-details-container .suggest-details .type{overflow-wrap:break-word!important}.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .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-89d4c84e] .monaco-editor .suggest-widget .tree,.monaco-editor-target[data-v-89d4c84e] .monaco-editor .suggest-widget .monaco-scrollable-element,.monaco-editor-target[data-v-89d4c84e] .monaco-editor .suggest-widget .monaco-list,.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .monaco-editor .suggest-widget .monaco-list-rows{overflow-x:hidden;overflow-y:auto}.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .monaco-editor .suggest-widget .monaco-list-row.focused{background:#e0e4ea;background:var(--kui-color-background-neutral-weaker, #e0e4ea)}.monaco-editor-target[data-v-89d4c84e] .monaco-editor .suggest-widget .monaco-list-row.focused .monaco-icon-label,.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .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-89d4c84e] .monaco-editor .suggest-widget .monaco-list-row .highlight{font-weight:600;font-weight:var(--kui-font-weight-semibold, 600)}.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .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-89d4c84e] .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-89d4c84e] .monaco-editor .codicon-suggest-more-info{transform:translateY(2px)!important}.monaco-editor-target[data-v-89d4c84e] .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-89d4c84e] .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-89d4c84e] .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-89d4c84e],.fade-leave-active[data-v-89d4c84e]{transition:opacity .2s ease;transition:opacity var(--kui-animation-duration-20, .2s) ease}.fade-enter-from[data-v-89d4c84e],.fade-leave-to[data-v-89d4c84e]{opacity:0}.fade-enter-to[data-v-89d4c84e],.fade-leave-from[data-v-89d4c84e]{opacity:1}
@@ -21,6 +21,16 @@ type __VLS_Props = {
21
21
  * @default undefined
22
22
  */
23
23
  options?: Partial<editor.IStandaloneEditorConstructionOptions> | undefined;
24
+ /**
25
+ * Whether to show the loading state overlay.
26
+ * @default true
27
+ */
28
+ showLoadingState?: boolean;
29
+ /**
30
+ * Whether to show the empty state overlay.
31
+ * @default true
32
+ */
33
+ showEmptyState?: boolean;
24
34
  };
25
35
  /**
26
36
  * The model content for the Monaco Editor.
@@ -1 +1 @@
1
- {"version":3,"file":"MonacoEditor.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/MonacoEditor.vue"],"names":[],"mappings":"AA6UA,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;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;MAGE;IACF,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,GAAG,SAAS,CAAA;CAC3E,CAAC;AAkBF;;GAEG;AACH,QAAA,MAAM,KAAK,wDAGT,CAAA;AAsCF,KAAK,gBAAgB,GAAG;IACxB;;OAEG;IACH,UAAU,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAKF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AA+IxD,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;AAOtD,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;kFAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
1
+ {"version":3,"file":"MonacoEditor.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/MonacoEditor.vue"],"names":[],"mappings":"AA8VA,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;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;MAGE;IACF,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oCAAoC,CAAC,GAAG,SAAS,CAAA;IAC1E;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;AAoBF;;GAEG;AACH,QAAA,MAAM,KAAK,wDAGT,CAAA;AA0CF,KAAK,gBAAgB,GAAG;IACxB;;OAEG;IACH,UAAU,EAAE,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAKF,KAAK,iBAAiB,GAAG,WAAW,GAAG,gBAAgB,CAAC;AAmJxD,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;AAOtD,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;kFAId,CAAC;AACH,QAAA,MAAM,YAAY,EAAS,eAAe,CAAC,OAAO,UAAU,EAAE,WAAW,CAAC,CAAC;wBACtD,OAAO,YAAY;AAAxC,wBAAyC;AACzC,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1 +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;AAyC1E;;;;;EAKE;AACF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB;;;;;;;;0BA2BF,MAAM,KAAG,IAAI;4BAOX,OAAO,KAAG,IAAI;iBAG3B,IAAI;4BAES,MAAM,KAAG,IAAI;;8BAuBb,IAAI;iCAXC,MAAM,KAAG,IAAI;EAyKlD"}
1
+ {"version":3,"file":"useMonacoEditor.d.ts","sourceRoot":"","sources":["../../../../src/composables/useMonacoEditor.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAKvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACzE,OAAO,KAAK,EAAsB,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAyC1E;;;;;EAKE;AACF,wBAAgB,eAAe,CAAC,CAAC,SAAS,YAAY,EACpD,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,EAClC,OAAO,EAAE,sBAAsB;;;;;;;;0BA2BF,MAAM,KAAG,IAAI;4BAOX,OAAO,KAAG,IAAI;iBAG3B,IAAI;4BAES,MAAM,KAAG,IAAI;;8BAuBb,IAAI;iCAXC,MAAM,KAAG,IAAI;EA6KlD"}
@@ -1,21 +1,19 @@
1
1
  /**
2
2
  * Lifecycle tracker for {@link IDisposable disposables} in Monaco Editor.
3
3
  *
4
- * Although it's usually okay to register listeners on a model/editor without manually
5
- * calling `.dispose()` before or after disposing the model/editor itself, which may
6
- * also apply to other disposables, as long as the scope they are attached to correctly
7
- * disposes them (though such bugs once existed in Monaco Editor), it's still a good
8
- * practice to dispose when a resource is no longer needed.
4
+ * In Monaco Editor, when attaching listeners in the global scope (e.g.,
5
+ * {@link Editor.onDidCreateModel onDidCreateModel}) or in the per-resource scope
6
+ * (e.g.,{@link Editor.ITextModel.onDidChangeContent onDidChangeContent}), an
7
+ * {@link IDisposable disposable} is always returned to allow detaching the listener.
9
8
  *
10
- * > Many Monaco related objects often implement the `.dispose()` method. This method
11
- * > is intended to perform cleanups when a resource is no longer needed. For example,
12
- * > calling `model.dispose()` will unregister it, freeing up the URI for a new model.
13
- * > Editors should be disposed to free up resources and remove their model listeners.
14
- * > (from https://github.com/microsoft/monaco-editor/blob/de983bf5d7efbd36622f44bc0e44097a0531a58c/README.md#disposables)
9
+ * However, per-resource-scoped disposables are not automatically disposed when
10
+ * the resource is disposed. This can lead to memory leaks if the disposables are
11
+ * not properly tracked and disposed.
15
12
  *
16
- * This tracker is designed to be a singleton to track disposables in different scopes.
13
+ * This tracker is designed to be a singleton to track disposables in all the scopes
14
+ * mentioned above.
17
15
  */
18
- import type { editor as Editor, IDisposable } from 'monaco-editor';
16
+ import { type editor as Editor, type IDisposable } from 'monaco-editor';
19
17
  /**
20
18
  * A type friendly representation of a scope.
21
19
  */
@@ -33,8 +31,8 @@ type ScopeSource = Editor.ICodeEditor | Editor.ITextModel;
33
31
  /**
34
32
  * Track a disposable in an optional scope.
35
33
  *
36
- * **NOTE**: It's not recommended to call {@link IDisposable.dispose dispose} on the
37
- * original disposable being passed in after being tracked.
34
+ * **WARNING**: Should not call {@link IDisposable.dispose dispose} on the
35
+ * disposable being passed in. Otherwise, the tracking will be broken.
38
36
  *
39
37
  * @param disposable - The disposable to track. When passing a decorated disposable,
40
38
  * the **SAME** decorated disposable will be **UPDATED** (if scope changes)
@@ -44,42 +42,38 @@ type ScopeSource = Editor.ICodeEditor | Editor.ITextModel;
44
42
  *
45
43
  * @returns A decorated disposable to dispose the disposable and untrack it.
46
44
  */
47
- export declare function trackDisposable(disposable: IDisposable, scope?: Scope): IDisposable;
45
+ export declare function track(disposable: IDisposable, scope?: Scope): IDisposable;
48
46
  /**
49
47
  * Track a disposable for an {@link Editor.ICodeEditor editor}.
50
48
  *
51
49
  * The tracker uses {@link Editor.ICodeEditor.onDidDispose onDidDispose} to dispose
52
- * the tracked disposable automatically upon editor disposal.
50
+ * the tracked disposable.
53
51
  *
54
52
  * @param editor - The editor to track
55
53
  * @param disposable - The disposable to track
56
54
  * @returns A decorated disposable to dispose the disposable and untrack it.
57
55
  */
58
- export declare function trackDisposableForEditor(editor: Editor.ICodeEditor, disposable: IDisposable): IDisposable;
56
+ export declare function trackForEditor(editor: Editor.ICodeEditor, disposable: IDisposable): IDisposable;
59
57
  /**
60
58
  * Track a disposable for a {@link Editor.ITextModel text model}.
61
59
  *
62
60
  * The tracker uses {@link Editor.ITextModel.onWillDispose onWillDispose} to dispose
63
- * the tracked disposable automatically upon model disposal.
61
+ * the tracked disposable.
64
62
  *
65
63
  * @param model - The text model to track
66
64
  * @param disposable - The disposable to track
67
65
  * @returns A decorated disposable to dispose the disposable and untrack it.
68
66
  */
69
- export declare function trackDisposableForModel(model: Editor.ITextModel, disposable: IDisposable): IDisposable;
67
+ export declare function trackForModel(model: Editor.ITextModel, disposable: IDisposable): IDisposable;
70
68
  /**
71
69
  * Dispose all tracked disposables in a scope.
72
70
  *
73
71
  * @param source - The scope source whose tracked disposables to dispose.
74
72
  */
75
- export declare function disposeScopedDisposables(source: ScopeSource): void;
76
- /**
77
- * Dispose all globally tracked disposables.
78
- */
79
- export declare function disposeGlobalDisposables(): void;
73
+ export declare function disposeScoped(source: ScopeSource): void;
80
74
  /**
81
75
  * Dispose all tracked disposables.
82
76
  */
83
- export declare function disposeAllDisposables(): void;
77
+ export declare function disposeAll(): void;
84
78
  export {};
85
79
  //# sourceMappingURL=lifecycle.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/singletons/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAIlE;;GAEG;AACH,KAAK,KAAK,GACN;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,CAAA;AAEhD;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAA;AAuHzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,WAAW,CAgEnF;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,GAAG,WAAW,CAEzG;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,WAAW,CAEtG;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAUlE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAU/C;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAW5C"}
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/singletons/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,MAAM,IAAI,MAAM,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAA;AAIvE;;GAEG;AACH,KAAK,KAAK,GACN;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,CAAA;AAEhD;;GAEG;AACH,KAAK,WAAW,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAA;AAsHzD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,WAAW,CA0DzE;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,GAAG,WAAW,CAE/F;AAED;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,WAAW,CAE5F;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAWvD;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAQjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kong-ui-public/monaco-editor",
3
- "version": "0.8.1-pr.2799.4a7245eab.0",
3
+ "version": "0.8.1-pr.2808.079ab5d08.0",
4
4
  "type": "module",
5
5
  "description": "A kong UI Monaco Editor wrapper for Vue 3 with syntax highlighting powered by Shiki.",
6
6
  "main": "./dist/runtime/monaco-editor.umd.js",