@airalogy/aimd-editor 1.12.0 → 1.13.1

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.
Files changed (41) hide show
  1. package/README.md +24 -0
  2. package/README.zh-CN.md +24 -0
  3. package/dist/AimdEditorTopBar.vue_vue_type_script_setup_true_lang-x8F65dCh.js +2277 -0
  4. package/dist/{AimdSourceEditor.vue_vue_type_script_setup_true_lang-CJJTlVZ7.js → AimdSourceEditor.vue_vue_type_script_setup_true_lang-m07PHAyw.js} +29 -27
  5. package/dist/{AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-Dme3UQEf.js → AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-8nbo78nG.js} +6118 -5822
  6. package/dist/aimd-editor.css +1 -1
  7. package/dist/authoring.js +15 -8
  8. package/dist/embedded.js +2 -2
  9. package/dist/fields-DZsN-S-N.js +51 -0
  10. package/dist/fig-DzERhLmG.js +219 -0
  11. package/dist/index.js +54 -45
  12. package/dist/{index-BqB8Xukp.js → lexer-Dj-IVtCT.js} +932 -1053
  13. package/dist/vue.js +28 -26
  14. package/dist/wysiwyg.js +1 -1
  15. package/package.json +4 -3
  16. package/src/__tests__/check-authoring.test.ts +46 -0
  17. package/src/__tests__/code-block-metadata.test.ts +40 -0
  18. package/src/__tests__/input-authoring.test.ts +93 -0
  19. package/src/__tests__/input-dialog-layout.test.ts +52 -0
  20. package/src/__tests__/input-toolbar.test.ts +88 -0
  21. package/src/__tests__/multiline-field-roundtrip.test.ts +70 -0
  22. package/src/__tests__/quoted-inline-roundtrip.test.ts +80 -0
  23. package/src/__tests__/step-authoring.test.ts +62 -0
  24. package/src/__tests__/type-picker.test.ts +48 -0
  25. package/src/authoring/fields.ts +86 -0
  26. package/src/authoring/index.ts +1 -0
  27. package/src/vue/AimdEditor.vue +112 -0
  28. package/src/vue/AimdEditorToolbar.vue +4 -1
  29. package/src/vue/AimdFieldDialog.vue +14 -9
  30. package/src/vue/AimdInputFieldDialog.vue +166 -0
  31. package/src/vue/AimdInputToolbar.vue +77 -0
  32. package/src/vue/AimdStepFieldDialog.vue +112 -0
  33. package/src/vue/AimdTypePicker.vue +42 -0
  34. package/src/vue/AimdWysiwygEditor.vue +24 -2
  35. package/src/vue/aimdInlineMarkdownNormalization.ts +37 -5
  36. package/src/vue/index.ts +2 -0
  37. package/src/vue/locales.ts +94 -7
  38. package/src/vue/milkdown-aimd-plugin.ts +148 -16
  39. package/src/vue/milkdown-code-block-metadata.ts +46 -0
  40. package/src/vue/types.ts +6 -4
  41. package/dist/AimdEditorTopBar.vue_vue_type_script_setup_true_lang-BXsn4cFX.js +0 -1171
