@airalogy/aimd-editor 1.7.1 → 1.8.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/LICENSE +201 -0
- package/README.md +6 -1
- package/README.zh-CN.md +6 -1
- package/dist/{AimdEditorTopBar.vue_vue_type_script_setup_true_lang-gbfMDZSh.js → AimdEditorTopBar.vue_vue_type_script_setup_true_lang-yYY-Yq1g.js} +2 -2
- package/dist/AimdSourceEditor.vue_vue_type_script_setup_true_lang-ttzw5IdG.js +4976 -0
- package/dist/{AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-B8o1VbUH.js → AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-tRm4S2Nv.js} +651 -651
- package/dist/embedded.js +2 -2
- package/dist/index.js +3 -3
- package/dist/vue.js +3 -3
- package/dist/wysiwyg.js +1 -1
- package/package.json +12 -12
- package/src/vue/AimdSourceEditor.vue +39 -0
- package/src/vue/aimdDiagnostics.ts +39 -0
- package/src/vue/aimdInlineMarkdownNormalization.ts +2 -1
- package/dist/AimdSourceEditor.vue_vue_type_script_setup_true_lang-t_sUoXky.js +0 -274
package/dist/embedded.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as s } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
2
|
-
import { _ as i, D as d, i as o, j as t, k as A, r as m } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as s } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-ttzw5IdG.js";
|
|
2
|
+
import { _ as i, D as d, i as o, j as t, k as A, r as m } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-tRm4S2Nv.js";
|
|
3
3
|
export {
|
|
4
4
|
s as AimdSourceEditor,
|
|
5
5
|
i as AimdWysiwygEditor,
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as i, a as s, b as d, D as o, K as m, M as r, c as t, d as A, e as n, f as l, g as D, l as E, s as T } from "./theme-B8dCnOx-.js";
|
|
2
|
-
import { _, a as c, b as f, c as u, u as M } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-
|
|
3
|
-
import { _ as p } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
4
|
-
import { A as k, a as x, _ as L, D as O, M as S, b as y, c as b, d as N, e as P, f as R, g as w, h, i as B, j as C, k as v, l as K, m as V, n as Y, r as j } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
2
|
+
import { _, a as c, b as f, c as u, u as M } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-yYY-Yq1g.js";
|
|
3
|
+
import { _ as p } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-ttzw5IdG.js";
|
|
4
|
+
import { A as k, a as x, _ as L, D as O, M as S, b as y, c as b, d as N, e as P, f as R, g as w, h, i as B, j as C, k as v, l as K, m as V, n as Y, r as j } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-tRm4S2Nv.js";
|
|
5
5
|
export {
|
|
6
6
|
k as AIMD_FIELD_TYPES,
|
|
7
7
|
x as AIMD_FIELD_TYPE_DEFINITIONS,
|
package/dist/vue.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _ as e, a as d, b as s, c as r, u as o } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-
|
|
2
|
-
import { _ as m } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-
|
|
3
|
-
import { A as E, a as l, _ as I, D as _, M as T, b as D, c as F, d as M, e as u, f as c, g as n, h as g, i as L, j as O, k as p, l as S, m as y, n as b, r as f } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as e, a as d, b as s, c as r, u as o } from "./AimdEditorTopBar.vue_vue_type_script_setup_true_lang-yYY-Yq1g.js";
|
|
2
|
+
import { _ as m } from "./AimdSourceEditor.vue_vue_type_script_setup_true_lang-ttzw5IdG.js";
|
|
3
|
+
import { A as E, a as l, _ as I, D as _, M as T, b as D, c as F, d as M, e as u, f as c, g as n, h as g, i as L, j as O, k as p, l as S, m as y, n as b, r as f } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-tRm4S2Nv.js";
|
|
4
4
|
export {
|
|
5
5
|
E as AIMD_FIELD_TYPES,
|
|
6
6
|
l as AIMD_FIELD_TYPE_DEFINITIONS,
|
package/dist/wysiwyg.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as a, D as r, i, j as d, k as t, r as A } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as a, D as r, i, j as d, k as t, r as A } from "./AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-tRm4S2Nv.js";
|
|
2
2
|
export {
|
|
3
3
|
a as AimdWysiwygEditor,
|
|
4
4
|
r as DEFAULT_AIMD_EDITOR_LOCALE,
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airalogy/aimd-editor",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"description": "AIMD editor with Monaco source mode and Milkdown WYSIWYG mode",
|
|
4
|
+
"version": "1.8.0",
|
|
5
|
+
"description": "AIMD (Airalogy Markdown) editor with Monaco source mode and Milkdown WYSIWYG mode",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -53,20 +53,14 @@
|
|
|
53
53
|
"dist",
|
|
54
54
|
"src"
|
|
55
55
|
],
|
|
56
|
-
"scripts": {
|
|
57
|
-
"type-check": "tsc --noEmit",
|
|
58
|
-
"build": "vite build",
|
|
59
|
-
"dev": "vite build --watch",
|
|
60
|
-
"test": "node --test ./tests/*.test.mjs"
|
|
61
|
-
},
|
|
62
56
|
"dependencies": {
|
|
63
|
-
"@airalogy/aimd-core": "workspace:^",
|
|
64
|
-
"@airalogy/aimd-renderer": "workspace:^",
|
|
65
57
|
"@codingame/monaco-vscode-editor-api": "^20.2.1",
|
|
66
58
|
"@codingame/monaco-vscode-standalone-languages": "^20.2.1",
|
|
67
59
|
"@milkdown/kit": "^7.18.0",
|
|
68
60
|
"@milkdown/theme-nord": "^7.18.0",
|
|
69
|
-
"@milkdown/vue": "^7.18.0"
|
|
61
|
+
"@milkdown/vue": "^7.18.0",
|
|
62
|
+
"@airalogy/aimd-core": "^2.6.0",
|
|
63
|
+
"@airalogy/aimd-renderer": "^2.5.0"
|
|
70
64
|
},
|
|
71
65
|
"peerDependencies": {
|
|
72
66
|
"monaco-editor": ">=0.50.0",
|
|
@@ -86,5 +80,11 @@
|
|
|
86
80
|
"vite-tsconfig-paths": "^5.1.4",
|
|
87
81
|
"vue": "^3.5.17",
|
|
88
82
|
"@vitejs/plugin-vue": "^6.0.1"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"type-check": "tsc --noEmit",
|
|
86
|
+
"build": "vite build",
|
|
87
|
+
"dev": "vite build --watch",
|
|
88
|
+
"test": "node --test ./tests/*.test.mjs"
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { ref, onMounted, onBeforeUnmount, watch } from 'vue'
|
|
3
3
|
import type { AimdEditorMessages } from './locales'
|
|
4
|
+
import { collectAimdDiagnostics } from './aimdDiagnostics'
|
|
4
5
|
|
|
5
6
|
const props = defineProps<{
|
|
6
7
|
content: string
|
|
@@ -22,6 +23,7 @@ const SERVER_ASSIGNER_FENCE = /^\s*(```|~~~)\s*assigner(?:\s+.*)?\s*$/
|
|
|
22
23
|
const QUIZ_FENCE = /^\s*(```|~~~)\s*quiz(?:\s+.*)?\s*$/
|
|
23
24
|
const GENERIC_CODE_FENCE = /^\s*(```|~~~)\s*((?:\w|[/#-])+)(?:\s+.*)?\s*$/
|
|
24
25
|
const EMPTY_CODE_FENCE = /^\s*(```|~~~)\s*$/
|
|
26
|
+
const AIMD_DIAGNOSTIC_OWNER = 'airalogy-aimd'
|
|
25
27
|
|
|
26
28
|
const editorContainer = ref<HTMLElement | null>(null)
|
|
27
29
|
|
|
@@ -207,6 +209,40 @@ function registerAimdLanguage(monaco: any) {
|
|
|
207
209
|
})
|
|
208
210
|
}
|
|
209
211
|
|
|
212
|
+
function updateAimdDiagnostics() {
|
|
213
|
+
if (!monacoModule || !monacoEditorInstance) return
|
|
214
|
+
|
|
215
|
+
const model = monacoEditorInstance.getModel()
|
|
216
|
+
if (!model) return
|
|
217
|
+
|
|
218
|
+
const markers = collectAimdDiagnostics(model.getValue()).map((diagnostic) => {
|
|
219
|
+
const start = model.getPositionAt(diagnostic.startOffset)
|
|
220
|
+
const end = model.getPositionAt(diagnostic.endOffset)
|
|
221
|
+
return {
|
|
222
|
+
severity: diagnostic.severity === 'error'
|
|
223
|
+
? monacoModule.MarkerSeverity.Error
|
|
224
|
+
: monacoModule.MarkerSeverity.Warning,
|
|
225
|
+
message: diagnostic.message,
|
|
226
|
+
source: 'AIMD',
|
|
227
|
+
startLineNumber: start.lineNumber,
|
|
228
|
+
startColumn: start.column,
|
|
229
|
+
endLineNumber: end.lineNumber,
|
|
230
|
+
endColumn: end.column,
|
|
231
|
+
}
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
monacoModule.editor.setModelMarkers(model, AIMD_DIAGNOSTIC_OWNER, markers)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function clearAimdDiagnostics() {
|
|
238
|
+
if (!monacoModule || !monacoEditorInstance) return
|
|
239
|
+
|
|
240
|
+
const model = monacoEditorInstance.getModel()
|
|
241
|
+
if (model) {
|
|
242
|
+
monacoModule.editor.setModelMarkers(model, AIMD_DIAGNOSTIC_OWNER, [])
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
210
246
|
function createEditor(monaco: any) {
|
|
211
247
|
if (!editorContainer.value || monacoEditorInstance) return
|
|
212
248
|
const MONACO_OPTIONS_BLACKLIST = new Set(['value', 'language', 'model'])
|
|
@@ -230,10 +266,12 @@ function createEditor(monaco: any) {
|
|
|
230
266
|
...safeMonacoOptions,
|
|
231
267
|
})
|
|
232
268
|
monacoEditorInstance.onDidChangeModelContent(() => {
|
|
269
|
+
updateAimdDiagnostics()
|
|
233
270
|
if (!isSyncing) {
|
|
234
271
|
emit('content-change', monacoEditorInstance.getValue())
|
|
235
272
|
}
|
|
236
273
|
})
|
|
274
|
+
updateAimdDiagnostics()
|
|
237
275
|
emit('ready', monacoEditorInstance)
|
|
238
276
|
emit('monaco-loaded', monaco, monacoEditorInstance)
|
|
239
277
|
}
|
|
@@ -251,6 +289,7 @@ onMounted(async () => {
|
|
|
251
289
|
})
|
|
252
290
|
|
|
253
291
|
onBeforeUnmount(() => {
|
|
292
|
+
clearAimdDiagnostics()
|
|
254
293
|
monacoEditorInstance?.dispose()
|
|
255
294
|
})
|
|
256
295
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { parseVarDefinition, validateVarDefinition } from '@airalogy/aimd-core/parser'
|
|
2
|
+
|
|
3
|
+
export type AimdDiagnosticSeverity = 'warning' | 'error'
|
|
4
|
+
|
|
5
|
+
export interface AimdDiagnostic {
|
|
6
|
+
message: string
|
|
7
|
+
severity: AimdDiagnosticSeverity
|
|
8
|
+
startOffset: number
|
|
9
|
+
endOffset: number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const AIMD_VAR_TEMPLATE_PATTERN = /\{\{\s*(var_table|var)\s*\|([\s\S]*?)\}\}/g
|
|
13
|
+
|
|
14
|
+
export function collectAimdDiagnostics(content: string): AimdDiagnostic[] {
|
|
15
|
+
const diagnostics: AimdDiagnostic[] = []
|
|
16
|
+
|
|
17
|
+
for (const match of content.matchAll(AIMD_VAR_TEMPLATE_PATTERN)) {
|
|
18
|
+
const startOffset = match.index ?? 0
|
|
19
|
+
const raw = match[0]
|
|
20
|
+
const fieldContent = match[2] ?? ''
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
const warnings = validateVarDefinition(parseVarDefinition(fieldContent))
|
|
24
|
+
if (warnings.length > 0) {
|
|
25
|
+
diagnostics.push({
|
|
26
|
+
message: warnings.join('\n'),
|
|
27
|
+
severity: 'warning',
|
|
28
|
+
startOffset,
|
|
29
|
+
endOffset: startOffset + raw.length,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
} catch {
|
|
33
|
+
// Keep source editing permissive; syntax-level parser failures should not
|
|
34
|
+
// block Monaco from rendering or reporting other diagnostics.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return diagnostics
|
|
39
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
const
|
|
1
|
+
const AIMD_INLINE_TEMPLATE_TYPE_PATTERN = String.raw`(?:var(?:\\?_table)?|step|check|ref\\?_(?:step|var|fig)|cite)`
|
|
2
|
+
const AIMD_INLINE_TEMPLATE_PATTERN = new RegExp(String.raw`\{\{${AIMD_INLINE_TEMPLATE_TYPE_PATTERN}\s*\|[^}]+?\}\}`, 'g')
|
|
2
3
|
const MARKDOWN_ESCAPABLE_PATTERN = /\\([\\!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~-])/g
|
|
3
4
|
|
|
4
5
|
function normalizeSingleAimdInlineTemplate(template: string): string {
|
|
@@ -1,274 +0,0 @@
|
|
|
1
|
-
import { defineComponent as V, ref as p, onMounted as q, onBeforeUnmount as F, watch as u, openBlock as k, createElementBlock as b, normalizeStyle as P, toDisplayString as R, createCommentVNode as D, createElementVNode as K } from "vue";
|
|
2
|
-
const Z = {
|
|
3
|
-
key: 0,
|
|
4
|
-
class: "aimd-editor-loading"
|
|
5
|
-
}, G = /* @__PURE__ */ V({
|
|
6
|
-
__name: "AimdSourceEditor",
|
|
7
|
-
props: {
|
|
8
|
-
content: {},
|
|
9
|
-
theme: {},
|
|
10
|
-
minHeight: {},
|
|
11
|
-
readonly: { type: Boolean },
|
|
12
|
-
monacoOptions: {},
|
|
13
|
-
resolvedMessages: {}
|
|
14
|
-
},
|
|
15
|
-
emits: ["content-change", "ready", "monaco-loaded"],
|
|
16
|
-
setup(l, { expose: _, emit: y }) {
|
|
17
|
-
const n = l, c = y, x = /^\s*(```|~~~)\s*assigner(?:\s+.*\bruntime\s*=\s*(?:"client"|'client'|client)\b.*)\s*$/, h = /^\s*(```|~~~)\s*assigner(?:\s+.*)?\s*$/, E = /^\s*(```|~~~)\s*quiz(?:\s+.*)?\s*$/, v = /^\s*(```|~~~)\s*((?:\w|[/#-])+)(?:\s+.*)?\s*$/, C = /^\s*(```|~~~)\s*$/, m = p(null);
|
|
18
|
-
let t = null, r = null, i = !1;
|
|
19
|
-
const d = p(!0);
|
|
20
|
-
function S(e) {
|
|
21
|
-
const o = n.resolvedMessages;
|
|
22
|
-
e.languages.getLanguages().some((s) => s.id === "aimd") || (e.languages.register({
|
|
23
|
-
id: "aimd",
|
|
24
|
-
extensions: [".aimd"],
|
|
25
|
-
aliases: ["AIMD", "aimd"],
|
|
26
|
-
mimetypes: ["text/x-aimd"]
|
|
27
|
-
}), e.languages.setLanguageConfiguration("aimd", {
|
|
28
|
-
brackets: [
|
|
29
|
-
["{", "}"],
|
|
30
|
-
["[", "]"],
|
|
31
|
-
["(", ")"]
|
|
32
|
-
],
|
|
33
|
-
autoClosingPairs: [
|
|
34
|
-
{ open: "{", close: "}" },
|
|
35
|
-
{ open: "[", close: "]" },
|
|
36
|
-
{ open: "(", close: ")" },
|
|
37
|
-
{ open: '"', close: '"' },
|
|
38
|
-
{ open: "'", close: "'" },
|
|
39
|
-
{ open: "`", close: "`" },
|
|
40
|
-
{ open: "{{", close: "}}" }
|
|
41
|
-
],
|
|
42
|
-
surroundingPairs: [
|
|
43
|
-
{ open: "{", close: "}" },
|
|
44
|
-
{ open: "[", close: "]" },
|
|
45
|
-
{ open: "(", close: ")" },
|
|
46
|
-
{ open: '"', close: '"' },
|
|
47
|
-
{ open: "'", close: "'" },
|
|
48
|
-
{ open: "`", close: "`" }
|
|
49
|
-
]
|
|
50
|
-
}), e.languages.setMonarchTokensProvider("aimd", {
|
|
51
|
-
defaultToken: "",
|
|
52
|
-
tokenPostfix: ".aimd",
|
|
53
|
-
tokenizer: {
|
|
54
|
-
root: [
|
|
55
|
-
[/\{\{/, { token: "delimiter.bracket.aimd", next: "@aimdField" }],
|
|
56
|
-
[/^#{1,6}\s.*$/, "keyword.md"],
|
|
57
|
-
[E, { token: "string.code", next: "@embeddedCodeblock", nextEmbedded: "yaml" }],
|
|
58
|
-
[x, { token: "string.code", next: "@embeddedCodeblock", nextEmbedded: "javascript" }],
|
|
59
|
-
[h, { token: "string.code", next: "@embeddedCodeblock", nextEmbedded: "python" }],
|
|
60
|
-
[v, { token: "string.code", next: "@embeddedCodeblock", nextEmbedded: "$2" }],
|
|
61
|
-
[C, { token: "string.code", next: "@codeblock" }],
|
|
62
|
-
[/`[^`]+`/, "string.code"],
|
|
63
|
-
[/\*\*[^*]+\*\*/, "strong"],
|
|
64
|
-
[/__[^_]+__/, "strong"],
|
|
65
|
-
[/\*[^*]+\*/, "emphasis"],
|
|
66
|
-
[/_[^_]+_/, "emphasis"],
|
|
67
|
-
[/\[[^\]]+\]\([^)]+\)/, "string.link"],
|
|
68
|
-
[/!\[[^\]]*\]\([^)]+\)/, "string.link"],
|
|
69
|
-
[/^>.*$/, "comment.quote"],
|
|
70
|
-
[/^\s*[-*+]\s/, "keyword.list"],
|
|
71
|
-
[/^\s*\d+\.\s/, "keyword.list"],
|
|
72
|
-
[/^[-*_]{3,}\s*$/, "keyword.hr"],
|
|
73
|
-
[/<\/?[\w-][^>]*>/, "tag"]
|
|
74
|
-
],
|
|
75
|
-
aimdField: [
|
|
76
|
-
[/\}\}/, { token: "delimiter.bracket.aimd", next: "@pop" }],
|
|
77
|
-
[/\b(var_table|var|step|check|ref_step|ref_var|ref_fig|cite)\b/, "keyword.aimd"],
|
|
78
|
-
[/\|/, "delimiter.aimd"],
|
|
79
|
-
[/:/, "delimiter"],
|
|
80
|
-
[/\b(str|int|float|bool|list|dict|any)\b/, "type.aimd"],
|
|
81
|
-
[/\b[A-Z][A-Za-z0-9_]*(?:\[[A-Za-z0-9_,\s]+\])?\b/, "type.aimd"],
|
|
82
|
-
[/[[\]()]/, "delimiter.bracket"],
|
|
83
|
-
[/=/, "delimiter"],
|
|
84
|
-
[/"[^"]*"/, "string"],
|
|
85
|
-
[/'[^']*'/, "string"],
|
|
86
|
-
[/-?\d+\.?\d*/, "number"],
|
|
87
|
-
[/\b(true|false|True|False|null|None)\b/, "constant"],
|
|
88
|
-
[/\bsubvars\b/, "keyword"],
|
|
89
|
-
[/,/, "delimiter"],
|
|
90
|
-
[/[A-Za-z_]\w*/, "variable.aimd"],
|
|
91
|
-
[/\s+/, ""]
|
|
92
|
-
],
|
|
93
|
-
codeblock: [
|
|
94
|
-
[/^```\s*$/, { token: "string.code", next: "@pop" }],
|
|
95
|
-
[/^~~~\s*$/, { token: "string.code", next: "@pop" }],
|
|
96
|
-
[/.*$/, "string.code"]
|
|
97
|
-
],
|
|
98
|
-
embeddedCodeblock: [
|
|
99
|
-
[/^```\s*$/, { token: "string.code", next: "@pop", nextEmbedded: "@pop" }],
|
|
100
|
-
[/^~~~\s*$/, { token: "string.code", next: "@pop", nextEmbedded: "@pop" }],
|
|
101
|
-
[/.*$/, ""]
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
}), e.languages.registerCompletionItemProvider("aimd", {
|
|
105
|
-
provideCompletionItems: () => {
|
|
106
|
-
const s = ["var", "var_table", "step", "check", "ref_step", "ref_var", "ref_fig", "cite"], L = {
|
|
107
|
-
var: "var_id",
|
|
108
|
-
var_table: "table_id",
|
|
109
|
-
step: "step_id",
|
|
110
|
-
check: "check_id",
|
|
111
|
-
ref_step: "step_id",
|
|
112
|
-
ref_var: "var_id",
|
|
113
|
-
ref_fig: "fig_id",
|
|
114
|
-
cite: "ref_id"
|
|
115
|
-
}, f = s.map((a) => ({
|
|
116
|
-
label: `{{${a}|}}`,
|
|
117
|
-
kind: e.languages.CompletionItemKind.Snippet,
|
|
118
|
-
insertText: `{{${a}|\${1:${L[a] ?? "id"}}}}`,
|
|
119
|
-
insertTextRules: e.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
120
|
-
documentation: o.completions.insertAimdField(a)
|
|
121
|
-
}));
|
|
122
|
-
return f.push({
|
|
123
|
-
label: o.completions.quizBlockLabel,
|
|
124
|
-
kind: e.languages.CompletionItemKind.Snippet,
|
|
125
|
-
insertText: [
|
|
126
|
-
"```quiz",
|
|
127
|
-
"id: ${1:quiz_choice_1}",
|
|
128
|
-
"type: choice",
|
|
129
|
-
"mode: single",
|
|
130
|
-
"stem: |",
|
|
131
|
-
` \${2:${o.defaults.questionStem}}`,
|
|
132
|
-
"options:",
|
|
133
|
-
" - key: A",
|
|
134
|
-
` text: ${o.defaults.optionText("A")}`,
|
|
135
|
-
" - key: B",
|
|
136
|
-
` text: ${o.defaults.optionText("B")}`,
|
|
137
|
-
"answer: A",
|
|
138
|
-
"```"
|
|
139
|
-
].join(`
|
|
140
|
-
`),
|
|
141
|
-
insertTextRules: e.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
142
|
-
documentation: o.completions.quizBlock
|
|
143
|
-
}), { suggestions: f };
|
|
144
|
-
}
|
|
145
|
-
}), e.editor.defineTheme("aimd-light", {
|
|
146
|
-
base: "vs",
|
|
147
|
-
inherit: !0,
|
|
148
|
-
rules: [
|
|
149
|
-
{ token: "delimiter.bracket.aimd", foreground: "2563eb" },
|
|
150
|
-
{ token: "keyword.aimd", foreground: "2563eb", fontStyle: "bold" },
|
|
151
|
-
{ token: "delimiter.aimd", foreground: "6b7280" },
|
|
152
|
-
{ token: "type.aimd", foreground: "7c3aed" },
|
|
153
|
-
{ token: "variable.aimd", foreground: "059669" },
|
|
154
|
-
{ token: "keyword.md", foreground: "1e40af" },
|
|
155
|
-
{ token: "string.code", foreground: "be185d" },
|
|
156
|
-
{ token: "strong", fontStyle: "bold" },
|
|
157
|
-
{ token: "emphasis", fontStyle: "italic" },
|
|
158
|
-
{ token: "string.link", foreground: "2563eb" },
|
|
159
|
-
{ token: "comment.quote", foreground: "6b7280", fontStyle: "italic" }
|
|
160
|
-
],
|
|
161
|
-
colors: {}
|
|
162
|
-
}), e.editor.defineTheme("aimd-dark", {
|
|
163
|
-
base: "vs-dark",
|
|
164
|
-
inherit: !0,
|
|
165
|
-
rules: [
|
|
166
|
-
{ token: "delimiter.bracket.aimd", foreground: "60a5fa" },
|
|
167
|
-
{ token: "keyword.aimd", foreground: "60a5fa", fontStyle: "bold" },
|
|
168
|
-
{ token: "delimiter.aimd", foreground: "9ca3af" },
|
|
169
|
-
{ token: "type.aimd", foreground: "a78bfa" },
|
|
170
|
-
{ token: "variable.aimd", foreground: "34d399" },
|
|
171
|
-
{ token: "keyword.md", foreground: "93c5fd" },
|
|
172
|
-
{ token: "string.code", foreground: "f472b6" },
|
|
173
|
-
{ token: "strong", fontStyle: "bold" },
|
|
174
|
-
{ token: "emphasis", fontStyle: "italic" },
|
|
175
|
-
{ token: "string.link", foreground: "60a5fa" },
|
|
176
|
-
{ token: "comment.quote", foreground: "9ca3af", fontStyle: "italic" }
|
|
177
|
-
],
|
|
178
|
-
colors: {}
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
function $(e) {
|
|
182
|
-
if (!m.value || t) return;
|
|
183
|
-
const o = /* @__PURE__ */ new Set(["value", "language", "model"]), g = Object.fromEntries(
|
|
184
|
-
Object.entries(n.monacoOptions).filter(([s]) => !o.has(s))
|
|
185
|
-
);
|
|
186
|
-
t = e.editor.create(m.value, {
|
|
187
|
-
value: n.content,
|
|
188
|
-
language: "aimd",
|
|
189
|
-
theme: n.theme,
|
|
190
|
-
minimap: { enabled: !1 },
|
|
191
|
-
fontSize: 14,
|
|
192
|
-
lineNumbers: "on",
|
|
193
|
-
wordWrap: "on",
|
|
194
|
-
scrollBeyondLastLine: !1,
|
|
195
|
-
automaticLayout: !0,
|
|
196
|
-
tabSize: 2,
|
|
197
|
-
padding: { top: 12 },
|
|
198
|
-
readOnly: n.readonly,
|
|
199
|
-
...g
|
|
200
|
-
}), t.onDidChangeModelContent(() => {
|
|
201
|
-
i || c("content-change", t.getValue());
|
|
202
|
-
}), c("ready", t), c("monaco-loaded", e, t);
|
|
203
|
-
}
|
|
204
|
-
q(async () => {
|
|
205
|
-
try {
|
|
206
|
-
d.value = !0;
|
|
207
|
-
const e = await import("monaco-editor");
|
|
208
|
-
r = e, S(e), $(e);
|
|
209
|
-
} finally {
|
|
210
|
-
d.value = !1;
|
|
211
|
-
}
|
|
212
|
-
}), F(() => {
|
|
213
|
-
t?.dispose();
|
|
214
|
-
}), u(() => n.content, (e) => {
|
|
215
|
-
!t || e === t.getValue() || (i = !0, t.setValue(e), i = !1);
|
|
216
|
-
}), u(() => n.theme, (e) => {
|
|
217
|
-
r && r.editor.setTheme(e);
|
|
218
|
-
}), u(() => n.readonly, (e) => {
|
|
219
|
-
t?.updateOptions({ readOnly: e });
|
|
220
|
-
});
|
|
221
|
-
function I() {
|
|
222
|
-
return t;
|
|
223
|
-
}
|
|
224
|
-
function T() {
|
|
225
|
-
return r;
|
|
226
|
-
}
|
|
227
|
-
function w(e) {
|
|
228
|
-
t && (i = !0, t.setValue(e), i = !1);
|
|
229
|
-
}
|
|
230
|
-
function A() {
|
|
231
|
-
return t?.getSelection();
|
|
232
|
-
}
|
|
233
|
-
function N(e, o) {
|
|
234
|
-
t?.executeEdits(e, o);
|
|
235
|
-
}
|
|
236
|
-
function M() {
|
|
237
|
-
t?.focus();
|
|
238
|
-
}
|
|
239
|
-
function O() {
|
|
240
|
-
return t?.getModel();
|
|
241
|
-
}
|
|
242
|
-
function z() {
|
|
243
|
-
return t?.getPosition();
|
|
244
|
-
}
|
|
245
|
-
function B() {
|
|
246
|
-
return t?.getValue();
|
|
247
|
-
}
|
|
248
|
-
return _({
|
|
249
|
-
getEditor: I,
|
|
250
|
-
getMonaco: T,
|
|
251
|
-
setValue: w,
|
|
252
|
-
getSelection: A,
|
|
253
|
-
executeEdits: N,
|
|
254
|
-
focus: M,
|
|
255
|
-
getModel: O,
|
|
256
|
-
getPosition: z,
|
|
257
|
-
getValue: B,
|
|
258
|
-
loading: d
|
|
259
|
-
}), (e, o) => (k(), b("div", {
|
|
260
|
-
class: "aimd-editor-source-mode",
|
|
261
|
-
style: P({ height: l.minHeight + "px" })
|
|
262
|
-
}, [
|
|
263
|
-
d.value ? (k(), b("div", Z, R(l.resolvedMessages.common.loadingEditor), 1)) : D("", !0),
|
|
264
|
-
K("div", {
|
|
265
|
-
ref_key: "editorContainer",
|
|
266
|
-
ref: m,
|
|
267
|
-
class: "aimd-editor-container"
|
|
268
|
-
}, null, 512)
|
|
269
|
-
], 4));
|
|
270
|
-
}
|
|
271
|
-
});
|
|
272
|
-
export {
|
|
273
|
-
G as _
|
|
274
|
-
};
|