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