@@ -1,1171 +0,0 @@
1
- import { defineComponent as ve, computed as $, ref as B, watch as E, openBlock as u, createBlock as Be, Teleport as Ue, createElementBlock as v, withModifiers as ue, createElementVNode as l, normalizeStyle as me, createTextVNode as N, toDisplayString as i, Fragment as q, renderList as j, normalizeClass as W, withDirectives as b, vModelText as x, createCommentVNode as z, vModelSelect as ke, vModelRadio as Le, vModelCheckbox as He, shallowRef as _e, nextTick as ze, unref as K, createVNode as Me, vShow as Ie } from "vue";
2
- import { callCommand as De, insert as Te, replaceAll as ce, getMarkdown as xe } from "@milkdown/kit/utils";
3
- import "@milkdown/theme-nord/style.css";
4
- import { j as Ve, m as ie, k as Pe, h as $e, o as Re, i as Ne, l as Fe, _ as Oe, n as Ke } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-Dme3UQEf.js";
5
- import { _ as Qe } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-CJJTlVZ7.js";
6
- import { protectAimdInlineTemplates as je, restoreAimdInlineTemplates as We } from "@airalogy/aimd-core";
7
- import { parseAndExtract as Ge } from "@airalogy/aimd-renderer";
8
- import { insertTableCommand as Je } from "@milkdown/kit/preset/gfm";
9
- const Xe = { class: "aimd-dialog" }, Ye = { class: "aimd-dialog-header" }, Ze = { class: "aimd-dialog-title" }, el = ["innerHTML"], ll = { class: "aimd-dialog-type-tabs" }, sl = ["onClick"], tl = ["innerHTML"], ol = { class: "aimd-dialog-body" }, al = { class: "aimd-field-row" }, il = { class: "aimd-field-label" }, nl = ["placeholder"], dl = { class: "aimd-field-row" }, rl = { class: "aimd-field-label" }, ul = { class: "aimd-field-hint" }, cl = { class: "aimd-var-type-grid" }, ml = ["onClick"], vl = { class: "aimd-var-type-card-title" }, pl = { class: "aimd-var-type-card-desc" }, gl = { class: "aimd-field-row" }, fl = { class: "aimd-field-label" }, hl = ["placeholder"], yl = { class: "aimd-field-hint" }, bl = { class: "aimd-field-row" }, wl = { class: "aimd-field-label" }, kl = ["placeholder"], _l = { class: "aimd-field-row" }, Ml = { class: "aimd-field-label" }, Tl = ["placeholder"], Cl = { class: "aimd-field-row" }, zl = { class: "aimd-field-label" }, Il = ["placeholder"], xl = { class: "aimd-field-row" }, $l = { class: "aimd-field-label" }, Bl = ["placeholder"], Vl = { class: "aimd-field-hint" }, Al = { class: "aimd-field-row" }, ql = { class: "aimd-field-label" }, Sl = ["placeholder"], El = { class: "aimd-field-row" }, Ul = { class: "aimd-field-label" }, Ll = { value: "1" }, Hl = { value: "2" }, Dl = { value: "3" }, Pl = { class: "aimd-field-row" }, Rl = { class: "aimd-field-label" }, Nl = ["placeholder"], Fl = { class: "aimd-field-row" }, Ol = { class: "aimd-field-label" }, Kl = { value: "choice" }, Ql = { value: "blank" }, jl = { value: "open" }, Wl = { class: "aimd-field-row" }, Gl = { class: "aimd-field-label" }, Jl = ["placeholder"], Xl = { class: "aimd-field-row" }, Yl = { class: "aimd-field-label" }, Zl = ["placeholder"], es = {
10
- key: 0,
11
- class: "aimd-field-hint"
12
- }, ls = { class: "aimd-field-row" }, ss = { class: "aimd-field-label" }, ts = { value: "single" }, os = { value: "multiple" }, as = { class: "aimd-field-row" }, is = { class: "aimd-field-label" }, ns = { class: "aimd-collection-editor" }, ds = ["onDragover", "onDrop"], rs = ["title", "onDragstart"], us = ["onUpdate:modelValue", "placeholder"], cs = ["onUpdate:modelValue", "placeholder"], ms = { class: "aimd-option-answer-toggle" }, vs = ["value", "disabled"], ps = ["value", "disabled"], gs = ["disabled", "onClick"], fs = { class: "aimd-field-hint" }, hs = {
13
- key: 1,
14
- class: "aimd-field-row"
15
- }, ys = { class: "aimd-field-label" }, bs = { class: "aimd-collection-editor" }, ws = ["onUpdate:modelValue", "placeholder"], ks = ["onUpdate:modelValue", "placeholder"], _s = ["disabled", "onClick"], Ms = { class: "aimd-field-hint" }, Ts = {
16
- key: 2,
17
- class: "aimd-field-row"
18
- }, Cs = { class: "aimd-field-label" }, zs = ["placeholder"], Is = {
19
- key: 4,
20
- class: "aimd-field-row"
21
- }, xs = { class: "aimd-field-label" }, $s = ["placeholder"], Bs = {
22
- key: 5,
23
- class: "aimd-field-row"
24
- }, Vs = { class: "aimd-field-label" }, As = ["placeholder"], qs = { id: "aimd-ref-suggestions" }, Ss = ["value"], Es = {
25
- key: 0,
26
- class: "aimd-field-hint"
27
- }, Us = {
28
- key: 6,
29
- class: "aimd-field-row"
30
- }, Ls = { class: "aimd-field-label" }, Hs = ["placeholder"], Ds = { class: "aimd-field-hint" }, Ps = { class: "aimd-dialog-preview" }, Rs = { class: "aimd-preview-header" }, Ns = { class: "aimd-preview-panel" }, Fs = { class: "aimd-preview-code" }, Os = {
31
- key: 7,
32
- class: "aimd-dialog-error"
33
- }, Ks = { class: "aimd-dialog-footer" }, Qs = /* @__PURE__ */ ve({
34
- __name: "AimdFieldDialog",
35
- props: {
36
- visible: { type: Boolean },
37
- initialType: {},
38
- messages: {},
39
- refSuggestions: {},
40
- varTypePlugins: {},
41
- allowedTypes: {},
42
- existingQuizIds: {}
43
- },
44
- emits: ["update:visible", "insert"],
45
- setup(c, { emit: F }) {
46
- const o = c, M = F, w = $(() => {
47
- const a = Ve(o.messages);
48
- if (!o.allowedTypes || o.allowedTypes.length === 0)
49
- return a;
50
- const s = new Set(o.allowedTypes);
51
- return a.filter((e) => s.has(e.type));
52
- });
53
- function f(a) {
54
- return a && w.value.some((s) => s.type === a) ? a : w.value[0]?.type ?? a ?? "var";
55
- }
56
- const p = $(() => new Set(o.existingQuizIds || [])), d = B(f(o.initialType)), t = B(ie(d.value, o.messages, p.value)), C = B([]), V = B([]), h = B([]), T = B(null), U = B(null), k = B(""), G = $(
57
- () => Pe(o.messages, o.varTypePlugins ?? [])
58
- );
59
- function D(a) {
60
- return (a || "").trim().toLowerCase().replace(/[\s_-]/g, "");
61
- }
62
- function J(a) {
63
- return D(t.value.type) === D(a);
64
- }
65
- function X(a) {
66
- t.value.type = a;
67
- }
68
- function Y(a, s) {
69
- const e = `quiz_${a}`;
70
- let g = 1;
71
- for (; s.has(`${e}_${g}`); )
72
- g += 1;
73
- return `${e}_${g}`;
74
- }
75
- function Z(a) {
76
- const s = a.split(",").map((e) => e.trim()).filter(Boolean);
77
- return s.length === 0 ? [
78
- { key: "A", text: "" },
79
- { key: "B", text: "" }
80
- ] : s.map((e, g) => {
81
- const y = e.indexOf(":");
82
- if (y > 0) {
83
- const Q = e.slice(0, y).trim() || String.fromCharCode(65 + g), re = e.slice(y + 1).trim() || o.messages.defaults.optionText(Q);
84
- return { key: Q, text: re };
85
- }
86
- return { key: String.fromCharCode(65 + g), text: e };
87
- });
88
- }
89
- function ee(a) {
90
- const s = a.map((e) => ({ key: e.key.trim(), text: e.text.trim() })).filter((e) => e.key && e.text);
91
- return s.length === 0 ? "A:, B:" : s.map((e) => `${e.key}:${e.text}`).join(", ");
92
- }
93
- function le(a) {
94
- const s = a.split(",").map((e) => e.trim()).filter(Boolean);
95
- return s.length === 0 ? [{ key: "b1", answer: "" }] : s.map((e, g) => {
96
- const y = e.indexOf(":");
97
- if (y > 0) {
98
- const oe = e.slice(0, y).trim() || `b${g + 1}`, Q = e.slice(y + 1).trim() || "";
99
- return { key: oe, answer: Q };
100
- }
101
- return { key: `b${g + 1}`, answer: e };
102
- });
103
- }
104
- function A(a) {
105
- const s = a.map((e) => ({ key: e.key.trim(), answer: e.answer.trim() })).filter((e) => e.key);
106
- return s.length === 0 ? "b1:" : s.map((e) => `${e.key}:${e.answer}`).join(", ");
107
- }
108
- function S(a) {
109
- return a.split(",").map((s) => s.trim()).filter(Boolean);
110
- }
111
- function L() {
112
- d.value === "quiz" && (t.value.quizType === "choice" ? (C.value = Z(t.value.options || ""), h.value = S(t.value.answer || "")) : t.value.quizType === "blank" && (V.value = le(t.value.blanks || "")));
113
- }
114
- function O() {
115
- if (d.value !== "quiz" || t.value.quizType !== "choice") return;
116
- const a = new Set(
117
- C.value.map((s) => s.key.trim()).filter(Boolean)
118
- );
119
- if (t.value.mode === "multiple") {
120
- const s = h.value.map((e) => e.trim()).filter((e) => e && a.has(e));
121
- s.length !== h.value.length && (h.value = s);
122
- } else {
123
- const s = (t.value.answer || "").trim();
124
- s && !a.has(s) && (t.value.answer = "");
125
- }
126
- }
127
- function se() {
128
- const a = new Set(
129
- C.value.map((s) => s.key.trim().toUpperCase()).filter(Boolean)
130
- );
131
- for (let s = 0; s < 26; s++) {
132
- const e = String.fromCharCode(65 + s);
133
- if (!a.has(e)) return e;
134
- }
135
- return `K${C.value.length + 1}`;
136
- }
137
- function n() {
138
- const a = se();
139
- C.value.push({ key: a, text: "" });
140
- }
141
- function m(a) {
142
- C.value.length <= 1 || C.value.splice(a, 1);
143
- }
144
- function I(a) {
145
- T.value = a, U.value = a;
146
- }
147
- function P(a) {
148
- T.value !== null && (U.value = a);
149
- }
150
- function H(a) {
151
- const s = T.value;
152
- if (s === null || s === a) {
153
- T.value = null, U.value = null;
154
- return;
155
- }
156
- const e = C.value.splice(s, 1)[0];
157
- C.value.splice(a, 0, e), T.value = null, U.value = null;
158
- }
159
- function R() {
160
- T.value = null, U.value = null;
161
- }
162
- function ne() {
163
- const a = new Set(
164
- V.value.map((e) => e.key.trim().toLowerCase()).filter(Boolean)
165
- );
166
- let s = 1;
167
- for (; a.has(`b${s}`); )
168
- s += 1;
169
- return `b${s}`;
170
- }
171
- function te() {
172
- V.value.push({ key: ne(), answer: "" });
173
- }
174
- function pe(a) {
175
- V.value.length <= 1 || V.value.splice(a, 1);
176
- }
177
- function de(a) {
178
- const s = /* @__PURE__ */ new Set(), e = [];
179
- for (const g of a)
180
- s.has(g) && !e.includes(g) && e.push(g), s.add(g);
181
- return e;
182
- }
183
- function ge(a) {
184
- const s = [], e = /\[\[([^\[\]\s]+)\]\]/g;
185
- for (const g of a.matchAll(e))
186
- s.push(g[1]);
187
- return s;
188
- }
189
- function fe() {
190
- const a = V.value.map((ae) => ae.key.trim()).filter(Boolean);
191
- if (a.length === 0)
192
- return o.messages.errors.blankQuizRequiresBlankKey;
193
- const s = de(a);
194
- if (s.length > 0)
195
- return o.messages.errors.blankKeysMustBeUnique(s);
196
- const e = t.value.stem || "", g = ge(e);
197
- if (g.length === 0)
198
- return o.messages.errors.blankStemRequiresPlaceholders;
199
- const y = de(g);
200
- if (y.length > 0)
201
- return o.messages.errors.duplicatePlaceholders(y);
202
- const oe = new Set(a), Q = new Set(g), re = [...Q].filter((ae) => !oe.has(ae));
203
- if (re.length > 0)
204
- return o.messages.errors.undefinedPlaceholders(re);
205
- const Ce = [...oe].filter((ae) => !Q.has(ae));
206
- return Ce.length > 0 ? o.messages.errors.missingPlaceholders(Ce) : null;
207
- }
208
- function r() {
209
- return d.value !== "quiz" || t.value.quizType !== "blank" ? null : fe();
210
- }
211
- E(() => o.initialType, (a) => {
212
- const s = f(a);
213
- d.value = s, t.value = ie(s, o.messages, p.value), L(), k.value = "";
214
- }), E(w, () => {
215
- const a = f(d.value);
216
- a !== d.value && (d.value = a, t.value = ie(a, o.messages, p.value), L(), k.value = "");
217
- }), E(() => o.visible, (a) => {
218
- a && (t.value = ie(d.value, o.messages, p.value), L(), k.value = "");
219
- });
220
- function _(a) {
221
- const s = f(a);
222
- d.value = s, t.value = ie(s, o.messages, p.value), L(), k.value = "";
223
- }
224
- const he = $(() => $e(d.value, t.value, o.messages));
225
- function Ae(a) {
226
- return w.value.find((s) => s.type === a) || { type: a, label: a, icon: "?", svgIcon: "", desc: "", color: "#666" };
227
- }
228
- const ye = $(() => Ae(d.value)), be = $(() => o.refSuggestions ? o.refSuggestions : []), qe = $(() => d.value === "ref_step" ? o.messages.dialog.referencedStepId : d.value === "ref_var" ? o.messages.dialog.referencedVariableId : o.messages.dialog.referencedFigureId), Se = $(() => d.value === "ref_step" ? "step_id" : d.value === "ref_var" ? "var_id" : "fig_id");
229
- E(() => [d.value, t.value.quizType], ([a, s], [e, g]) => {
230
- a === "quiz" && (a !== e || s !== g) && (s !== g && g && (t.value.id = Y(s, p.value), s === "choice" ? (t.value.stem = o.messages.defaults.questionStem, t.value.mode = "single", t.value.options = "A:, B:", t.value.answer = "A", t.value.blanks = "", t.value.rubric = "") : s === "blank" ? (t.value.stem = o.messages.defaults.fillQuestionStem, t.value.blanks = "b1:", t.value.options = "", t.value.answer = "", t.value.mode = "", t.value.rubric = "", V.value = [{ key: "b1", answer: "" }]) : s === "open" && (t.value.stem = o.messages.defaults.fillQuestionStem, t.value.rubric = "", t.value.options = "", t.value.answer = "", t.value.blanks = "", t.value.mode = "")), L());
231
- }), E(() => t.value.mode, () => {
232
- O();
233
- }), E(C, (a) => {
234
- d.value === "quiz" && t.value.quizType === "choice" && (t.value.options = ee(a), O());
235
- }, { deep: !0 }), E(V, (a) => {
236
- d.value === "quiz" && t.value.quizType === "blank" && (t.value.blanks = A(a));
237
- }, { deep: !0 }), E(h, (a) => {
238
- d.value === "quiz" && t.value.quizType === "choice" && t.value.mode === "multiple" && (t.value.answer = a.join(", "));
239
- }, { deep: !0 }), E(t, () => {
240
- k.value && (k.value = "");
241
- }, { deep: !0 }), E(V, () => {
242
- k.value && (k.value = "");
243
- }, { deep: !0 });
244
- function Ee() {
245
- const a = r();
246
- if (a) {
247
- k.value = a;
248
- return;
249
- }
250
- k.value = "", M("insert", $e(d.value, t.value, o.messages)), M("update:visible", !1);
251
- }
252
- function we() {
253
- M("update:visible", !1);
254
- }
255
- return (a, s) => (u(), Be(Ue, { to: "body" }, [
256
- c.visible ? (u(), v("div", {
257
- key: 0,
258
- class: "aimd-dialog-overlay",
259
- onClick: ue(we, ["self"])
260
- }, [
261
- l("div", Xe, [
262
- l("div", Ye, [
263
- l("span", Ze, [
264
- l("span", {
265
- class: "aimd-dialog-icon",
266
- style: me({ color: ye.value.color }),
267
- innerHTML: ye.value.svgIcon
268
- }, null, 12, el),
269
- N(" " + i(o.messages.dialog.title(ye.value.label)), 1)
270
- ]),
271
- l("button", {
272
- class: "aimd-dialog-close",
273
- onClick: we
274
- }, "×")
275
- ]),
276
- l("div", ll, [
277
- (u(!0), v(q, null, j(w.value, (e) => (u(), v("button", {
278
- key: e.type,
279
- class: W(["aimd-type-tab", { active: d.value === e.type }]),
280
- style: me(d.value === e.type ? { borderColor: e.color, color: e.color, background: `${e.color}14` } : {}),
281
- onClick: (g) => _(e.type)
282
- }, [
283
- l("span", {
284
- innerHTML: e.svgIcon,
285
- class: "aimd-type-tab-icon"
286
- }, null, 8, tl),
287
- N(" " + i(e.label), 1)
288
- ], 14, sl))), 128))
289
- ]),
290
- l("div", ol, [
291
- d.value === "var" ? (u(), v(q, { key: 0 }, [
292
- l("label", al, [
293
- l("span", il, [
294
- N(i(o.messages.dialog.variableId) + " ", 1),
295
- s[19] || (s[19] = l("em", null, "*", -1))
296
- ]),
297
- b(l("input", {
298
- "onUpdate:modelValue": s[0] || (s[0] = (e) => t.value.name = e),
299
- placeholder: o.messages.placeholders.variableId,
300
- class: "aimd-field-input"
301
- }, null, 8, nl), [
302
- [x, t.value.name]
303
- ])
304
- ]),
305
- l("div", dl, [
306
- l("span", rl, i(o.messages.dialog.typePresetLabel), 1),
307
- l("span", ul, i(o.messages.dialog.typeHint), 1),
308
- l("div", cl, [
309
- (u(!0), v(q, null, j(G.value, (e) => (u(), v("button", {
310
- key: e.key,
311
- type: "button",
312
- class: W(["aimd-var-type-card", { active: J(e.value) }]),
313
- onClick: (g) => X(e.value)
314
- }, [
315
- l("span", vl, i(e.label), 1),
316
- l("span", pl, i(e.desc), 1)
317
- ], 10, ml))), 128))
318
- ])
319
- ]),
320
- l("label", gl, [
321
- l("span", fl, i(o.messages.dialog.customType), 1),
322
- b(l("input", {
323
- "onUpdate:modelValue": s[1] || (s[1] = (e) => t.value.type = e),
324
- placeholder: o.messages.placeholders.type,
325
- class: "aimd-field-input"
326
- }, null, 8, hl), [
327
- [x, t.value.type]
328
- ]),
329
- l("span", yl, i(o.messages.dialog.customTypeHint), 1)
330
- ]),
331
- l("label", bl, [
332
- l("span", wl, i(o.messages.dialog.defaultValue), 1),
333
- b(l("input", {
334
- "onUpdate:modelValue": s[2] || (s[2] = (e) => t.value.default = e),
335
- placeholder: o.messages.placeholders.defaultValue,
336
- class: "aimd-field-input"
337
- }, null, 8, kl), [
338
- [x, t.value.default]
339
- ])
340
- ]),
341
- l("label", _l, [
342
- l("span", Ml, i(o.messages.dialog.titleLabel), 1),
343
- b(l("input", {
344
- "onUpdate:modelValue": s[3] || (s[3] = (e) => t.value.title = e),
345
- placeholder: o.messages.placeholders.title,
346
- class: "aimd-field-input"
347
- }, null, 8, Tl), [
348
- [x, t.value.title]
349
- ])
350
- ])
351
- ], 64)) : z("", !0),
352
- d.value === "var_table" ? (u(), v(q, { key: 1 }, [
353
- l("label", Cl, [
354
- l("span", zl, [
355
- N(i(o.messages.dialog.tableId) + " ", 1),
356
- s[20] || (s[20] = l("em", null, "*", -1))
357
- ]),
358
- b(l("input", {
359
- "onUpdate:modelValue": s[4] || (s[4] = (e) => t.value.name = e),
360
- placeholder: o.messages.placeholders.tableId,
361
- class: "aimd-field-input"
362
- }, null, 8, Il), [
363
- [x, t.value.name]
364
- ])
365
- ]),
366
- l("label", xl, [
367
- l("span", $l, i(o.messages.dialog.subVariableColumns), 1),
368
- b(l("input", {
369
- "onUpdate:modelValue": s[5] || (s[5] = (e) => t.value.subvars = e),
370
- placeholder: o.messages.placeholders.subVariableColumns,
371
- class: "aimd-field-input"
372
- }, null, 8, Bl), [
373
- [x, t.value.subvars]
374
- ]),
375
- l("span", Vl, i(o.messages.dialog.subVariableColumnsHint), 1)
376
- ])
377
- ], 64)) : z("", !0),
378
- d.value === "step" ? (u(), v(q, { key: 2 }, [
379
- l("label", Al, [
380
- l("span", ql, [
381
- N(i(o.messages.dialog.stepId) + " ", 1),
382
- s[21] || (s[21] = l("em", null, "*", -1))
383
- ]),
384
- b(l("input", {
385
- "onUpdate:modelValue": s[6] || (s[6] = (e) => t.value.name = e),
386
- placeholder: o.messages.placeholders.stepId,
387
- class: "aimd-field-input"
388
- }, null, 8, Sl), [
389
- [x, t.value.name]
390
- ])
391
- ]),
392
- l("label", El, [
393
- l("span", Ul, i(o.messages.dialog.level), 1),
394
- b(l("select", {
395
- "onUpdate:modelValue": s[7] || (s[7] = (e) => t.value.level = e),
396
- class: "aimd-field-input"
397
- }, [
398
- l("option", Ll, i(o.messages.dialog.level1), 1),
399
- l("option", Hl, i(o.messages.dialog.level2), 1),
400
- l("option", Dl, i(o.messages.dialog.level3), 1)
401
- ], 512), [
402
- [ke, t.value.level]
403
- ])
404
- ])
405
- ], 64)) : z("", !0),
406
- d.value === "quiz" ? (u(), v(q, { key: 3 }, [
407
- l("label", Pl, [
408
- l("span", Rl, [
409
- N(i(o.messages.dialog.quizId) + " ", 1),
410
- s[22] || (s[22] = l("em", null, "*", -1))
411
- ]),
412
- b(l("input", {
413
- "onUpdate:modelValue": s[8] || (s[8] = (e) => t.value.id = e),
414
- placeholder: o.messages.placeholders.quizId,
415
- class: "aimd-field-input"
416
- }, null, 8, Nl), [
417
- [x, t.value.id]
418
- ])
419
- ]),
420
- l("label", Fl, [
421
- l("span", Ol, i(o.messages.dialog.questionType), 1),
422
- b(l("select", {
423
- "onUpdate:modelValue": s[9] || (s[9] = (e) => t.value.quizType = e),
424
- class: "aimd-field-input"
425
- }, [
426
- l("option", Kl, i(o.messages.quiz.types.choice), 1),
427
- l("option", Ql, i(o.messages.quiz.types.blank), 1),
428
- l("option", jl, i(o.messages.quiz.types.open), 1)
429
- ], 512), [
430
- [ke, t.value.quizType]
431
- ])
432
- ]),
433
- l("label", Wl, [
434
- l("span", Gl, i(o.messages.dialog.score), 1),
435
- b(l("input", {
436
- "onUpdate:modelValue": s[10] || (s[10] = (e) => t.value.score = e),
437
- placeholder: o.messages.placeholders.score,
438
- class: "aimd-field-input"
439
- }, null, 8, Jl), [
440
- [x, t.value.score]
441
- ])
442
- ]),
443
- l("label", Xl, [
444
- l("span", Yl, [
445
- N(i(o.messages.dialog.stem) + " ", 1),
446
- s[23] || (s[23] = l("em", null, "*", -1))
447
- ]),
448
- b(l("textarea", {
449
- "onUpdate:modelValue": s[11] || (s[11] = (e) => t.value.stem = e),
450
- placeholder: o.messages.placeholders.stem,
451
- class: "aimd-field-input aimd-field-textarea"
452
- }, null, 8, Zl), [
453
- [x, t.value.stem]
454
- ]),
455
- t.value.quizType === "blank" ? (u(), v("span", es, i(o.messages.dialog.blankStemHint), 1)) : z("", !0)
456
- ]),
457
- t.value.quizType === "choice" ? (u(), v(q, { key: 0 }, [
458
- l("label", ls, [
459
- l("span", ss, i(o.messages.dialog.mode), 1),
460
- b(l("select", {
461
- "onUpdate:modelValue": s[12] || (s[12] = (e) => t.value.mode = e),
462
- class: "aimd-field-input"
463
- }, [
464
- l("option", ts, i(o.messages.quiz.modes.single), 1),
465
- l("option", os, i(o.messages.quiz.modes.multiple), 1)
466
- ], 512), [
467
- [ke, t.value.mode]
468
- ])
469
- ]),
470
- l("div", as, [
471
- l("span", is, i(o.messages.dialog.options), 1),
472
- l("div", ns, [
473
- (u(!0), v(q, null, j(C.value, (e, g) => (u(), v("div", {
474
- key: `choice-option-${g}`,
475
- class: W(["aimd-collection-row aimd-option-row", { "aimd-option-row-dragover": U.value === g && T.value !== null && T.value !== g }]),
476
- onDragover: ue((y) => P(g), ["prevent"]),
477
- onDrop: ue((y) => H(g), ["prevent"])
478
- }, [
479
- l("span", {
480
- class: "aimd-drag-handle",
481
- title: o.messages.dialog.dragToReorder,
482
- draggable: "true",
483
- onDragstart: (y) => I(g),
484
- onDragend: R
485
- }, " ⋮⋮ ", 40, rs),
486
- b(l("input", {
487
- "onUpdate:modelValue": (y) => e.key = y,
488
- placeholder: o.messages.placeholders.optionKey,
489
- class: "aimd-field-input"
490
- }, null, 8, us), [
491
- [x, e.key]
492
- ]),
493
- b(l("input", {
494
- "onUpdate:modelValue": (y) => e.text = y,
495
- placeholder: o.messages.placeholders.optionText,
496
- class: "aimd-field-input"
497
- }, null, 8, cs), [
498
- [x, e.text]
499
- ]),
500
- l("label", ms, [
501
- t.value.mode === "single" ? b((u(), v("input", {
502
- key: 0,
503
- "onUpdate:modelValue": s[13] || (s[13] = (y) => t.value.answer = y),
504
- type: "radio",
505
- name: "aimd-quiz-choice-answer",
506
- value: e.key.trim(),
507
- disabled: !e.key.trim()
508
- }, null, 8, vs)), [
509
- [Le, t.value.answer]
510
- ]) : b((u(), v("input", {
511
- key: 1,
512
- "onUpdate:modelValue": s[14] || (s[14] = (y) => h.value = y),
513
- type: "checkbox",
514
- value: e.key.trim(),
515
- disabled: !e.key.trim()
516
- }, null, 8, ps)), [
517
- [He, h.value]
518
- ]),
519
- l("span", null, i(o.messages.dialog.correctAnswer), 1)
520
- ]),
521
- l("button", {
522
- type: "button",
523
- class: "aimd-mini-btn",
524
- disabled: C.value.length <= 1,
525
- onClick: (y) => m(g)
526
- }, i(o.messages.common.remove), 9, gs)
527
- ], 42, ds))), 128)),
528
- l("button", {
529
- type: "button",
530
- class: "aimd-mini-btn aimd-mini-btn-add",
531
- onClick: n
532
- }, i(o.messages.actions.addOption), 1)
533
- ]),
534
- l("span", fs, i(o.messages.dialog.optionsHint), 1)
535
- ])
536
- ], 64)) : t.value.quizType === "blank" ? (u(), v("div", hs, [
537
- l("span", ys, i(o.messages.dialog.blanks), 1),
538
- l("div", bs, [
539
- (u(!0), v(q, null, j(V.value, (e, g) => (u(), v("div", {
540
- key: `blank-item-${g}`,
541
- class: "aimd-collection-row"
542
- }, [
543
- b(l("input", {
544
- "onUpdate:modelValue": (y) => e.key = y,
545
- placeholder: o.messages.placeholders.blankKey,
546
- class: "aimd-field-input"
547
- }, null, 8, ws), [
548
- [x, e.key]
549
- ]),
550
- b(l("input", {
551
- "onUpdate:modelValue": (y) => e.answer = y,
552
- placeholder: o.messages.placeholders.blankAnswer,
553
- class: "aimd-field-input"
554
- }, null, 8, ks), [
555
- [x, e.answer]
556
- ]),
557
- l("button", {
558
- type: "button",
559
- class: "aimd-mini-btn",
560
- disabled: V.value.length <= 1,
561
- onClick: (y) => pe(g)
562
- }, i(o.messages.common.remove), 9, _s)
563
- ]))), 128)),
564
- l("button", {
565
- type: "button",
566
- class: "aimd-mini-btn aimd-mini-btn-add",
567
- onClick: te
568
- }, i(o.messages.actions.addBlank), 1)
569
- ]),
570
- l("span", Ms, i(o.messages.dialog.blanksHint), 1)
571
- ])) : (u(), v("label", Ts, [
572
- l("span", Cs, i(o.messages.dialog.rubric), 1),
573
- b(l("textarea", {
574
- "onUpdate:modelValue": s[15] || (s[15] = (e) => t.value.rubric = e),
575
- placeholder: o.messages.placeholders.rubric,
576
- class: "aimd-field-input aimd-field-textarea"
577
- }, null, 8, zs), [
578
- [x, t.value.rubric]
579
- ])
580
- ]))
581
- ], 64)) : z("", !0),
582
- d.value === "check" ? (u(), v("label", Is, [
583
- l("span", xs, [
584
- N(i(o.messages.dialog.checkpointId) + " ", 1),
585
- s[24] || (s[24] = l("em", null, "*", -1))
586
- ]),
587
- b(l("input", {
588
- "onUpdate:modelValue": s[16] || (s[16] = (e) => t.value.name = e),
589
- placeholder: o.messages.placeholders.checkpointId,
590
- class: "aimd-field-input"
591
- }, null, 8, $s), [
592
- [x, t.value.name]
593
- ])
594
- ])) : z("", !0),
595
- ["ref_step", "ref_var", "ref_fig"].includes(d.value) ? (u(), v("label", Bs, [
596
- l("span", Vs, [
597
- N(i(qe.value) + " ", 1),
598
- s[25] || (s[25] = l("em", null, "*", -1))
599
- ]),
600
- b(l("input", {
601
- "onUpdate:modelValue": s[17] || (s[17] = (e) => t.value.name = e),
602
- placeholder: Se.value,
603
- class: "aimd-field-input",
604
- list: "aimd-ref-suggestions"
605
- }, null, 8, As), [
606
- [x, t.value.name]
607
- ]),
608
- l("datalist", qs, [
609
- (u(!0), v(q, null, j(be.value, (e) => (u(), v("option", {
610
- key: e,
611
- value: e
612
- }, null, 8, Ss))), 128))
613
- ]),
614
- be.value.length ? (u(), v("span", Es, i(o.messages.common.available) + ": " + i(be.value.join(", ")), 1)) : z("", !0)
615
- ])) : z("", !0),
616
- d.value === "cite" ? (u(), v("label", Us, [
617
- l("span", Ls, [
618
- N(i(o.messages.dialog.citationId) + " ", 1),
619
- s[26] || (s[26] = l("em", null, "*", -1))
620
- ]),
621
- b(l("input", {
622
- "onUpdate:modelValue": s[18] || (s[18] = (e) => t.value.refs = e),
623
- placeholder: o.messages.placeholders.citationIds,
624
- class: "aimd-field-input"
625
- }, null, 8, Hs), [
626
- [x, t.value.refs]
627
- ]),
628
- l("span", Ds, i(o.messages.dialog.citationHint), 1)
629
- ])) : z("", !0),
630
- l("div", Ps, [
631
- l("div", Rs, i(o.messages.common.preview), 1),
632
- l("pre", Ns, [
633
- l("code", Fs, i(he.value), 1)
634
- ])
635
- ]),
636
- k.value ? (u(), v("div", Os, i(k.value), 1)) : z("", !0)
637
- ]),
638
- l("div", Ks, [
639
- l("button", {
640
- class: "aimd-btn aimd-btn-cancel",
641
- onClick: we
642
- }, i(o.messages.common.cancel), 1),
643
- l("button", {
644
- class: "aimd-btn aimd-btn-primary",
645
- onClick: Ee
646
- }, i(o.messages.common.insert), 1)
647
- ])
648
- ])
649
- ])) : z("", !0)
650
- ]));
651
- }
652
- }), js = { class: "aimd-editor-toolbar" }, Ws = {
653
- key: 0,
654
- class: "aimd-editor-mode-switch"
655
- }, Gs = ["title"], Js = ["title"], Xs = {
656
- key: 1,
657
- class: "aimd-editor-toolbar-sep"
658
- }, Ys = {
659
- key: 0,
660
- class: "aimd-editor-toolbar-sep"
661
- }, Zs = ["title", "onClick", "innerHTML"], et = {
662
- key: 3,
663
- class: "aimd-editor-toolbar-divider"
664
- }, lt = ["title", "onClick", "onMouseup"], st = ["innerHTML"], tt = { class: "aimd-editor-aimd-btn-label" }, ot = /* @__PURE__ */ ve({
665
- __name: "AimdEditorToolbar",
666
- props: {
667
- showTopBar: { type: Boolean },
668
- showMdToolbar: { type: Boolean },
669
- showAimdToolbar: { type: Boolean },
670
- editorMode: {},
671
- resolvedMessages: {},
672
- localizedFieldTypes: {},
673
- localizedMdToolbarItems: {}
674
- },
675
- emits: ["switch-mode", "md-action", "open-aimd-dialog", "quick-insert-aimd"],
676
- setup(c, { emit: F }) {
677
- const o = F;
678
- return (M, w) => (u(), v("div", js, [
679
- c.showTopBar ? (u(), v("div", Ws, [
680
- l("button", {
681
- type: "button",
682
- class: W(["aimd-editor-mode-btn", { active: c.editorMode === "source" }]),
683
- onClick: w[0] || (w[0] = (f) => o("switch-mode", "source")),
684
- title: c.resolvedMessages.mode.sourceTitle
685
- }, [
686
- w[2] || (w[2] = l("span", {
687
- class: "aimd-editor-mode-icon",
688
- 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>'
689
- }, null, -1)),
690
- l("span", null, i(c.resolvedMessages.mode.source), 1)
691
- ], 10, Gs),
692
- l("button", {
693
- type: "button",
694
- class: W(["aimd-editor-mode-btn", { active: c.editorMode === "wysiwyg" }]),
695
- onClick: w[1] || (w[1] = (f) => o("switch-mode", "wysiwyg")),
696
- title: c.resolvedMessages.mode.wysiwygTitle
697
- }, [
698
- w[3] || (w[3] = l("span", {
699
- class: "aimd-editor-mode-icon",
700
- 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>'
701
- }, null, -1)),
702
- l("span", null, i(c.resolvedMessages.mode.wysiwyg), 1)
703
- ], 10, Js)
704
- ])) : z("", !0),
705
- c.showTopBar && c.showMdToolbar ? (u(), v("div", Xs)) : z("", !0),
706
- c.showMdToolbar ? (u(!0), v(q, { key: 2 }, j(c.localizedMdToolbarItems, (f) => (u(), v(q, {
707
- key: f.action
708
- }, [
709
- f.action.startsWith("sep") ? (u(), v("div", Ys)) : (u(), v("button", {
710
- key: 1,
711
- type: "button",
712
- class: "aimd-editor-fmt-btn",
713
- title: f.title,
714
- onClick: (p) => o("md-action", f.action, p),
715
- innerHTML: f.svgIcon
716
- }, null, 8, Zs))
717
- ], 64))), 128)) : z("", !0),
718
- c.showMdToolbar && c.showAimdToolbar ? (u(), v("div", et)) : z("", !0),
719
- c.showAimdToolbar ? (u(!0), v(q, { key: 4 }, j(c.localizedFieldTypes, (f) => (u(), v("button", {
720
- key: f.type,
721
- type: "button",
722
- class: "aimd-editor-fmt-btn aimd-editor-aimd-btn",
723
- title: f.desc,
724
- style: me({ "--aimd-color": f.color }),
725
- onClick: (p) => o("open-aimd-dialog", f.type),
726
- onMouseup: ue((p) => o("quick-insert-aimd", f.type), ["middle", "prevent"])
727
- }, [
728
- l("span", {
729
- class: "aimd-editor-aimd-btn-icon",
730
- innerHTML: f.svgIcon
731
- }, null, 8, st),
732
- l("span", tt, i(f.label), 1)
733
- ], 44, lt))), 128)) : z("", !0)
734
- ]));
735
- }
736
- });
737
- function at(c) {
738
- const { initialContent: F, initialMode: o, resolvedMessages: M, emitModelValue: w, emitMode: f } = c, p = B(o), d = B(F), t = _e(null), C = _e(null), V = B(!0), h = _e(null);
739
- let T = !1;
740
- function U(n) {
741
- n !== d.value && (d.value = n, w(n));
742
- }
743
- function k(n) {
744
- return je(n).content;
745
- }
746
- function G(n) {
747
- return /class="ProseMirror milkdown-editor-content editor"/.test(n) || /<div class="milkdown">/.test(n) || /<\/?[a-z][^>]*>/i.test(n) && /AIMDINLINETEMPLATE[0-9a-f]+TOKEN/.test(n);
748
- }
749
- function D(n, m) {
750
- const I = Re(We(n));
751
- return G(I) ? m : I;
752
- }
753
- function J(n) {
754
- return /\{\{(?:var_table|var|quiz|step|check|ref_step|ref_var|ref_fig|cite|fig)\|/.test(n) || /```(?:quiz|fig|assigner|connectors)\b/.test(n);
755
- }
756
- function X() {
757
- if (h.value)
758
- try {
759
- const n = h.value.action(xe());
760
- if (typeof n != "string")
761
- return;
762
- const m = D(n, d.value);
763
- h.value.action(ce(k(m)));
764
- } catch {
765
- }
766
- }
767
- const Y = $(() => {
768
- try {
769
- return Ge(d.value);
770
- } catch {
771
- return null;
772
- }
773
- });
774
- async function Z(n) {
775
- if (n !== p.value) {
776
- if (p.value === "source" && t.value && (d.value = t.value.getValue()), p.value === "wysiwyg" && h.value)
777
- try {
778
- const m = h.value.action(xe());
779
- typeof m == "string" && (d.value = D(m, d.value));
780
- } catch {
781
- }
782
- if (p.value = n, f(n), n === "source")
783
- await ze(), t.value && (T = !0, t.value.setValue(d.value), T = !1);
784
- else if (n === "wysiwyg" && (await ze(), h.value))
785
- try {
786
- T = !0, h.value.action(ce(k(d.value))), T = !1;
787
- } catch {
788
- T = !1;
789
- }
790
- }
791
- }
792
- function ee(n) {
793
- if (n !== d.value) {
794
- if (T = !0, d.value = n, p.value === "source" && t.value)
795
- t.value.setValue(n);
796
- else if (p.value === "wysiwyg" && h.value)
797
- try {
798
- h.value.action(ce(k(n)));
799
- } catch {
800
- }
801
- T = !1;
802
- }
803
- }
804
- function le(n) {
805
- if (p.value === "source" && t.value) {
806
- const m = t.value.getSelection(), I = t.value.getModel(), P = t.value.getPosition(), te = I.getLineContent(P.lineNumber).substring(0, P.column - 1).trim() !== "" && !n.startsWith(`
807
- `) ? `
808
- ` + n : n;
809
- t.value.executeEdits("toolbar", [{
810
- range: m,
811
- text: te,
812
- forceMoveMarkers: !0
813
- }]), t.value.focus();
814
- } else if (p.value === "wysiwyg" && h.value)
815
- try {
816
- h.value.action(Te(n)), J(n) && X();
817
- } catch {
818
- }
819
- }
820
- function A(n, m = "", I = "") {
821
- if (p.value === "source" && t.value) {
822
- const P = t.value.getSelection(), H = t.value.getModel().getValueInRange(P) || I, R = n + H + m;
823
- t.value.executeEdits("toolbar", [{
824
- range: P,
825
- text: R,
826
- forceMoveMarkers: !0
827
- }]), t.value.focus();
828
- } else if (p.value === "wysiwyg" && h.value)
829
- try {
830
- h.value.action(Te(n + I + m));
831
- } catch {
832
- }
833
- }
834
- function S(n, m = "") {
835
- if (p.value === "source" && t.value) {
836
- const I = t.value.getPosition(), H = t.value.getModel().getLineContent(I.lineNumber);
837
- if (H.trim() === "") {
838
- const R = { startLineNumber: I.lineNumber, startColumn: 1, endLineNumber: I.lineNumber, endColumn: H.length + 1 };
839
- t.value.executeEdits("toolbar", [{ range: R, text: n + m, forceMoveMarkers: !0 }]);
840
- } else {
841
- const R = { startLineNumber: I.lineNumber, startColumn: H.length + 1, endLineNumber: I.lineNumber, endColumn: H.length + 1 };
842
- t.value.executeEdits("toolbar", [{ range: R, text: `
843
- ` + n + m, forceMoveMarkers: !0 }]);
844
- }
845
- t.value.focus();
846
- } else if (p.value === "wysiwyg" && h.value)
847
- try {
848
- h.value.action(Te(`
849
- ` + n + m));
850
- } catch {
851
- }
852
- }
853
- function L(n) {
854
- const m = M.value.snippets;
855
- switch (n) {
856
- case "h1":
857
- S("# ", m.heading);
858
- break;
859
- case "h2":
860
- S("## ", m.heading);
861
- break;
862
- case "h3":
863
- S("### ", m.heading);
864
- break;
865
- case "bold":
866
- A("**", "**", m.boldText);
867
- break;
868
- case "italic":
869
- A("*", "*", m.italicText);
870
- break;
871
- case "strikethrough":
872
- A("~~", "~~", m.strikethrough);
873
- break;
874
- case "ul":
875
- S("- ", m.listItem);
876
- break;
877
- case "ol":
878
- S("1. ", m.listItem);
879
- break;
880
- case "blockquote":
881
- S("> ", m.quote);
882
- break;
883
- case "code":
884
- A("`", "`", m.code);
885
- break;
886
- case "codeblock":
887
- A("```\n", "\n```", m.codeBlock);
888
- break;
889
- case "link":
890
- A("[", "](url)", m.linkText);
891
- break;
892
- case "image":
893
- A("![", "](url)", m.altText);
894
- break;
895
- case "hr":
896
- S("---");
897
- break;
898
- case "math":
899
- A("$", "$", m.mathFormula);
900
- break;
901
- case "table":
902
- if (p.value === "wysiwyg" && h.value)
903
- try {
904
- h.value.action(De(Je.key, { row: 3, col: 3 }));
905
- } catch {
906
- }
907
- else
908
- S(
909
- `| ${m.tableColumnA} | ${m.tableColumnB} | ${m.tableColumnC} |
910
- |-------|-------|-------|
911
- | `,
912
- " | | |"
913
- );
914
- break;
915
- }
916
- }
917
- function O(n, m, I) {
918
- T || U(D(m, d.value));
919
- }
920
- function se(n) {
921
- h.value = n;
922
- }
923
- return {
924
- editorMode: p,
925
- content: d,
926
- commitUserContent: U,
927
- monacoEditor: t,
928
- monacoInstance: C,
929
- monacoLoading: V,
930
- milkdownEditorRef: h,
931
- extractedFields: Y,
932
- toMilkdownMarkdown: k,
933
- switchMode: Z,
934
- syncFromProp: ee,
935
- insertTextIntoActiveEditor: le,
936
- handleMdAction: L,
937
- onMilkdownMarkdownUpdated: O,
938
- onMilkdownReady: se
939
- };
940
- }
941
- const it = { class: "aimd-editor" }, nt = {
942
- key: 0,
943
- class: "aimd-editor-mode-host"
944
- }, dt = {
945
- key: 1,
946
- class: "aimd-editor-mode-host"
947
- }, _t = /* @__PURE__ */ ve({
948
- __name: "AimdEditor",
949
- props: {
950
- modelValue: { default: "" },
951
- locale: {},
952
- messages: { default: () => ({}) },
953
- mode: { default: "source" },
954
- theme: { default: "aimd-light" },
955
- showTopBar: { type: Boolean, default: !0 },
956
- showToolbar: { type: Boolean, default: !0 },
957
- showAimdToolbar: { type: Boolean, default: !0 },
958
- showMdToolbar: { type: Boolean, default: !0 },
959
- imageToolbarAction: { default: "markdown" },
960
- enableBlockHandle: { type: Boolean, default: !0 },
961
- enableSlashMenu: { type: Boolean, default: !0 },
962
- keepInactiveEditorsMounted: { type: Boolean, default: !0 },
963
- minHeight: { default: 500 },
964
- readonly: { type: Boolean, default: !1 },
965
- monacoOptions: { default: () => ({}) },
966
- varTypePlugins: {}
967
- },
968
- emits: ["update:modelValue", "update:mode", "ready", "request-image"],
969
- setup(c, { expose: F, emit: o }) {
970
- const M = c, w = o, f = $(() => Ne(M.locale, M.messages)), {
971
- editorMode: p,
972
- content: d,
973
- commitUserContent: t,
974
- monacoEditor: C,
975
- monacoInstance: V,
976
- milkdownEditorRef: h,
977
- extractedFields: T,
978
- toMilkdownMarkdown: U,
979
- switchMode: k,
980
- syncFromProp: G,
981
- insertTextIntoActiveEditor: D,
982
- handleMdAction: J,
983
- onMilkdownMarkdownUpdated: X,
984
- onMilkdownReady: Y
985
- } = at({
986
- initialContent: M.modelValue,
987
- initialMode: M.mode,
988
- resolvedMessages: f,
989
- emitModelValue: (r) => w("update:modelValue", r),
990
- emitMode: (r) => w("update:mode", r)
991
- });
992
- E(() => M.modelValue, (r) => G(r)), E(() => M.mode, (r) => {
993
- r !== p.value && k(r);
994
- });
995
- const Z = B(M.theme), ee = $(() => M.keepInactiveEditorsMounted || p.value === "source"), le = $(() => M.keepInactiveEditorsMounted || p.value === "wysiwyg"), A = $(() => Ve(f.value)), S = $(() => Fe(f.value)), L = B(!1), O = B("var"), se = $(() => {
996
- const r = T.value;
997
- if (!r) return [];
998
- const _ = O.value;
999
- return _ === "ref_step" ? r.step || [] : _ === "ref_var" ? r.var || [] : _ === "ref_fig" ? r.ref_fig || [] : [];
1000
- }), n = $(() => {
1001
- const r = T.value;
1002
- return r?.quiz ? r.quiz.map((_) => _.id) : [];
1003
- });
1004
- function m(r) {
1005
- O.value = r, L.value = !0;
1006
- }
1007
- function I(r) {
1008
- D(Ke(r, f.value));
1009
- }
1010
- function P(r) {
1011
- D(r);
1012
- }
1013
- function H(r) {
1014
- if (!(r instanceof HTMLElement)) return;
1015
- const _ = r.getBoundingClientRect();
1016
- return {
1017
- top: _.top,
1018
- right: _.right,
1019
- bottom: _.bottom,
1020
- left: _.left,
1021
- width: _.width,
1022
- height: _.height
1023
- };
1024
- }
1025
- function R(r, _) {
1026
- if (r === "image" && M.imageToolbarAction === "custom") {
1027
- w("request-image", { buttonRect: H(_.currentTarget) });
1028
- return;
1029
- }
1030
- J(r);
1031
- }
1032
- const ne = B(null), te = B(null);
1033
- function pe(r) {
1034
- t(r);
1035
- }
1036
- function de(r) {
1037
- w("ready", { monaco: r });
1038
- }
1039
- function ge(r, _) {
1040
- V.value = r, C.value = _;
1041
- }
1042
- function fe(r) {
1043
- Y(r), w("ready", { milkdown: r });
1044
- }
1045
- return F({
1046
- getContent: () => d.value,
1047
- setContent: (r) => {
1048
- if (d.value = r, p.value === "source" && C.value)
1049
- C.value.setValue(r);
1050
- else if (h.value)
1051
- try {
1052
- h.value.action(ce(U(r)));
1053
- } catch {
1054
- }
1055
- },
1056
- getMode: () => p.value,
1057
- setMode: (r) => k(r),
1058
- getMonacoEditor: () => C.value,
1059
- getMilkdownEditor: () => h.value,
1060
- insertText: D
1061
- }), (r, _) => (u(), v("div", it, [
1062
- c.showToolbar ? (u(), Be(ot, {
1063
- key: 0,
1064
- "show-top-bar": c.showTopBar,
1065
- "show-md-toolbar": c.showMdToolbar,
1066
- "show-aimd-toolbar": c.showAimdToolbar,
1067
- "editor-mode": K(p),
1068
- "resolved-messages": f.value,
1069
- "localized-field-types": A.value,
1070
- "localized-md-toolbar-items": S.value,
1071
- onSwitchMode: K(k),
1072
- onMdAction: R,
1073
- onOpenAimdDialog: m,
1074
- onQuickInsertAimd: I
1075
- }, null, 8, ["show-top-bar", "show-md-toolbar", "show-aimd-toolbar", "editor-mode", "resolved-messages", "localized-field-types", "localized-md-toolbar-items", "onSwitchMode"])) : z("", !0),
1076
- l("div", {
1077
- class: "aimd-editor-panel",
1078
- style: me({ minHeight: c.minHeight + "px" })
1079
- }, [
1080
- ee.value ? b((u(), v("div", nt, [
1081
- Me(Qe, {
1082
- ref_key: "sourceEditorRef",
1083
- ref: ne,
1084
- content: K(d),
1085
- theme: Z.value,
1086
- "min-height": c.minHeight,
1087
- readonly: c.readonly,
1088
- "monaco-options": c.monacoOptions,
1089
- "resolved-messages": f.value,
1090
- onContentChange: pe,
1091
- onReady: de,
1092
- onMonacoLoaded: ge
1093
- }, null, 8, ["content", "theme", "min-height", "readonly", "monaco-options", "resolved-messages"])
1094
- ], 512)), [
1095
- [Ie, K(p) === "source"]
1096
- ]) : z("", !0),
1097
- le.value ? b((u(), v("div", dt, [
1098
- Me(Oe, {
1099
- ref_key: "wysiwygEditorRef",
1100
- ref: te,
1101
- content: K(d),
1102
- "min-height": c.minHeight,
1103
- "enable-block-handle": c.enableBlockHandle,
1104
- active: K(p) === "wysiwyg",
1105
- "resolved-messages": f.value,
1106
- "localized-field-types": A.value,
1107
- onMarkdownUpdated: K(X),
1108
- onReady: fe,
1109
- onOpenAimdDialog: m
1110
- }, null, 8, ["content", "min-height", "enable-block-handle", "active", "resolved-messages", "localized-field-types", "onMarkdownUpdated"])
1111
- ], 512)), [
1112
- [Ie, K(p) === "wysiwyg"]
1113
- ]) : z("", !0)
1114
- ], 4),
1115
- Me(Qs, {
1116
- visible: L.value,
1117
- "initial-type": O.value,
1118
- messages: f.value,
1119
- "ref-suggestions": se.value,
1120
- "var-type-plugins": c.varTypePlugins,
1121
- "existing-quiz-ids": n.value,
1122
- "onUpdate:visible": _[0] || (_[0] = (he) => L.value = he),
1123
- onInsert: P
1124
- }, null, 8, ["visible", "initial-type", "messages", "ref-suggestions", "var-type-plugins", "existing-quiz-ids"])
1125
- ]));
1126
- }
1127
- }), rt = { class: "aimd-editor-mode-switch" }, ut = ["title"], ct = ["innerHTML"], mt = ["title"], vt = ["innerHTML"], Mt = /* @__PURE__ */ ve({
1128
- __name: "AimdEditorTopBar",
1129
- props: {
1130
- editorMode: {},
1131
- resolvedMessages: {}
1132
- },
1133
- emits: ["switch-mode"],
1134
- setup(c, { emit: F }) {
1135
- const o = F, M = {
1136
- 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>',
1137
- 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>'
1138
- };
1139
- return (w, f) => (u(), v("div", rt, [
1140
- l("button", {
1141
- class: W(["aimd-editor-mode-btn", { active: c.editorMode === "source" }]),
1142
- onClick: f[0] || (f[0] = (p) => o("switch-mode", "source")),
1143
- title: c.resolvedMessages.mode.sourceTitle
1144
- }, [
1145
- l("span", {
1146
- class: "aimd-editor-mode-icon",
1147
- innerHTML: M.source
1148
- }, null, 8, ct),
1149
- l("span", null, i(c.resolvedMessages.mode.source), 1)
1150
- ], 10, ut),
1151
- l("button", {
1152
- class: W(["aimd-editor-mode-btn", { active: c.editorMode === "wysiwyg" }]),
1153
- onClick: f[1] || (f[1] = (p) => o("switch-mode", "wysiwyg")),
1154
- title: c.resolvedMessages.mode.wysiwygTitle
1155
- }, [
1156
- l("span", {
1157
- class: "aimd-editor-mode-icon",
1158
- innerHTML: M.wysiwyg
1159
- }, null, 8, vt),
1160
- l("span", null, i(c.resolvedMessages.mode.wysiwyg), 1)
1161
- ], 10, mt)
1162
- ]));
1163
- }
1164
- });
1165
- export {
1166
- _t as _,
1167
- ot as a,
1168
- Mt as b,
1169
- Qs as c,
1170
- at as u
1171
- };