@object-ui/plugin-editor 0.3.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/CHANGELOG.md +48 -0
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/MonacoImpl-BSiaJCGx.js +575 -0
- package/dist/index-Bx39x2XN.js +657 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.umd.cjs +25 -0
- package/dist/src/MonacoImpl.d.ts +14 -0
- package/dist/src/index.d.ts +25 -0
- package/dist/src/index.test.d.ts +1 -0
- package/dist/src/types.d.ts +49 -0
- package/package.json +42 -0
- package/src/MonacoImpl.tsx +45 -0
- package/src/index.test.ts +90 -0
- package/src/index.tsx +75 -0
- package/src/types.ts +63 -0
- package/tsconfig.json +17 -0
- package/vite.config.ts +38 -0
- package/vite.config.ts.timestamp-1768467704562-21cdd04a7c5ed.mjs +43 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
import { j as ae } from "./index-Bx39x2XN.js";
|
|
2
|
+
import L, { memo as ne, useState as F, useRef as g, useCallback as re, useEffect as j } from "react";
|
|
3
|
+
function ue(e, t) {
|
|
4
|
+
(t == null || t > e.length) && (t = e.length);
|
|
5
|
+
for (var r = 0, n = Array(t); r < t; r++) n[r] = e[r];
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
function je(e) {
|
|
9
|
+
if (Array.isArray(e)) return e;
|
|
10
|
+
}
|
|
11
|
+
function Me(e, t, r) {
|
|
12
|
+
return (t = Ce(t)) in e ? Object.defineProperty(e, t, {
|
|
13
|
+
value: r,
|
|
14
|
+
enumerable: !0,
|
|
15
|
+
configurable: !0,
|
|
16
|
+
writable: !0
|
|
17
|
+
}) : e[t] = r, e;
|
|
18
|
+
}
|
|
19
|
+
function Pe(e, t) {
|
|
20
|
+
var r = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
|
|
21
|
+
if (r != null) {
|
|
22
|
+
var n, o, i, a, l = [], s = !0, d = !1;
|
|
23
|
+
try {
|
|
24
|
+
if (i = (r = r.call(e)).next, t !== 0) for (; !(s = (n = i.call(r)).done) && (l.push(n.value), l.length !== t); s = !0) ;
|
|
25
|
+
} catch (M) {
|
|
26
|
+
d = !0, o = M;
|
|
27
|
+
} finally {
|
|
28
|
+
try {
|
|
29
|
+
if (!s && r.return != null && (a = r.return(), Object(a) !== a)) return;
|
|
30
|
+
} finally {
|
|
31
|
+
if (d) throw o;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return l;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function Se() {
|
|
38
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
39
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
40
|
+
}
|
|
41
|
+
function ce(e, t) {
|
|
42
|
+
var r = Object.keys(e);
|
|
43
|
+
if (Object.getOwnPropertySymbols) {
|
|
44
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
45
|
+
t && (n = n.filter(function(o) {
|
|
46
|
+
return Object.getOwnPropertyDescriptor(e, o).enumerable;
|
|
47
|
+
})), r.push.apply(r, n);
|
|
48
|
+
}
|
|
49
|
+
return r;
|
|
50
|
+
}
|
|
51
|
+
function le(e) {
|
|
52
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
53
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
54
|
+
t % 2 ? ce(Object(r), !0).forEach(function(n) {
|
|
55
|
+
Me(e, n, r[n]);
|
|
56
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : ce(Object(r)).forEach(function(n) {
|
|
57
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return e;
|
|
61
|
+
}
|
|
62
|
+
function Ee(e, t) {
|
|
63
|
+
if (e == null) return {};
|
|
64
|
+
var r, n, o = Ie(e, t);
|
|
65
|
+
if (Object.getOwnPropertySymbols) {
|
|
66
|
+
var i = Object.getOwnPropertySymbols(e);
|
|
67
|
+
for (n = 0; n < i.length; n++) r = i[n], t.indexOf(r) === -1 && {}.propertyIsEnumerable.call(e, r) && (o[r] = e[r]);
|
|
68
|
+
}
|
|
69
|
+
return o;
|
|
70
|
+
}
|
|
71
|
+
function Ie(e, t) {
|
|
72
|
+
if (e == null) return {};
|
|
73
|
+
var r = {};
|
|
74
|
+
for (var n in e) if ({}.hasOwnProperty.call(e, n)) {
|
|
75
|
+
if (t.indexOf(n) !== -1) continue;
|
|
76
|
+
r[n] = e[n];
|
|
77
|
+
}
|
|
78
|
+
return r;
|
|
79
|
+
}
|
|
80
|
+
function Le(e, t) {
|
|
81
|
+
return je(e) || Pe(e, t) || Ae(e, t) || Se();
|
|
82
|
+
}
|
|
83
|
+
function Te(e, t) {
|
|
84
|
+
if (typeof e != "object" || !e) return e;
|
|
85
|
+
var r = e[Symbol.toPrimitive];
|
|
86
|
+
if (r !== void 0) {
|
|
87
|
+
var n = r.call(e, t);
|
|
88
|
+
if (typeof n != "object") return n;
|
|
89
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
90
|
+
}
|
|
91
|
+
return (t === "string" ? String : Number)(e);
|
|
92
|
+
}
|
|
93
|
+
function Ce(e) {
|
|
94
|
+
var t = Te(e, "string");
|
|
95
|
+
return typeof t == "symbol" ? t : t + "";
|
|
96
|
+
}
|
|
97
|
+
function Ae(e, t) {
|
|
98
|
+
if (e) {
|
|
99
|
+
if (typeof e == "string") return ue(e, t);
|
|
100
|
+
var r = {}.toString.call(e).slice(8, -1);
|
|
101
|
+
return r === "Object" && e.constructor && (r = e.constructor.name), r === "Map" || r === "Set" ? Array.from(e) : r === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? ue(e, t) : void 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function xe(e, t, r) {
|
|
105
|
+
return t in e ? Object.defineProperty(e, t, {
|
|
106
|
+
value: r,
|
|
107
|
+
enumerable: !0,
|
|
108
|
+
configurable: !0,
|
|
109
|
+
writable: !0
|
|
110
|
+
}) : e[t] = r, e;
|
|
111
|
+
}
|
|
112
|
+
function se(e, t) {
|
|
113
|
+
var r = Object.keys(e);
|
|
114
|
+
if (Object.getOwnPropertySymbols) {
|
|
115
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
116
|
+
t && (n = n.filter(function(o) {
|
|
117
|
+
return Object.getOwnPropertyDescriptor(e, o).enumerable;
|
|
118
|
+
})), r.push.apply(r, n);
|
|
119
|
+
}
|
|
120
|
+
return r;
|
|
121
|
+
}
|
|
122
|
+
function fe(e) {
|
|
123
|
+
for (var t = 1; t < arguments.length; t++) {
|
|
124
|
+
var r = arguments[t] != null ? arguments[t] : {};
|
|
125
|
+
t % 2 ? se(Object(r), !0).forEach(function(n) {
|
|
126
|
+
xe(e, n, r[n]);
|
|
127
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : se(Object(r)).forEach(function(n) {
|
|
128
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
return e;
|
|
132
|
+
}
|
|
133
|
+
function $e() {
|
|
134
|
+
for (var e = arguments.length, t = new Array(e), r = 0; r < e; r++)
|
|
135
|
+
t[r] = arguments[r];
|
|
136
|
+
return function(n) {
|
|
137
|
+
return t.reduceRight(function(o, i) {
|
|
138
|
+
return i(o);
|
|
139
|
+
}, n);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function $(e) {
|
|
143
|
+
return function t() {
|
|
144
|
+
for (var r = this, n = arguments.length, o = new Array(n), i = 0; i < n; i++)
|
|
145
|
+
o[i] = arguments[i];
|
|
146
|
+
return o.length >= e.length ? e.apply(this, o) : function() {
|
|
147
|
+
for (var a = arguments.length, l = new Array(a), s = 0; s < a; s++)
|
|
148
|
+
l[s] = arguments[s];
|
|
149
|
+
return t.apply(r, [].concat(o, l));
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function H(e) {
|
|
154
|
+
return {}.toString.call(e).includes("Object");
|
|
155
|
+
}
|
|
156
|
+
function De(e) {
|
|
157
|
+
return !Object.keys(e).length;
|
|
158
|
+
}
|
|
159
|
+
function R(e) {
|
|
160
|
+
return typeof e == "function";
|
|
161
|
+
}
|
|
162
|
+
function Re(e, t) {
|
|
163
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
164
|
+
}
|
|
165
|
+
function Ve(e, t) {
|
|
166
|
+
return H(t) || S("changeType"), Object.keys(t).some(function(r) {
|
|
167
|
+
return !Re(e, r);
|
|
168
|
+
}) && S("changeField"), t;
|
|
169
|
+
}
|
|
170
|
+
function Ne(e) {
|
|
171
|
+
R(e) || S("selectorType");
|
|
172
|
+
}
|
|
173
|
+
function ze(e) {
|
|
174
|
+
R(e) || H(e) || S("handlerType"), H(e) && Object.values(e).some(function(t) {
|
|
175
|
+
return !R(t);
|
|
176
|
+
}) && S("handlersType");
|
|
177
|
+
}
|
|
178
|
+
function qe(e) {
|
|
179
|
+
e || S("initialIsRequired"), H(e) || S("initialType"), De(e) && S("initialContent");
|
|
180
|
+
}
|
|
181
|
+
function Ue(e, t) {
|
|
182
|
+
throw new Error(e[t] || e.default);
|
|
183
|
+
}
|
|
184
|
+
var Fe = {
|
|
185
|
+
initialIsRequired: "initial state is required",
|
|
186
|
+
initialType: "initial state should be an object",
|
|
187
|
+
initialContent: "initial state shouldn't be an empty object",
|
|
188
|
+
handlerType: "handler should be an object or a function",
|
|
189
|
+
handlersType: "all handlers should be a functions",
|
|
190
|
+
selectorType: "selector should be a function",
|
|
191
|
+
changeType: "provided value of changes should be an object",
|
|
192
|
+
changeField: 'it seams you want to change a field in the state which is not specified in the "initial" state',
|
|
193
|
+
default: "an unknown error accured in `state-local` package"
|
|
194
|
+
}, S = $(Ue)(Fe), q = {
|
|
195
|
+
changes: Ve,
|
|
196
|
+
selector: Ne,
|
|
197
|
+
handler: ze,
|
|
198
|
+
initial: qe
|
|
199
|
+
};
|
|
200
|
+
function He(e) {
|
|
201
|
+
var t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
202
|
+
q.initial(e), q.handler(t);
|
|
203
|
+
var r = {
|
|
204
|
+
current: e
|
|
205
|
+
}, n = $(Ke)(r, t), o = $(Be)(r), i = $(q.changes)(e), a = $(We)(r);
|
|
206
|
+
function l() {
|
|
207
|
+
var d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : function(M) {
|
|
208
|
+
return M;
|
|
209
|
+
};
|
|
210
|
+
return q.selector(d), d(r.current);
|
|
211
|
+
}
|
|
212
|
+
function s(d) {
|
|
213
|
+
$e(n, o, i, a)(d);
|
|
214
|
+
}
|
|
215
|
+
return [l, s];
|
|
216
|
+
}
|
|
217
|
+
function We(e, t) {
|
|
218
|
+
return R(t) ? t(e.current) : t;
|
|
219
|
+
}
|
|
220
|
+
function Be(e, t) {
|
|
221
|
+
return e.current = fe(fe({}, e.current), t), t;
|
|
222
|
+
}
|
|
223
|
+
function Ke(e, t, r) {
|
|
224
|
+
return R(t) ? t(e.current) : Object.keys(r).forEach(function(n) {
|
|
225
|
+
var o;
|
|
226
|
+
return (o = t[n]) === null || o === void 0 ? void 0 : o.call(t, e.current[n]);
|
|
227
|
+
}), r;
|
|
228
|
+
}
|
|
229
|
+
var Ge = {
|
|
230
|
+
create: He
|
|
231
|
+
}, Ye = {
|
|
232
|
+
paths: {
|
|
233
|
+
vs: "https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
function _e(e) {
|
|
237
|
+
return function t() {
|
|
238
|
+
for (var r = this, n = arguments.length, o = new Array(n), i = 0; i < n; i++)
|
|
239
|
+
o[i] = arguments[i];
|
|
240
|
+
return o.length >= e.length ? e.apply(this, o) : function() {
|
|
241
|
+
for (var a = arguments.length, l = new Array(a), s = 0; s < a; s++)
|
|
242
|
+
l[s] = arguments[s];
|
|
243
|
+
return t.apply(r, [].concat(o, l));
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function Je(e) {
|
|
248
|
+
return {}.toString.call(e).includes("Object");
|
|
249
|
+
}
|
|
250
|
+
function Qe(e) {
|
|
251
|
+
return e || de("configIsRequired"), Je(e) || de("configType"), e.urls ? (Xe(), {
|
|
252
|
+
paths: {
|
|
253
|
+
vs: e.urls.monacoBase
|
|
254
|
+
}
|
|
255
|
+
}) : e;
|
|
256
|
+
}
|
|
257
|
+
function Xe() {
|
|
258
|
+
console.warn(pe.deprecation);
|
|
259
|
+
}
|
|
260
|
+
function Ze(e, t) {
|
|
261
|
+
throw new Error(e[t] || e.default);
|
|
262
|
+
}
|
|
263
|
+
var pe = {
|
|
264
|
+
configIsRequired: "the configuration object is required",
|
|
265
|
+
configType: "the configuration object should be an object",
|
|
266
|
+
default: "an unknown error accured in `@monaco-editor/loader` package",
|
|
267
|
+
deprecation: `Deprecation warning!
|
|
268
|
+
You are using deprecated way of configuration.
|
|
269
|
+
|
|
270
|
+
Instead of using
|
|
271
|
+
monaco.config({ urls: { monacoBase: '...' } })
|
|
272
|
+
use
|
|
273
|
+
monaco.config({ paths: { vs: '...' } })
|
|
274
|
+
|
|
275
|
+
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
276
|
+
`
|
|
277
|
+
}, de = _e(Ze)(pe), ke = {
|
|
278
|
+
config: Qe
|
|
279
|
+
}, et = function() {
|
|
280
|
+
for (var t = arguments.length, r = new Array(t), n = 0; n < t; n++)
|
|
281
|
+
r[n] = arguments[n];
|
|
282
|
+
return function(o) {
|
|
283
|
+
return r.reduceRight(function(i, a) {
|
|
284
|
+
return a(i);
|
|
285
|
+
}, o);
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
function ge(e, t) {
|
|
289
|
+
return Object.keys(t).forEach(function(r) {
|
|
290
|
+
t[r] instanceof Object && e[r] && Object.assign(t[r], ge(e[r], t[r]));
|
|
291
|
+
}), le(le({}, e), t);
|
|
292
|
+
}
|
|
293
|
+
var tt = {
|
|
294
|
+
type: "cancelation",
|
|
295
|
+
msg: "operation is manually canceled"
|
|
296
|
+
};
|
|
297
|
+
function k(e) {
|
|
298
|
+
var t = !1, r = new Promise(function(n, o) {
|
|
299
|
+
e.then(function(i) {
|
|
300
|
+
return t ? o(tt) : n(i);
|
|
301
|
+
}), e.catch(o);
|
|
302
|
+
});
|
|
303
|
+
return r.cancel = function() {
|
|
304
|
+
return t = !0;
|
|
305
|
+
}, r;
|
|
306
|
+
}
|
|
307
|
+
var rt = ["monaco"], nt = Ge.create({
|
|
308
|
+
config: Ye,
|
|
309
|
+
isInitialized: !1,
|
|
310
|
+
resolve: null,
|
|
311
|
+
reject: null,
|
|
312
|
+
monaco: null
|
|
313
|
+
}), ve = Le(nt, 2), V = ve[0], W = ve[1];
|
|
314
|
+
function ot(e) {
|
|
315
|
+
var t = ke.config(e), r = t.monaco, n = Ee(t, rt);
|
|
316
|
+
W(function(o) {
|
|
317
|
+
return {
|
|
318
|
+
config: ge(o.config, n),
|
|
319
|
+
monaco: r
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
function it() {
|
|
324
|
+
var e = V(function(t) {
|
|
325
|
+
var r = t.monaco, n = t.isInitialized, o = t.resolve;
|
|
326
|
+
return {
|
|
327
|
+
monaco: r,
|
|
328
|
+
isInitialized: n,
|
|
329
|
+
resolve: o
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
if (!e.isInitialized) {
|
|
333
|
+
if (W({
|
|
334
|
+
isInitialized: !0
|
|
335
|
+
}), e.monaco)
|
|
336
|
+
return e.resolve(e.monaco), k(ee);
|
|
337
|
+
if (window.monaco && window.monaco.editor)
|
|
338
|
+
return he(window.monaco), e.resolve(window.monaco), k(ee);
|
|
339
|
+
et(at, ct)(lt);
|
|
340
|
+
}
|
|
341
|
+
return k(ee);
|
|
342
|
+
}
|
|
343
|
+
function at(e) {
|
|
344
|
+
return document.body.appendChild(e);
|
|
345
|
+
}
|
|
346
|
+
function ut(e) {
|
|
347
|
+
var t = document.createElement("script");
|
|
348
|
+
return e && (t.src = e), t;
|
|
349
|
+
}
|
|
350
|
+
function ct(e) {
|
|
351
|
+
var t = V(function(n) {
|
|
352
|
+
var o = n.config, i = n.reject;
|
|
353
|
+
return {
|
|
354
|
+
config: o,
|
|
355
|
+
reject: i
|
|
356
|
+
};
|
|
357
|
+
}), r = ut("".concat(t.config.paths.vs, "/loader.js"));
|
|
358
|
+
return r.onload = function() {
|
|
359
|
+
return e();
|
|
360
|
+
}, r.onerror = t.reject, r;
|
|
361
|
+
}
|
|
362
|
+
function lt() {
|
|
363
|
+
var e = V(function(r) {
|
|
364
|
+
var n = r.config, o = r.resolve, i = r.reject;
|
|
365
|
+
return {
|
|
366
|
+
config: n,
|
|
367
|
+
resolve: o,
|
|
368
|
+
reject: i
|
|
369
|
+
};
|
|
370
|
+
}), t = window.require;
|
|
371
|
+
t.config(e.config), t(["vs/editor/editor.main"], function(r) {
|
|
372
|
+
var n = r.m || r;
|
|
373
|
+
he(n), e.resolve(n);
|
|
374
|
+
}, function(r) {
|
|
375
|
+
e.reject(r);
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
function he(e) {
|
|
379
|
+
V().monaco || W({
|
|
380
|
+
monaco: e
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
function st() {
|
|
384
|
+
return V(function(e) {
|
|
385
|
+
var t = e.monaco;
|
|
386
|
+
return t;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
var ee = new Promise(function(e, t) {
|
|
390
|
+
return W({
|
|
391
|
+
resolve: e,
|
|
392
|
+
reject: t
|
|
393
|
+
});
|
|
394
|
+
}), me = {
|
|
395
|
+
config: ot,
|
|
396
|
+
init: it,
|
|
397
|
+
__getMonacoInstance: st
|
|
398
|
+
}, ft = { wrapper: { display: "flex", position: "relative", textAlign: "initial" }, fullWidth: { width: "100%" }, hide: { display: "none" } }, te = ft, dt = { container: { display: "flex", height: "100%", width: "100%", justifyContent: "center", alignItems: "center" } }, pt = dt;
|
|
399
|
+
function gt({ children: e }) {
|
|
400
|
+
return L.createElement("div", { style: pt.container }, e);
|
|
401
|
+
}
|
|
402
|
+
var vt = gt, ht = vt;
|
|
403
|
+
function mt({ width: e, height: t, isEditorReady: r, loading: n, _ref: o, className: i, wrapperProps: a }) {
|
|
404
|
+
return L.createElement("section", { style: { ...te.wrapper, width: e, height: t }, ...a }, !r && L.createElement(ht, null, n), L.createElement("div", { ref: o, style: { ...te.fullWidth, ...!r && te.hide }, className: i }));
|
|
405
|
+
}
|
|
406
|
+
var bt = mt, be = ne(bt);
|
|
407
|
+
function yt(e) {
|
|
408
|
+
j(e, []);
|
|
409
|
+
}
|
|
410
|
+
var ye = yt;
|
|
411
|
+
function wt(e, t, r = !0) {
|
|
412
|
+
let n = g(!0);
|
|
413
|
+
j(n.current || !r ? () => {
|
|
414
|
+
n.current = !1;
|
|
415
|
+
} : e, t);
|
|
416
|
+
}
|
|
417
|
+
var w = wt;
|
|
418
|
+
function D() {
|
|
419
|
+
}
|
|
420
|
+
function I(e, t, r, n) {
|
|
421
|
+
return Ot(e, n) || jt(e, t, r, n);
|
|
422
|
+
}
|
|
423
|
+
function Ot(e, t) {
|
|
424
|
+
return e.editor.getModel(we(e, t));
|
|
425
|
+
}
|
|
426
|
+
function jt(e, t, r, n) {
|
|
427
|
+
return e.editor.createModel(t, r, n ? we(e, n) : void 0);
|
|
428
|
+
}
|
|
429
|
+
function we(e, t) {
|
|
430
|
+
return e.Uri.parse(t);
|
|
431
|
+
}
|
|
432
|
+
function Mt({ original: e, modified: t, language: r, originalLanguage: n, modifiedLanguage: o, originalModelPath: i, modifiedModelPath: a, keepCurrentOriginalModel: l = !1, keepCurrentModifiedModel: s = !1, theme: d = "light", loading: M = "Loading...", options: O = {}, height: B = "100%", width: K = "100%", className: G, wrapperProps: Y = {}, beforeMount: _ = D, onMount: J = D }) {
|
|
433
|
+
let [y, T] = F(!1), [C, p] = F(!0), v = g(null), f = g(null), A = g(null), m = g(J), u = g(_), E = g(!1);
|
|
434
|
+
ye(() => {
|
|
435
|
+
let c = me.init();
|
|
436
|
+
return c.then((h) => (f.current = h) && p(!1)).catch((h) => h?.type !== "cancelation" && console.error("Monaco initialization: error:", h)), () => v.current ? x() : c.cancel();
|
|
437
|
+
}), w(() => {
|
|
438
|
+
if (v.current && f.current) {
|
|
439
|
+
let c = v.current.getOriginalEditor(), h = I(f.current, e || "", n || r || "text", i || "");
|
|
440
|
+
h !== c.getModel() && c.setModel(h);
|
|
441
|
+
}
|
|
442
|
+
}, [i], y), w(() => {
|
|
443
|
+
if (v.current && f.current) {
|
|
444
|
+
let c = v.current.getModifiedEditor(), h = I(f.current, t || "", o || r || "text", a || "");
|
|
445
|
+
h !== c.getModel() && c.setModel(h);
|
|
446
|
+
}
|
|
447
|
+
}, [a], y), w(() => {
|
|
448
|
+
let c = v.current.getModifiedEditor();
|
|
449
|
+
c.getOption(f.current.editor.EditorOption.readOnly) ? c.setValue(t || "") : t !== c.getValue() && (c.executeEdits("", [{ range: c.getModel().getFullModelRange(), text: t || "", forceMoveMarkers: !0 }]), c.pushUndoStop());
|
|
450
|
+
}, [t], y), w(() => {
|
|
451
|
+
v.current?.getModel()?.original.setValue(e || "");
|
|
452
|
+
}, [e], y), w(() => {
|
|
453
|
+
let { original: c, modified: h } = v.current.getModel();
|
|
454
|
+
f.current.editor.setModelLanguage(c, n || r || "text"), f.current.editor.setModelLanguage(h, o || r || "text");
|
|
455
|
+
}, [r, n, o], y), w(() => {
|
|
456
|
+
f.current?.editor.setTheme(d);
|
|
457
|
+
}, [d], y), w(() => {
|
|
458
|
+
v.current?.updateOptions(O);
|
|
459
|
+
}, [O], y);
|
|
460
|
+
let N = re(() => {
|
|
461
|
+
if (!f.current) return;
|
|
462
|
+
u.current(f.current);
|
|
463
|
+
let c = I(f.current, e || "", n || r || "text", i || ""), h = I(f.current, t || "", o || r || "text", a || "");
|
|
464
|
+
v.current?.setModel({ original: c, modified: h });
|
|
465
|
+
}, [r, t, o, e, n, i, a]), z = re(() => {
|
|
466
|
+
!E.current && A.current && (v.current = f.current.editor.createDiffEditor(A.current, { automaticLayout: !0, ...O }), N(), f.current?.editor.setTheme(d), T(!0), E.current = !0);
|
|
467
|
+
}, [O, d, N]);
|
|
468
|
+
j(() => {
|
|
469
|
+
y && m.current(v.current, f.current);
|
|
470
|
+
}, [y]), j(() => {
|
|
471
|
+
!C && !y && z();
|
|
472
|
+
}, [C, y, z]);
|
|
473
|
+
function x() {
|
|
474
|
+
let c = v.current?.getModel();
|
|
475
|
+
l || c?.original?.dispose(), s || c?.modified?.dispose(), v.current?.dispose();
|
|
476
|
+
}
|
|
477
|
+
return L.createElement(be, { width: K, height: B, isEditorReady: y, loading: M, _ref: A, className: G, wrapperProps: Y });
|
|
478
|
+
}
|
|
479
|
+
var Pt = Mt;
|
|
480
|
+
ne(Pt);
|
|
481
|
+
function St(e) {
|
|
482
|
+
let t = g();
|
|
483
|
+
return j(() => {
|
|
484
|
+
t.current = e;
|
|
485
|
+
}, [e]), t.current;
|
|
486
|
+
}
|
|
487
|
+
var Et = St, U = /* @__PURE__ */ new Map();
|
|
488
|
+
function It({ defaultValue: e, defaultLanguage: t, defaultPath: r, value: n, language: o, path: i, theme: a = "light", line: l, loading: s = "Loading...", options: d = {}, overrideServices: M = {}, saveViewState: O = !0, keepCurrentModel: B = !1, width: K = "100%", height: G = "100%", className: Y, wrapperProps: _ = {}, beforeMount: J = D, onMount: y = D, onChange: T, onValidate: C = D }) {
|
|
489
|
+
let [p, v] = F(!1), [f, A] = F(!0), m = g(null), u = g(null), E = g(null), N = g(y), z = g(J), x = g(), c = g(n), h = Et(i), oe = g(!1), Q = g(!1);
|
|
490
|
+
ye(() => {
|
|
491
|
+
let b = me.init();
|
|
492
|
+
return b.then((P) => (m.current = P) && A(!1)).catch((P) => P?.type !== "cancelation" && console.error("Monaco initialization: error:", P)), () => u.current ? Oe() : b.cancel();
|
|
493
|
+
}), w(() => {
|
|
494
|
+
let b = I(m.current, e || n || "", t || o || "", i || r || "");
|
|
495
|
+
b !== u.current?.getModel() && (O && U.set(h, u.current?.saveViewState()), u.current?.setModel(b), O && u.current?.restoreViewState(U.get(i)));
|
|
496
|
+
}, [i], p), w(() => {
|
|
497
|
+
u.current?.updateOptions(d);
|
|
498
|
+
}, [d], p), w(() => {
|
|
499
|
+
!u.current || n === void 0 || (u.current.getOption(m.current.editor.EditorOption.readOnly) ? u.current.setValue(n) : n !== u.current.getValue() && (Q.current = !0, u.current.executeEdits("", [{ range: u.current.getModel().getFullModelRange(), text: n, forceMoveMarkers: !0 }]), u.current.pushUndoStop(), Q.current = !1));
|
|
500
|
+
}, [n], p), w(() => {
|
|
501
|
+
let b = u.current?.getModel();
|
|
502
|
+
b && o && m.current?.editor.setModelLanguage(b, o);
|
|
503
|
+
}, [o], p), w(() => {
|
|
504
|
+
l !== void 0 && u.current?.revealLine(l);
|
|
505
|
+
}, [l], p), w(() => {
|
|
506
|
+
m.current?.editor.setTheme(a);
|
|
507
|
+
}, [a], p);
|
|
508
|
+
let ie = re(() => {
|
|
509
|
+
if (!(!E.current || !m.current) && !oe.current) {
|
|
510
|
+
z.current(m.current);
|
|
511
|
+
let b = i || r, P = I(m.current, n || e || "", t || o || "", b || "");
|
|
512
|
+
u.current = m.current?.editor.create(E.current, { model: P, automaticLayout: !0, ...d }, M), O && u.current.restoreViewState(U.get(b)), m.current.editor.setTheme(a), l !== void 0 && u.current.revealLine(l), v(!0), oe.current = !0;
|
|
513
|
+
}
|
|
514
|
+
}, [e, t, r, n, o, i, d, M, O, a, l]);
|
|
515
|
+
j(() => {
|
|
516
|
+
p && N.current(u.current, m.current);
|
|
517
|
+
}, [p]), j(() => {
|
|
518
|
+
!f && !p && ie();
|
|
519
|
+
}, [f, p, ie]), c.current = n, j(() => {
|
|
520
|
+
p && T && (x.current?.dispose(), x.current = u.current?.onDidChangeModelContent((b) => {
|
|
521
|
+
Q.current || T(u.current.getValue(), b);
|
|
522
|
+
}));
|
|
523
|
+
}, [p, T]), j(() => {
|
|
524
|
+
if (p) {
|
|
525
|
+
let b = m.current.editor.onDidChangeMarkers((P) => {
|
|
526
|
+
let X = u.current.getModel()?.uri;
|
|
527
|
+
if (X && P.find((Z) => Z.path === X.path)) {
|
|
528
|
+
let Z = m.current.editor.getModelMarkers({ resource: X });
|
|
529
|
+
C?.(Z);
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
return () => {
|
|
533
|
+
b?.dispose();
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
return () => {
|
|
537
|
+
};
|
|
538
|
+
}, [p, C]);
|
|
539
|
+
function Oe() {
|
|
540
|
+
x.current?.dispose(), B ? O && U.set(i, u.current.saveViewState()) : u.current.getModel()?.dispose(), u.current.dispose();
|
|
541
|
+
}
|
|
542
|
+
return L.createElement(be, { width: K, height: G, isEditorReady: p, loading: s, _ref: E, className: Y, wrapperProps: _ });
|
|
543
|
+
}
|
|
544
|
+
var Lt = It, Tt = ne(Lt), Ct = Tt;
|
|
545
|
+
function $t({
|
|
546
|
+
value: e = "",
|
|
547
|
+
language: t = "javascript",
|
|
548
|
+
theme: r = "vs-dark",
|
|
549
|
+
height: n = "400px",
|
|
550
|
+
onChange: o,
|
|
551
|
+
readOnly: i = !1,
|
|
552
|
+
className: a = ""
|
|
553
|
+
}) {
|
|
554
|
+
return /* @__PURE__ */ ae.jsx("div", { className: a, children: /* @__PURE__ */ ae.jsx(
|
|
555
|
+
Ct,
|
|
556
|
+
{
|
|
557
|
+
height: n,
|
|
558
|
+
language: t,
|
|
559
|
+
theme: r,
|
|
560
|
+
value: e,
|
|
561
|
+
onChange: o,
|
|
562
|
+
options: {
|
|
563
|
+
readOnly: i,
|
|
564
|
+
minimap: { enabled: !1 },
|
|
565
|
+
fontSize: 14,
|
|
566
|
+
lineNumbers: "on",
|
|
567
|
+
scrollBeyondLastLine: !1,
|
|
568
|
+
automaticLayout: !0
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
) });
|
|
572
|
+
}
|
|
573
|
+
export {
|
|
574
|
+
$t as default
|
|
575
|
+
};
|