@gpustack/core-ui 1.0.22 → 1.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{parse-worker-Dzai8qsE.js → parse-worker-DASzfShu.js} +3 -3
- package/dist/{highlight-code-CLpz1xT8.js → highlight-code-C8SfAI6k.js} +17 -10
- package/dist/index.es.js +56 -51
- package/dist/markdown.es.js +1 -1
- package/dist/src/lib/components/yaml-editor/editor.d.ts +3 -0
- package/dist/src/lib/components/yaml-editor/index.d.ts +3 -0
- package/dist/src/lib/hooks/use-overlay-scroller.d.ts +1 -1
- package/dist/yaml-editor.es.js +39 -31
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(){let e=/\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g,t=e=>e.startsWith(`(…)`)?e.slice(3):e,n=new class{cursorRow=0;cursorCol=0;screen=[[``]];rawDataRows=0;uid=0;isProcessing=!1;taskQueue=[];page=1;progress=0;percent=0;isComplete=!1;chunked=!0;reminder=``;lines=[];isDownloading=!1;pageSize=500;colorMap={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`};constructor(){this.reset()}reset(){this.cursorRow=0,this.cursorCol=0,this.screen=[[``]],this.rawDataRows=0,this.uid+=1,this.lines=[],this.reminder=``,this.page=1}setPage(e){this.page=e??1}setPercent(e){this.percent=e??0}setProgress(e){this.progress=e??0}setIsCompelete(e){this.isComplete=e}setChunked(e){this.chunked=e??!0}setIsDownloading(e){this.isDownloading=e}setId(){return this.uid+=1,this.uid}handleText(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`\r`){if(e[t+1]===`
|
|
1
|
+
(function(){let e=/\x1b\[(\d*);?(\d*)?([A-DJKHfm])/g,t=e=>e.startsWith(`(…)`)?e.slice(3):e,n=new class{cursorRow=0;cursorCol=0;screen=[[``]];rawDataRows=0;uid=0;isProcessing=!1;taskQueue=[];page=1;progress=0;percent=0;isComplete=!1;chunked=!0;reminder=``;lines=[];isDownloading=!1;pageSize=500;resetFlag=!1;colorMap={30:`black`,31:`red`,32:`green`,33:`yellow`,34:`blue`,35:`magenta`,36:`cyan`,37:`white`};constructor(){this.reset()}reset(){this.cursorRow=0,this.cursorCol=0,this.screen=[[``]],this.rawDataRows=0,this.uid+=1,this.lines=[],this.reminder=``,this.page=1,this.resetFlag=!0}setPage(e){this.page=e??1}setPercent(e){this.percent=e??0}setProgress(e){this.progress=e??0}setIsCompelete(e){this.isComplete=e}setChunked(e){this.chunked=e??!0}setIsDownloading(e){this.isDownloading=e}setId(){return this.uid+=1,this.uid}handleText(e){for(let t=0;t<e.length;t++){let n=e[t];if(n===`\r`){if(e[t+1]===`
|
|
2
2
|
`)continue;this.cursorCol=0}else if(n===`
|
|
3
3
|
`)this.rawDataRows++,this.cursorRow++,this.cursorCol=0,this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);else{let e=this.screen[this.cursorRow]||(this.screen[this.cursorRow]=[``]);e[this.cursorCol]=n||``,this.cursorCol++}}}handleAnsiSequence(e,t){let n=parseInt(e[1]||`1`,10),r=parseInt(e[2]||`1`,10);switch(e[3]){case`A`:this.cursorRow=Math.max(0,this.cursorRow-n);break;case`B`:this.cursorRow+=n;break;case`C`:this.cursorCol+=n;break;case`D`:this.cursorCol=Math.max(0,this.cursorCol-n);break;case`H`:this.cursorRow=Math.max(0,n-1),this.cursorCol=Math.max(0,r-1);break;case`J`:n===2&&this.reset();break;case`m`:break}for(;this.screen.length<=this.cursorRow&&!t;)this.screen.push([``]);for(;this.screen[this.cursorRow].length<=this.cursorCol&&!t;)this.screen[this.cursorRow].push(``)}processInput(n){let r,i=0;for(;(r=e.exec(n))!==null;){let t=n.slice(i,r.index);this.handleText(t),i=e.lastIndex,this.handleAnsiSequence(r,i===n.length-1)}let a=n.slice(i);return this.handleText(a),{data:this.screen.map((e,n)=>t(e.join(``))),lines:this.rawDataRows,remainder:``}}getScreenText(){return this.screen.map(e=>t(e.join(``))).join(`
|
|
4
|
-
`)}processInputByLine(e){let t=e?.split(/\r?\n/)||[],n=t.pop()||``;return this.rawDataRows+=t.length,t.forEach(e=>{this.lines.push(e)}),{data:
|
|
5
|
-
`)}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.taskQueue.length>0;){let e=``;if(e=this.isDownloading?this.taskQueue.shift()||``:this.reminder+this.taskQueue.shift(),e)try{let t=this.isDownloading?this.processInput(e):this.processInputByLine(e);this.isDownloading||(this.reminder=t.remainder),this.chunked?self.postMessage({result:t.data,lines:t.lines}):this.isComplete||self.postMessage({result:``,percent:this.percent,isComplete:!1})}catch(e){console.error(`Error processing input:`,e)}await new Promise(e=>{setTimeout(e,0)})}this.isProcessing=!1,this.taskQueue.length>0?this.processQueue():this.isComplete&&!this.chunked&&(self.postMessage({result:this.getAllLines(),percent:this.percent,isComplete:!0}),this.reset())}}enqueueData(e){this.taskQueue.push(e),this.isProcessing||this.processQueue()}};self.onmessage=function(e){let{inputStr:t,reset:r,page:i,isComplete:a=!1,chunked:o=!0,percent:s=0,isDownloading:c=!1}=e.data;n.setIsDownloading(c),n.setPage(i),n.setIsCompelete(a),n.setChunked(o),n.setPercent(s),r&&n.reset(),n.enqueueData(t)},self.onerror=function(e){console.error(`parse logs error===`,e)}})();
|
|
4
|
+
`)}processInputByLine(e){let t=e?.split(/\r?\n/)||[],n=t.pop()||``;return this.rawDataRows+=t.length,this.chunked||t.forEach(e=>{this.lines.push(e)}),{data:t,lines:this.rawDataRows,remainder:n}}getAllLines(){return this.lines.join(`
|
|
5
|
+
`)}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.taskQueue.length>0;){let e=``;if(e=this.isDownloading?this.taskQueue.shift()||``:this.reminder+this.taskQueue.shift(),e)try{let t=this.isDownloading?this.processInput(e):this.processInputByLine(e);this.isDownloading||(this.reminder=t.remainder),this.chunked?(self.postMessage({result:t.data,lines:t.lines,append:!this.isDownloading,reset:this.resetFlag}),this.resetFlag=!1):this.isComplete||self.postMessage({result:``,percent:this.percent,isComplete:!1})}catch(e){console.error(`Error processing input:`,e)}await new Promise(e=>{setTimeout(e,0)})}this.isProcessing=!1,this.taskQueue.length>0?this.processQueue():this.isComplete&&!this.chunked&&(self.postMessage({result:this.getAllLines(),percent:this.percent,isComplete:!0}),this.reset())}}enqueueData(e){this.taskQueue.push(e),this.isProcessing||this.processQueue()}};self.onmessage=function(e){let{inputStr:t,reset:r,page:i,isComplete:a=!1,chunked:o=!0,percent:s=0,isDownloading:c=!1}=e.data;n.setIsDownloading(c),n.setPage(i),n.setIsCompelete(a),n.setChunked(o),n.setPercent(s),r&&n.reset(),n.enqueueData(t)},self.onerror=function(e){console.error(`parse logs error===`,e)}})();
|
|
@@ -28,16 +28,17 @@ function D(e) {
|
|
|
28
28
|
},
|
|
29
29
|
events: { ...a },
|
|
30
30
|
defer: s
|
|
31
|
-
})
|
|
31
|
+
});
|
|
32
|
+
p.current = y?.(), f.current = p.current?.elements()?.scrollEventElement;
|
|
33
|
+
let b = () => {
|
|
32
34
|
let e = f.current?.scrollTop, t = f.current?.scrollHeight;
|
|
33
35
|
e + f.current?.clientHeight + 20 >= t ? g.current = !1 : g.current = !0;
|
|
34
|
-
}, x = (0, T.throttle)(() => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
top: e.scrollHeight,
|
|
36
|
+
}, x = S((0, T.throttle)(() => {
|
|
37
|
+
f.current?.scrollTo?.({
|
|
38
|
+
top: f.current?.scrollHeight,
|
|
38
39
|
behavior: "smooth"
|
|
39
|
-
}),
|
|
40
|
-
}, 100), w = S(() => {
|
|
40
|
+
}), p.current?.update?.();
|
|
41
|
+
}, 100)), w = S(() => {
|
|
41
42
|
f.current?.scrollTo?.({
|
|
42
43
|
top: f.current.scrollHeight,
|
|
43
44
|
behavior: "auto"
|
|
@@ -66,7 +67,7 @@ function D(e) {
|
|
|
66
67
|
initialize: N,
|
|
67
68
|
instance: p,
|
|
68
69
|
scrollEventElement: f,
|
|
69
|
-
initialized: m,
|
|
70
|
+
initialized: m.current,
|
|
70
71
|
getScrollElementScrollableHeight: () => {
|
|
71
72
|
(!p.current || !f.current) && (p.current = y?.(), f.current = p.current?.elements()?.scrollEventElement);
|
|
72
73
|
let e = p.current?.elements().viewport;
|
|
@@ -227,7 +228,10 @@ var O = { wrapper: "index-module__wrapper___AP3Au" }, k = ({ children: e, maxHei
|
|
|
227
228
|
} catch {
|
|
228
229
|
a = !1;
|
|
229
230
|
} finally {
|
|
230
|
-
document.body.removeChild(t)
|
|
231
|
+
document.body.removeChild(t);
|
|
232
|
+
try {
|
|
233
|
+
n && (n.removeAllRanges(), r && n.addRange(r)), i?.focus?.();
|
|
234
|
+
} catch {}
|
|
231
235
|
}
|
|
232
236
|
return a;
|
|
233
237
|
}, k = async () => {
|
|
@@ -19026,7 +19030,10 @@ var mr = x.div`
|
|
|
19026
19030
|
children: [/* @__PURE__ */ f("span", { children: t }), /* @__PURE__ */ f(N, {
|
|
19027
19031
|
text: e || "",
|
|
19028
19032
|
size: "small",
|
|
19029
|
-
style: {
|
|
19033
|
+
style: {
|
|
19034
|
+
color: "#abb2bf",
|
|
19035
|
+
backgroundColor: n === "dark" ? "transparent" : "#fff"
|
|
19036
|
+
}
|
|
19030
19037
|
})]
|
|
19031
19038
|
}) : null, _r = (e) => {
|
|
19032
19039
|
let { code: t = "", copyValue: n, lang: r, autodetect: i = !0, ignoreIllegals: a = !0, copyable: o = !0, height: s = "auto", style: c, xScrollable: u = !1 } = e || {}, d = l(() => {
|
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as e, r as t, t as n } from "./rolldown-runtime-gEudmnaM.js";
|
|
2
2
|
import { i as r, n as i, r as a, t as o } from "./useIntl-CQ7P5Olk.js";
|
|
3
3
|
import { t as s } from "./lodash-DVkZQU_K.js";
|
|
4
|
-
import { a as c, i as l, n as u, o as d, r as f, t as p } from "./highlight-code-
|
|
4
|
+
import { a as c, i as l, n as u, o as d, r as f, t as p } from "./highlight-code-C8SfAI6k.js";
|
|
5
5
|
import { A as m, _ as h, a as g, c as _, f as v, g as y, n as b, s as x, y as S } from "./utils-CIKJeIzI.js";
|
|
6
6
|
import { t as C } from "./editor-wrap-LcV3ZHZv.js";
|
|
7
7
|
import w from "axios";
|
|
@@ -2973,7 +2973,7 @@ function ra() {
|
|
|
2973
2973
|
};
|
|
2974
2974
|
return F(() => (t.current?.terminate?.(), t.current = new Worker(new URL(
|
|
2975
2975
|
/* @vite-ignore */
|
|
2976
|
-
"" + new URL("assets/parse-worker-
|
|
2976
|
+
"" + new URL("assets/parse-worker-DASzfShu.js", import.meta.url).href,
|
|
2977
2977
|
"" + import.meta.url
|
|
2978
2978
|
), { type: "module" }), t.current.onmessage = (t) => {
|
|
2979
2979
|
let { result: n, isComplete: a, percent: s } = t.data, c = e.current?.current?.signal?.aborted;
|
|
@@ -8596,61 +8596,61 @@ var Pc = (e) => {
|
|
|
8596
8596
|
totalPage: i
|
|
8597
8597
|
};
|
|
8598
8598
|
}, nl = A((e, t) => {
|
|
8599
|
-
let { diffHeight: n, url: r, tail: i, enableScorllLoad: a = !0, isDownloading: o, watchable: s, params: c } = e, { pageSize: l, page: u, setPage: d, setTotalPage: f, totalPage: p } = tl(), { setChunkFetch: m } = Vi(), h = z(null),
|
|
8599
|
+
let { diffHeight: n, url: r, tail: i, enableScorllLoad: a = !0, isDownloading: o, watchable: s, params: c } = e, { pageSize: l, page: u, setPage: d, setTotalPage: f, totalPage: p } = tl(), { setChunkFetch: m } = Vi(), h = z(null), g = z([]), _ = z(null), v = z(i), [y, b] = B(!1), [x, S] = B(!1), [C, w] = B([]), T = z(null), E = z(!1), D = z(u), O = z(p), k = z(!1), [A, j] = B([]), M = z({
|
|
8600
8600
|
pos: "bottom",
|
|
8601
8601
|
page: 1
|
|
8602
|
-
}),
|
|
8602
|
+
}), P = z(0), L = z(!1);
|
|
8603
8603
|
I(t, () => ({ abort() {
|
|
8604
|
-
h.current?.current?.abort?.(),
|
|
8604
|
+
h.current?.current?.abort?.(), _.current?.terminate?.();
|
|
8605
8605
|
} }));
|
|
8606
8606
|
let ee = (e) => {
|
|
8607
|
-
|
|
8607
|
+
j(e.map((e, t) => ({
|
|
8608
8608
|
content: e,
|
|
8609
|
-
uid: `${
|
|
8609
|
+
uid: `${D.current}-${t}`
|
|
8610
8610
|
})));
|
|
8611
8611
|
}, V = Z.default.debounce(() => {
|
|
8612
|
-
|
|
8612
|
+
b(!1), k.current = !1, T.current?.scroller && (T.current.scroller.style["pointer-events"] = "auto");
|
|
8613
8613
|
}, 1e3), W = N(() => {
|
|
8614
|
-
|
|
8615
|
-
let e = (
|
|
8616
|
-
d(
|
|
8617
|
-
}, [
|
|
8618
|
-
--
|
|
8614
|
+
D.current < 1 && (D.current = 1);
|
|
8615
|
+
let e = (D.current - 1) * l, t = D.current * l, n = g.current.slice(e, t);
|
|
8616
|
+
d(D.current), ee(n);
|
|
8617
|
+
}, [l]), te = N(() => {
|
|
8618
|
+
--D.current, W(), w(["bottom", D.current]), M.current = {
|
|
8619
8619
|
pos: "bottom",
|
|
8620
|
-
page:
|
|
8620
|
+
page: D.current
|
|
8621
8621
|
};
|
|
8622
8622
|
}, [W]), ne = N(() => {
|
|
8623
|
-
|
|
8623
|
+
D.current += 1, W(), w(["top", D.current]), M.current = {
|
|
8624
8624
|
pos: "top",
|
|
8625
|
-
page:
|
|
8625
|
+
page: D.current
|
|
8626
8626
|
};
|
|
8627
8627
|
}, [W]), re = N(() => {
|
|
8628
|
-
|
|
8628
|
+
D.current = O.current, W(), console.log("pageRef.current", D.current), w(["bottom", D.current]), M.current = {
|
|
8629
8629
|
pos: "bottom",
|
|
8630
|
-
page:
|
|
8630
|
+
page: D.current
|
|
8631
8631
|
};
|
|
8632
8632
|
}, [W]), ie = N(() => {
|
|
8633
|
-
|
|
8633
|
+
D.current = 1, W(), w(["top", D.current]), M.current = {
|
|
8634
8634
|
pos: "top",
|
|
8635
|
-
page:
|
|
8635
|
+
page: D.current
|
|
8636
8636
|
};
|
|
8637
8637
|
}, [W]), ae = (e) => {
|
|
8638
|
-
|
|
8638
|
+
k.current && (b(!0), T.current?.scroller && (T.current.scroller.style["pointer-events"] = "none")), _.current.postMessage({
|
|
8639
8639
|
inputStr: e,
|
|
8640
|
-
page:
|
|
8641
|
-
reset:
|
|
8640
|
+
page: D.current,
|
|
8641
|
+
reset: L.current,
|
|
8642
8642
|
isDownloading: o
|
|
8643
|
-
}),
|
|
8643
|
+
}), L.current = !1;
|
|
8644
8644
|
}, oe = async () => {
|
|
8645
|
-
h.current?.current?.abort?.(),
|
|
8645
|
+
h.current?.current?.abort?.(), _.current?.postMessage({
|
|
8646
8646
|
inputStr: "",
|
|
8647
|
-
page:
|
|
8647
|
+
page: D.current,
|
|
8648
8648
|
reset: !0,
|
|
8649
8649
|
isDownloading: o
|
|
8650
8650
|
}), h.current = m({
|
|
8651
8651
|
url: r,
|
|
8652
8652
|
params: {
|
|
8653
|
-
tail:
|
|
8653
|
+
tail: v.current,
|
|
8654
8654
|
...e.params
|
|
8655
8655
|
},
|
|
8656
8656
|
...s ? { watch: c?.watch ?? !0 } : {},
|
|
@@ -8659,19 +8659,19 @@ var Pc = (e) => {
|
|
|
8659
8659
|
});
|
|
8660
8660
|
}, se = zt(async (e) => {
|
|
8661
8661
|
let { isTop: t, isBottom: n } = e;
|
|
8662
|
-
|
|
8662
|
+
S(t), n ? M.current = {
|
|
8663
8663
|
pos: "bottom",
|
|
8664
8664
|
page: u
|
|
8665
|
-
} : t ?
|
|
8665
|
+
} : t ? M.current = {
|
|
8666
8666
|
pos: "top",
|
|
8667
8667
|
page: u
|
|
8668
|
-
} :
|
|
8668
|
+
} : M.current = {
|
|
8669
8669
|
pos: "middle",
|
|
8670
8670
|
page: u
|
|
8671
|
-
}, !(
|
|
8672
|
-
}), ce =
|
|
8673
|
-
|
|
8674
|
-
}, 150), [
|
|
8671
|
+
}, !(y || g.current.length > 0 && P.current < l - 1 && !E.current || !a) && t && !E.current && (v.current = void 0, oe(), E.current = !0, k.current = !0, L.current = !0);
|
|
8672
|
+
}), ce = R(() => Z.default.throttle(() => {
|
|
8673
|
+
console.log("scrollPos===", C), C[0] === "top" && M.current.pos === "top" && T.current?.scrollToTop(), M.current.pos === "bottom" && T.current?.scrollToBottom();
|
|
8674
|
+
}, 150), [C]);
|
|
8675
8675
|
return F(() => (oe(), () => {
|
|
8676
8676
|
h.current?.current?.abort?.();
|
|
8677
8677
|
}), [
|
|
@@ -8680,37 +8680,42 @@ var Pc = (e) => {
|
|
|
8680
8680
|
e.params
|
|
8681
8681
|
]), F(() => {
|
|
8682
8682
|
ce();
|
|
8683
|
-
}, [
|
|
8683
|
+
}, [C, ce]), F(() => (_.current?.terminate?.(), _.current = new Worker(new URL(
|
|
8684
8684
|
/* @vite-ignore */
|
|
8685
|
-
"" + new URL("assets/parse-worker-
|
|
8685
|
+
"" + new URL("assets/parse-worker-DASzfShu.js", import.meta.url).href,
|
|
8686
8686
|
"" + import.meta.url
|
|
8687
|
-
), { type: "module" }),
|
|
8688
|
-
let { result: t, lines: n } = e.data;
|
|
8689
|
-
|
|
8690
|
-
|
|
8691
|
-
|
|
8687
|
+
), { type: "module" }), _.current.onmessage = (e) => {
|
|
8688
|
+
let { result: t, lines: n, append: r, reset: i } = e.data;
|
|
8689
|
+
if (P.current = n, i && (g.current = []), r) {
|
|
8690
|
+
let e = g.current;
|
|
8691
|
+
for (let n = 0; n < t.length; n++) e.push(t[n]);
|
|
8692
|
+
} else g.current = t || [];
|
|
8693
|
+
let a = g.current;
|
|
8694
|
+
D.current < 1 && (D.current = 1);
|
|
8695
|
+
let o = O.current;
|
|
8696
|
+
O.current = Math.ceil(a.length / l), console.log("onmessage===", k.current, O.current), k.current ? D.current = O.current : D.current === o && M.current.pos === "bottom" && (M.current = {
|
|
8692
8697
|
pos: "bottom",
|
|
8693
|
-
page:
|
|
8694
|
-
},
|
|
8695
|
-
let
|
|
8696
|
-
|
|
8698
|
+
page: D.current
|
|
8699
|
+
}, D.current = O.current, w(["bottom", D.current]));
|
|
8700
|
+
let s = (D.current - 1) * l, c = D.current * l, u = a.slice(s, c);
|
|
8701
|
+
f(O.current), d(D.current), ee(u), V();
|
|
8697
8702
|
}, () => {
|
|
8698
|
-
|
|
8703
|
+
_.current && _.current.terminate();
|
|
8699
8704
|
}), []), /* @__PURE__ */ H("div", {
|
|
8700
8705
|
className: "logs-viewer-wrap-w2",
|
|
8701
8706
|
children: /* @__PURE__ */ U("div", {
|
|
8702
8707
|
className: "wrap",
|
|
8703
8708
|
children: [
|
|
8704
8709
|
/* @__PURE__ */ H("div", { children: /* @__PURE__ */ H(Qc, {
|
|
8705
|
-
ref:
|
|
8706
|
-
dataList:
|
|
8710
|
+
ref: T,
|
|
8711
|
+
dataList: A,
|
|
8707
8712
|
diffHeight: n,
|
|
8708
8713
|
onScroll: se
|
|
8709
8714
|
}) }),
|
|
8710
|
-
|
|
8715
|
+
y && /* @__PURE__ */ H(Dt, {
|
|
8711
8716
|
size: "middle",
|
|
8712
|
-
spinning:
|
|
8713
|
-
className: (0, X.default)({ loading:
|
|
8717
|
+
spinning: y,
|
|
8718
|
+
className: (0, X.default)({ loading: y })
|
|
8714
8719
|
}),
|
|
8715
8720
|
p > 1 && /* @__PURE__ */ H("div", {
|
|
8716
8721
|
className: "pg",
|
package/dist/markdown.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { o as e, r as t, t as n } from "./rolldown-runtime-gEudmnaM.js";
|
|
2
2
|
import { t as r } from "./lodash-DVkZQU_K.js";
|
|
3
|
-
import { t as i } from "./highlight-code-
|
|
3
|
+
import { t as i } from "./highlight-code-C8SfAI6k.js";
|
|
4
4
|
import a, { Fragment as o, useCallback as s, useEffect as c, useMemo as l } from "react";
|
|
5
5
|
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
6
6
|
import { EyeOutlined as p } from "@ant-design/icons";
|
|
@@ -10,6 +10,9 @@ interface ViewerProps {
|
|
|
10
10
|
placeholder?: string;
|
|
11
11
|
variant?: 'bordered' | 'borderless';
|
|
12
12
|
schema?: any;
|
|
13
|
+
onChange?: (value: string | undefined, event: any) => void;
|
|
14
|
+
onBlur?: () => void;
|
|
15
|
+
onFocus?: () => void;
|
|
13
16
|
}
|
|
14
17
|
declare const EditorInner: React.FC<ViewerProps>;
|
|
15
18
|
export default EditorInner;
|
|
@@ -12,6 +12,9 @@ interface ViewerProps {
|
|
|
12
12
|
schema?: any;
|
|
13
13
|
isDarkTheme?: boolean;
|
|
14
14
|
onUpload?: (content: string) => void;
|
|
15
|
+
onChange?: (value: string | undefined, event: any) => void;
|
|
16
|
+
onBlur?: () => void;
|
|
17
|
+
onFocus?: () => void;
|
|
15
18
|
}
|
|
16
19
|
declare const YamlEditor: React.FC<ViewerProps>;
|
|
17
20
|
export default YamlEditor;
|
|
@@ -28,7 +28,7 @@ export default function useOverlayScroller(data?: {
|
|
|
28
28
|
initialize: (this: unknown, el: any) => any;
|
|
29
29
|
instance: React.MutableRefObject<any>;
|
|
30
30
|
scrollEventElement: React.MutableRefObject<any>;
|
|
31
|
-
initialized:
|
|
31
|
+
initialized: boolean;
|
|
32
32
|
getScrollElementScrollableHeight: () => {
|
|
33
33
|
scrollTop: any;
|
|
34
34
|
scrollHeight: number;
|
package/dist/yaml-editor.es.js
CHANGED
|
@@ -12,7 +12,7 @@ import { yamlDefaults as v } from "monaco-yaml";
|
|
|
12
12
|
//#region src/lib/components/yaml-editor/editor.tsx
|
|
13
13
|
g.config({ monaco: _ });
|
|
14
14
|
var y = "inmemory://model/config.yaml", b = n((e, n) => {
|
|
15
|
-
let { value: s, height: c = 380, theme: u = "vs-dark", header: d, variant: f = "borderless", schema: p, placeholder: m } = e,
|
|
15
|
+
let { value: s, height: c = 380, theme: u = "vs-dark", header: d, variant: f = "borderless", schema: p, placeholder: m, onChange: g, onBlur: _, onFocus: b } = e, x = a(null), S = a(null), C = a(null), w = (e) => {
|
|
16
16
|
let t = e.Uri.parse(y);
|
|
17
17
|
v.setDiagnosticsOptions({
|
|
18
18
|
validate: !1,
|
|
@@ -24,35 +24,39 @@ var y = "inmemory://model/config.yaml", b = n((e, n) => {
|
|
|
24
24
|
schema: p
|
|
25
25
|
}]
|
|
26
26
|
});
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
}, T = (e, t) => {
|
|
28
|
+
x.current = e, S.current = t, e.onDidBlurEditorText?.(() => {
|
|
29
|
+
_?.();
|
|
30
|
+
}), e.onDidFocusEditorText?.(() => {
|
|
31
|
+
b?.();
|
|
32
|
+
});
|
|
33
|
+
}, E = () => {
|
|
34
|
+
x.current && setTimeout(() => {
|
|
35
|
+
x.current?.getAction?.("editor.action.formatDocument")?.run().then(() => {
|
|
32
36
|
console.log("format success");
|
|
33
37
|
});
|
|
34
38
|
}, 100);
|
|
35
|
-
},
|
|
36
|
-
let e =
|
|
37
|
-
return
|
|
39
|
+
}, D = () => {
|
|
40
|
+
let e = x.current?.getModel()?.uri;
|
|
41
|
+
return S.current?.editor.getModelMarkers({ resource: e });
|
|
38
42
|
};
|
|
39
43
|
return i(n, () => ({
|
|
40
44
|
format: () => {
|
|
41
|
-
|
|
45
|
+
E();
|
|
42
46
|
},
|
|
43
|
-
getValue: () =>
|
|
47
|
+
getValue: () => x.current?.getValue?.(),
|
|
44
48
|
setValue: (e) => {
|
|
45
|
-
|
|
49
|
+
x.current?.setValue?.(e);
|
|
46
50
|
},
|
|
47
51
|
dispose: () => {
|
|
48
|
-
|
|
52
|
+
x.current?.dispose?.(), C.current?.dispose?.();
|
|
49
53
|
},
|
|
50
54
|
validate() {
|
|
51
|
-
return
|
|
55
|
+
return D();
|
|
52
56
|
},
|
|
53
|
-
editor:
|
|
57
|
+
editor: x.current
|
|
54
58
|
})), r(() => {
|
|
55
|
-
|
|
59
|
+
E();
|
|
56
60
|
}, [s]), /* @__PURE__ */ o(t, {
|
|
57
61
|
header: d,
|
|
58
62
|
variant: f,
|
|
@@ -76,8 +80,9 @@ var y = "inmemory://model/config.yaml", b = n((e, n) => {
|
|
|
76
80
|
}
|
|
77
81
|
},
|
|
78
82
|
loading: /* @__PURE__ */ o(l, { style: { fontSize: 24 } }),
|
|
79
|
-
beforeMount:
|
|
80
|
-
onMount:
|
|
83
|
+
beforeMount: w,
|
|
84
|
+
onMount: T,
|
|
85
|
+
onChange: g
|
|
81
86
|
})
|
|
82
87
|
});
|
|
83
88
|
}), { Text: x } = d;
|
|
@@ -113,31 +118,31 @@ var S = m.div`
|
|
|
113
118
|
background-color: var(--ant-color-fill-quaternary);
|
|
114
119
|
border-radius: var(--ant-border-radius-lg) var(--ant-border-radius-lg) 0 0;
|
|
115
120
|
`, T = n((t, n) => {
|
|
116
|
-
let { value: l, height: d = 380, variant: m = "borderless", isDarkTheme: h, schema: g, placeholder: _, validateMessage: v, title: y, onUpload: x } = t,
|
|
117
|
-
|
|
121
|
+
let { value: l, height: d = 380, variant: m = "borderless", isDarkTheme: h, schema: g, placeholder: _, validateMessage: v, title: y, onUpload: x, onChange: T, onBlur: E, onFocus: D } = t, O = e(), k = a(null), A = (e) => {
|
|
122
|
+
k.current?.setValue?.(e);
|
|
118
123
|
};
|
|
119
124
|
return i(n, () => ({
|
|
120
125
|
format: () => {
|
|
121
|
-
|
|
126
|
+
k.current?.format();
|
|
122
127
|
},
|
|
123
|
-
getValue: () =>
|
|
128
|
+
getValue: () => k.current?.getValue?.(),
|
|
124
129
|
setValue: (e) => {
|
|
125
|
-
|
|
130
|
+
k.current?.setValue?.(e);
|
|
126
131
|
},
|
|
127
132
|
dispose: () => {
|
|
128
|
-
|
|
133
|
+
k.current?.dispose?.();
|
|
129
134
|
},
|
|
130
135
|
validate() {
|
|
131
|
-
return
|
|
136
|
+
return k.current?.validate();
|
|
132
137
|
},
|
|
133
|
-
editor:
|
|
138
|
+
editor: k.current
|
|
134
139
|
})), r(() => {
|
|
135
|
-
|
|
140
|
+
k.current?.format();
|
|
136
141
|
}, [l]), /* @__PURE__ */ s(S, {
|
|
137
142
|
className: "yaml-editor-container",
|
|
138
143
|
style: { minHeight: d },
|
|
139
144
|
children: [/* @__PURE__ */ o(b, {
|
|
140
|
-
ref:
|
|
145
|
+
ref: k,
|
|
141
146
|
header: /* @__PURE__ */ s(w, { children: [/* @__PURE__ */ o("span", {
|
|
142
147
|
className: "title",
|
|
143
148
|
children: y || "YAML"
|
|
@@ -149,7 +154,7 @@ var S = m.div`
|
|
|
149
154
|
let t = new FileReader();
|
|
150
155
|
return t.onload = (e) => {
|
|
151
156
|
let t = e.target?.result;
|
|
152
|
-
typeof t == "string" ? (x?.(t),
|
|
157
|
+
typeof t == "string" ? (x?.(t), A(t)) : p.error("Failed to read file content!");
|
|
153
158
|
}, t.readAsText(e), !1;
|
|
154
159
|
},
|
|
155
160
|
showUploadList: !1,
|
|
@@ -158,7 +163,7 @@ var S = m.div`
|
|
|
158
163
|
icon: /* @__PURE__ */ o(c, {}),
|
|
159
164
|
type: "text",
|
|
160
165
|
size: "small",
|
|
161
|
-
children:
|
|
166
|
+
children: O.formatMessage({ id: "common.button.import" })
|
|
162
167
|
})
|
|
163
168
|
})] }),
|
|
164
169
|
variant: m,
|
|
@@ -166,7 +171,10 @@ var S = m.div`
|
|
|
166
171
|
theme: h ? "vs-dark" : "light",
|
|
167
172
|
value: l,
|
|
168
173
|
placeholder: _,
|
|
169
|
-
schema: g
|
|
174
|
+
schema: g,
|
|
175
|
+
onChange: T,
|
|
176
|
+
onBlur: E,
|
|
177
|
+
onFocus: D
|
|
170
178
|
}), v && /* @__PURE__ */ o(C, {
|
|
171
179
|
type: "danger",
|
|
172
180
|
children: v
|