@airalogy/aimd-editor 1.14.0 → 1.15.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/README.md +5 -1
- package/README.zh-CN.md +5 -1
- package/dist/AimdEditorTopBar.vue_vue_type_script_setup_true_lang-Bn17A3TY.js +2417 -0
- package/dist/{AimdSourceEditor.vue_vue_type_script_setup_true_lang-ey9GBO3X.js → AimdSourceEditor.vue_vue_type_script_setup_true_lang-DTu36rqy.js} +1 -1
- package/dist/{AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-BR8KCFMg.js → AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DAnR-8Ny.js} +20583 -20224
- package/dist/aimd-editor.css +1 -1
- package/dist/embedded.js +2 -2
- package/dist/index.js +4 -4
- package/dist/monaco.js +1 -1
- package/dist/{theme-CB0dPzmd.js → theme-5__dt-6K.js} +2 -2
- package/dist/vue.js +3 -3
- package/dist/wysiwyg.js +1 -1
- package/package.json +4 -3
- package/src/__tests__/input-toolbar.test.ts +22 -8
- package/src/__tests__/quoted-inline-roundtrip.test.ts +30 -2
- package/src/language-config.ts +2 -2
- package/src/vue/AimdInputToolbar.vue +88 -30
- package/src/vue/AimdSourceEditor.vue +1 -1
- package/src/vue/milkdown-aimd-plugin.ts +57 -37
- package/src/vue/useEditorContent.ts +1 -1
- package/dist/AimdEditorTopBar.vue_vue_type_script_setup_true_lang-DxnCT_yh.js +0 -2352
|
@@ -0,0 +1,2417 @@
|
|
|
1
|
+
import { defineComponent as pe, computed as B, openBlock as g, createElementBlock as h, createElementVNode as i, createTextVNode as U, toDisplayString as m, Fragment as R, renderList as Y, unref as G, createCommentVNode as N, ref as F, watch as ee, createBlock as me, Teleport as Oe, withModifiers as ae, normalizeStyle as Ue, normalizeClass as ye, withDirectives as D, vModelText as L, createVNode as oe, vModelSelect as be, vModelRadio as kt, vModelCheckbox as pt, nextTick as Re, inject as wt, h as tt, resolveDynamicComponent as it, withKeys as nt, shallowRef as Xe, vShow as at } from "vue";
|
|
2
|
+
import { callCommand as Mt, insert as Ye, replaceAll as Le, getMarkdown as ot } from "@milkdown/kit/utils";
|
|
3
|
+
import "@milkdown/theme-nord/style.css";
|
|
4
|
+
import { j as ft, m as ze, k as _t, h as ut, o as Tt, p as xt, q as Ct, s as $t, t as It, u as Ft, v as At, i as zt, l as Vt, _ as St, n as Dt } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-DAnR-8Ny.js";
|
|
5
|
+
import { u as ve, g as lt, f as gt, i as De, s as Ve, h as Se, a as Ze, j as Ge, c as Et, b as rt, p as qt } from "./lexer-DKU2sEoR.js";
|
|
6
|
+
import { a as _e, c as Te, A as ht, b as Bt, u as Nt, d as Pt } from "./fields-CC93ner-.js";
|
|
7
|
+
import { _ as Lt } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-DTu36rqy.js";
|
|
8
|
+
import { protectAimdInlineTemplates as Ut, restoreAimdInlineTemplates as Rt } from "@airalogy/aimd-core";
|
|
9
|
+
import { parseAndExtract as Ot } from "@airalogy/aimd-renderer";
|
|
10
|
+
import { insertTableCommand as Ht } from "@milkdown/kit/preset/gfm";
|
|
11
|
+
var ke = 1e6, dt = 1e6, Ee = "[big.js] ", qe = Ee + "Invalid ", He = qe + "decimal places", jt = qe + "rounding mode", yt = Ee + "Division by zero", P = {}, ue = void 0;
|
|
12
|
+
function we(e, n, t, a) {
|
|
13
|
+
var o = e.c;
|
|
14
|
+
if (t === ue && (t = e.constructor.RM), t !== 0 && t !== 1 && t !== 2 && t !== 3)
|
|
15
|
+
throw Error(jt);
|
|
16
|
+
if (n < 1)
|
|
17
|
+
a = t === 3 && (a || !!o[0]) || n === 0 && (t === 1 && o[0] >= 5 || t === 2 && (o[0] > 5 || o[0] === 5 && (a || o[1] !== ue))), o.length = 1, a ? (e.e = e.e - n + 1, o[0] = 1) : o[0] = e.e = 0;
|
|
18
|
+
else if (n < o.length) {
|
|
19
|
+
if (a = t === 1 && o[n] >= 5 || t === 2 && (o[n] > 5 || o[n] === 5 && (a || o[n + 1] !== ue || o[n - 1] & 1)) || t === 3 && (a || !!o[0]), o.length = n, a) {
|
|
20
|
+
for (; ++o[--n] > 9; )
|
|
21
|
+
if (o[n] = 0, n === 0) {
|
|
22
|
+
++e.e, o.unshift(1);
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
for (n = o.length; !o[--n]; ) o.pop();
|
|
27
|
+
}
|
|
28
|
+
return e;
|
|
29
|
+
}
|
|
30
|
+
function Me(e, n, t) {
|
|
31
|
+
var a = e.e, o = e.c.join(""), v = o.length;
|
|
32
|
+
if (n)
|
|
33
|
+
o = o.charAt(0) + (v > 1 ? "." + o.slice(1) : "") + (a < 0 ? "e" : "e+") + a;
|
|
34
|
+
else if (a < 0) {
|
|
35
|
+
for (; ++a; ) o = "0" + o;
|
|
36
|
+
o = "0." + o;
|
|
37
|
+
} else if (a > 0)
|
|
38
|
+
if (++a > v)
|
|
39
|
+
for (a -= v; a--; ) o += "0";
|
|
40
|
+
else a < v && (o = o.slice(0, a) + "." + o.slice(a));
|
|
41
|
+
else v > 1 && (o = o.charAt(0) + "." + o.slice(1));
|
|
42
|
+
return e.s < 0 && t ? "-" + o : o;
|
|
43
|
+
}
|
|
44
|
+
P.abs = function() {
|
|
45
|
+
var e = new this.constructor(this);
|
|
46
|
+
return e.s = 1, e;
|
|
47
|
+
};
|
|
48
|
+
P.cmp = function(e) {
|
|
49
|
+
var n, t = this, a = t.c, o = (e = new t.constructor(e)).c, v = t.s, p = e.s, u = t.e, l = e.e;
|
|
50
|
+
if (!a[0] || !o[0]) return a[0] ? v : o[0] ? -p : 0;
|
|
51
|
+
if (v != p) return v;
|
|
52
|
+
if (n = v < 0, u != l) return u > l ^ n ? 1 : -1;
|
|
53
|
+
for (p = (u = a.length) < (l = o.length) ? u : l, v = -1; ++v < p; )
|
|
54
|
+
if (a[v] != o[v]) return a[v] > o[v] ^ n ? 1 : -1;
|
|
55
|
+
return u == l ? 0 : u > l ^ n ? 1 : -1;
|
|
56
|
+
};
|
|
57
|
+
P.div = function(e) {
|
|
58
|
+
var n = this, t = n.constructor, a = n.c, o = (e = new t(e)).c, v = n.s == e.s ? 1 : -1, p = t.DP;
|
|
59
|
+
if (p !== ~~p || p < 0 || p > ke)
|
|
60
|
+
throw Error(He);
|
|
61
|
+
if (!o[0])
|
|
62
|
+
throw Error(yt);
|
|
63
|
+
if (!a[0])
|
|
64
|
+
return e.s = v, e.c = [e.e = 0], e;
|
|
65
|
+
var u, l, c, _, d, k = o.slice(), S = u = o.length, V = a.length, y = a.slice(0, u), b = y.length, A = e, E = A.c = [], C = 0, I = p + (A.e = n.e - e.e) + 1;
|
|
66
|
+
for (A.s = v, v = I < 0 ? 0 : I, k.unshift(0); b++ < u; ) y.push(0);
|
|
67
|
+
do {
|
|
68
|
+
for (c = 0; c < 10; c++) {
|
|
69
|
+
if (u != (b = y.length))
|
|
70
|
+
_ = u > b ? 1 : -1;
|
|
71
|
+
else
|
|
72
|
+
for (d = -1, _ = 0; ++d < u; )
|
|
73
|
+
if (o[d] != y[d]) {
|
|
74
|
+
_ = o[d] > y[d] ? 1 : -1;
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (_ < 0) {
|
|
78
|
+
for (l = b == u ? o : k; b; ) {
|
|
79
|
+
if (y[--b] < l[b]) {
|
|
80
|
+
for (d = b; d && !y[--d]; ) y[d] = 9;
|
|
81
|
+
--y[d], y[b] += 10;
|
|
82
|
+
}
|
|
83
|
+
y[b] -= l[b];
|
|
84
|
+
}
|
|
85
|
+
for (; !y[0]; ) y.shift();
|
|
86
|
+
} else
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
E[C++] = _ ? c : ++c, y[0] && _ ? y[b] = a[S] || 0 : y = [a[S]];
|
|
90
|
+
} while ((S++ < V || y[0] !== ue) && v--);
|
|
91
|
+
return !E[0] && C != 1 && (E.shift(), A.e--, I--), C > I && we(A, I, t.RM, y[0] !== ue), A;
|
|
92
|
+
};
|
|
93
|
+
P.eq = function(e) {
|
|
94
|
+
return this.cmp(e) === 0;
|
|
95
|
+
};
|
|
96
|
+
P.gt = function(e) {
|
|
97
|
+
return this.cmp(e) > 0;
|
|
98
|
+
};
|
|
99
|
+
P.gte = function(e) {
|
|
100
|
+
return this.cmp(e) > -1;
|
|
101
|
+
};
|
|
102
|
+
P.lt = function(e) {
|
|
103
|
+
return this.cmp(e) < 0;
|
|
104
|
+
};
|
|
105
|
+
P.lte = function(e) {
|
|
106
|
+
return this.cmp(e) < 1;
|
|
107
|
+
};
|
|
108
|
+
P.minus = P.sub = function(e) {
|
|
109
|
+
var n, t, a, o, v = this, p = v.constructor, u = v.s, l = (e = new p(e)).s;
|
|
110
|
+
if (u != l)
|
|
111
|
+
return e.s = -l, v.plus(e);
|
|
112
|
+
var c = v.c.slice(), _ = v.e, d = e.c, k = e.e;
|
|
113
|
+
if (!c[0] || !d[0])
|
|
114
|
+
return d[0] ? e.s = -l : c[0] ? e = new p(v) : e.s = 1, e;
|
|
115
|
+
if (u = _ - k) {
|
|
116
|
+
for ((o = u < 0) ? (u = -u, a = c) : (k = _, a = d), a.reverse(), l = u; l--; ) a.push(0);
|
|
117
|
+
a.reverse();
|
|
118
|
+
} else
|
|
119
|
+
for (t = ((o = c.length < d.length) ? c : d).length, u = l = 0; l < t; l++)
|
|
120
|
+
if (c[l] != d[l]) {
|
|
121
|
+
o = c[l] < d[l];
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
if (o && (a = c, c = d, d = a, e.s = -e.s), (l = (t = d.length) - (n = c.length)) > 0) for (; l--; ) c[n++] = 0;
|
|
125
|
+
for (l = n; t > u; ) {
|
|
126
|
+
if (c[--t] < d[t]) {
|
|
127
|
+
for (n = t; n && !c[--n]; ) c[n] = 9;
|
|
128
|
+
--c[n], c[t] += 10;
|
|
129
|
+
}
|
|
130
|
+
c[t] -= d[t];
|
|
131
|
+
}
|
|
132
|
+
for (; c[--l] === 0; ) c.pop();
|
|
133
|
+
for (; c[0] === 0; )
|
|
134
|
+
c.shift(), --k;
|
|
135
|
+
return c[0] || (e.s = 1, c = [k = 0]), e.c = c, e.e = k, e;
|
|
136
|
+
};
|
|
137
|
+
P.mod = function(e) {
|
|
138
|
+
var n, t = this, a = t.constructor, o = t.s, v = (e = new a(e)).s;
|
|
139
|
+
if (!e.c[0])
|
|
140
|
+
throw Error(yt);
|
|
141
|
+
return t.s = e.s = 1, n = e.cmp(t) == 1, t.s = o, e.s = v, n ? new a(t) : (o = a.DP, v = a.RM, a.DP = a.RM = 0, t = t.div(e), a.DP = o, a.RM = v, this.minus(t.times(e)));
|
|
142
|
+
};
|
|
143
|
+
P.neg = function() {
|
|
144
|
+
var e = new this.constructor(this);
|
|
145
|
+
return e.s = -e.s, e;
|
|
146
|
+
};
|
|
147
|
+
P.plus = P.add = function(e) {
|
|
148
|
+
var n, t, a, o = this, v = o.constructor;
|
|
149
|
+
if (e = new v(e), o.s != e.s)
|
|
150
|
+
return e.s = -e.s, o.minus(e);
|
|
151
|
+
var p = o.e, u = o.c, l = e.e, c = e.c;
|
|
152
|
+
if (!u[0] || !c[0])
|
|
153
|
+
return c[0] || (u[0] ? e = new v(o) : e.s = o.s), e;
|
|
154
|
+
if (u = u.slice(), n = p - l) {
|
|
155
|
+
for (n > 0 ? (l = p, a = c) : (n = -n, a = u), a.reverse(); n--; ) a.push(0);
|
|
156
|
+
a.reverse();
|
|
157
|
+
}
|
|
158
|
+
for (u.length - c.length < 0 && (a = c, c = u, u = a), n = c.length, t = 0; n; u[n] %= 10) t = (u[--n] = u[n] + c[n] + t) / 10 | 0;
|
|
159
|
+
for (t && (u.unshift(t), ++l), n = u.length; u[--n] === 0; ) u.pop();
|
|
160
|
+
return e.c = u, e.e = l, e;
|
|
161
|
+
};
|
|
162
|
+
P.pow = function(e) {
|
|
163
|
+
var n = this, t = new n.constructor("1"), a = t, o = e < 0;
|
|
164
|
+
if (e !== ~~e || e < -dt || e > dt)
|
|
165
|
+
throw Error(qe + "exponent");
|
|
166
|
+
for (o && (e = -e); e & 1 && (a = a.times(n)), e >>= 1, !!e; )
|
|
167
|
+
n = n.times(n);
|
|
168
|
+
return o ? t.div(a) : a;
|
|
169
|
+
};
|
|
170
|
+
P.prec = function(e, n) {
|
|
171
|
+
if (e !== ~~e || e < 1 || e > ke)
|
|
172
|
+
throw Error(qe + "precision");
|
|
173
|
+
return we(new this.constructor(this), e, n);
|
|
174
|
+
};
|
|
175
|
+
P.round = function(e, n) {
|
|
176
|
+
if (e === ue) e = 0;
|
|
177
|
+
else if (e !== ~~e || e < -ke || e > ke)
|
|
178
|
+
throw Error(He);
|
|
179
|
+
return we(new this.constructor(this), e + this.e + 1, n);
|
|
180
|
+
};
|
|
181
|
+
P.sqrt = function() {
|
|
182
|
+
var e, n, t, a = this, o = a.constructor, v = a.s, p = a.e, u = new o("0.5");
|
|
183
|
+
if (!a.c[0]) return new o(a);
|
|
184
|
+
if (v < 0)
|
|
185
|
+
throw Error(Ee + "No square root");
|
|
186
|
+
v = Math.sqrt(+Me(a, !0, !0)), v === 0 || v === 1 / 0 ? (n = a.c.join(""), n.length + p & 1 || (n += "0"), v = Math.sqrt(n), p = ((p + 1) / 2 | 0) - (p < 0 || p & 1), e = new o((v == 1 / 0 ? "5e" : (v = v.toExponential()).slice(0, v.indexOf("e") + 1)) + p)) : e = new o(v + ""), p = e.e + (o.DP += 4);
|
|
187
|
+
do
|
|
188
|
+
t = e, e = u.times(t.plus(a.div(t)));
|
|
189
|
+
while (t.c.slice(0, p).join("") !== e.c.slice(0, p).join(""));
|
|
190
|
+
return we(e, (o.DP -= 4) + e.e + 1, o.RM);
|
|
191
|
+
};
|
|
192
|
+
P.times = P.mul = function(e) {
|
|
193
|
+
var n, t = this, a = t.constructor, o = t.c, v = (e = new a(e)).c, p = o.length, u = v.length, l = t.e, c = e.e;
|
|
194
|
+
if (e.s = t.s == e.s ? 1 : -1, !o[0] || !v[0])
|
|
195
|
+
return e.c = [e.e = 0], e;
|
|
196
|
+
for (e.e = l + c, p < u && (n = o, o = v, v = n, c = p, p = u, u = c), n = new Array(c = p + u); c--; ) n[c] = 0;
|
|
197
|
+
for (l = u; l--; ) {
|
|
198
|
+
for (u = 0, c = p + l; c > l; )
|
|
199
|
+
u = n[c] + v[l] * o[c - l - 1] + u, n[c--] = u % 10, u = u / 10 | 0;
|
|
200
|
+
n[c] = u;
|
|
201
|
+
}
|
|
202
|
+
for (u ? ++e.e : n.shift(), l = n.length; !n[--l]; ) n.pop();
|
|
203
|
+
return e.c = n, e;
|
|
204
|
+
};
|
|
205
|
+
P.toExponential = function(e, n) {
|
|
206
|
+
var t = this, a = t.c[0];
|
|
207
|
+
if (e !== ue) {
|
|
208
|
+
if (e !== ~~e || e < 0 || e > ke)
|
|
209
|
+
throw Error(He);
|
|
210
|
+
for (t = we(new t.constructor(t), ++e, n); t.c.length < e; ) t.c.push(0);
|
|
211
|
+
}
|
|
212
|
+
return Me(t, !0, !!a);
|
|
213
|
+
};
|
|
214
|
+
P.toFixed = function(e, n) {
|
|
215
|
+
var t = this, a = t.c[0];
|
|
216
|
+
if (e !== ue) {
|
|
217
|
+
if (e !== ~~e || e < 0 || e > ke)
|
|
218
|
+
throw Error(He);
|
|
219
|
+
for (t = we(new t.constructor(t), e + t.e + 1, n), e = e + t.e + 1; t.c.length < e; ) t.c.push(0);
|
|
220
|
+
}
|
|
221
|
+
return Me(t, !1, !!a);
|
|
222
|
+
};
|
|
223
|
+
P[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P.toJSON = P.toString = function() {
|
|
224
|
+
var e = this, n = e.constructor;
|
|
225
|
+
return Me(e, e.e <= n.NE || e.e >= n.PE, !!e.c[0]);
|
|
226
|
+
};
|
|
227
|
+
P.toNumber = function() {
|
|
228
|
+
var e = +Me(this, !0, !0);
|
|
229
|
+
if (this.constructor.strict === !0 && !this.eq(e.toString()))
|
|
230
|
+
throw Error(Ee + "Imprecise conversion");
|
|
231
|
+
return e;
|
|
232
|
+
};
|
|
233
|
+
P.toPrecision = function(e, n) {
|
|
234
|
+
var t = this, a = t.constructor, o = t.c[0];
|
|
235
|
+
if (e !== ue) {
|
|
236
|
+
if (e !== ~~e || e < 1 || e > ke)
|
|
237
|
+
throw Error(qe + "precision");
|
|
238
|
+
for (t = we(new a(t), e, n); t.c.length < e; ) t.c.push(0);
|
|
239
|
+
}
|
|
240
|
+
return Me(t, e <= t.e || t.e <= a.NE || t.e >= a.PE, !!o);
|
|
241
|
+
};
|
|
242
|
+
P.valueOf = function() {
|
|
243
|
+
var e = this, n = e.constructor;
|
|
244
|
+
if (n.strict === !0)
|
|
245
|
+
throw Error(Ee + "valueOf disallowed");
|
|
246
|
+
return Me(e, e.e <= n.NE || e.e >= n.PE, !0);
|
|
247
|
+
};
|
|
248
|
+
const Kt = { class: "aimd-type-picker" }, Wt = ["value"], Qt = { value: "" }, Jt = ["label"], Xt = ["value"], Yt = ["label"], Zt = ["value"], Gt = ["value", "placeholder"], el = /* @__PURE__ */ pe({
|
|
249
|
+
__name: "AimdTypePicker",
|
|
250
|
+
props: {
|
|
251
|
+
modelValue: {},
|
|
252
|
+
messages: {},
|
|
253
|
+
varTypePlugins: {}
|
|
254
|
+
},
|
|
255
|
+
emits: ["update:modelValue"],
|
|
256
|
+
setup(e, { emit: n }) {
|
|
257
|
+
const t = e, a = n, o = gt();
|
|
258
|
+
function v(c) {
|
|
259
|
+
const _ = lt(c)?.title;
|
|
260
|
+
return _ && _ !== c ? `${_} (${c})` : c;
|
|
261
|
+
}
|
|
262
|
+
const p = B(() => [...new Map((t.varTypePlugins ?? []).map((c) => [c.value, c])).values()].filter((c) => !o.includes(c.value))), u = B(() => {
|
|
263
|
+
const c = ve(t.modelValue);
|
|
264
|
+
return lt(c)?.type_name ?? (p.value.some((_) => _.value === c) ? c : "");
|
|
265
|
+
});
|
|
266
|
+
function l(c) {
|
|
267
|
+
const _ = c.target.value;
|
|
268
|
+
_ && a("update:modelValue", _ + (De(t.modelValue) ? " | None" : ""));
|
|
269
|
+
}
|
|
270
|
+
return (c, _) => (g(), h("div", Kt, [
|
|
271
|
+
i("label", null, [
|
|
272
|
+
U(m(e.messages.inputField.knownTypes) + " ", 1),
|
|
273
|
+
i("select", {
|
|
274
|
+
name: "knownType",
|
|
275
|
+
value: u.value,
|
|
276
|
+
onChange: l
|
|
277
|
+
}, [
|
|
278
|
+
i("option", Qt, m(e.messages.inputField.customExpression), 1),
|
|
279
|
+
i("optgroup", {
|
|
280
|
+
label: e.messages.inputField.builtInTypes
|
|
281
|
+
}, [
|
|
282
|
+
(g(!0), h(R, null, Y(G(o), (d) => (g(), h("option", {
|
|
283
|
+
key: d,
|
|
284
|
+
value: d
|
|
285
|
+
}, m(v(d)), 9, Xt))), 128))
|
|
286
|
+
], 8, Jt),
|
|
287
|
+
p.value.length ? (g(), h("optgroup", {
|
|
288
|
+
key: 0,
|
|
289
|
+
label: e.messages.inputField.pluginTypes
|
|
290
|
+
}, [
|
|
291
|
+
(g(!0), h(R, null, Y(p.value, (d) => (g(), h("option", {
|
|
292
|
+
key: d.value,
|
|
293
|
+
value: d.value
|
|
294
|
+
}, m(d.label) + " (" + m(d.value) + ")", 9, Zt))), 128))
|
|
295
|
+
], 8, Yt)) : N("", !0)
|
|
296
|
+
], 40, Wt)
|
|
297
|
+
]),
|
|
298
|
+
i("label", null, [
|
|
299
|
+
U(m(e.messages.dialog.customType), 1),
|
|
300
|
+
i("input", {
|
|
301
|
+
name: "type",
|
|
302
|
+
value: e.modelValue,
|
|
303
|
+
placeholder: e.messages.placeholders.type,
|
|
304
|
+
spellcheck: "false",
|
|
305
|
+
onInput: _[0] || (_[0] = (d) => a("update:modelValue", d.target.value))
|
|
306
|
+
}, null, 40, Gt)
|
|
307
|
+
])
|
|
308
|
+
]));
|
|
309
|
+
}
|
|
310
|
+
}), je = (e, n) => {
|
|
311
|
+
const t = e.__vccOpts || e;
|
|
312
|
+
for (const [a, o] of n)
|
|
313
|
+
t[a] = o;
|
|
314
|
+
return t;
|
|
315
|
+
}, bt = /* @__PURE__ */ je(el, [["__scopeId", "data-v-be127780"]]), tl = { class: "aimd-dialog" }, ll = { class: "aimd-dialog-header" }, sl = { class: "aimd-dialog-title" }, il = ["innerHTML"], nl = { class: "aimd-dialog-type-tabs" }, al = ["onClick"], ol = ["innerHTML"], ul = { class: "aimd-dialog-body" }, rl = { class: "aimd-field-row" }, dl = { class: "aimd-field-label" }, cl = ["placeholder"], vl = { class: "aimd-field-row" }, ml = { class: "aimd-field-label" }, pl = { class: "aimd-field-hint" }, fl = { class: "aimd-var-type-grid" }, gl = ["onClick"], hl = { class: "aimd-var-type-card-title" }, yl = { class: "aimd-var-type-card-desc" }, bl = { class: "aimd-field-row" }, kl = { class: "aimd-field-label" }, wl = ["placeholder"], Ml = { class: "aimd-field-row" }, _l = { class: "aimd-field-label" }, Tl = ["placeholder"], xl = { class: "aimd-field-row" }, Cl = { class: "aimd-field-label" }, $l = ["placeholder"], Il = { class: "aimd-field-row" }, Fl = { class: "aimd-field-label" }, Al = ["placeholder"], zl = { class: "aimd-field-hint" }, Vl = { class: "aimd-field-row" }, Sl = { class: "aimd-field-label" }, Dl = { class: "aimd-field-row" }, El = { class: "aimd-field-label" }, ql = ["placeholder"], Bl = { class: "aimd-field-row" }, Nl = { class: "aimd-field-label" }, Pl = { value: "1" }, Ll = { value: "2" }, Ul = { value: "3" }, Rl = { class: "aimd-field-row" }, Ol = { class: "aimd-field-label" }, Hl = ["placeholder"], jl = { class: "aimd-field-row" }, Kl = { class: "aimd-field-label" }, Wl = { value: "choice" }, Ql = { value: "blank" }, Jl = { value: "open" }, Xl = { class: "aimd-field-row" }, Yl = { class: "aimd-field-label" }, Zl = ["placeholder"], Gl = { class: "aimd-field-row" }, es = { class: "aimd-field-label" }, ts = ["placeholder"], ls = {
|
|
316
|
+
key: 0,
|
|
317
|
+
class: "aimd-field-hint"
|
|
318
|
+
}, ss = { class: "aimd-field-row" }, is = { class: "aimd-field-label" }, ns = { value: "single" }, as = { value: "multiple" }, os = { class: "aimd-field-row" }, us = { class: "aimd-field-label" }, rs = { class: "aimd-collection-editor" }, ds = ["onDragover", "onDrop"], cs = ["title", "onDragstart"], vs = ["onUpdate:modelValue", "placeholder"], ms = ["onUpdate:modelValue", "placeholder"], ps = { class: "aimd-option-answer-toggle" }, fs = ["value", "disabled"], gs = ["value", "disabled"], hs = ["disabled", "onClick"], ys = { class: "aimd-field-hint" }, bs = {
|
|
319
|
+
key: 1,
|
|
320
|
+
class: "aimd-field-row"
|
|
321
|
+
}, ks = { class: "aimd-field-label" }, ws = { class: "aimd-collection-editor" }, Ms = ["onUpdate:modelValue", "placeholder"], _s = ["onUpdate:modelValue", "placeholder"], Ts = ["disabled", "onClick"], xs = { class: "aimd-field-hint" }, Cs = {
|
|
322
|
+
key: 2,
|
|
323
|
+
class: "aimd-field-row"
|
|
324
|
+
}, $s = { class: "aimd-field-label" }, Is = ["placeholder"], Fs = { class: "aimd-field-row" }, As = { class: "aimd-field-label" }, zs = { class: "aimd-field-row" }, Vs = { class: "aimd-field-label" }, Ss = ["placeholder"], Ds = { class: "aimd-field-row" }, Es = { class: "aimd-field-label" }, qs = {
|
|
325
|
+
key: 5,
|
|
326
|
+
class: "aimd-field-row"
|
|
327
|
+
}, Bs = { class: "aimd-field-label" }, Ns = ["placeholder"], Ps = { id: "aimd-ref-suggestions" }, Ls = ["value"], Us = {
|
|
328
|
+
key: 0,
|
|
329
|
+
class: "aimd-field-hint"
|
|
330
|
+
}, Rs = {
|
|
331
|
+
key: 6,
|
|
332
|
+
class: "aimd-field-row"
|
|
333
|
+
}, Os = { class: "aimd-field-label" }, Hs = ["placeholder"], js = { class: "aimd-field-hint" }, Ks = { class: "aimd-dialog-preview" }, Ws = { class: "aimd-preview-header" }, Qs = { class: "aimd-preview-panel" }, Js = { class: "aimd-preview-code" }, Xs = {
|
|
334
|
+
key: 7,
|
|
335
|
+
class: "aimd-dialog-error"
|
|
336
|
+
}, Ys = { class: "aimd-dialog-footer" }, Zs = /* @__PURE__ */ pe({
|
|
337
|
+
__name: "AimdFieldDialog",
|
|
338
|
+
props: {
|
|
339
|
+
visible: { type: Boolean },
|
|
340
|
+
initialType: {},
|
|
341
|
+
messages: {},
|
|
342
|
+
refSuggestions: {},
|
|
343
|
+
varTypePlugins: {},
|
|
344
|
+
allowedTypes: {},
|
|
345
|
+
existingQuizIds: {}
|
|
346
|
+
},
|
|
347
|
+
emits: ["update:visible", "insert"],
|
|
348
|
+
setup(e, { emit: n }) {
|
|
349
|
+
const t = e, a = n, o = B(() => {
|
|
350
|
+
const f = ft(t.messages);
|
|
351
|
+
if (!t.allowedTypes || t.allowedTypes.length === 0)
|
|
352
|
+
return f;
|
|
353
|
+
const r = new Set(t.allowedTypes);
|
|
354
|
+
return f.filter((s) => r.has(s.type));
|
|
355
|
+
});
|
|
356
|
+
function v(f) {
|
|
357
|
+
return f && o.value.some((r) => r.type === f) ? f : o.value[0]?.type ?? f ?? "var";
|
|
358
|
+
}
|
|
359
|
+
const p = B(() => new Set(t.existingQuizIds || [])), u = F(v(t.initialType)), l = F(ze(u.value, t.messages, p.value)), c = F([]), _ = F([]), d = F([]), k = F(null), S = F(null), V = F(""), y = B(
|
|
360
|
+
() => _t(t.messages, t.varTypePlugins ?? [])
|
|
361
|
+
);
|
|
362
|
+
function b(f) {
|
|
363
|
+
return (f || "").trim().toLowerCase().replace(/[\s_-]/g, "");
|
|
364
|
+
}
|
|
365
|
+
function A(f) {
|
|
366
|
+
return b(l.value.type) === b(f);
|
|
367
|
+
}
|
|
368
|
+
function E(f) {
|
|
369
|
+
l.value.type = f;
|
|
370
|
+
}
|
|
371
|
+
function C(f, r) {
|
|
372
|
+
const s = `quiz_${f}`;
|
|
373
|
+
let M = 1;
|
|
374
|
+
for (; r.has(`${s}_${M}`); )
|
|
375
|
+
M += 1;
|
|
376
|
+
return `${s}_${M}`;
|
|
377
|
+
}
|
|
378
|
+
function I(f) {
|
|
379
|
+
const r = f.split(",").map((s) => s.trim()).filter(Boolean);
|
|
380
|
+
return r.length === 0 ? [
|
|
381
|
+
{ key: "A", text: "" },
|
|
382
|
+
{ key: "B", text: "" }
|
|
383
|
+
] : r.map((s, M) => {
|
|
384
|
+
const q = s.indexOf(":");
|
|
385
|
+
if (q > 0) {
|
|
386
|
+
const ge = s.slice(0, q).trim() || String.fromCharCode(65 + M), Be = s.slice(q + 1).trim() || t.messages.defaults.optionText(ge);
|
|
387
|
+
return { key: ge, text: Be };
|
|
388
|
+
}
|
|
389
|
+
return { key: String.fromCharCode(65 + M), text: s };
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
function W(f) {
|
|
393
|
+
const r = f.map((s) => ({ key: s.key.trim(), text: s.text.trim() })).filter((s) => s.key && s.text);
|
|
394
|
+
return r.length === 0 ? "A:, B:" : r.map((s) => `${s.key}:${s.text}`).join(", ");
|
|
395
|
+
}
|
|
396
|
+
function le(f) {
|
|
397
|
+
const r = f.split(",").map((s) => s.trim()).filter(Boolean);
|
|
398
|
+
return r.length === 0 ? [{ key: "b1", answer: "" }] : r.map((s, M) => {
|
|
399
|
+
const q = s.indexOf(":");
|
|
400
|
+
if (q > 0) {
|
|
401
|
+
const Fe = s.slice(0, q).trim() || `b${M + 1}`, ge = s.slice(q + 1).trim() || "";
|
|
402
|
+
return { key: Fe, answer: ge };
|
|
403
|
+
}
|
|
404
|
+
return { key: `b${M + 1}`, answer: s };
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
function j(f) {
|
|
408
|
+
const r = f.map((s) => ({ key: s.key.trim(), answer: s.answer.trim() })).filter((s) => s.key);
|
|
409
|
+
return r.length === 0 ? "b1:" : r.map((s) => `${s.key}:${s.answer}`).join(", ");
|
|
410
|
+
}
|
|
411
|
+
function O(f) {
|
|
412
|
+
return f.split(",").map((r) => r.trim()).filter(Boolean);
|
|
413
|
+
}
|
|
414
|
+
function K() {
|
|
415
|
+
u.value === "quiz" && (l.value.quizType === "choice" ? (c.value = I(l.value.options || ""), d.value = O(l.value.answer || "")) : l.value.quizType === "blank" && (_.value = le(l.value.blanks || "")));
|
|
416
|
+
}
|
|
417
|
+
function X() {
|
|
418
|
+
if (u.value !== "quiz" || l.value.quizType !== "choice") return;
|
|
419
|
+
const f = new Set(
|
|
420
|
+
c.value.map((r) => r.key.trim()).filter(Boolean)
|
|
421
|
+
);
|
|
422
|
+
if (l.value.mode === "multiple") {
|
|
423
|
+
const r = d.value.map((s) => s.trim()).filter((s) => s && f.has(s));
|
|
424
|
+
r.length !== d.value.length && (d.value = r);
|
|
425
|
+
} else {
|
|
426
|
+
const r = (l.value.answer || "").trim();
|
|
427
|
+
r && !f.has(r) && (l.value.answer = "");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function se() {
|
|
431
|
+
const f = new Set(
|
|
432
|
+
c.value.map((r) => r.key.trim().toUpperCase()).filter(Boolean)
|
|
433
|
+
);
|
|
434
|
+
for (let r = 0; r < 26; r++) {
|
|
435
|
+
const s = String.fromCharCode(65 + r);
|
|
436
|
+
if (!f.has(s)) return s;
|
|
437
|
+
}
|
|
438
|
+
return `K${c.value.length + 1}`;
|
|
439
|
+
}
|
|
440
|
+
function T() {
|
|
441
|
+
const f = se();
|
|
442
|
+
c.value.push({ key: f, text: "" });
|
|
443
|
+
}
|
|
444
|
+
function z(f) {
|
|
445
|
+
c.value.length <= 1 || c.value.splice(f, 1);
|
|
446
|
+
}
|
|
447
|
+
function H(f) {
|
|
448
|
+
k.value = f, S.value = f;
|
|
449
|
+
}
|
|
450
|
+
function J(f) {
|
|
451
|
+
k.value !== null && (S.value = f);
|
|
452
|
+
}
|
|
453
|
+
function x(f) {
|
|
454
|
+
const r = k.value;
|
|
455
|
+
if (r === null || r === f) {
|
|
456
|
+
k.value = null, S.value = null;
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const s = c.value.splice(r, 1)[0];
|
|
460
|
+
c.value.splice(f, 0, s), k.value = null, S.value = null;
|
|
461
|
+
}
|
|
462
|
+
function w() {
|
|
463
|
+
k.value = null, S.value = null;
|
|
464
|
+
}
|
|
465
|
+
function $() {
|
|
466
|
+
const f = new Set(
|
|
467
|
+
_.value.map((s) => s.key.trim().toLowerCase()).filter(Boolean)
|
|
468
|
+
);
|
|
469
|
+
let r = 1;
|
|
470
|
+
for (; f.has(`b${r}`); )
|
|
471
|
+
r += 1;
|
|
472
|
+
return `b${r}`;
|
|
473
|
+
}
|
|
474
|
+
function Q() {
|
|
475
|
+
_.value.push({ key: $(), answer: "" });
|
|
476
|
+
}
|
|
477
|
+
function Z(f) {
|
|
478
|
+
_.value.length <= 1 || _.value.splice(f, 1);
|
|
479
|
+
}
|
|
480
|
+
function te(f) {
|
|
481
|
+
const r = /* @__PURE__ */ new Set(), s = [];
|
|
482
|
+
for (const M of f)
|
|
483
|
+
r.has(M) && !s.includes(M) && s.push(M), r.add(M);
|
|
484
|
+
return s;
|
|
485
|
+
}
|
|
486
|
+
function re(f) {
|
|
487
|
+
const r = [], s = /\[\[([^\[\]\s]+)\]\]/g;
|
|
488
|
+
for (const M of f.matchAll(s))
|
|
489
|
+
r.push(M[1]);
|
|
490
|
+
return r;
|
|
491
|
+
}
|
|
492
|
+
function ne() {
|
|
493
|
+
const f = _.value.map((Ae) => Ae.key.trim()).filter(Boolean);
|
|
494
|
+
if (f.length === 0)
|
|
495
|
+
return t.messages.errors.blankQuizRequiresBlankKey;
|
|
496
|
+
const r = te(f);
|
|
497
|
+
if (r.length > 0)
|
|
498
|
+
return t.messages.errors.blankKeysMustBeUnique(r);
|
|
499
|
+
const s = l.value.stem || "", M = re(s);
|
|
500
|
+
if (M.length === 0)
|
|
501
|
+
return t.messages.errors.blankStemRequiresPlaceholders;
|
|
502
|
+
const q = te(M);
|
|
503
|
+
if (q.length > 0)
|
|
504
|
+
return t.messages.errors.duplicatePlaceholders(q);
|
|
505
|
+
const Fe = new Set(f), ge = new Set(M), Be = [...ge].filter((Ae) => !Fe.has(Ae));
|
|
506
|
+
if (Be.length > 0)
|
|
507
|
+
return t.messages.errors.undefinedPlaceholders(Be);
|
|
508
|
+
const st = [...Fe].filter((Ae) => !ge.has(Ae));
|
|
509
|
+
return st.length > 0 ? t.messages.errors.missingPlaceholders(st) : null;
|
|
510
|
+
}
|
|
511
|
+
function fe() {
|
|
512
|
+
return u.value !== "quiz" || l.value.quizType !== "blank" ? null : ne();
|
|
513
|
+
}
|
|
514
|
+
ee(() => t.initialType, (f) => {
|
|
515
|
+
const r = v(f);
|
|
516
|
+
u.value = r, l.value = ze(r, t.messages, p.value), K(), V.value = "";
|
|
517
|
+
}), ee(o, () => {
|
|
518
|
+
const f = v(u.value);
|
|
519
|
+
f !== u.value && (u.value = f, l.value = ze(f, t.messages, p.value), K(), V.value = "");
|
|
520
|
+
}), ee(() => t.visible, (f) => {
|
|
521
|
+
f && (l.value = ze(u.value, t.messages, p.value), K(), V.value = "");
|
|
522
|
+
});
|
|
523
|
+
function de(f) {
|
|
524
|
+
const r = v(f);
|
|
525
|
+
u.value = r, l.value = ze(r, t.messages, p.value), K(), V.value = "";
|
|
526
|
+
}
|
|
527
|
+
const xe = B(() => ut(u.value, l.value, t.messages));
|
|
528
|
+
function Ke(f) {
|
|
529
|
+
return o.value.find((r) => r.type === f) || { type: f, label: f, icon: "?", svgIcon: "", desc: "", color: "#666" };
|
|
530
|
+
}
|
|
531
|
+
const Ce = B(() => Ke(u.value)), $e = B(() => t.refSuggestions ? t.refSuggestions : []), We = B(() => u.value === "ref_step" ? t.messages.dialog.referencedStepId : u.value === "ref_var" ? t.messages.dialog.referencedVariableId : t.messages.dialog.referencedFigureId), Qe = B(() => u.value === "ref_step" ? "step_id" : u.value === "ref_var" ? "var_id" : "fig_id");
|
|
532
|
+
ee(() => [u.value, l.value.quizType], ([f, r], [s, M]) => {
|
|
533
|
+
f === "quiz" && (f !== s || r !== M) && (r !== M && M && (l.value.id = C(r, p.value), r === "choice" ? (l.value.stem = t.messages.defaults.questionStem, l.value.mode = "single", l.value.options = "A:, B:", l.value.answer = "A", l.value.blanks = "", l.value.rubric = "") : r === "blank" ? (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.blanks = "b1:", l.value.options = "", l.value.answer = "", l.value.mode = "", l.value.rubric = "", _.value = [{ key: "b1", answer: "" }]) : r === "open" && (l.value.stem = t.messages.defaults.fillQuestionStem, l.value.rubric = "", l.value.options = "", l.value.answer = "", l.value.blanks = "", l.value.mode = "")), K());
|
|
534
|
+
}), ee(() => l.value.mode, () => {
|
|
535
|
+
X();
|
|
536
|
+
}), ee(c, (f) => {
|
|
537
|
+
u.value === "quiz" && l.value.quizType === "choice" && (l.value.options = W(f), X());
|
|
538
|
+
}, { deep: !0 }), ee(_, (f) => {
|
|
539
|
+
u.value === "quiz" && l.value.quizType === "blank" && (l.value.blanks = j(f));
|
|
540
|
+
}, { deep: !0 }), ee(d, (f) => {
|
|
541
|
+
u.value === "quiz" && l.value.quizType === "choice" && l.value.mode === "multiple" && (l.value.answer = f.join(", "));
|
|
542
|
+
}, { deep: !0 }), ee(l, () => {
|
|
543
|
+
V.value && (V.value = "");
|
|
544
|
+
}, { deep: !0 }), ee(_, () => {
|
|
545
|
+
V.value && (V.value = "");
|
|
546
|
+
}, { deep: !0 });
|
|
547
|
+
function Je() {
|
|
548
|
+
const f = fe();
|
|
549
|
+
if (f) {
|
|
550
|
+
V.value = f;
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
V.value = "", a("insert", ut(u.value, l.value, t.messages)), a("update:visible", !1);
|
|
554
|
+
}
|
|
555
|
+
function Ie() {
|
|
556
|
+
a("update:visible", !1);
|
|
557
|
+
}
|
|
558
|
+
return (f, r) => (g(), me(Oe, { to: "body" }, [
|
|
559
|
+
e.visible ? (g(), h("div", {
|
|
560
|
+
key: 0,
|
|
561
|
+
class: "aimd-dialog-overlay",
|
|
562
|
+
onClick: ae(Ie, ["self"])
|
|
563
|
+
}, [
|
|
564
|
+
i("div", tl, [
|
|
565
|
+
i("div", ll, [
|
|
566
|
+
i("span", sl, [
|
|
567
|
+
i("span", {
|
|
568
|
+
class: "aimd-dialog-icon",
|
|
569
|
+
style: Ue({ color: Ce.value.color }),
|
|
570
|
+
innerHTML: Ce.value.svgIcon
|
|
571
|
+
}, null, 12, il),
|
|
572
|
+
U(" " + m(t.messages.dialog.title(Ce.value.label)), 1)
|
|
573
|
+
]),
|
|
574
|
+
i("button", {
|
|
575
|
+
class: "aimd-dialog-close",
|
|
576
|
+
onClick: Ie
|
|
577
|
+
}, "×")
|
|
578
|
+
]),
|
|
579
|
+
i("div", nl, [
|
|
580
|
+
(g(!0), h(R, null, Y(o.value, (s) => (g(), h("button", {
|
|
581
|
+
key: s.type,
|
|
582
|
+
class: ye(["aimd-type-tab", { active: u.value === s.type }]),
|
|
583
|
+
style: Ue(u.value === s.type ? { borderColor: s.color, color: s.color, background: `${s.color}14` } : {}),
|
|
584
|
+
onClick: (M) => de(s.type)
|
|
585
|
+
}, [
|
|
586
|
+
i("span", {
|
|
587
|
+
innerHTML: s.svgIcon,
|
|
588
|
+
class: "aimd-type-tab-icon"
|
|
589
|
+
}, null, 8, ol),
|
|
590
|
+
U(" " + m(s.label), 1)
|
|
591
|
+
], 14, al))), 128))
|
|
592
|
+
]),
|
|
593
|
+
i("div", ul, [
|
|
594
|
+
u.value === "var" ? (g(), h(R, { key: 0 }, [
|
|
595
|
+
i("label", rl, [
|
|
596
|
+
i("span", dl, [
|
|
597
|
+
U(m(t.messages.dialog.variableId) + " ", 1),
|
|
598
|
+
r[22] || (r[22] = i("em", null, "*", -1))
|
|
599
|
+
]),
|
|
600
|
+
D(i("input", {
|
|
601
|
+
"onUpdate:modelValue": r[0] || (r[0] = (s) => l.value.name = s),
|
|
602
|
+
placeholder: t.messages.placeholders.variableId,
|
|
603
|
+
class: "aimd-field-input"
|
|
604
|
+
}, null, 8, cl), [
|
|
605
|
+
[L, l.value.name]
|
|
606
|
+
])
|
|
607
|
+
]),
|
|
608
|
+
i("div", vl, [
|
|
609
|
+
i("span", ml, m(t.messages.dialog.typePresetLabel), 1),
|
|
610
|
+
i("span", pl, m(t.messages.dialog.typeHint), 1),
|
|
611
|
+
i("div", fl, [
|
|
612
|
+
(g(!0), h(R, null, Y(y.value, (s) => (g(), h("button", {
|
|
613
|
+
key: s.key,
|
|
614
|
+
type: "button",
|
|
615
|
+
class: ye(["aimd-var-type-card", { active: A(s.value) }]),
|
|
616
|
+
onClick: (M) => E(s.value)
|
|
617
|
+
}, [
|
|
618
|
+
i("span", hl, m(s.label), 1),
|
|
619
|
+
i("span", yl, m(s.desc), 1)
|
|
620
|
+
], 10, gl))), 128))
|
|
621
|
+
])
|
|
622
|
+
]),
|
|
623
|
+
oe(bt, {
|
|
624
|
+
modelValue: l.value.type,
|
|
625
|
+
"onUpdate:modelValue": r[1] || (r[1] = (s) => l.value.type = s),
|
|
626
|
+
messages: e.messages,
|
|
627
|
+
"var-type-plugins": e.varTypePlugins
|
|
628
|
+
}, null, 8, ["modelValue", "messages", "var-type-plugins"]),
|
|
629
|
+
i("label", bl, [
|
|
630
|
+
i("span", kl, m(t.messages.dialog.defaultValue), 1),
|
|
631
|
+
D(i("input", {
|
|
632
|
+
"onUpdate:modelValue": r[2] || (r[2] = (s) => l.value.default = s),
|
|
633
|
+
placeholder: t.messages.placeholders.defaultValue,
|
|
634
|
+
class: "aimd-field-input"
|
|
635
|
+
}, null, 8, wl), [
|
|
636
|
+
[L, l.value.default]
|
|
637
|
+
])
|
|
638
|
+
]),
|
|
639
|
+
i("label", Ml, [
|
|
640
|
+
i("span", _l, m(t.messages.dialog.titleLabel), 1),
|
|
641
|
+
D(i("input", {
|
|
642
|
+
"onUpdate:modelValue": r[3] || (r[3] = (s) => l.value.title = s),
|
|
643
|
+
placeholder: t.messages.placeholders.title,
|
|
644
|
+
class: "aimd-field-input"
|
|
645
|
+
}, null, 8, Tl), [
|
|
646
|
+
[L, l.value.title]
|
|
647
|
+
])
|
|
648
|
+
])
|
|
649
|
+
], 64)) : N("", !0),
|
|
650
|
+
u.value === "var_table" ? (g(), h(R, { key: 1 }, [
|
|
651
|
+
i("label", xl, [
|
|
652
|
+
i("span", Cl, [
|
|
653
|
+
U(m(t.messages.dialog.tableId) + " ", 1),
|
|
654
|
+
r[23] || (r[23] = i("em", null, "*", -1))
|
|
655
|
+
]),
|
|
656
|
+
D(i("input", {
|
|
657
|
+
"onUpdate:modelValue": r[4] || (r[4] = (s) => l.value.name = s),
|
|
658
|
+
placeholder: t.messages.placeholders.tableId,
|
|
659
|
+
class: "aimd-field-input"
|
|
660
|
+
}, null, 8, $l), [
|
|
661
|
+
[L, l.value.name]
|
|
662
|
+
])
|
|
663
|
+
]),
|
|
664
|
+
i("label", Il, [
|
|
665
|
+
i("span", Fl, m(t.messages.dialog.subVariableColumns), 1),
|
|
666
|
+
D(i("input", {
|
|
667
|
+
"onUpdate:modelValue": r[5] || (r[5] = (s) => l.value.subvars = s),
|
|
668
|
+
placeholder: t.messages.placeholders.subVariableColumns,
|
|
669
|
+
class: "aimd-field-input"
|
|
670
|
+
}, null, 8, Al), [
|
|
671
|
+
[L, l.value.subvars]
|
|
672
|
+
]),
|
|
673
|
+
i("span", zl, m(t.messages.dialog.subVariableColumnsHint), 1)
|
|
674
|
+
])
|
|
675
|
+
], 64)) : N("", !0),
|
|
676
|
+
u.value === "step" ? (g(), h(R, { key: 2 }, [
|
|
677
|
+
i("label", Vl, [
|
|
678
|
+
i("span", Sl, m(t.messages.stepField.name), 1),
|
|
679
|
+
D(i("input", {
|
|
680
|
+
"onUpdate:modelValue": r[6] || (r[6] = (s) => l.value.title = s),
|
|
681
|
+
class: "aimd-field-input"
|
|
682
|
+
}, null, 512), [
|
|
683
|
+
[L, l.value.title]
|
|
684
|
+
])
|
|
685
|
+
]),
|
|
686
|
+
i("label", Dl, [
|
|
687
|
+
i("span", El, [
|
|
688
|
+
U(m(t.messages.dialog.stepId) + " ", 1),
|
|
689
|
+
r[24] || (r[24] = i("em", null, "*", -1))
|
|
690
|
+
]),
|
|
691
|
+
D(i("input", {
|
|
692
|
+
"onUpdate:modelValue": r[7] || (r[7] = (s) => l.value.name = s),
|
|
693
|
+
placeholder: t.messages.placeholders.stepId,
|
|
694
|
+
class: "aimd-field-input"
|
|
695
|
+
}, null, 8, ql), [
|
|
696
|
+
[L, l.value.name]
|
|
697
|
+
])
|
|
698
|
+
]),
|
|
699
|
+
i("label", Bl, [
|
|
700
|
+
i("span", Nl, m(t.messages.dialog.level), 1),
|
|
701
|
+
D(i("select", {
|
|
702
|
+
"onUpdate:modelValue": r[8] || (r[8] = (s) => l.value.level = s),
|
|
703
|
+
class: "aimd-field-input"
|
|
704
|
+
}, [
|
|
705
|
+
i("option", Pl, m(t.messages.dialog.level1), 1),
|
|
706
|
+
i("option", Ll, m(t.messages.dialog.level2), 1),
|
|
707
|
+
i("option", Ul, m(t.messages.dialog.level3), 1)
|
|
708
|
+
], 512), [
|
|
709
|
+
[be, l.value.level]
|
|
710
|
+
])
|
|
711
|
+
])
|
|
712
|
+
], 64)) : N("", !0),
|
|
713
|
+
u.value === "quiz" ? (g(), h(R, { key: 3 }, [
|
|
714
|
+
i("label", Rl, [
|
|
715
|
+
i("span", Ol, [
|
|
716
|
+
U(m(t.messages.dialog.quizId) + " ", 1),
|
|
717
|
+
r[25] || (r[25] = i("em", null, "*", -1))
|
|
718
|
+
]),
|
|
719
|
+
D(i("input", {
|
|
720
|
+
"onUpdate:modelValue": r[9] || (r[9] = (s) => l.value.id = s),
|
|
721
|
+
placeholder: t.messages.placeholders.quizId,
|
|
722
|
+
class: "aimd-field-input"
|
|
723
|
+
}, null, 8, Hl), [
|
|
724
|
+
[L, l.value.id]
|
|
725
|
+
])
|
|
726
|
+
]),
|
|
727
|
+
i("label", jl, [
|
|
728
|
+
i("span", Kl, m(t.messages.dialog.questionType), 1),
|
|
729
|
+
D(i("select", {
|
|
730
|
+
"onUpdate:modelValue": r[10] || (r[10] = (s) => l.value.quizType = s),
|
|
731
|
+
class: "aimd-field-input"
|
|
732
|
+
}, [
|
|
733
|
+
i("option", Wl, m(t.messages.quiz.types.choice), 1),
|
|
734
|
+
i("option", Ql, m(t.messages.quiz.types.blank), 1),
|
|
735
|
+
i("option", Jl, m(t.messages.quiz.types.open), 1)
|
|
736
|
+
], 512), [
|
|
737
|
+
[be, l.value.quizType]
|
|
738
|
+
])
|
|
739
|
+
]),
|
|
740
|
+
i("label", Xl, [
|
|
741
|
+
i("span", Yl, m(t.messages.dialog.score), 1),
|
|
742
|
+
D(i("input", {
|
|
743
|
+
"onUpdate:modelValue": r[11] || (r[11] = (s) => l.value.score = s),
|
|
744
|
+
placeholder: t.messages.placeholders.score,
|
|
745
|
+
class: "aimd-field-input"
|
|
746
|
+
}, null, 8, Zl), [
|
|
747
|
+
[L, l.value.score]
|
|
748
|
+
])
|
|
749
|
+
]),
|
|
750
|
+
i("label", Gl, [
|
|
751
|
+
i("span", es, [
|
|
752
|
+
U(m(t.messages.dialog.stem) + " ", 1),
|
|
753
|
+
r[26] || (r[26] = i("em", null, "*", -1))
|
|
754
|
+
]),
|
|
755
|
+
D(i("textarea", {
|
|
756
|
+
"onUpdate:modelValue": r[12] || (r[12] = (s) => l.value.stem = s),
|
|
757
|
+
placeholder: t.messages.placeholders.stem,
|
|
758
|
+
class: "aimd-field-input aimd-field-textarea"
|
|
759
|
+
}, null, 8, ts), [
|
|
760
|
+
[L, l.value.stem]
|
|
761
|
+
]),
|
|
762
|
+
l.value.quizType === "blank" ? (g(), h("span", ls, m(t.messages.dialog.blankStemHint), 1)) : N("", !0)
|
|
763
|
+
]),
|
|
764
|
+
l.value.quizType === "choice" ? (g(), h(R, { key: 0 }, [
|
|
765
|
+
i("label", ss, [
|
|
766
|
+
i("span", is, m(t.messages.dialog.mode), 1),
|
|
767
|
+
D(i("select", {
|
|
768
|
+
"onUpdate:modelValue": r[13] || (r[13] = (s) => l.value.mode = s),
|
|
769
|
+
class: "aimd-field-input"
|
|
770
|
+
}, [
|
|
771
|
+
i("option", ns, m(t.messages.quiz.modes.single), 1),
|
|
772
|
+
i("option", as, m(t.messages.quiz.modes.multiple), 1)
|
|
773
|
+
], 512), [
|
|
774
|
+
[be, l.value.mode]
|
|
775
|
+
])
|
|
776
|
+
]),
|
|
777
|
+
i("div", os, [
|
|
778
|
+
i("span", us, m(t.messages.dialog.options), 1),
|
|
779
|
+
i("div", rs, [
|
|
780
|
+
(g(!0), h(R, null, Y(c.value, (s, M) => (g(), h("div", {
|
|
781
|
+
key: `choice-option-${M}`,
|
|
782
|
+
class: ye(["aimd-collection-row aimd-option-row", { "aimd-option-row-dragover": S.value === M && k.value !== null && k.value !== M }]),
|
|
783
|
+
onDragover: ae((q) => J(M), ["prevent"]),
|
|
784
|
+
onDrop: ae((q) => x(M), ["prevent"])
|
|
785
|
+
}, [
|
|
786
|
+
i("span", {
|
|
787
|
+
class: "aimd-drag-handle",
|
|
788
|
+
title: t.messages.dialog.dragToReorder,
|
|
789
|
+
draggable: "true",
|
|
790
|
+
onDragstart: (q) => H(M),
|
|
791
|
+
onDragend: w
|
|
792
|
+
}, " ⋮⋮ ", 40, cs),
|
|
793
|
+
D(i("input", {
|
|
794
|
+
"onUpdate:modelValue": (q) => s.key = q,
|
|
795
|
+
placeholder: t.messages.placeholders.optionKey,
|
|
796
|
+
class: "aimd-field-input"
|
|
797
|
+
}, null, 8, vs), [
|
|
798
|
+
[L, s.key]
|
|
799
|
+
]),
|
|
800
|
+
D(i("input", {
|
|
801
|
+
"onUpdate:modelValue": (q) => s.text = q,
|
|
802
|
+
placeholder: t.messages.placeholders.optionText,
|
|
803
|
+
class: "aimd-field-input"
|
|
804
|
+
}, null, 8, ms), [
|
|
805
|
+
[L, s.text]
|
|
806
|
+
]),
|
|
807
|
+
i("label", ps, [
|
|
808
|
+
l.value.mode === "single" ? D((g(), h("input", {
|
|
809
|
+
key: 0,
|
|
810
|
+
"onUpdate:modelValue": r[14] || (r[14] = (q) => l.value.answer = q),
|
|
811
|
+
type: "radio",
|
|
812
|
+
name: "aimd-quiz-choice-answer",
|
|
813
|
+
value: s.key.trim(),
|
|
814
|
+
disabled: !s.key.trim()
|
|
815
|
+
}, null, 8, fs)), [
|
|
816
|
+
[kt, l.value.answer]
|
|
817
|
+
]) : D((g(), h("input", {
|
|
818
|
+
key: 1,
|
|
819
|
+
"onUpdate:modelValue": r[15] || (r[15] = (q) => d.value = q),
|
|
820
|
+
type: "checkbox",
|
|
821
|
+
value: s.key.trim(),
|
|
822
|
+
disabled: !s.key.trim()
|
|
823
|
+
}, null, 8, gs)), [
|
|
824
|
+
[pt, d.value]
|
|
825
|
+
]),
|
|
826
|
+
i("span", null, m(t.messages.dialog.correctAnswer), 1)
|
|
827
|
+
]),
|
|
828
|
+
i("button", {
|
|
829
|
+
type: "button",
|
|
830
|
+
class: "aimd-mini-btn",
|
|
831
|
+
disabled: c.value.length <= 1,
|
|
832
|
+
onClick: (q) => z(M)
|
|
833
|
+
}, m(t.messages.common.remove), 9, hs)
|
|
834
|
+
], 42, ds))), 128)),
|
|
835
|
+
i("button", {
|
|
836
|
+
type: "button",
|
|
837
|
+
class: "aimd-mini-btn aimd-mini-btn-add",
|
|
838
|
+
onClick: T
|
|
839
|
+
}, m(t.messages.actions.addOption), 1)
|
|
840
|
+
]),
|
|
841
|
+
i("span", ys, m(t.messages.dialog.optionsHint), 1)
|
|
842
|
+
])
|
|
843
|
+
], 64)) : l.value.quizType === "blank" ? (g(), h("div", bs, [
|
|
844
|
+
i("span", ks, m(t.messages.dialog.blanks), 1),
|
|
845
|
+
i("div", ws, [
|
|
846
|
+
(g(!0), h(R, null, Y(_.value, (s, M) => (g(), h("div", {
|
|
847
|
+
key: `blank-item-${M}`,
|
|
848
|
+
class: "aimd-collection-row"
|
|
849
|
+
}, [
|
|
850
|
+
D(i("input", {
|
|
851
|
+
"onUpdate:modelValue": (q) => s.key = q,
|
|
852
|
+
placeholder: t.messages.placeholders.blankKey,
|
|
853
|
+
class: "aimd-field-input"
|
|
854
|
+
}, null, 8, Ms), [
|
|
855
|
+
[L, s.key]
|
|
856
|
+
]),
|
|
857
|
+
D(i("input", {
|
|
858
|
+
"onUpdate:modelValue": (q) => s.answer = q,
|
|
859
|
+
placeholder: t.messages.placeholders.blankAnswer,
|
|
860
|
+
class: "aimd-field-input"
|
|
861
|
+
}, null, 8, _s), [
|
|
862
|
+
[L, s.answer]
|
|
863
|
+
]),
|
|
864
|
+
i("button", {
|
|
865
|
+
type: "button",
|
|
866
|
+
class: "aimd-mini-btn",
|
|
867
|
+
disabled: _.value.length <= 1,
|
|
868
|
+
onClick: (q) => Z(M)
|
|
869
|
+
}, m(t.messages.common.remove), 9, Ts)
|
|
870
|
+
]))), 128)),
|
|
871
|
+
i("button", {
|
|
872
|
+
type: "button",
|
|
873
|
+
class: "aimd-mini-btn aimd-mini-btn-add",
|
|
874
|
+
onClick: Q
|
|
875
|
+
}, m(t.messages.actions.addBlank), 1)
|
|
876
|
+
]),
|
|
877
|
+
i("span", xs, m(t.messages.dialog.blanksHint), 1)
|
|
878
|
+
])) : (g(), h("label", Cs, [
|
|
879
|
+
i("span", $s, m(t.messages.dialog.rubric), 1),
|
|
880
|
+
D(i("textarea", {
|
|
881
|
+
"onUpdate:modelValue": r[16] || (r[16] = (s) => l.value.rubric = s),
|
|
882
|
+
placeholder: t.messages.placeholders.rubric,
|
|
883
|
+
class: "aimd-field-input aimd-field-textarea"
|
|
884
|
+
}, null, 8, Is), [
|
|
885
|
+
[L, l.value.rubric]
|
|
886
|
+
])
|
|
887
|
+
]))
|
|
888
|
+
], 64)) : N("", !0),
|
|
889
|
+
u.value === "check" ? (g(), h(R, { key: 4 }, [
|
|
890
|
+
i("label", Fs, [
|
|
891
|
+
i("span", As, m(t.messages.checkField.name), 1),
|
|
892
|
+
D(i("input", {
|
|
893
|
+
"onUpdate:modelValue": r[17] || (r[17] = (s) => l.value.title = s),
|
|
894
|
+
class: "aimd-field-input"
|
|
895
|
+
}, null, 512), [
|
|
896
|
+
[L, l.value.title]
|
|
897
|
+
])
|
|
898
|
+
]),
|
|
899
|
+
i("label", zs, [
|
|
900
|
+
i("span", Vs, [
|
|
901
|
+
U(m(t.messages.dialog.checkpointId) + " ", 1),
|
|
902
|
+
r[27] || (r[27] = i("em", null, "*", -1))
|
|
903
|
+
]),
|
|
904
|
+
D(i("input", {
|
|
905
|
+
"onUpdate:modelValue": r[18] || (r[18] = (s) => l.value.name = s),
|
|
906
|
+
placeholder: t.messages.placeholders.checkpointId,
|
|
907
|
+
class: "aimd-field-input"
|
|
908
|
+
}, null, 8, Ss), [
|
|
909
|
+
[L, l.value.name]
|
|
910
|
+
])
|
|
911
|
+
]),
|
|
912
|
+
i("label", Ds, [
|
|
913
|
+
i("span", Es, m(t.messages.checkField.checkedMessage), 1),
|
|
914
|
+
D(i("input", {
|
|
915
|
+
"onUpdate:modelValue": r[19] || (r[19] = (s) => l.value.checkedMessage = s),
|
|
916
|
+
class: "aimd-field-input"
|
|
917
|
+
}, null, 512), [
|
|
918
|
+
[L, l.value.checkedMessage]
|
|
919
|
+
])
|
|
920
|
+
])
|
|
921
|
+
], 64)) : N("", !0),
|
|
922
|
+
["ref_step", "ref_var", "ref_fig"].includes(u.value) ? (g(), h("label", qs, [
|
|
923
|
+
i("span", Bs, [
|
|
924
|
+
U(m(We.value) + " ", 1),
|
|
925
|
+
r[28] || (r[28] = i("em", null, "*", -1))
|
|
926
|
+
]),
|
|
927
|
+
D(i("input", {
|
|
928
|
+
"onUpdate:modelValue": r[20] || (r[20] = (s) => l.value.name = s),
|
|
929
|
+
placeholder: Qe.value,
|
|
930
|
+
class: "aimd-field-input",
|
|
931
|
+
list: "aimd-ref-suggestions"
|
|
932
|
+
}, null, 8, Ns), [
|
|
933
|
+
[L, l.value.name]
|
|
934
|
+
]),
|
|
935
|
+
i("datalist", Ps, [
|
|
936
|
+
(g(!0), h(R, null, Y($e.value, (s) => (g(), h("option", {
|
|
937
|
+
key: s,
|
|
938
|
+
value: s
|
|
939
|
+
}, null, 8, Ls))), 128))
|
|
940
|
+
]),
|
|
941
|
+
$e.value.length ? (g(), h("span", Us, m(t.messages.common.available) + ": " + m($e.value.join(", ")), 1)) : N("", !0)
|
|
942
|
+
])) : N("", !0),
|
|
943
|
+
u.value === "cite" ? (g(), h("label", Rs, [
|
|
944
|
+
i("span", Os, [
|
|
945
|
+
U(m(t.messages.dialog.citationId) + " ", 1),
|
|
946
|
+
r[29] || (r[29] = i("em", null, "*", -1))
|
|
947
|
+
]),
|
|
948
|
+
D(i("input", {
|
|
949
|
+
"onUpdate:modelValue": r[21] || (r[21] = (s) => l.value.refs = s),
|
|
950
|
+
placeholder: t.messages.placeholders.citationIds,
|
|
951
|
+
class: "aimd-field-input"
|
|
952
|
+
}, null, 8, Hs), [
|
|
953
|
+
[L, l.value.refs]
|
|
954
|
+
]),
|
|
955
|
+
i("span", js, m(t.messages.dialog.citationHint), 1)
|
|
956
|
+
])) : N("", !0),
|
|
957
|
+
i("div", Ks, [
|
|
958
|
+
i("div", Ws, m(t.messages.common.preview), 1),
|
|
959
|
+
i("pre", Qs, [
|
|
960
|
+
i("code", Js, m(xe.value), 1)
|
|
961
|
+
])
|
|
962
|
+
]),
|
|
963
|
+
V.value ? (g(), h("div", Xs, m(V.value), 1)) : N("", !0)
|
|
964
|
+
]),
|
|
965
|
+
i("div", Ys, [
|
|
966
|
+
i("button", {
|
|
967
|
+
class: "aimd-btn aimd-btn-cancel",
|
|
968
|
+
onClick: Ie
|
|
969
|
+
}, m(t.messages.common.cancel), 1),
|
|
970
|
+
i("button", {
|
|
971
|
+
class: "aimd-btn aimd-btn-primary",
|
|
972
|
+
onClick: Je
|
|
973
|
+
}, m(t.messages.common.insert), 1)
|
|
974
|
+
])
|
|
975
|
+
])
|
|
976
|
+
])) : N("", !0)
|
|
977
|
+
]));
|
|
978
|
+
}
|
|
979
|
+
}), Gs = ["aria-label"], ei = ["value"], ti = { class: "aimd-input-dialog__required" }, li = ["checked"], si = { key: 0 }, ii = { key: 1 }, ni = ["value"], ai = ["value"], oi = ["size"], ui = ["value", "selected"], ri = { value: "" }, di = ["value"], ci = ["value", "type", "step", "placeholder"], vi = ["open"], mi = {
|
|
980
|
+
key: 3,
|
|
981
|
+
class: "aimd-input-dialog__error",
|
|
982
|
+
role: "alert"
|
|
983
|
+
}, pi = {
|
|
984
|
+
type: "submit",
|
|
985
|
+
class: "aimd-input-dialog__save"
|
|
986
|
+
}, ce = "bool | None", Ne = "Literal[True, False]", fi = /* @__PURE__ */ pe({
|
|
987
|
+
__name: "AimdInputFieldDialog",
|
|
988
|
+
props: {
|
|
989
|
+
visible: { type: Boolean },
|
|
990
|
+
content: {},
|
|
991
|
+
fieldContent: {},
|
|
992
|
+
messages: {},
|
|
993
|
+
varTypePlugins: {},
|
|
994
|
+
reservedIds: {},
|
|
995
|
+
initialPreset: {}
|
|
996
|
+
},
|
|
997
|
+
emits: ["update:visible", "save"],
|
|
998
|
+
setup(e, { emit: n }) {
|
|
999
|
+
const t = e, a = n, o = F(), v = F(), p = F(""), u = F(""), l = F("str"), c = F(""), _ = F(""), d = F("str"), k = F(""), S = F(!1), V = F(), y = F(!1), b = B(() => V.value ?? !De(l.value)), A = B(() => _.value.split(/\r?\n/).map((x) => x.trim()).filter(Boolean)), E = B(() => /^(?:(?:typing|typing_extensions)\.)?Optional\[/.test(l.value.trim()) ? Ve(Ve(l.value, !1), !0) : ""), C = B(() => {
|
|
1000
|
+
const x = Se(c.value);
|
|
1001
|
+
return Array.isArray(x) ? x : [];
|
|
1002
|
+
});
|
|
1003
|
+
function I(x) {
|
|
1004
|
+
const w = Array.from(x.target.selectedOptions, ($) => $.value);
|
|
1005
|
+
c.value = w.length ? JSON.stringify(w) : b.value ? "" : "None";
|
|
1006
|
+
}
|
|
1007
|
+
const W = B(() => d.value === ce || d.value === "bool" ? [["True", t.messages.inputField.yes], ["False", t.messages.inputField.no]] : d.value === "choice" ? A.value.map((x) => [JSON.stringify(x), x]) : []);
|
|
1008
|
+
function le(x) {
|
|
1009
|
+
const w = Se(x);
|
|
1010
|
+
return W.value.find(([$]) => Object.is(Se($), w))?.[0];
|
|
1011
|
+
}
|
|
1012
|
+
const j = B(() => ["str", "date", "time", "datetime"].includes(d.value)), O = B(() => d.value === "int" || d.value === "float" ? "number" : d.value === "date" || d.value === "time" ? d.value : "text"), K = B({
|
|
1013
|
+
get() {
|
|
1014
|
+
return c.value === "None" ? "" : j.value && /^(['"]).*\1$/s.test(c.value) ? String(Se(c.value)) : W.value.length && c.value ? le(c.value) ?? c.value : c.value;
|
|
1015
|
+
},
|
|
1016
|
+
set(x) {
|
|
1017
|
+
c.value = x === "" ? b.value ? "" : "None" : j.value ? JSON.stringify(x) : x;
|
|
1018
|
+
}
|
|
1019
|
+
}), X = gt().filter((x) => lt(x)?.storage_kind === "file-id"), se = B(() => [
|
|
1020
|
+
["str", t.messages.inputField.text],
|
|
1021
|
+
["int", t.messages.inputField.integer],
|
|
1022
|
+
["float", t.messages.inputField.number],
|
|
1023
|
+
["choice", t.messages.inputField.choice],
|
|
1024
|
+
["multiple-choice", t.messages.inputField.multipleChoice],
|
|
1025
|
+
["bool | None", t.messages.inputField.boolean],
|
|
1026
|
+
["bool", t.messages.inputField.checkbox],
|
|
1027
|
+
["date", t.messages.inputField.date],
|
|
1028
|
+
["time", t.messages.inputField.time],
|
|
1029
|
+
["datetime", t.messages.inputField.datetime],
|
|
1030
|
+
["file", t.messages.inputField.file],
|
|
1031
|
+
["list[str]", t.messages.inputField.list],
|
|
1032
|
+
...(t.varTypePlugins ?? []).map((x) => [x.value, x.label]),
|
|
1033
|
+
["custom", t.messages.inputField.custom]
|
|
1034
|
+
]);
|
|
1035
|
+
ee(() => t.visible, async (x) => {
|
|
1036
|
+
if (!x) {
|
|
1037
|
+
o.value?.close();
|
|
1038
|
+
return;
|
|
1039
|
+
}
|
|
1040
|
+
const w = t.fieldContent ? Ze(t.fieldContent) : void 0;
|
|
1041
|
+
p.value = w?.id ?? _e([...Te(t.content), ...t.reservedIds ?? []]), u.value = typeof w?.kwargs?.title == "string" ? w.kwargs.title : "", l.value = w?.type ?? (t.initialPreset === "file" ? "FileIdPDF" : ["choice", "multiple-choice", "custom"].includes(t.initialPreset ?? "") ? "str" : t.initialPreset ?? "str"), c.value = w?.defaultRaw ?? "", V.value = typeof w?.kwargs?.required == "boolean" ? w.kwargs.required : void 0, y.value = !1;
|
|
1042
|
+
const $ = ve(l.value);
|
|
1043
|
+
d.value = l.value === Ne || $ === "bool" && De(l.value) ? ce : se.value.some(([ne]) => ne === $) ? $ : "custom";
|
|
1044
|
+
const Q = Ge(l.value), Z = Q.length ? Q : w?.enum, re = (Array.isArray(w?.kwargs?.enum) || /^(?:(?:typing|typing_extensions)\.)?(?:(?:list|List)\s*\[\s*(?:(?:typing|typing_extensions)\.)?)?Literal\s*\[/.test(ve(l.value))) && Array.isArray(Z) && Z.every((ne) => typeof ne == "string" && !ne.includes(`
|
|
1045
|
+
`));
|
|
1046
|
+
re && (d.value = Q.length ? "multiple-choice" : "choice"), X.includes(ve(l.value)) && (d.value = "file"), !w && t.initialPreset && (d.value = t.initialPreset), !w && d.value === ce && (l.value = Ne), _.value = re ? Z.join(`
|
|
1047
|
+
`) : "", S.value = d.value === "custom", k.value = "", await Re(), o.value?.showModal(), v.value?.focus();
|
|
1048
|
+
}, { immediate: !0 });
|
|
1049
|
+
function T() {
|
|
1050
|
+
const x = !b.value;
|
|
1051
|
+
d.value === ce ? l.value = x ? ce : Ne : ["custom", "choice", "multiple-choice", "file"].includes(d.value) || (l.value = Ve(d.value, x)), d.value === "file" && !X.includes(ve(l.value)) && (l.value = Ve("FileIdPDF", x)), d.value === "custom" && (S.value = !0);
|
|
1052
|
+
}
|
|
1053
|
+
function z(x) {
|
|
1054
|
+
y.value = !0, V.value = void 0, d.value === ce ? l.value = x ? Ne : ce : l.value = Ve(l.value, !x), d.value === "bool" && !x && (d.value = ce), x && c.value === "None" && (c.value = ""), !x && !c.value.trim() && (c.value = "None");
|
|
1055
|
+
}
|
|
1056
|
+
function H(x) {
|
|
1057
|
+
l.value = x.target.value + (De(l.value) ? " | None" : "");
|
|
1058
|
+
}
|
|
1059
|
+
function J() {
|
|
1060
|
+
const x = /* @__PURE__ */ new Set([...Te(t.content), ...t.reservedIds ?? []]), w = t.fieldContent ? Ze(t.fieldContent) : void 0, $ = w?.id, Q = p.value.trim() || _e(x);
|
|
1061
|
+
if (!ht.test(Q)) {
|
|
1062
|
+
k.value = t.messages.inputField.invalidId, S.value = !0;
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (Q !== $ && x.has(Q)) {
|
|
1066
|
+
k.value = t.messages.inputField.duplicateId, S.value = !0;
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
let Z = l.value;
|
|
1070
|
+
if (d.value === "choice" || d.value === "multiple-choice") {
|
|
1071
|
+
if (!A.value.length || new Set(A.value).size !== A.value.length) {
|
|
1072
|
+
k.value = t.messages.inputField.invalidOptions;
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
Z = `Literal[${A.value.map((xe) => JSON.stringify(xe)).join(", ")}]`, d.value === "multiple-choice" && (Z = `list[${Z}]`), De(l.value) && (Z += " | None");
|
|
1076
|
+
const de = d.value === "multiple-choice" ? Ge(w?.type) : w?.enum;
|
|
1077
|
+
w?.type === l.value && !w?.kwargs?.enum && JSON.stringify(A.value) === JSON.stringify(de) && Ge(w.type).length > 0 == (d.value === "multiple-choice") && (Z = l.value);
|
|
1078
|
+
}
|
|
1079
|
+
const te = c.value.trim(), re = d.value === "multiple-choice" && te && te !== "None" && (!Array.isArray(Se(te)) || C.value.some((de) => !A.value.includes(de)));
|
|
1080
|
+
if (b.value && te === "None" || W.value.length && te && te !== "None" && !le(te) || re) {
|
|
1081
|
+
k.value = t.messages.inputField.invalidDefault;
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
const ne = Bt(t.fieldContent, {
|
|
1085
|
+
id: Q,
|
|
1086
|
+
type: Z,
|
|
1087
|
+
title: u.value,
|
|
1088
|
+
defaultRaw: te,
|
|
1089
|
+
clearRequiredOverride: y.value,
|
|
1090
|
+
clearEnum: d.value === "choice" || d.value === "multiple-choice" || ve(Z) !== ve(w?.type)
|
|
1091
|
+
}), fe = Et(Ze(ne));
|
|
1092
|
+
if (fe.length) {
|
|
1093
|
+
k.value = fe.join(" "), S.value = !0;
|
|
1094
|
+
return;
|
|
1095
|
+
}
|
|
1096
|
+
a("save", ne), a("update:visible", !1);
|
|
1097
|
+
}
|
|
1098
|
+
return (x, w) => (g(), me(Oe, { to: "body" }, [
|
|
1099
|
+
i("dialog", {
|
|
1100
|
+
ref_key: "dialog",
|
|
1101
|
+
ref: o,
|
|
1102
|
+
class: "aimd-input-dialog",
|
|
1103
|
+
"aria-label": e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert,
|
|
1104
|
+
onClose: w[12] || (w[12] = ($) => a("update:visible", !1)),
|
|
1105
|
+
onCancel: w[13] || (w[13] = ($) => a("update:visible", !1))
|
|
1106
|
+
}, [
|
|
1107
|
+
i("form", {
|
|
1108
|
+
onSubmit: ae(J, ["prevent"])
|
|
1109
|
+
}, [
|
|
1110
|
+
i("h2", null, m(e.fieldContent ? e.messages.inputField.edit : e.messages.inputField.insert), 1),
|
|
1111
|
+
i("label", null, [
|
|
1112
|
+
U(m(e.messages.inputField.name), 1),
|
|
1113
|
+
D(i("input", {
|
|
1114
|
+
ref_key: "nameInput",
|
|
1115
|
+
ref: v,
|
|
1116
|
+
"onUpdate:modelValue": w[0] || (w[0] = ($) => u.value = $),
|
|
1117
|
+
name: "title",
|
|
1118
|
+
autocomplete: "off"
|
|
1119
|
+
}, null, 512), [
|
|
1120
|
+
[L, u.value]
|
|
1121
|
+
])
|
|
1122
|
+
]),
|
|
1123
|
+
i("label", null, [
|
|
1124
|
+
U(m(e.messages.dialog.type) + " ", 1),
|
|
1125
|
+
D(i("select", {
|
|
1126
|
+
"onUpdate:modelValue": w[1] || (w[1] = ($) => d.value = $),
|
|
1127
|
+
name: "preset",
|
|
1128
|
+
onChange: T
|
|
1129
|
+
}, [
|
|
1130
|
+
(g(!0), h(R, null, Y(se.value, ([$, Q]) => (g(), h("option", {
|
|
1131
|
+
key: $,
|
|
1132
|
+
value: $
|
|
1133
|
+
}, m(Q), 9, ei))), 128))
|
|
1134
|
+
], 544), [
|
|
1135
|
+
[be, d.value]
|
|
1136
|
+
])
|
|
1137
|
+
]),
|
|
1138
|
+
i("label", ti, [
|
|
1139
|
+
U(m(e.messages.inputField.required) + " ", 1),
|
|
1140
|
+
i("input", {
|
|
1141
|
+
name: "required",
|
|
1142
|
+
type: "checkbox",
|
|
1143
|
+
role: "switch",
|
|
1144
|
+
checked: b.value,
|
|
1145
|
+
onChange: w[2] || (w[2] = ($) => z($.target.checked))
|
|
1146
|
+
}, null, 40, li)
|
|
1147
|
+
]),
|
|
1148
|
+
d.value === "choice" || d.value === "multiple-choice" ? (g(), h("label", si, [
|
|
1149
|
+
U(m(e.messages.inputField.options), 1),
|
|
1150
|
+
D(i("textarea", {
|
|
1151
|
+
"onUpdate:modelValue": w[3] || (w[3] = ($) => _.value = $),
|
|
1152
|
+
name: "options",
|
|
1153
|
+
rows: "4"
|
|
1154
|
+
}, null, 512), [
|
|
1155
|
+
[L, _.value]
|
|
1156
|
+
])
|
|
1157
|
+
])) : N("", !0),
|
|
1158
|
+
d.value === "file" ? (g(), h("label", ii, [
|
|
1159
|
+
U(m(e.messages.inputField.fileFormat), 1),
|
|
1160
|
+
i("select", {
|
|
1161
|
+
name: "fileType",
|
|
1162
|
+
value: G(ve)(l.value),
|
|
1163
|
+
onChange: H
|
|
1164
|
+
}, [
|
|
1165
|
+
(g(!0), h(R, null, Y(G(X), ($) => (g(), h("option", {
|
|
1166
|
+
key: $,
|
|
1167
|
+
value: $
|
|
1168
|
+
}, m($.replace(/^FileId/, "")), 9, ai))), 128))
|
|
1169
|
+
], 40, ni)
|
|
1170
|
+
])) : N("", !0),
|
|
1171
|
+
i("label", null, [
|
|
1172
|
+
U(m(e.messages.dialog.defaultValue) + " ", 1),
|
|
1173
|
+
d.value === "multiple-choice" ? (g(), h("select", {
|
|
1174
|
+
key: 0,
|
|
1175
|
+
name: "default",
|
|
1176
|
+
multiple: "",
|
|
1177
|
+
size: Math.min(4, Math.max(2, A.value.length)),
|
|
1178
|
+
onChange: I
|
|
1179
|
+
}, [
|
|
1180
|
+
(g(!0), h(R, null, Y(A.value, ($) => (g(), h("option", {
|
|
1181
|
+
key: $,
|
|
1182
|
+
value: $,
|
|
1183
|
+
selected: C.value.includes($)
|
|
1184
|
+
}, m($), 9, ui))), 128))
|
|
1185
|
+
], 40, oi)) : W.value.length || d.value === "choice" ? D((g(), h("select", {
|
|
1186
|
+
key: 1,
|
|
1187
|
+
"onUpdate:modelValue": w[4] || (w[4] = ($) => K.value = $),
|
|
1188
|
+
name: "default"
|
|
1189
|
+
}, [
|
|
1190
|
+
i("option", ri, m(e.messages.inputField.noDefault), 1),
|
|
1191
|
+
(g(!0), h(R, null, Y(W.value, ([$, Q]) => (g(), h("option", {
|
|
1192
|
+
key: $,
|
|
1193
|
+
value: $
|
|
1194
|
+
}, m(Q), 9, di))), 128))
|
|
1195
|
+
], 512)), [
|
|
1196
|
+
[be, K.value]
|
|
1197
|
+
]) : (g(), h("input", {
|
|
1198
|
+
key: 2,
|
|
1199
|
+
value: K.value,
|
|
1200
|
+
name: "default",
|
|
1201
|
+
type: O.value,
|
|
1202
|
+
step: d.value === "float" ? "any" : void 0,
|
|
1203
|
+
placeholder: e.messages.inputField.noDefault,
|
|
1204
|
+
onInput: w[5] || (w[5] = ($) => K.value = $.target.value)
|
|
1205
|
+
}, null, 40, ci))
|
|
1206
|
+
]),
|
|
1207
|
+
E.value ? (g(), h("button", {
|
|
1208
|
+
key: 2,
|
|
1209
|
+
type: "button",
|
|
1210
|
+
onClick: w[6] || (w[6] = ($) => l.value = E.value)
|
|
1211
|
+
}, m(e.messages.inputField.useType(E.value)), 1)) : N("", !0),
|
|
1212
|
+
i("details", {
|
|
1213
|
+
open: S.value,
|
|
1214
|
+
onToggle: w[10] || (w[10] = ($) => S.value = $.target.open)
|
|
1215
|
+
}, [
|
|
1216
|
+
i("summary", null, m(e.messages.inputField.advanced), 1),
|
|
1217
|
+
i("label", null, [
|
|
1218
|
+
U(m(e.messages.inputField.id), 1),
|
|
1219
|
+
D(i("input", {
|
|
1220
|
+
"onUpdate:modelValue": w[7] || (w[7] = ($) => p.value = $),
|
|
1221
|
+
name: "id",
|
|
1222
|
+
autocomplete: "off",
|
|
1223
|
+
spellcheck: "false"
|
|
1224
|
+
}, null, 512), [
|
|
1225
|
+
[L, p.value]
|
|
1226
|
+
])
|
|
1227
|
+
]),
|
|
1228
|
+
oe(bt, {
|
|
1229
|
+
modelValue: l.value,
|
|
1230
|
+
"onUpdate:modelValue": [
|
|
1231
|
+
w[8] || (w[8] = ($) => l.value = $),
|
|
1232
|
+
w[9] || (w[9] = ($) => d.value = "custom")
|
|
1233
|
+
],
|
|
1234
|
+
messages: e.messages,
|
|
1235
|
+
"var-type-plugins": e.varTypePlugins
|
|
1236
|
+
}, null, 8, ["modelValue", "messages", "var-type-plugins"])
|
|
1237
|
+
], 40, vi),
|
|
1238
|
+
k.value ? (g(), h("p", mi, m(k.value), 1)) : N("", !0),
|
|
1239
|
+
i("footer", null, [
|
|
1240
|
+
i("button", {
|
|
1241
|
+
type: "button",
|
|
1242
|
+
onClick: w[11] || (w[11] = ($) => a("update:visible", !1))
|
|
1243
|
+
}, m(e.messages.common.cancel), 1),
|
|
1244
|
+
i("button", pi, m(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
|
|
1245
|
+
])
|
|
1246
|
+
], 32)
|
|
1247
|
+
], 40, Gs)
|
|
1248
|
+
]));
|
|
1249
|
+
}
|
|
1250
|
+
}), gi = /* @__PURE__ */ je(fi, [["__scopeId", "data-v-e4307a72"]]), hi = ["aria-label"], yi = {
|
|
1251
|
+
key: 0,
|
|
1252
|
+
class: "aimd-step-dialog__check"
|
|
1253
|
+
}, bi = ["open"], ki = ["readonly"], wi = { key: 0 }, Mi = ["value"], _i = { value: "elapsed" }, Ti = { value: "countdown" }, xi = { value: "both" }, Ci = {
|
|
1254
|
+
key: 1,
|
|
1255
|
+
role: "alert"
|
|
1256
|
+
}, $i = {
|
|
1257
|
+
type: "submit",
|
|
1258
|
+
class: "aimd-step-dialog__save"
|
|
1259
|
+
}, Ii = /* @__PURE__ */ pe({
|
|
1260
|
+
__name: "AimdStepFieldDialog",
|
|
1261
|
+
props: {
|
|
1262
|
+
visible: { type: Boolean },
|
|
1263
|
+
content: {},
|
|
1264
|
+
fieldContent: {},
|
|
1265
|
+
fieldType: {},
|
|
1266
|
+
reservedIds: {},
|
|
1267
|
+
messages: {}
|
|
1268
|
+
},
|
|
1269
|
+
emits: ["update:visible", "save"],
|
|
1270
|
+
setup(e, { emit: n }) {
|
|
1271
|
+
const t = e, a = n, o = F(), v = F(), p = F(""), u = F(""), l = F(1), c = F(!0), _ = F(""), d = F("elapsed"), k = F(""), S = F(!1), V = F(""), y = B(() => t.fieldType === "check"), b = B(() => y.value ? t.messages.checkField : t.messages.stepField);
|
|
1272
|
+
ee(() => t.visible, async (E) => {
|
|
1273
|
+
if (!E) {
|
|
1274
|
+
o.value?.close();
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
const C = t.fieldContent && !y.value ? rt(t.fieldContent) : void 0, I = t.fieldContent && y.value ? qt(t.fieldContent) : void 0;
|
|
1278
|
+
p.value = (I ?? C)?.id ?? _e([...Te(t.content), ...t.reservedIds ?? []], y.value ? "check" : "step"), u.value = (I ?? C)?.title ?? "", V.value = I?.checked_message ?? "", l.value = C?.level ?? 1, c.value = C?.check ?? !0, _.value = String(C?.props.duration ?? ""), d.value = C?.timer_mode ?? "elapsed", k.value = "", S.value = !1, await Re(), o.value?.showModal(), v.value?.focus();
|
|
1279
|
+
}, { immediate: !0 });
|
|
1280
|
+
function A() {
|
|
1281
|
+
const E = /* @__PURE__ */ new Set([...Te(t.content), ...t.reservedIds ?? []]), C = p.value.trim() || _e(E, y.value ? "check" : "step");
|
|
1282
|
+
if (!ht.test(C)) {
|
|
1283
|
+
k.value = t.messages.inputField.invalidId, S.value = !0;
|
|
1284
|
+
return;
|
|
1285
|
+
}
|
|
1286
|
+
if (!t.fieldContent && E.has(C)) {
|
|
1287
|
+
k.value = t.messages.inputField.duplicateId, S.value = !0;
|
|
1288
|
+
return;
|
|
1289
|
+
}
|
|
1290
|
+
if (y.value) {
|
|
1291
|
+
a("save", Nt(t.fieldContent, { id: C, title: u.value, checkedMessage: V.value })), a("update:visible", !1);
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
const I = Pt(t.fieldContent, { id: C, title: u.value, level: l.value, check: c.value, duration: _.value, timer: d.value }), W = rt(I);
|
|
1295
|
+
if (_.value.trim() && W.estimated_duration_ms === void 0 || d.value !== "elapsed" && !W.estimated_duration_ms) {
|
|
1296
|
+
k.value = t.messages.stepField.invalidDuration, S.value = !0;
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
a("save", I), a("update:visible", !1);
|
|
1300
|
+
}
|
|
1301
|
+
return (E, C) => (g(), me(Oe, { to: "body" }, [
|
|
1302
|
+
i("dialog", {
|
|
1303
|
+
ref_key: "dialog",
|
|
1304
|
+
ref: o,
|
|
1305
|
+
class: "aimd-step-dialog",
|
|
1306
|
+
"aria-label": e.fieldContent ? b.value.edit : b.value.insert,
|
|
1307
|
+
onClose: C[9] || (C[9] = (I) => a("update:visible", !1)),
|
|
1308
|
+
onCancel: C[10] || (C[10] = (I) => a("update:visible", !1))
|
|
1309
|
+
}, [
|
|
1310
|
+
i("form", {
|
|
1311
|
+
onSubmit: ae(A, ["prevent"])
|
|
1312
|
+
}, [
|
|
1313
|
+
i("h2", null, m(e.fieldContent ? b.value.edit : b.value.insert), 1),
|
|
1314
|
+
i("label", null, [
|
|
1315
|
+
U(m(b.value.name), 1),
|
|
1316
|
+
D(i("input", {
|
|
1317
|
+
ref_key: "nameInput",
|
|
1318
|
+
ref: v,
|
|
1319
|
+
"onUpdate:modelValue": C[0] || (C[0] = (I) => u.value = I),
|
|
1320
|
+
name: "title",
|
|
1321
|
+
autocomplete: "off"
|
|
1322
|
+
}, null, 512), [
|
|
1323
|
+
[L, u.value]
|
|
1324
|
+
])
|
|
1325
|
+
]),
|
|
1326
|
+
y.value ? N("", !0) : (g(), h("label", yi, [
|
|
1327
|
+
D(i("input", {
|
|
1328
|
+
"onUpdate:modelValue": C[1] || (C[1] = (I) => c.value = I),
|
|
1329
|
+
name: "check",
|
|
1330
|
+
type: "checkbox"
|
|
1331
|
+
}, null, 512), [
|
|
1332
|
+
[pt, c.value]
|
|
1333
|
+
]),
|
|
1334
|
+
U(m(e.messages.stepField.check), 1)
|
|
1335
|
+
])),
|
|
1336
|
+
i("details", {
|
|
1337
|
+
open: S.value,
|
|
1338
|
+
onToggle: C[7] || (C[7] = (I) => S.value = I.target.open)
|
|
1339
|
+
}, [
|
|
1340
|
+
i("summary", null, m(e.messages.inputField.advanced), 1),
|
|
1341
|
+
i("label", null, [
|
|
1342
|
+
U(m(b.value.id), 1),
|
|
1343
|
+
D(i("input", {
|
|
1344
|
+
"onUpdate:modelValue": C[2] || (C[2] = (I) => p.value = I),
|
|
1345
|
+
name: "id",
|
|
1346
|
+
readonly: !!e.fieldContent,
|
|
1347
|
+
autocomplete: "off",
|
|
1348
|
+
spellcheck: "false"
|
|
1349
|
+
}, null, 8, ki), [
|
|
1350
|
+
[L, p.value]
|
|
1351
|
+
])
|
|
1352
|
+
]),
|
|
1353
|
+
y.value ? (g(), h("label", wi, [
|
|
1354
|
+
U(m(e.messages.checkField.checkedMessage), 1),
|
|
1355
|
+
D(i("input", {
|
|
1356
|
+
"onUpdate:modelValue": C[3] || (C[3] = (I) => V.value = I),
|
|
1357
|
+
name: "checkedMessage"
|
|
1358
|
+
}, null, 512), [
|
|
1359
|
+
[L, V.value]
|
|
1360
|
+
])
|
|
1361
|
+
])) : (g(), h(R, { key: 1 }, [
|
|
1362
|
+
i("label", null, [
|
|
1363
|
+
U(m(e.messages.dialog.level), 1),
|
|
1364
|
+
D(i("select", {
|
|
1365
|
+
"onUpdate:modelValue": C[4] || (C[4] = (I) => l.value = I),
|
|
1366
|
+
name: "level"
|
|
1367
|
+
}, [
|
|
1368
|
+
(g(), h(R, null, Y(3, (I) => i("option", {
|
|
1369
|
+
key: I,
|
|
1370
|
+
value: I
|
|
1371
|
+
}, m(I), 9, Mi)), 64))
|
|
1372
|
+
], 512), [
|
|
1373
|
+
[be, l.value]
|
|
1374
|
+
])
|
|
1375
|
+
]),
|
|
1376
|
+
i("label", null, [
|
|
1377
|
+
U(m(e.messages.stepField.duration), 1),
|
|
1378
|
+
D(i("input", {
|
|
1379
|
+
"onUpdate:modelValue": C[5] || (C[5] = (I) => _.value = I),
|
|
1380
|
+
name: "duration",
|
|
1381
|
+
placeholder: "2m"
|
|
1382
|
+
}, null, 512), [
|
|
1383
|
+
[L, _.value]
|
|
1384
|
+
])
|
|
1385
|
+
]),
|
|
1386
|
+
i("label", null, [
|
|
1387
|
+
U(m(e.messages.stepField.timer), 1),
|
|
1388
|
+
D(i("select", {
|
|
1389
|
+
"onUpdate:modelValue": C[6] || (C[6] = (I) => d.value = I),
|
|
1390
|
+
name: "timer"
|
|
1391
|
+
}, [
|
|
1392
|
+
i("option", _i, m(e.messages.stepField.elapsed), 1),
|
|
1393
|
+
i("option", Ti, m(e.messages.stepField.countdown), 1),
|
|
1394
|
+
i("option", xi, m(e.messages.stepField.both), 1)
|
|
1395
|
+
], 512), [
|
|
1396
|
+
[be, d.value]
|
|
1397
|
+
])
|
|
1398
|
+
])
|
|
1399
|
+
], 64))
|
|
1400
|
+
], 40, bi),
|
|
1401
|
+
k.value ? (g(), h("p", Ci, m(k.value), 1)) : N("", !0),
|
|
1402
|
+
i("footer", null, [
|
|
1403
|
+
i("button", {
|
|
1404
|
+
type: "button",
|
|
1405
|
+
onClick: C[8] || (C[8] = (I) => a("update:visible", !1))
|
|
1406
|
+
}, m(e.messages.common.cancel), 1),
|
|
1407
|
+
i("button", $i, m(e.fieldContent ? e.messages.inputField.save : e.messages.common.insert), 1)
|
|
1408
|
+
])
|
|
1409
|
+
], 32)
|
|
1410
|
+
], 40, hi)
|
|
1411
|
+
]));
|
|
1412
|
+
}
|
|
1413
|
+
}), Fi = /* @__PURE__ */ je(Ii, [["__scopeId", "data-v-fc5a778d"]]);
|
|
1414
|
+
const he = {
|
|
1415
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1416
|
+
width: 24,
|
|
1417
|
+
height: 24,
|
|
1418
|
+
viewBox: "0 0 24 24",
|
|
1419
|
+
fill: "none",
|
|
1420
|
+
stroke: "currentColor",
|
|
1421
|
+
"stroke-width": 2,
|
|
1422
|
+
"stroke-linecap": "round",
|
|
1423
|
+
"stroke-linejoin": "round"
|
|
1424
|
+
};
|
|
1425
|
+
const ct = (...e) => e.filter((n, t, a) => !!n && n.trim() !== "" && a.indexOf(n) === t).join(" ").trim();
|
|
1426
|
+
function et(e) {
|
|
1427
|
+
return e != null;
|
|
1428
|
+
}
|
|
1429
|
+
function Ai(e, n = {}) {
|
|
1430
|
+
const t = n.attributeNames ?? {}, a = (k) => t[k] ?? k, o = e.size ?? e.width ?? he.width, v = e.size ?? e.height ?? he.height, p = e.aliases?.filter((k) => typeof k == "string" && k.trim() !== "").map((k) => `lucide-${k}`) ?? [], u = [...e.name ? [`lucide-${e.name}`] : [], ...p], l = n.className?.split(" ").filter(Boolean) ?? [], c = n.includeDefaultClasses === !1 ? ct(...l) : ct("lucide", ...u, ...l), _ = n.absoluteStrokeWidth ? Number(n.strokeWidth ?? he["stroke-width"]) * Number(e.size ?? e.width ?? he.width) / Number(n.size ?? n.width ?? he.width) : n.strokeWidth ?? he["stroke-width"];
|
|
1431
|
+
return [
|
|
1432
|
+
"svg",
|
|
1433
|
+
{
|
|
1434
|
+
...Object.entries(he).reduce((k, [S, V]) => (k[a(S)] = V, k), {}),
|
|
1435
|
+
..."color" in n && n.color && {
|
|
1436
|
+
[a("stroke")]: n.color
|
|
1437
|
+
},
|
|
1438
|
+
..."size" in n && et(n.size) && {
|
|
1439
|
+
[a("width")]: n.size,
|
|
1440
|
+
[a("height")]: n.size
|
|
1441
|
+
},
|
|
1442
|
+
..."width" in n && et(n.width) && {
|
|
1443
|
+
[a("width")]: n.width
|
|
1444
|
+
},
|
|
1445
|
+
..."height" in n && et(n.height) && {
|
|
1446
|
+
[a("height")]: n.height
|
|
1447
|
+
},
|
|
1448
|
+
[a("stroke-width")]: _,
|
|
1449
|
+
...c && {
|
|
1450
|
+
[a("class")]: c
|
|
1451
|
+
},
|
|
1452
|
+
[a("viewBox")]: `0 0 ${o} ${v}`,
|
|
1453
|
+
...n.hasA11yProp === !1 ? {
|
|
1454
|
+
[a("aria-hidden")]: "true"
|
|
1455
|
+
} : {},
|
|
1456
|
+
..."attributes" in n && n.attributes
|
|
1457
|
+
},
|
|
1458
|
+
e.node.map((k) => {
|
|
1459
|
+
const [S, V, y] = k, b = n.nonScalingStroke ? { [a("vector-effect")]: "non-scaling-stroke", ...V } : V;
|
|
1460
|
+
return y ? [S, b, y] : [S, b];
|
|
1461
|
+
})
|
|
1462
|
+
];
|
|
1463
|
+
}
|
|
1464
|
+
const zi = (e) => {
|
|
1465
|
+
for (const n in e)
|
|
1466
|
+
if (n.startsWith("aria-") || n === "role" || n === "title")
|
|
1467
|
+
return !0;
|
|
1468
|
+
return !1;
|
|
1469
|
+
};
|
|
1470
|
+
const Pe = (e) => e === "";
|
|
1471
|
+
const Vi = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
1472
|
+
const Si = /* @__PURE__ */ Symbol("lucide-icons");
|
|
1473
|
+
function Di() {
|
|
1474
|
+
return wt(Si, {});
|
|
1475
|
+
}
|
|
1476
|
+
const Ei = ({
|
|
1477
|
+
name: e,
|
|
1478
|
+
iconNode: n,
|
|
1479
|
+
"icon-node": t,
|
|
1480
|
+
icon: a = {
|
|
1481
|
+
name: e && Vi(e),
|
|
1482
|
+
node: n ?? t ?? [],
|
|
1483
|
+
size: 24,
|
|
1484
|
+
aliases: []
|
|
1485
|
+
},
|
|
1486
|
+
absoluteStrokeWidth: o,
|
|
1487
|
+
"absolute-stroke-width": v,
|
|
1488
|
+
nonScalingStroke: p,
|
|
1489
|
+
"non-scaling-stroke": u,
|
|
1490
|
+
strokeWidth: l,
|
|
1491
|
+
"stroke-width": c,
|
|
1492
|
+
size: _,
|
|
1493
|
+
width: d = _,
|
|
1494
|
+
height: k = _,
|
|
1495
|
+
color: S,
|
|
1496
|
+
...V
|
|
1497
|
+
}, { slots: y }) => {
|
|
1498
|
+
const {
|
|
1499
|
+
size: b,
|
|
1500
|
+
color: A,
|
|
1501
|
+
strokeWidth: E = 2,
|
|
1502
|
+
absoluteStrokeWidth: C = !1,
|
|
1503
|
+
nonScalingStroke: I = !1,
|
|
1504
|
+
class: W = ""
|
|
1505
|
+
} = Di(), le = Pe(o) || Pe(v) || o === !0 || v === !0 || C === !0, j = Pe(p) || Pe(u) || p === !0 || u === !0 || I === !0;
|
|
1506
|
+
delete V.class;
|
|
1507
|
+
const O = y.default?.(), [, K, X = []] = Ai(a, {
|
|
1508
|
+
color: S ?? A,
|
|
1509
|
+
width: d ?? _ ?? b,
|
|
1510
|
+
height: k ?? _ ?? b,
|
|
1511
|
+
strokeWidth: l ?? c ?? E,
|
|
1512
|
+
absoluteStrokeWidth: le,
|
|
1513
|
+
nonScalingStroke: j,
|
|
1514
|
+
className: W,
|
|
1515
|
+
hasA11yProp: O != null && O.length > 0 || zi(V),
|
|
1516
|
+
attributes: V
|
|
1517
|
+
});
|
|
1518
|
+
return tt("svg", K, [
|
|
1519
|
+
...X.map(([se, T]) => tt(se, T)),
|
|
1520
|
+
...O ?? []
|
|
1521
|
+
]);
|
|
1522
|
+
};
|
|
1523
|
+
function ie(e, n = []) {
|
|
1524
|
+
const t = typeof e == "string" ? {
|
|
1525
|
+
name: e,
|
|
1526
|
+
node: n
|
|
1527
|
+
} : e;
|
|
1528
|
+
return (a, { slots: o }) => tt(
|
|
1529
|
+
Ei,
|
|
1530
|
+
{
|
|
1531
|
+
...a,
|
|
1532
|
+
icon: t
|
|
1533
|
+
},
|
|
1534
|
+
o.default ? { default: o.default } : void 0
|
|
1535
|
+
);
|
|
1536
|
+
}
|
|
1537
|
+
const qi = {
|
|
1538
|
+
name: "calendar-days",
|
|
1539
|
+
size: 24,
|
|
1540
|
+
node: [
|
|
1541
|
+
["path", { d: "M8 2v3", key: "1ioesn" }],
|
|
1542
|
+
["path", { d: "M16 2v3", key: "otl347" }],
|
|
1543
|
+
["rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", key: "h1oib" }],
|
|
1544
|
+
["path", { d: "M3 9h18", key: "1pudct" }],
|
|
1545
|
+
["path", { d: "M8 13h.01", key: "1sbv64" }],
|
|
1546
|
+
["path", { d: "M12 13h.01", key: "y0uutt" }],
|
|
1547
|
+
["path", { d: "M16 13h.01", key: "wip0gl" }],
|
|
1548
|
+
["path", { d: "M8 17h.01", key: "p3bg7i" }],
|
|
1549
|
+
["path", { d: "M12 17h.01", key: "p32p05" }],
|
|
1550
|
+
["path", { d: "M16 17h.01", key: "ql8jdd" }]
|
|
1551
|
+
]
|
|
1552
|
+
}, vt = ie(qi);
|
|
1553
|
+
const Bi = {
|
|
1554
|
+
name: "chevron-down",
|
|
1555
|
+
size: 24,
|
|
1556
|
+
node: [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]]
|
|
1557
|
+
}, Ni = ie(Bi);
|
|
1558
|
+
const Pi = {
|
|
1559
|
+
name: "circle-dot",
|
|
1560
|
+
size: 24,
|
|
1561
|
+
node: [
|
|
1562
|
+
["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
|
|
1563
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
|
|
1564
|
+
]
|
|
1565
|
+
}, Li = ie(Pi);
|
|
1566
|
+
const Ui = {
|
|
1567
|
+
name: "clock",
|
|
1568
|
+
size: 24,
|
|
1569
|
+
node: [
|
|
1570
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
1571
|
+
["path", { d: "M12 6v6l4 2", key: "mmk7yg" }]
|
|
1572
|
+
]
|
|
1573
|
+
}, Ri = ie(Ui);
|
|
1574
|
+
const Oi = {
|
|
1575
|
+
name: "hash",
|
|
1576
|
+
size: 24,
|
|
1577
|
+
node: [
|
|
1578
|
+
["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
|
|
1579
|
+
["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
|
|
1580
|
+
["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
|
|
1581
|
+
["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
|
|
1582
|
+
]
|
|
1583
|
+
}, mt = ie(Oi);
|
|
1584
|
+
const Hi = {
|
|
1585
|
+
name: "list-checks",
|
|
1586
|
+
size: 24,
|
|
1587
|
+
node: [
|
|
1588
|
+
["path", { d: "M13 5h8", key: "a7qcls" }],
|
|
1589
|
+
["path", { d: "M13 12h8", key: "h98zly" }],
|
|
1590
|
+
["path", { d: "M13 19h8", key: "c3s6r1" }],
|
|
1591
|
+
["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
|
|
1592
|
+
["path", { d: "m3 7 2 2 4-4", key: "1obspn" }]
|
|
1593
|
+
]
|
|
1594
|
+
}, ji = ie(Hi);
|
|
1595
|
+
const Ki = {
|
|
1596
|
+
name: "list-ordered",
|
|
1597
|
+
size: 24,
|
|
1598
|
+
node: [
|
|
1599
|
+
["path", { d: "M11 5h10", key: "1cz7ny" }],
|
|
1600
|
+
["path", { d: "M11 12h10", key: "1438ji" }],
|
|
1601
|
+
["path", { d: "M11 19h10", key: "11t30w" }],
|
|
1602
|
+
["path", { d: "M4 4h1v5", key: "10yrso" }],
|
|
1603
|
+
["path", { d: "M4 9h2", key: "r1h2o0" }],
|
|
1604
|
+
["path", { d: "M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02", key: "xtkcd5" }]
|
|
1605
|
+
]
|
|
1606
|
+
}, Wi = ie(Ki);
|
|
1607
|
+
const Qi = {
|
|
1608
|
+
name: "paperclip",
|
|
1609
|
+
size: 24,
|
|
1610
|
+
node: [
|
|
1611
|
+
[
|
|
1612
|
+
"path",
|
|
1613
|
+
{
|
|
1614
|
+
d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",
|
|
1615
|
+
key: "1miecu"
|
|
1616
|
+
}
|
|
1617
|
+
]
|
|
1618
|
+
]
|
|
1619
|
+
}, Ji = ie(Qi);
|
|
1620
|
+
const Xi = {
|
|
1621
|
+
name: "settings-2",
|
|
1622
|
+
size: 24,
|
|
1623
|
+
node: [
|
|
1624
|
+
["path", { d: "M14 17H5", key: "gfn3mx" }],
|
|
1625
|
+
["path", { d: "M19 7h-9", key: "6i9tg" }],
|
|
1626
|
+
["circle", { cx: "17", cy: "17", r: "3", key: "18b49y" }],
|
|
1627
|
+
["circle", { cx: "7", cy: "7", r: "3", key: "dfmy0x" }]
|
|
1628
|
+
]
|
|
1629
|
+
}, Yi = ie(Xi);
|
|
1630
|
+
const Zi = {
|
|
1631
|
+
name: "square-check",
|
|
1632
|
+
size: 24,
|
|
1633
|
+
node: [
|
|
1634
|
+
["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
|
|
1635
|
+
["path", { d: "m16 9-5.5 5.5L8 12", key: "xofnsj" }]
|
|
1636
|
+
],
|
|
1637
|
+
aliases: ["check-square-2"]
|
|
1638
|
+
}, Gi = ie(Zi);
|
|
1639
|
+
const en = {
|
|
1640
|
+
name: "text-cursor-input",
|
|
1641
|
+
size: 24,
|
|
1642
|
+
node: [
|
|
1643
|
+
["path", { d: "M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6", key: "1528k5" }],
|
|
1644
|
+
["path", { d: "M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7", key: "13ksps" }],
|
|
1645
|
+
["path", { d: "M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1", key: "1n9rhb" }],
|
|
1646
|
+
["path", { d: "M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1", key: "1mj8rg" }],
|
|
1647
|
+
["path", { d: "M9 6v12", key: "velyjx" }]
|
|
1648
|
+
]
|
|
1649
|
+
}, tn = ie(en);
|
|
1650
|
+
const ln = {
|
|
1651
|
+
name: "toggle-left",
|
|
1652
|
+
size: 24,
|
|
1653
|
+
node: [
|
|
1654
|
+
["circle", { cx: "9", cy: "12", r: "3", key: "u3jwor" }],
|
|
1655
|
+
["rect", { width: "20", height: "14", x: "2", y: "5", rx: "7", key: "g7kal2" }]
|
|
1656
|
+
]
|
|
1657
|
+
}, sn = ie(ln), nn = ["aria-label"], an = ["title", "aria-label", "onClick"], on = ["aria-expanded"], un = ["aria-label"], rn = ["title", "onClick"], dn = /* @__PURE__ */ pe({
|
|
1658
|
+
__name: "AimdInputToolbar",
|
|
1659
|
+
props: {
|
|
1660
|
+
messages: {}
|
|
1661
|
+
},
|
|
1662
|
+
emits: ["insert"],
|
|
1663
|
+
setup(e, { emit: n }) {
|
|
1664
|
+
const t = e, a = n, o = F(), v = F(), p = F(!1), u = F();
|
|
1665
|
+
let l = 0;
|
|
1666
|
+
const c = B(() => [
|
|
1667
|
+
{ preset: "str", label: t.messages.inputField.text, icon: tn },
|
|
1668
|
+
{ preset: "int", label: t.messages.inputField.integer, icon: mt },
|
|
1669
|
+
{ preset: "float", label: t.messages.inputField.number, icon: mt },
|
|
1670
|
+
{ preset: "choice", label: t.messages.inputField.choice, icon: Li },
|
|
1671
|
+
{ preset: "multiple-choice", label: t.messages.inputField.multipleChoice, icon: Gi },
|
|
1672
|
+
{ preset: "bool | None", label: t.messages.inputField.boolean, icon: sn }
|
|
1673
|
+
]), _ = B(() => [
|
|
1674
|
+
{ preset: "date", label: t.messages.inputField.date, icon: vt },
|
|
1675
|
+
{ preset: "time", label: t.messages.inputField.time, icon: Ri },
|
|
1676
|
+
{ preset: "datetime", label: t.messages.inputField.datetime, icon: vt },
|
|
1677
|
+
{ preset: "list[str]", label: t.messages.inputField.list, icon: Wi },
|
|
1678
|
+
{ preset: "file", label: t.messages.inputField.file, icon: Ji },
|
|
1679
|
+
{ preset: "custom", label: t.messages.inputField.custom, icon: Yi }
|
|
1680
|
+
]);
|
|
1681
|
+
function d(y = !1) {
|
|
1682
|
+
o.value && (l = y ? _.value.length - 1 : 0, u.value = o.value.closest('dialog[open], [popover], [role="dialog"]') ?? o.value.ownerDocument.body, p.value = !0);
|
|
1683
|
+
}
|
|
1684
|
+
function k(y = !1) {
|
|
1685
|
+
p.value = !1, y && o.value?.focus({ preventScroll: !0 });
|
|
1686
|
+
}
|
|
1687
|
+
function S(y) {
|
|
1688
|
+
p.value && k(!0), a("insert", y);
|
|
1689
|
+
}
|
|
1690
|
+
function V(y) {
|
|
1691
|
+
if (y.key === "Tab" || y.key === "Escape") {
|
|
1692
|
+
y.key === "Escape" && (y.preventDefault(), y.stopPropagation()), k(!0);
|
|
1693
|
+
return;
|
|
1694
|
+
}
|
|
1695
|
+
const b = Array.from(v.value?.querySelectorAll("button") ?? []), A = b.indexOf(y.target);
|
|
1696
|
+
let E;
|
|
1697
|
+
switch (y.key) {
|
|
1698
|
+
case "Home":
|
|
1699
|
+
E = 0;
|
|
1700
|
+
break;
|
|
1701
|
+
case "End":
|
|
1702
|
+
E = b.length - 1;
|
|
1703
|
+
break;
|
|
1704
|
+
case "ArrowDown":
|
|
1705
|
+
E = (A + 1) % b.length;
|
|
1706
|
+
break;
|
|
1707
|
+
case "ArrowUp":
|
|
1708
|
+
E = (A - 1 + b.length) % b.length;
|
|
1709
|
+
break;
|
|
1710
|
+
default:
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
y.preventDefault(), b[E]?.focus();
|
|
1714
|
+
}
|
|
1715
|
+
return ee(v, (y, b, A) => {
|
|
1716
|
+
const E = o.value;
|
|
1717
|
+
if (!y || !E) return;
|
|
1718
|
+
const C = E.ownerDocument, I = (O) => {
|
|
1719
|
+
O.target instanceof Node && !y.contains(O.target) && !E.contains(O.target) && k();
|
|
1720
|
+
};
|
|
1721
|
+
C.addEventListener("pointerdown", I, !0), C.addEventListener("focusin", I);
|
|
1722
|
+
let W = !0, le = !1;
|
|
1723
|
+
const j = Tt(E, y, async () => {
|
|
1724
|
+
const { x: O, y: K } = await xt(E, y, {
|
|
1725
|
+
strategy: "fixed",
|
|
1726
|
+
placement: "bottom-start",
|
|
1727
|
+
middleware: [
|
|
1728
|
+
Ct(4),
|
|
1729
|
+
$t({ padding: 8 }),
|
|
1730
|
+
It({ padding: 8 }),
|
|
1731
|
+
Ft({ padding: 8, apply({ availableHeight: X }) {
|
|
1732
|
+
y.style.maxHeight = `${Math.max(0, X)}px`;
|
|
1733
|
+
} })
|
|
1734
|
+
]
|
|
1735
|
+
});
|
|
1736
|
+
W && (y.style.left = `${O}px`, y.style.top = `${K}px`, le || (le = !0, y.style.visibility = "visible", y.querySelectorAll("button")[l]?.focus({ preventScroll: !0 })));
|
|
1737
|
+
});
|
|
1738
|
+
A(() => {
|
|
1739
|
+
W = !1, j(), C.removeEventListener("pointerdown", I, !0), C.removeEventListener("focusin", I);
|
|
1740
|
+
});
|
|
1741
|
+
}, { flush: "post" }), (y, b) => (g(), h("div", {
|
|
1742
|
+
class: "aimd-input-tools",
|
|
1743
|
+
role: "group",
|
|
1744
|
+
"aria-label": e.messages.inputField.insert
|
|
1745
|
+
}, [
|
|
1746
|
+
(g(!0), h(R, null, Y(c.value, (A) => (g(), h("button", {
|
|
1747
|
+
key: A.preset,
|
|
1748
|
+
type: "button",
|
|
1749
|
+
title: e.messages.inputField.insertType(A.label),
|
|
1750
|
+
"aria-label": e.messages.inputField.insertType(A.label),
|
|
1751
|
+
onMousedown: b[0] || (b[0] = ae(() => {
|
|
1752
|
+
}, ["prevent"])),
|
|
1753
|
+
onClick: (E) => S(A.preset)
|
|
1754
|
+
}, [
|
|
1755
|
+
(g(), me(it(A.icon), {
|
|
1756
|
+
size: 16,
|
|
1757
|
+
"aria-hidden": "true"
|
|
1758
|
+
})),
|
|
1759
|
+
i("span", null, m(A.label), 1)
|
|
1760
|
+
], 40, an))), 128)),
|
|
1761
|
+
i("button", {
|
|
1762
|
+
ref_key: "trigger",
|
|
1763
|
+
ref: o,
|
|
1764
|
+
type: "button",
|
|
1765
|
+
class: "aimd-input-tools__more",
|
|
1766
|
+
"aria-haspopup": "menu",
|
|
1767
|
+
"aria-expanded": p.value,
|
|
1768
|
+
onMousedown: b[1] || (b[1] = ae(() => {
|
|
1769
|
+
}, ["prevent"])),
|
|
1770
|
+
onClick: b[2] || (b[2] = (A) => p.value ? k(!0) : d()),
|
|
1771
|
+
onKeydown: [
|
|
1772
|
+
b[3] || (b[3] = nt(ae((A) => d(), ["prevent"]), ["down"])),
|
|
1773
|
+
b[4] || (b[4] = nt(ae((A) => d(!0), ["prevent"]), ["up"]))
|
|
1774
|
+
]
|
|
1775
|
+
}, [
|
|
1776
|
+
oe(G(ji), {
|
|
1777
|
+
size: 16,
|
|
1778
|
+
"aria-hidden": "true"
|
|
1779
|
+
}),
|
|
1780
|
+
i("span", null, m(e.messages.inputField.more), 1),
|
|
1781
|
+
oe(G(Ni), {
|
|
1782
|
+
size: 14,
|
|
1783
|
+
"aria-hidden": "true"
|
|
1784
|
+
})
|
|
1785
|
+
], 40, on),
|
|
1786
|
+
p.value && u.value ? (g(), me(Oe, {
|
|
1787
|
+
key: 0,
|
|
1788
|
+
to: u.value
|
|
1789
|
+
}, [
|
|
1790
|
+
i("div", {
|
|
1791
|
+
ref_key: "menu",
|
|
1792
|
+
ref: v,
|
|
1793
|
+
class: "aimd-input-tools__menu",
|
|
1794
|
+
role: "menu",
|
|
1795
|
+
"aria-label": e.messages.inputField.more,
|
|
1796
|
+
onKeydown: V
|
|
1797
|
+
}, [
|
|
1798
|
+
(g(!0), h(R, null, Y(_.value, (A) => (g(), h("button", {
|
|
1799
|
+
key: A.preset,
|
|
1800
|
+
type: "button",
|
|
1801
|
+
role: "menuitem",
|
|
1802
|
+
tabindex: "-1",
|
|
1803
|
+
title: e.messages.inputField.insertType(A.label),
|
|
1804
|
+
onMousedown: b[5] || (b[5] = ae(() => {
|
|
1805
|
+
}, ["prevent"])),
|
|
1806
|
+
onClick: (E) => S(A.preset)
|
|
1807
|
+
}, [
|
|
1808
|
+
(g(), me(it(A.icon), {
|
|
1809
|
+
size: 16,
|
|
1810
|
+
"aria-hidden": "true"
|
|
1811
|
+
})),
|
|
1812
|
+
i("span", null, m(A.label), 1)
|
|
1813
|
+
], 40, rn))), 128))
|
|
1814
|
+
], 40, un)
|
|
1815
|
+
], 8, ["to"])) : N("", !0)
|
|
1816
|
+
], 8, nn));
|
|
1817
|
+
}
|
|
1818
|
+
}), cn = /* @__PURE__ */ je(dn, [["__scopeId", "data-v-4f8b17e2"]]), vn = { class: "aimd-editor-toolbar" }, mn = {
|
|
1819
|
+
key: 0,
|
|
1820
|
+
class: "aimd-editor-mode-switch"
|
|
1821
|
+
}, pn = ["title"], fn = ["title"], gn = {
|
|
1822
|
+
key: 1,
|
|
1823
|
+
class: "aimd-editor-toolbar-sep"
|
|
1824
|
+
}, hn = {
|
|
1825
|
+
key: 0,
|
|
1826
|
+
class: "aimd-editor-toolbar-sep"
|
|
1827
|
+
}, yn = ["title", "onClick", "innerHTML"], bn = {
|
|
1828
|
+
key: 3,
|
|
1829
|
+
class: "aimd-editor-toolbar-divider"
|
|
1830
|
+
}, kn = ["title", "onClick", "onMouseup"], wn = ["innerHTML"], Mn = { class: "aimd-editor-aimd-btn-label" }, _n = /* @__PURE__ */ pe({
|
|
1831
|
+
__name: "AimdEditorToolbar",
|
|
1832
|
+
props: {
|
|
1833
|
+
showTopBar: { type: Boolean },
|
|
1834
|
+
showMdToolbar: { type: Boolean },
|
|
1835
|
+
showAimdToolbar: { type: Boolean },
|
|
1836
|
+
editorMode: {},
|
|
1837
|
+
resolvedMessages: {},
|
|
1838
|
+
localizedFieldTypes: {},
|
|
1839
|
+
localizedMdToolbarItems: {}
|
|
1840
|
+
},
|
|
1841
|
+
emits: ["switch-mode", "md-action", "open-aimd-dialog", "quick-insert-aimd", "insert-input"],
|
|
1842
|
+
setup(e, { emit: n }) {
|
|
1843
|
+
const t = n;
|
|
1844
|
+
return (a, o) => (g(), h("div", vn, [
|
|
1845
|
+
e.showTopBar ? (g(), h("div", mn, [
|
|
1846
|
+
i("button", {
|
|
1847
|
+
type: "button",
|
|
1848
|
+
class: ye(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
|
|
1849
|
+
onClick: o[0] || (o[0] = (v) => t("switch-mode", "source")),
|
|
1850
|
+
title: e.resolvedMessages.mode.sourceTitle
|
|
1851
|
+
}, [
|
|
1852
|
+
o[3] || (o[3] = i("span", {
|
|
1853
|
+
class: "aimd-editor-mode-icon",
|
|
1854
|
+
innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>'
|
|
1855
|
+
}, null, -1)),
|
|
1856
|
+
i("span", null, m(e.resolvedMessages.mode.source), 1)
|
|
1857
|
+
], 10, pn),
|
|
1858
|
+
i("button", {
|
|
1859
|
+
type: "button",
|
|
1860
|
+
class: ye(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
|
|
1861
|
+
onClick: o[1] || (o[1] = (v) => t("switch-mode", "wysiwyg")),
|
|
1862
|
+
title: e.resolvedMessages.mode.wysiwygTitle
|
|
1863
|
+
}, [
|
|
1864
|
+
o[4] || (o[4] = i("span", {
|
|
1865
|
+
class: "aimd-editor-mode-icon",
|
|
1866
|
+
innerHTML: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
|
|
1867
|
+
}, null, -1)),
|
|
1868
|
+
i("span", null, m(e.resolvedMessages.mode.wysiwyg), 1)
|
|
1869
|
+
], 10, fn)
|
|
1870
|
+
])) : N("", !0),
|
|
1871
|
+
e.showTopBar && e.showMdToolbar ? (g(), h("div", gn)) : N("", !0),
|
|
1872
|
+
e.showMdToolbar ? (g(!0), h(R, { key: 2 }, Y(e.localizedMdToolbarItems, (v) => (g(), h(R, {
|
|
1873
|
+
key: v.action
|
|
1874
|
+
}, [
|
|
1875
|
+
v.action.startsWith("sep") ? (g(), h("div", hn)) : (g(), h("button", {
|
|
1876
|
+
key: 1,
|
|
1877
|
+
type: "button",
|
|
1878
|
+
class: "aimd-editor-fmt-btn",
|
|
1879
|
+
title: v.title,
|
|
1880
|
+
onClick: (p) => t("md-action", v.action, p),
|
|
1881
|
+
innerHTML: v.svgIcon
|
|
1882
|
+
}, null, 8, yn))
|
|
1883
|
+
], 64))), 128)) : N("", !0),
|
|
1884
|
+
e.showMdToolbar && e.showAimdToolbar ? (g(), h("div", bn)) : N("", !0),
|
|
1885
|
+
e.showAimdToolbar ? (g(), h(R, { key: 4 }, [
|
|
1886
|
+
(g(!0), h(R, null, Y(e.localizedFieldTypes.filter((v) => v.type !== "var"), (v) => (g(), h("button", {
|
|
1887
|
+
key: v.type,
|
|
1888
|
+
type: "button",
|
|
1889
|
+
class: "aimd-editor-fmt-btn aimd-editor-aimd-btn",
|
|
1890
|
+
title: v.desc,
|
|
1891
|
+
style: Ue({ "--aimd-color": v.color }),
|
|
1892
|
+
onClick: (p) => t("open-aimd-dialog", v.type),
|
|
1893
|
+
onMouseup: ae((p) => t("quick-insert-aimd", v.type), ["middle", "prevent"])
|
|
1894
|
+
}, [
|
|
1895
|
+
i("span", {
|
|
1896
|
+
class: "aimd-editor-aimd-btn-icon",
|
|
1897
|
+
innerHTML: v.svgIcon
|
|
1898
|
+
}, null, 8, wn),
|
|
1899
|
+
i("span", Mn, m(v.label), 1)
|
|
1900
|
+
], 44, kn))), 128)),
|
|
1901
|
+
e.localizedFieldTypes.some((v) => v.type === "var") ? (g(), me(cn, {
|
|
1902
|
+
key: 0,
|
|
1903
|
+
messages: e.resolvedMessages,
|
|
1904
|
+
onInsert: o[2] || (o[2] = (v) => t("insert-input", v))
|
|
1905
|
+
}, null, 8, ["messages"])) : N("", !0)
|
|
1906
|
+
], 64)) : N("", !0)
|
|
1907
|
+
]));
|
|
1908
|
+
}
|
|
1909
|
+
});
|
|
1910
|
+
function Tn(e) {
|
|
1911
|
+
const { initialContent: n, initialMode: t, resolvedMessages: a, emitModelValue: o, emitMode: v } = e, p = F(t), u = F(n), l = Xe(null), c = Xe(null), _ = F(!0), d = Xe(null);
|
|
1912
|
+
let k = !1;
|
|
1913
|
+
function S(T) {
|
|
1914
|
+
T !== u.value && (u.value = T, o(T));
|
|
1915
|
+
}
|
|
1916
|
+
function V(T) {
|
|
1917
|
+
return Ut(T).content;
|
|
1918
|
+
}
|
|
1919
|
+
function y(T) {
|
|
1920
|
+
return /class="ProseMirror milkdown-editor-content editor"/.test(T) || /<div class="milkdown">/.test(T) || /<\/?[a-z][^>]*>/i.test(T) && /AIMDINLINETEMPLATE[0-9a-f]+TOKEN/.test(T);
|
|
1921
|
+
}
|
|
1922
|
+
function b(T, z) {
|
|
1923
|
+
const H = At(Rt(T));
|
|
1924
|
+
return y(H) ? z : H;
|
|
1925
|
+
}
|
|
1926
|
+
function A(T) {
|
|
1927
|
+
return /\{\{(?:var_table|var|quiz|step|check|task|ref_step|ref_var|ref_fig|cite|fig)\|/.test(T) || /```(?:quiz|fig|assigner|connectors)\b/.test(T);
|
|
1928
|
+
}
|
|
1929
|
+
function E() {
|
|
1930
|
+
if (d.value)
|
|
1931
|
+
try {
|
|
1932
|
+
const T = d.value.action(ot());
|
|
1933
|
+
if (typeof T != "string")
|
|
1934
|
+
return;
|
|
1935
|
+
const z = b(T, u.value);
|
|
1936
|
+
d.value.action(Le(V(z)));
|
|
1937
|
+
} catch {
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
const C = B(() => {
|
|
1941
|
+
try {
|
|
1942
|
+
return Ot(u.value);
|
|
1943
|
+
} catch {
|
|
1944
|
+
return null;
|
|
1945
|
+
}
|
|
1946
|
+
});
|
|
1947
|
+
async function I(T) {
|
|
1948
|
+
if (T !== p.value) {
|
|
1949
|
+
if (p.value === "source" && l.value && (u.value = l.value.getValue()), p.value === "wysiwyg" && d.value)
|
|
1950
|
+
try {
|
|
1951
|
+
const z = d.value.action(ot());
|
|
1952
|
+
typeof z == "string" && (u.value = b(z, u.value));
|
|
1953
|
+
} catch {
|
|
1954
|
+
}
|
|
1955
|
+
if (p.value = T, v(T), T === "source")
|
|
1956
|
+
await Re(), l.value && (k = !0, l.value.setValue(u.value), k = !1);
|
|
1957
|
+
else if (T === "wysiwyg" && (await Re(), d.value))
|
|
1958
|
+
try {
|
|
1959
|
+
k = !0, d.value.action(Le(V(u.value))), k = !1;
|
|
1960
|
+
} catch {
|
|
1961
|
+
k = !1;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
function W(T) {
|
|
1966
|
+
if (T !== u.value) {
|
|
1967
|
+
if (k = !0, u.value = T, p.value === "source" && l.value)
|
|
1968
|
+
l.value.setValue(T);
|
|
1969
|
+
else if (p.value === "wysiwyg" && d.value)
|
|
1970
|
+
try {
|
|
1971
|
+
d.value.action(Le(V(T)));
|
|
1972
|
+
} catch {
|
|
1973
|
+
}
|
|
1974
|
+
k = !1;
|
|
1975
|
+
}
|
|
1976
|
+
}
|
|
1977
|
+
function le(T) {
|
|
1978
|
+
if (p.value === "source" && l.value) {
|
|
1979
|
+
const z = l.value.getSelection(), H = l.value.getModel(), J = l.value.getPosition(), Q = H.getLineContent(J.lineNumber).substring(0, J.column - 1).trim() !== "" && !T.startsWith(`
|
|
1980
|
+
`) ? `
|
|
1981
|
+
` + T : T;
|
|
1982
|
+
l.value.executeEdits("toolbar", [{
|
|
1983
|
+
range: z,
|
|
1984
|
+
text: Q,
|
|
1985
|
+
forceMoveMarkers: !0
|
|
1986
|
+
}]), l.value.focus();
|
|
1987
|
+
} else if (p.value === "wysiwyg" && d.value)
|
|
1988
|
+
try {
|
|
1989
|
+
d.value.action(Ye(T)), A(T) && E();
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
function j(T, z = "", H = "") {
|
|
1994
|
+
if (p.value === "source" && l.value) {
|
|
1995
|
+
const J = l.value.getSelection(), x = l.value.getModel().getValueInRange(J) || H, w = T + x + z;
|
|
1996
|
+
l.value.executeEdits("toolbar", [{
|
|
1997
|
+
range: J,
|
|
1998
|
+
text: w,
|
|
1999
|
+
forceMoveMarkers: !0
|
|
2000
|
+
}]), l.value.focus();
|
|
2001
|
+
} else if (p.value === "wysiwyg" && d.value)
|
|
2002
|
+
try {
|
|
2003
|
+
d.value.action(Ye(T + H + z));
|
|
2004
|
+
} catch {
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
function O(T, z = "") {
|
|
2008
|
+
if (p.value === "source" && l.value) {
|
|
2009
|
+
const H = l.value.getPosition(), x = l.value.getModel().getLineContent(H.lineNumber);
|
|
2010
|
+
if (x.trim() === "") {
|
|
2011
|
+
const w = { startLineNumber: H.lineNumber, startColumn: 1, endLineNumber: H.lineNumber, endColumn: x.length + 1 };
|
|
2012
|
+
l.value.executeEdits("toolbar", [{ range: w, text: T + z, forceMoveMarkers: !0 }]);
|
|
2013
|
+
} else {
|
|
2014
|
+
const w = { startLineNumber: H.lineNumber, startColumn: x.length + 1, endLineNumber: H.lineNumber, endColumn: x.length + 1 };
|
|
2015
|
+
l.value.executeEdits("toolbar", [{ range: w, text: `
|
|
2016
|
+
` + T + z, forceMoveMarkers: !0 }]);
|
|
2017
|
+
}
|
|
2018
|
+
l.value.focus();
|
|
2019
|
+
} else if (p.value === "wysiwyg" && d.value)
|
|
2020
|
+
try {
|
|
2021
|
+
d.value.action(Ye(`
|
|
2022
|
+
` + T + z));
|
|
2023
|
+
} catch {
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
function K(T) {
|
|
2027
|
+
const z = a.value.snippets;
|
|
2028
|
+
switch (T) {
|
|
2029
|
+
case "h1":
|
|
2030
|
+
O("# ", z.heading);
|
|
2031
|
+
break;
|
|
2032
|
+
case "h2":
|
|
2033
|
+
O("## ", z.heading);
|
|
2034
|
+
break;
|
|
2035
|
+
case "h3":
|
|
2036
|
+
O("### ", z.heading);
|
|
2037
|
+
break;
|
|
2038
|
+
case "bold":
|
|
2039
|
+
j("**", "**", z.boldText);
|
|
2040
|
+
break;
|
|
2041
|
+
case "italic":
|
|
2042
|
+
j("*", "*", z.italicText);
|
|
2043
|
+
break;
|
|
2044
|
+
case "strikethrough":
|
|
2045
|
+
j("~~", "~~", z.strikethrough);
|
|
2046
|
+
break;
|
|
2047
|
+
case "ul":
|
|
2048
|
+
O("- ", z.listItem);
|
|
2049
|
+
break;
|
|
2050
|
+
case "ol":
|
|
2051
|
+
O("1. ", z.listItem);
|
|
2052
|
+
break;
|
|
2053
|
+
case "blockquote":
|
|
2054
|
+
O("> ", z.quote);
|
|
2055
|
+
break;
|
|
2056
|
+
case "code":
|
|
2057
|
+
j("`", "`", z.code);
|
|
2058
|
+
break;
|
|
2059
|
+
case "codeblock":
|
|
2060
|
+
j("```\n", "\n```", z.codeBlock);
|
|
2061
|
+
break;
|
|
2062
|
+
case "link":
|
|
2063
|
+
j("[", "](url)", z.linkText);
|
|
2064
|
+
break;
|
|
2065
|
+
case "image":
|
|
2066
|
+
j("", z.altText);
|
|
2067
|
+
break;
|
|
2068
|
+
case "hr":
|
|
2069
|
+
O("---");
|
|
2070
|
+
break;
|
|
2071
|
+
case "math":
|
|
2072
|
+
j("$", "$", z.mathFormula);
|
|
2073
|
+
break;
|
|
2074
|
+
case "table":
|
|
2075
|
+
if (p.value === "wysiwyg" && d.value)
|
|
2076
|
+
try {
|
|
2077
|
+
d.value.action(Mt(Ht.key, { row: 3, col: 3 }));
|
|
2078
|
+
} catch {
|
|
2079
|
+
}
|
|
2080
|
+
else
|
|
2081
|
+
O(
|
|
2082
|
+
`| ${z.tableColumnA} | ${z.tableColumnB} | ${z.tableColumnC} |
|
|
2083
|
+
|-------|-------|-------|
|
|
2084
|
+
| `,
|
|
2085
|
+
" | | |"
|
|
2086
|
+
);
|
|
2087
|
+
break;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
function X(T, z, H) {
|
|
2091
|
+
k || S(b(z, u.value));
|
|
2092
|
+
}
|
|
2093
|
+
function se(T) {
|
|
2094
|
+
d.value = T;
|
|
2095
|
+
}
|
|
2096
|
+
return {
|
|
2097
|
+
editorMode: p,
|
|
2098
|
+
content: u,
|
|
2099
|
+
commitUserContent: S,
|
|
2100
|
+
monacoEditor: l,
|
|
2101
|
+
monacoInstance: c,
|
|
2102
|
+
monacoLoading: _,
|
|
2103
|
+
milkdownEditorRef: d,
|
|
2104
|
+
extractedFields: C,
|
|
2105
|
+
toMilkdownMarkdown: V,
|
|
2106
|
+
switchMode: I,
|
|
2107
|
+
syncFromProp: W,
|
|
2108
|
+
insertTextIntoActiveEditor: le,
|
|
2109
|
+
handleMdAction: K,
|
|
2110
|
+
onMilkdownMarkdownUpdated: X,
|
|
2111
|
+
onMilkdownReady: se
|
|
2112
|
+
};
|
|
2113
|
+
}
|
|
2114
|
+
const xn = { class: "aimd-editor" }, Cn = {
|
|
2115
|
+
key: 0,
|
|
2116
|
+
class: "aimd-editor-mode-host"
|
|
2117
|
+
}, $n = {
|
|
2118
|
+
key: 1,
|
|
2119
|
+
class: "aimd-editor-mode-host"
|
|
2120
|
+
}, On = /* @__PURE__ */ pe({
|
|
2121
|
+
__name: "AimdEditor",
|
|
2122
|
+
props: {
|
|
2123
|
+
modelValue: { default: "" },
|
|
2124
|
+
locale: {},
|
|
2125
|
+
messages: { default: () => ({}) },
|
|
2126
|
+
mode: { default: "source" },
|
|
2127
|
+
fieldDisplay: { default: "detailed" },
|
|
2128
|
+
theme: { default: "aimd-light" },
|
|
2129
|
+
showTopBar: { type: Boolean, default: !0 },
|
|
2130
|
+
showToolbar: { type: Boolean, default: !0 },
|
|
2131
|
+
showAimdToolbar: { type: Boolean, default: !0 },
|
|
2132
|
+
showMdToolbar: { type: Boolean, default: !0 },
|
|
2133
|
+
imageToolbarAction: { default: "markdown" },
|
|
2134
|
+
enableBlockHandle: { type: Boolean, default: !0 },
|
|
2135
|
+
enableSlashMenu: { type: Boolean, default: !0 },
|
|
2136
|
+
keepInactiveEditorsMounted: { type: Boolean, default: !0 },
|
|
2137
|
+
minHeight: { default: 500 },
|
|
2138
|
+
readonly: { type: Boolean, default: !1 },
|
|
2139
|
+
monacoOptions: { default: () => ({}) },
|
|
2140
|
+
varTypePlugins: {}
|
|
2141
|
+
},
|
|
2142
|
+
emits: ["update:modelValue", "update:mode", "ready", "request-image"],
|
|
2143
|
+
setup(e, { expose: n, emit: t }) {
|
|
2144
|
+
const a = e, o = t, v = B(() => zt(a.locale, a.messages)), {
|
|
2145
|
+
editorMode: p,
|
|
2146
|
+
content: u,
|
|
2147
|
+
commitUserContent: l,
|
|
2148
|
+
monacoEditor: c,
|
|
2149
|
+
monacoInstance: _,
|
|
2150
|
+
milkdownEditorRef: d,
|
|
2151
|
+
extractedFields: k,
|
|
2152
|
+
toMilkdownMarkdown: S,
|
|
2153
|
+
switchMode: V,
|
|
2154
|
+
syncFromProp: y,
|
|
2155
|
+
insertTextIntoActiveEditor: b,
|
|
2156
|
+
handleMdAction: A,
|
|
2157
|
+
onMilkdownMarkdownUpdated: E,
|
|
2158
|
+
onMilkdownReady: C
|
|
2159
|
+
} = Tn({
|
|
2160
|
+
initialContent: a.modelValue,
|
|
2161
|
+
initialMode: a.mode,
|
|
2162
|
+
resolvedMessages: v,
|
|
2163
|
+
emitModelValue: (s) => o("update:modelValue", s),
|
|
2164
|
+
emitMode: (s) => o("update:mode", s)
|
|
2165
|
+
});
|
|
2166
|
+
ee(() => a.modelValue, (s) => y(s)), ee(() => a.mode, (s) => {
|
|
2167
|
+
s !== p.value && V(s);
|
|
2168
|
+
});
|
|
2169
|
+
const I = F(a.theme), W = B(() => a.keepInactiveEditorsMounted || p.value === "source"), le = B(() => a.keepInactiveEditorsMounted || p.value === "wysiwyg"), j = B(() => ft(v.value)), O = B(() => Vt(v.value)), K = F(!1), X = F("var"), se = F(!1), T = F("str"), z = F(), H = F(!1), J = F("step"), x = F();
|
|
2170
|
+
function w(s) {
|
|
2171
|
+
a.readonly || (J.value = "step", x.value = s, H.value = !0);
|
|
2172
|
+
}
|
|
2173
|
+
function $(s) {
|
|
2174
|
+
a.readonly || (J.value = "check", x.value = s, H.value = !0);
|
|
2175
|
+
}
|
|
2176
|
+
function Q(s) {
|
|
2177
|
+
a.readonly || (x.value ? x.value.apply(s) : b(`{{${J.value}|${s}}}${J.value === "step" ? `
|
|
2178
|
+
|
|
2179
|
+
` : " "}`));
|
|
2180
|
+
}
|
|
2181
|
+
function Z(s) {
|
|
2182
|
+
a.readonly || (z.value = s, se.value = !0);
|
|
2183
|
+
}
|
|
2184
|
+
function te(s) {
|
|
2185
|
+
a.readonly || (z.value ? z.value.apply(s) : b(`{{var|${s}}}`));
|
|
2186
|
+
}
|
|
2187
|
+
const re = B(() => {
|
|
2188
|
+
const s = k.value;
|
|
2189
|
+
if (!s) return [];
|
|
2190
|
+
const M = X.value;
|
|
2191
|
+
return M === "ref_step" ? s.step || [] : M === "ref_var" ? s.var || [] : M === "ref_fig" ? s.ref_fig || [] : [];
|
|
2192
|
+
}), ne = B(() => {
|
|
2193
|
+
const s = k.value;
|
|
2194
|
+
return s?.quiz ? s.quiz.map((M) => M.id) : [];
|
|
2195
|
+
});
|
|
2196
|
+
function fe(s) {
|
|
2197
|
+
if (!a.readonly) {
|
|
2198
|
+
if (s === "step" || s === "check") {
|
|
2199
|
+
J.value = s, x.value = void 0, H.value = !0;
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2202
|
+
if (s === "var") {
|
|
2203
|
+
de("str");
|
|
2204
|
+
return;
|
|
2205
|
+
}
|
|
2206
|
+
X.value = s, K.value = !0;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
function de(s) {
|
|
2210
|
+
a.readonly || (z.value = void 0, T.value = s, se.value = !0);
|
|
2211
|
+
}
|
|
2212
|
+
function xe(s) {
|
|
2213
|
+
if (!a.readonly) {
|
|
2214
|
+
if (s === "step") {
|
|
2215
|
+
b(`{{step|${_e(Te(u.value), "step")}, check=True}}
|
|
2216
|
+
|
|
2217
|
+
`);
|
|
2218
|
+
return;
|
|
2219
|
+
}
|
|
2220
|
+
if (s === "var") {
|
|
2221
|
+
const M = _e(Te(u.value));
|
|
2222
|
+
b(`{{var|${M}: str}}`);
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
b(Dt(s, v.value));
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
function Ke(s) {
|
|
2229
|
+
b(s);
|
|
2230
|
+
}
|
|
2231
|
+
function Ce(s) {
|
|
2232
|
+
if (!(s instanceof HTMLElement)) return;
|
|
2233
|
+
const M = s.getBoundingClientRect();
|
|
2234
|
+
return {
|
|
2235
|
+
top: M.top,
|
|
2236
|
+
right: M.right,
|
|
2237
|
+
bottom: M.bottom,
|
|
2238
|
+
left: M.left,
|
|
2239
|
+
width: M.width,
|
|
2240
|
+
height: M.height
|
|
2241
|
+
};
|
|
2242
|
+
}
|
|
2243
|
+
function $e(s, M) {
|
|
2244
|
+
if (s === "image" && a.imageToolbarAction === "custom") {
|
|
2245
|
+
o("request-image", { buttonRect: Ce(M.currentTarget) });
|
|
2246
|
+
return;
|
|
2247
|
+
}
|
|
2248
|
+
A(s);
|
|
2249
|
+
}
|
|
2250
|
+
const We = F(null), Qe = F(null);
|
|
2251
|
+
function Je(s) {
|
|
2252
|
+
l(s);
|
|
2253
|
+
}
|
|
2254
|
+
function Ie(s) {
|
|
2255
|
+
o("ready", { monaco: s });
|
|
2256
|
+
}
|
|
2257
|
+
function f(s, M) {
|
|
2258
|
+
_.value = s, c.value = M;
|
|
2259
|
+
}
|
|
2260
|
+
function r(s) {
|
|
2261
|
+
C(s), o("ready", { milkdown: s });
|
|
2262
|
+
}
|
|
2263
|
+
return n({
|
|
2264
|
+
getContent: () => u.value,
|
|
2265
|
+
setContent: (s) => {
|
|
2266
|
+
if (u.value = s, p.value === "source" && c.value)
|
|
2267
|
+
c.value.setValue(s);
|
|
2268
|
+
else if (d.value)
|
|
2269
|
+
try {
|
|
2270
|
+
d.value.action(Le(S(s)));
|
|
2271
|
+
} catch {
|
|
2272
|
+
}
|
|
2273
|
+
},
|
|
2274
|
+
getMode: () => p.value,
|
|
2275
|
+
setMode: (s) => V(s),
|
|
2276
|
+
getMonacoEditor: () => c.value,
|
|
2277
|
+
getMilkdownEditor: () => d.value,
|
|
2278
|
+
insertText: b
|
|
2279
|
+
}), (s, M) => (g(), h("div", xn, [
|
|
2280
|
+
e.showToolbar ? (g(), me(_n, {
|
|
2281
|
+
key: 0,
|
|
2282
|
+
"show-top-bar": e.showTopBar,
|
|
2283
|
+
"show-md-toolbar": e.showMdToolbar,
|
|
2284
|
+
"show-aimd-toolbar": e.showAimdToolbar,
|
|
2285
|
+
"editor-mode": G(p),
|
|
2286
|
+
"resolved-messages": v.value,
|
|
2287
|
+
"localized-field-types": j.value,
|
|
2288
|
+
"localized-md-toolbar-items": O.value,
|
|
2289
|
+
onSwitchMode: G(V),
|
|
2290
|
+
onMdAction: $e,
|
|
2291
|
+
onOpenAimdDialog: fe,
|
|
2292
|
+
onQuickInsertAimd: xe,
|
|
2293
|
+
onInsertInput: de
|
|
2294
|
+
}, null, 8, ["show-top-bar", "show-md-toolbar", "show-aimd-toolbar", "editor-mode", "resolved-messages", "localized-field-types", "localized-md-toolbar-items", "onSwitchMode"])) : N("", !0),
|
|
2295
|
+
i("div", {
|
|
2296
|
+
class: "aimd-editor-panel",
|
|
2297
|
+
style: Ue({ minHeight: e.minHeight + "px" })
|
|
2298
|
+
}, [
|
|
2299
|
+
W.value ? D((g(), h("div", Cn, [
|
|
2300
|
+
oe(Lt, {
|
|
2301
|
+
ref_key: "sourceEditorRef",
|
|
2302
|
+
ref: We,
|
|
2303
|
+
content: G(u),
|
|
2304
|
+
theme: I.value,
|
|
2305
|
+
"min-height": e.minHeight,
|
|
2306
|
+
readonly: e.readonly,
|
|
2307
|
+
"monaco-options": e.monacoOptions,
|
|
2308
|
+
"resolved-messages": v.value,
|
|
2309
|
+
onContentChange: Je,
|
|
2310
|
+
onReady: Ie,
|
|
2311
|
+
onMonacoLoaded: f
|
|
2312
|
+
}, null, 8, ["content", "theme", "min-height", "readonly", "monaco-options", "resolved-messages"])
|
|
2313
|
+
], 512)), [
|
|
2314
|
+
[at, G(p) === "source"]
|
|
2315
|
+
]) : N("", !0),
|
|
2316
|
+
le.value ? D((g(), h("div", $n, [
|
|
2317
|
+
oe(St, {
|
|
2318
|
+
ref_key: "wysiwygEditorRef",
|
|
2319
|
+
ref: Qe,
|
|
2320
|
+
content: G(u),
|
|
2321
|
+
"min-height": e.minHeight,
|
|
2322
|
+
"enable-block-handle": e.enableBlockHandle,
|
|
2323
|
+
active: G(p) === "wysiwyg",
|
|
2324
|
+
"resolved-messages": v.value,
|
|
2325
|
+
"localized-field-types": j.value,
|
|
2326
|
+
"field-display": e.fieldDisplay,
|
|
2327
|
+
"edit-input-fields": !0,
|
|
2328
|
+
readonly: e.readonly,
|
|
2329
|
+
onMarkdownUpdated: G(E),
|
|
2330
|
+
onReady: r,
|
|
2331
|
+
onOpenAimdDialog: fe,
|
|
2332
|
+
onEditInput: Z,
|
|
2333
|
+
onEditStep: w,
|
|
2334
|
+
onEditCheck: $
|
|
2335
|
+
}, null, 8, ["content", "min-height", "enable-block-handle", "active", "resolved-messages", "localized-field-types", "field-display", "readonly", "onMarkdownUpdated"])
|
|
2336
|
+
], 512)), [
|
|
2337
|
+
[at, G(p) === "wysiwyg"]
|
|
2338
|
+
]) : N("", !0)
|
|
2339
|
+
], 4),
|
|
2340
|
+
oe(Fi, {
|
|
2341
|
+
visible: H.value,
|
|
2342
|
+
"onUpdate:visible": M[0] || (M[0] = (q) => H.value = q),
|
|
2343
|
+
"field-type": J.value,
|
|
2344
|
+
content: G(u),
|
|
2345
|
+
"field-content": x.value?.content,
|
|
2346
|
+
messages: v.value,
|
|
2347
|
+
onSave: Q
|
|
2348
|
+
}, null, 8, ["visible", "field-type", "content", "field-content", "messages"]),
|
|
2349
|
+
oe(gi, {
|
|
2350
|
+
visible: se.value,
|
|
2351
|
+
"onUpdate:visible": M[1] || (M[1] = (q) => se.value = q),
|
|
2352
|
+
content: G(u),
|
|
2353
|
+
"field-content": z.value?.content,
|
|
2354
|
+
"initial-preset": T.value,
|
|
2355
|
+
"var-type-plugins": e.varTypePlugins,
|
|
2356
|
+
messages: v.value,
|
|
2357
|
+
onSave: te
|
|
2358
|
+
}, null, 8, ["visible", "content", "field-content", "initial-preset", "var-type-plugins", "messages"]),
|
|
2359
|
+
oe(Zs, {
|
|
2360
|
+
visible: K.value,
|
|
2361
|
+
"initial-type": X.value,
|
|
2362
|
+
messages: v.value,
|
|
2363
|
+
"ref-suggestions": re.value,
|
|
2364
|
+
"var-type-plugins": e.varTypePlugins,
|
|
2365
|
+
"existing-quiz-ids": ne.value,
|
|
2366
|
+
"onUpdate:visible": M[2] || (M[2] = (q) => K.value = q),
|
|
2367
|
+
onInsert: Ke
|
|
2368
|
+
}, null, 8, ["visible", "initial-type", "messages", "ref-suggestions", "var-type-plugins", "existing-quiz-ids"])
|
|
2369
|
+
]));
|
|
2370
|
+
}
|
|
2371
|
+
}), In = { class: "aimd-editor-mode-switch" }, Fn = ["title"], An = ["innerHTML"], zn = ["title"], Vn = ["innerHTML"], Hn = /* @__PURE__ */ pe({
|
|
2372
|
+
__name: "AimdEditorTopBar",
|
|
2373
|
+
props: {
|
|
2374
|
+
editorMode: {},
|
|
2375
|
+
resolvedMessages: {}
|
|
2376
|
+
},
|
|
2377
|
+
emits: ["switch-mode"],
|
|
2378
|
+
setup(e, { emit: n }) {
|
|
2379
|
+
const t = n, a = {
|
|
2380
|
+
source: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
|
|
2381
|
+
wysiwyg: '<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
|
|
2382
|
+
};
|
|
2383
|
+
return (o, v) => (g(), h("div", In, [
|
|
2384
|
+
i("button", {
|
|
2385
|
+
class: ye(["aimd-editor-mode-btn", { active: e.editorMode === "source" }]),
|
|
2386
|
+
onClick: v[0] || (v[0] = (p) => t("switch-mode", "source")),
|
|
2387
|
+
title: e.resolvedMessages.mode.sourceTitle
|
|
2388
|
+
}, [
|
|
2389
|
+
i("span", {
|
|
2390
|
+
class: "aimd-editor-mode-icon",
|
|
2391
|
+
innerHTML: a.source
|
|
2392
|
+
}, null, 8, An),
|
|
2393
|
+
i("span", null, m(e.resolvedMessages.mode.source), 1)
|
|
2394
|
+
], 10, Fn),
|
|
2395
|
+
i("button", {
|
|
2396
|
+
class: ye(["aimd-editor-mode-btn", { active: e.editorMode === "wysiwyg" }]),
|
|
2397
|
+
onClick: v[1] || (v[1] = (p) => t("switch-mode", "wysiwyg")),
|
|
2398
|
+
title: e.resolvedMessages.mode.wysiwygTitle
|
|
2399
|
+
}, [
|
|
2400
|
+
i("span", {
|
|
2401
|
+
class: "aimd-editor-mode-icon",
|
|
2402
|
+
innerHTML: a.wysiwyg
|
|
2403
|
+
}, null, 8, Vn),
|
|
2404
|
+
i("span", null, m(e.resolvedMessages.mode.wysiwyg), 1)
|
|
2405
|
+
], 10, zn)
|
|
2406
|
+
]));
|
|
2407
|
+
}
|
|
2408
|
+
});
|
|
2409
|
+
export {
|
|
2410
|
+
gi as A,
|
|
2411
|
+
On as _,
|
|
2412
|
+
_n as a,
|
|
2413
|
+
Hn as b,
|
|
2414
|
+
Zs as c,
|
|
2415
|
+
Fi as d,
|
|
2416
|
+
Tn as u
|
|
2417
|
+
};
|