@airalogy/aimd-recorder 1.14.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 (178) hide show
  1. package/README.md +240 -0
  2. package/README.zh-CN.md +224 -0
  3. package/dist/AimdCodeField-DC3DPvgc.js +172 -0
  4. package/dist/AimdDnaSequenceField-__jdnFS9.js +59466 -0
  5. package/dist/AimdEditor.vue_vue_type_style_index_0_lang-Bq79rKNw.js +28370 -0
  6. package/dist/AimdMarkdownField-98ImHGbc.js +66 -0
  7. package/dist/AimdMarkdownNoteField-CuUJZkgT.js +185 -0
  8. package/dist/_.contribution-IP0cDNhs.js +38 -0
  9. package/dist/_commonjsHelpers-CZXJ37nu.js +40 -0
  10. package/dist/abap-Bs8kvjsq.js +1398 -0
  11. package/dist/aimd-recorder.css +1 -0
  12. package/dist/apex-Dspwrl5m.js +326 -0
  13. package/dist/assets/css.worker-Dmf38jDD.js +79 -0
  14. package/dist/assets/editor.worker-CpuX8TSY.js +12 -0
  15. package/dist/assets/html.worker-DotaEs7v.js +456 -0
  16. package/dist/assets/json.worker-B4VHhH6h.js +44 -0
  17. package/dist/assets/ts.worker-sl17zBDo.js +51316 -0
  18. package/dist/azcli-k1BiOau1.js +68 -0
  19. package/dist/bat-BIP72KWc.js +100 -0
  20. package/dist/bicep-VhQeYhS3.js +102 -0
  21. package/dist/cameligo-DnuAXtHg.js +174 -0
  22. package/dist/clojure-BAuDPsal.js +761 -0
  23. package/dist/coffee-BV06qSnj.js +232 -0
  24. package/dist/components.js +3595 -0
  25. package/dist/composables.js +72 -0
  26. package/dist/cpp-Cz8Jeyrf.js +389 -0
  27. package/dist/csharp-F6hhlXFb.js +326 -0
  28. package/dist/csp-KzlEHCyI.js +53 -0
  29. package/dist/css-e4FKntZ3.js +187 -0
  30. package/dist/cssMode-uz9U6SUU.js +1571 -0
  31. package/dist/cypher-CpvDGKRr.js +263 -0
  32. package/dist/dart-DdHeFWR0.js +281 -0
  33. package/dist/dockerfile-aoNXDcio.js +130 -0
  34. package/dist/ecl-C4Q0DYuA.js +456 -0
  35. package/dist/editor.api-CgD9w0gG.js +77091 -0
  36. package/dist/editor.main-Du02abDl.js +33783 -0
  37. package/dist/elixir-C9X42b0T.js +569 -0
  38. package/dist/flow9-Bff42pfB.js +142 -0
  39. package/dist/freemarker2-DFLX4iQ-.js +989 -0
  40. package/dist/fsharp-C6vPAsHG.js +217 -0
  41. package/dist/go-DEr8zx9f.js +218 -0
  42. package/dist/graphql-BiNBBRFh.js +151 -0
  43. package/dist/handlebars-aiZbIuWY.js +419 -0
  44. package/dist/hcl-2T9lKuFg.js +183 -0
  45. package/dist/html-phzTMObN.js +308 -0
  46. package/dist/htmlMode-BF7wMi3N.js +1581 -0
  47. package/dist/index.js +89 -0
  48. package/dist/ini-CZGtssYM.js +71 -0
  49. package/dist/ini.contribution-DyWtiacL.js +8 -0
  50. package/dist/java-B260NeH3.js +232 -0
  51. package/dist/javascript-BKKOItMi.js +70 -0
  52. package/dist/jsonMode-CDYK4B5l.js +1996 -0
  53. package/dist/julia-kuNLM9c5.js +511 -0
  54. package/dist/kotlin-Bz6kAefA.js +253 -0
  55. package/dist/less-AZUtS89I.js +162 -0
  56. package/dist/lexon-BcmgnyRb.js +157 -0
  57. package/dist/liquid-B2eRz5SA.js +240 -0
  58. package/dist/lua-Dz1RbATg.js +162 -0
  59. package/dist/m3-CIMooLFn.js +210 -0
  60. package/dist/markdown-C1BsCK9P.js +229 -0
  61. package/dist/markdown.contribution-DYYk6zUU.js +7 -0
  62. package/dist/mdx-BfV1HDRG.js +165 -0
  63. package/dist/mips-BovsnfLQ.js +198 -0
  64. package/dist/monaco.contribution-C-bQhUTI.js +114 -0
  65. package/dist/monaco.contribution-CCVvl3Jx.js +72 -0
  66. package/dist/monaco.contribution-Col-f0XR.js +164 -0
  67. package/dist/monaco.contribution-b5xkgQ-s.js +112 -0
  68. package/dist/msdax-CiRB2ZB-.js +375 -0
  69. package/dist/mysql-BwdpPE19.js +878 -0
  70. package/dist/objective-c-D4nfHfso.js +183 -0
  71. package/dist/pascal--j5-PYtz.js +251 -0
  72. package/dist/pascaligo-C7TcJxNL.js +164 -0
  73. package/dist/perl-BzEWqUb5.js +626 -0
  74. package/dist/pgsql-B_KZ0mGX.js +851 -0
  75. package/dist/php-A19QHzQV.js +500 -0
  76. package/dist/pla-COeKY1hA.js +137 -0
  77. package/dist/postiats-BfMp7zJL.js +907 -0
  78. package/dist/powerquery-B0TS_5Gb.js +890 -0
  79. package/dist/powershell-5jSbKdYB.js +239 -0
  80. package/dist/protobuf-YgnOutn3.js +420 -0
  81. package/dist/pug-DLej6kn5.js +402 -0
  82. package/dist/python-CQrZx9mR.js +301 -0
  83. package/dist/python.contribution-CcKs2Ktm.js +8 -0
  84. package/dist/qsharp-AhjqtSHB.js +301 -0
  85. package/dist/r-D-F4P80w.js +243 -0
  86. package/dist/razor-DWmpHMcx.js +550 -0
  87. package/dist/redis-hwwIlMnV.js +302 -0
  88. package/dist/redshift-Bcm_kjEG.js +809 -0
  89. package/dist/restructuredtext-CrdzfPP-.js +174 -0
  90. package/dist/ruby-QC2UNm1s.js +511 -0
  91. package/dist/rust-5aqiQ3L5.js +343 -0
  92. package/dist/sb-B1g1ZfLJ.js +115 -0
  93. package/dist/scala-C2U4R5Gb.js +370 -0
  94. package/dist/scheme-DeFRbslr.js +108 -0
  95. package/dist/scss-RSTCiCmI.js +262 -0
  96. package/dist/shell-BpF-iNu8.js +221 -0
  97. package/dist/shell.contribution-B80NZ3iO.js +7 -0
  98. package/dist/solidity-C00r2mbQ.js +1367 -0
  99. package/dist/sophia-DVW5ZKDB.js +199 -0
  100. package/dist/sparql-B0nmpxeX.js +201 -0
  101. package/dist/sql-CJwKPERn.js +853 -0
  102. package/dist/sql.contribution-DQy36aE5.js +7 -0
  103. package/dist/st-DPlKG5DT.js +416 -0
  104. package/dist/swift-YZBAbVHV.js +309 -0
  105. package/dist/systemverilog-CDQSaH63.js +576 -0
  106. package/dist/tcl-Dlu8sp6Q.js +232 -0
  107. package/dist/tsMode-Bh-v12OL.js +887 -0
  108. package/dist/twig-C5TO7-kw.js +392 -0
  109. package/dist/typescript-c7y6IZVP.js +343 -0
  110. package/dist/typespec-BsmjDEu7.js +117 -0
  111. package/dist/useFieldRendering-BIqeE3qo.js +6083 -0
  112. package/dist/vb-ChHvIDrk.js +372 -0
  113. package/dist/wgsl-XEp1ju8c.js +439 -0
  114. package/dist/xml-MAEprTnF.js +95 -0
  115. package/dist/xml.contribution-XMOaon8i.js +27 -0
  116. package/dist/yaml-C1p8rXG7.js +206 -0
  117. package/dist/yaml.contribution-DRRVhJmJ.js +8 -0
  118. package/package.json +88 -0
  119. package/src/__tests__/client-assigner.test.ts +341 -0
  120. package/src/__tests__/code-types.test.ts +30 -0
  121. package/src/__tests__/markdown-field.test.ts +34 -0
  122. package/src/__tests__/markdown-note-field.test.ts +135 -0
  123. package/src/__tests__/quiz-recorder.test.ts +195 -0
  124. package/src/__tests__/recorder-editor-content-sync.test.ts +172 -0
  125. package/src/__tests__/recorder-editor.test.ts +143 -0
  126. package/src/__tests__/recorder-render.test.ts +57 -0
  127. package/src/__tests__/recorder-wysiwyg-field-host.test.ts +33 -0
  128. package/src/__tests__/step-field.test.ts +270 -0
  129. package/src/__tests__/type-plugins.test.ts +59 -0
  130. package/src/__tests__/var-field-render.test.ts +26 -0
  131. package/src/client-assigner.ts +269 -0
  132. package/src/code-types.ts +94 -0
  133. package/src/components/AimdCodeField.vue +228 -0
  134. package/src/components/AimdDnaSequenceField.vue +983 -0
  135. package/src/components/AimdMarkdownField.vue +168 -0
  136. package/src/components/AimdMarkdownNoteField.vue +457 -0
  137. package/src/components/AimdQuizRecorder.vue +792 -0
  138. package/src/components/AimdRecorder.vue +1959 -0
  139. package/src/components/AimdRecorderEditor.vue +2281 -0
  140. package/src/components/AimdRecorderWysiwygFieldHost.vue +93 -0
  141. package/src/components/AimdRecorderWysiwygSurface.vue +487 -0
  142. package/src/components/AimdSeqVizViewer.vue +122 -0
  143. package/src/components/AimdStepCheckField.vue +453 -0
  144. package/src/components/AimdVarField.vue +213 -0
  145. package/src/components/AimdVarTableField.vue +516 -0
  146. package/src/components/DnaAnnotationEditor.vue +477 -0
  147. package/src/components/DnaSequenceEditor.vue +44 -0
  148. package/src/components/DnaSequenceToolbar.vue +98 -0
  149. package/src/components/DnaSequenceViewer.vue +162 -0
  150. package/src/components/index.ts +21 -0
  151. package/src/components/recorderMilkdownPlugin.ts +632 -0
  152. package/src/composables/__tests__/useDnaSequence.test.ts +467 -0
  153. package/src/composables/__tests__/useFieldAdapters.test.ts +115 -0
  154. package/src/composables/__tests__/useFocusManagement.test.ts +66 -0
  155. package/src/composables/__tests__/useRecordState.test.ts +586 -0
  156. package/src/composables/__tests__/useStepTimers.test.ts +64 -0
  157. package/src/composables/__tests__/useVarHelpers.test.ts +424 -0
  158. package/src/composables/__tests__/workbenchFieldEditing.test.ts +97 -0
  159. package/src/composables/index.ts +94 -0
  160. package/src/composables/useClientAssignerRunner.ts +74 -0
  161. package/src/composables/useDnaSequence.ts +400 -0
  162. package/src/composables/useDnaSequenceField.ts +316 -0
  163. package/src/composables/useFieldAdapters.ts +61 -0
  164. package/src/composables/useFieldRendering.ts +269 -0
  165. package/src/composables/useFocusManagement.ts +144 -0
  166. package/src/composables/useRecordState.ts +429 -0
  167. package/src/composables/useStepTimers.ts +243 -0
  168. package/src/composables/useVarHelpers.ts +545 -0
  169. package/src/composables/useVarTableDragDrop.ts +236 -0
  170. package/src/composables/workbenchFieldEditing.ts +705 -0
  171. package/src/css.d.ts +9 -0
  172. package/src/index.ts +65 -0
  173. package/src/locales.ts +559 -0
  174. package/src/monaco-code.ts +75 -0
  175. package/src/styles/aimd.css +994 -0
  176. package/src/type-plugins.ts +132 -0
  177. package/src/type-utils.ts +3 -0
  178. package/src/types.ts +191 -0
@@ -0,0 +1,168 @@
1
+ <script setup lang="ts">
2
+ import { ref, watch } from 'vue'
3
+ import { AimdEditor } from '@airalogy/aimd-editor/vue'
4
+ import type { AimdRecorderMessages } from '../locales'
5
+ import { getAimdRecorderScopeLabel } from '../locales'
6
+
7
+ const props = withDefaults(defineProps<{
8
+ modelValue?: unknown
9
+ varId: string
10
+ disabled?: boolean
11
+ locale?: string
12
+ messages: Pick<AimdRecorderMessages, 'scope'>
13
+ }>(), {
14
+ modelValue: undefined,
15
+ disabled: false,
16
+ locale: undefined,
17
+ })
18
+
19
+ const emit = defineEmits<{
20
+ (e: 'update:modelValue', value: string): void
21
+ (e: 'blur'): void
22
+ }>()
23
+
24
+ function normalizeMarkdownModelValue(value: unknown): string {
25
+ if (typeof value === 'string') {
26
+ return value
27
+ }
28
+
29
+ if (value == null) {
30
+ return ''
31
+ }
32
+
33
+ return String(value)
34
+ }
35
+
36
+ const fieldRootRef = ref<HTMLElement | null>(null)
37
+ const draftValue = ref(normalizeMarkdownModelValue(props.modelValue))
38
+
39
+ function emitDraftValue(markdown: string) {
40
+ if (markdown === draftValue.value) {
41
+ return
42
+ }
43
+
44
+ draftValue.value = markdown
45
+ emit('update:modelValue', markdown)
46
+ }
47
+
48
+ function emitBlurIfLeavingField(event: FocusEvent) {
49
+ const currentTarget = fieldRootRef.value
50
+ const nextTarget = event.relatedTarget as Node | null
51
+ if (!currentTarget || (nextTarget && currentTarget.contains(nextTarget))) {
52
+ return
53
+ }
54
+
55
+ emit('blur')
56
+ }
57
+
58
+ watch(() => props.modelValue, (value) => {
59
+ const nextValue = normalizeMarkdownModelValue(value)
60
+ if (nextValue === draftValue.value) {
61
+ return
62
+ }
63
+
64
+ draftValue.value = nextValue
65
+ })
66
+ </script>
67
+
68
+ <template>
69
+ <div
70
+ ref="fieldRootRef"
71
+ class="aimd-rec-inline aimd-rec-inline--var-stacked aimd-rec-inline--var-markdown aimd-field-wrapper aimd-markdown-field"
72
+ :class="{ 'aimd-markdown-field--disabled': disabled }"
73
+ @focusout="emitBlurIfLeavingField"
74
+ >
75
+ <span class="aimd-field aimd-field--no-style aimd-field__label">
76
+ <span class="aimd-field__scope aimd-field__scope--var">
77
+ {{ getAimdRecorderScopeLabel('var', messages) }}
78
+ </span>
79
+ <span class="aimd-field__id">{{ varId }}</span>
80
+ </span>
81
+
82
+ <div class="aimd-markdown-field__editor-shell">
83
+ <AimdEditor
84
+ class="aimd-markdown-field__editor"
85
+ :model-value="draftValue"
86
+ :locale="locale"
87
+ mode="source"
88
+ theme="aimd-light"
89
+ :show-top-bar="true"
90
+ :show-toolbar="!disabled"
91
+ :show-md-toolbar="true"
92
+ :show-aimd-toolbar="true"
93
+ :enable-block-handle="!disabled"
94
+ :keep-inactive-editors-mounted="false"
95
+ :min-height="360"
96
+ :readonly="disabled"
97
+ :monaco-options="{ minimap: { enabled: false } }"
98
+ @update:model-value="emitDraftValue"
99
+ />
100
+ </div>
101
+ </div>
102
+ </template>
103
+
104
+ <style scoped>
105
+ .aimd-markdown-field {
106
+ width: min(100%, 1040px);
107
+ min-width: 0;
108
+ max-width: 100%;
109
+ }
110
+
111
+ .aimd-markdown-field__editor-shell {
112
+ width: 100%;
113
+ min-width: 0;
114
+ background: #fff;
115
+ }
116
+
117
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor) {
118
+ border: 0 none;
119
+ border-radius: 0;
120
+ overflow: visible;
121
+ background: transparent;
122
+ }
123
+
124
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-toolbar) {
125
+ border-bottom-color: #d9e6fb;
126
+ background: #fff;
127
+ }
128
+
129
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-panel) {
130
+ min-width: 0;
131
+ }
132
+
133
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-source-mode),
134
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-wysiwyg-mode) {
135
+ height: auto !important;
136
+ min-height: 360px;
137
+ overflow-y: visible !important;
138
+ background: #fff;
139
+ border-radius: 0 0 8px 8px;
140
+ }
141
+
142
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-source-mode) {
143
+ padding: 0 0 2px;
144
+ }
145
+
146
+ .aimd-markdown-field__editor-shell :deep(.aimd-editor-container) {
147
+ min-height: 360px;
148
+ }
149
+
150
+ .aimd-markdown-field__editor-shell :deep(.milkdown) {
151
+ min-height: 360px;
152
+ }
153
+
154
+ .aimd-markdown-field__editor-shell :deep(.milkdown-editor-content) {
155
+ min-height: 360px;
156
+ padding: 14px 16px 18px;
157
+ box-sizing: border-box;
158
+ }
159
+
160
+ .aimd-markdown-field__editor-shell :deep(.milkdown-editor-content--readonly) {
161
+ cursor: default;
162
+ background: #f8fbff;
163
+ }
164
+
165
+ .aimd-markdown-field--disabled {
166
+ opacity: 0.92;
167
+ }
168
+ </style>
@@ -0,0 +1,457 @@
1
+ <script setup lang="ts">
2
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, ref, shallowRef, watch, type VNode } from 'vue'
3
+ import { AimdEditor } from '@airalogy/aimd-editor/vue'
4
+ import { renderToVue } from '@airalogy/aimd-renderer'
5
+
6
+ type AimdEditorExpose = {
7
+ getMonacoEditor?: () => { focus?: () => void } | null
8
+ }
9
+
10
+ const props = withDefaults(defineProps<{
11
+ modelValue?: unknown
12
+ disabled?: boolean
13
+ locale?: string
14
+ minHeight?: number
15
+ }>(), {
16
+ modelValue: undefined,
17
+ disabled: false,
18
+ locale: undefined,
19
+ minHeight: 220,
20
+ })
21
+
22
+ const emit = defineEmits<{
23
+ (e: 'update:modelValue', value: string): void
24
+ (e: 'blur'): void
25
+ (e: 'close'): void
26
+ }>()
27
+
28
+ function normalizeMarkdownModelValue(value: unknown): string {
29
+ if (typeof value === 'string') {
30
+ return value
31
+ }
32
+
33
+ if (value == null) {
34
+ return ''
35
+ }
36
+
37
+ return String(value)
38
+ }
39
+
40
+ function isZhLocale(locale?: string): boolean {
41
+ return locale?.toLowerCase().startsWith('zh') ?? false
42
+ }
43
+
44
+ const fieldRootRef = ref<HTMLElement | null>(null)
45
+ const editorRef = ref<AimdEditorExpose | null>(null)
46
+ const draftValue = ref(normalizeMarkdownModelValue(props.modelValue))
47
+ const editing = ref(false)
48
+ const previewNodes = shallowRef<VNode[]>([])
49
+ const previewRenderFailed = ref(false)
50
+ let previewRenderRequestId = 0
51
+ let focusOutCheckTimer: ReturnType<typeof setTimeout> | null = null
52
+
53
+ const hasValue = computed(() => Boolean(draftValue.value.trim()))
54
+ const showPreview = computed(() => hasValue.value && !editing.value)
55
+ const showEditor = computed(() => !props.disabled && (!hasValue.value || editing.value))
56
+ const showEmptyState = computed(() => !showPreview.value && !showEditor.value)
57
+ const editLabel = computed(() => (isZhLocale(props.locale) ? '编辑备注' : 'Edit note'))
58
+ const closeLabel = computed(() => (isZhLocale(props.locale) ? '关闭备注' : 'Close note'))
59
+ const emptyLabel = computed(() => (isZhLocale(props.locale) ? '暂无备注' : 'No notes'))
60
+
61
+ const PreviewOutlet = defineComponent({
62
+ name: 'AimdMarkdownNotePreviewOutlet',
63
+ props: {
64
+ nodes: {
65
+ type: Array as () => VNode[],
66
+ required: true,
67
+ },
68
+ },
69
+ setup(previewProps) {
70
+ return () => previewProps.nodes
71
+ },
72
+ })
73
+
74
+ function syncEditingState() {
75
+ if (props.disabled) {
76
+ editing.value = false
77
+ return
78
+ }
79
+
80
+ if (!hasValue.value) {
81
+ editing.value = true
82
+ }
83
+ }
84
+
85
+ function emitDraftValue(markdown: string) {
86
+ if (markdown === draftValue.value) {
87
+ return
88
+ }
89
+
90
+ draftValue.value = markdown
91
+ emit('update:modelValue', markdown)
92
+ }
93
+
94
+ async function renderPreview() {
95
+ const currentContent = draftValue.value.trim()
96
+ const requestId = ++previewRenderRequestId
97
+
98
+ if (!currentContent) {
99
+ previewNodes.value = []
100
+ previewRenderFailed.value = false
101
+ return
102
+ }
103
+
104
+ try {
105
+ const rendered = await renderToVue(currentContent, {
106
+ locale: props.locale,
107
+ })
108
+
109
+ if (requestId !== previewRenderRequestId) {
110
+ return
111
+ }
112
+
113
+ previewNodes.value = rendered.nodes
114
+ previewRenderFailed.value = false
115
+ } catch {
116
+ if (requestId !== previewRenderRequestId) {
117
+ return
118
+ }
119
+
120
+ previewNodes.value = []
121
+ previewRenderFailed.value = true
122
+ }
123
+ }
124
+
125
+ async function beginEditing() {
126
+ if (props.disabled) {
127
+ return
128
+ }
129
+
130
+ editing.value = true
131
+ await nextTick()
132
+ editorRef.value?.getMonacoEditor?.()?.focus?.()
133
+ }
134
+
135
+ function closeEditor() {
136
+ clearPendingFocusOutCheck()
137
+ editing.value = false
138
+ emit('close')
139
+ emit('blur')
140
+ }
141
+
142
+ function handlePreviewClick(event: MouseEvent) {
143
+ if (props.disabled) {
144
+ return
145
+ }
146
+
147
+ if (event.target instanceof Element && event.target.closest('a, button, input, textarea, select, summary, details')) {
148
+ return
149
+ }
150
+
151
+ void beginEditing()
152
+ }
153
+
154
+ function handlePreviewKeydown(event: KeyboardEvent) {
155
+ if (props.disabled) {
156
+ return
157
+ }
158
+
159
+ if (event.key !== 'Enter' && event.key !== ' ') {
160
+ return
161
+ }
162
+
163
+ event.preventDefault()
164
+ void beginEditing()
165
+ }
166
+
167
+ function clearPendingFocusOutCheck() {
168
+ if (focusOutCheckTimer) {
169
+ clearTimeout(focusOutCheckTimer)
170
+ focusOutCheckTimer = null
171
+ }
172
+ }
173
+
174
+ function handleFocusIn() {
175
+ clearPendingFocusOutCheck()
176
+ }
177
+
178
+ function emitBlurIfLeavingField(event: FocusEvent) {
179
+ const currentTarget = fieldRootRef.value
180
+ const nextTarget = event.relatedTarget as Node | null
181
+ if (!currentTarget || (nextTarget && currentTarget.contains(nextTarget))) {
182
+ return
183
+ }
184
+
185
+ clearPendingFocusOutCheck()
186
+ focusOutCheckTimer = setTimeout(() => {
187
+ focusOutCheckTimer = null
188
+ const activeElement = typeof document !== 'undefined' ? document.activeElement : null
189
+ if (activeElement instanceof Node && currentTarget.contains(activeElement)) {
190
+ return
191
+ }
192
+
193
+ if (hasValue.value) {
194
+ editing.value = false
195
+ }
196
+
197
+ emit('blur')
198
+ }, 0)
199
+ }
200
+
201
+ watch(() => props.modelValue, (value) => {
202
+ const nextValue = normalizeMarkdownModelValue(value)
203
+ if (nextValue === draftValue.value) {
204
+ return
205
+ }
206
+
207
+ draftValue.value = nextValue
208
+ })
209
+
210
+ watch(
211
+ () => [draftValue.value, props.locale] as const,
212
+ () => {
213
+ syncEditingState()
214
+ void renderPreview()
215
+ },
216
+ { immediate: true },
217
+ )
218
+
219
+ watch(() => props.disabled, () => {
220
+ syncEditingState()
221
+ })
222
+
223
+ onBeforeUnmount(() => {
224
+ clearPendingFocusOutCheck()
225
+ })
226
+ </script>
227
+
228
+ <template>
229
+ <div
230
+ ref="fieldRootRef"
231
+ class="aimd-markdown-note-field"
232
+ :class="{
233
+ 'aimd-markdown-note-field--disabled': disabled,
234
+ 'aimd-markdown-note-field--preview': showPreview,
235
+ 'aimd-markdown-note-field--editor': showEditor,
236
+ 'aimd-markdown-note-field--empty': showEmptyState,
237
+ }"
238
+ @focusin="handleFocusIn"
239
+ @focusout="emitBlurIfLeavingField"
240
+ >
241
+ <div v-if="showPreview" class="aimd-markdown-note-field__preview-shell">
242
+ <div v-if="!disabled" class="aimd-markdown-note-field__preview-actions">
243
+ <button
244
+ type="button"
245
+ class="aimd-markdown-note-field__preview-edit"
246
+ @click="beginEditing"
247
+ >
248
+ {{ editLabel }}
249
+ </button>
250
+ </div>
251
+ <div
252
+ class="aimd-markdown-note-field__preview"
253
+ :class="{ 'aimd-markdown-note-field__preview--interactive': !disabled }"
254
+ :tabindex="disabled ? undefined : 0"
255
+ :role="disabled ? undefined : 'button'"
256
+ @click="handlePreviewClick"
257
+ @keydown="handlePreviewKeydown"
258
+ >
259
+ <pre
260
+ v-if="previewRenderFailed"
261
+ class="aimd-markdown-note-field__preview-fallback"
262
+ >{{ draftValue }}</pre>
263
+ <PreviewOutlet v-else :nodes="previewNodes" />
264
+ </div>
265
+ </div>
266
+
267
+ <div v-else-if="showEditor" class="aimd-markdown-note-field__editor-shell">
268
+ <div class="aimd-markdown-note-field__editor-actions">
269
+ <button
270
+ type="button"
271
+ class="aimd-markdown-note-field__editor-close"
272
+ @click="closeEditor"
273
+ >
274
+ {{ closeLabel }}
275
+ </button>
276
+ </div>
277
+ <AimdEditor
278
+ ref="editorRef"
279
+ class="aimd-markdown-note-field__editor"
280
+ :model-value="draftValue"
281
+ :locale="locale"
282
+ mode="source"
283
+ theme="aimd-light"
284
+ :show-top-bar="true"
285
+ :show-toolbar="!disabled"
286
+ :show-md-toolbar="true"
287
+ :show-aimd-toolbar="true"
288
+ :enable-block-handle="!disabled"
289
+ :keep-inactive-editors-mounted="false"
290
+ :min-height="minHeight"
291
+ :readonly="disabled"
292
+ :monaco-options="{ minimap: { enabled: false } }"
293
+ @update:model-value="emitDraftValue"
294
+ />
295
+ </div>
296
+
297
+ <div v-else class="aimd-markdown-note-field__empty">
298
+ {{ emptyLabel }}
299
+ </div>
300
+ </div>
301
+ </template>
302
+
303
+ <style scoped>
304
+ .aimd-markdown-note-field {
305
+ width: min(100%, 920px);
306
+ min-width: 0;
307
+ max-width: 100%;
308
+ background: #fff;
309
+ border: 1px solid #d8e1ee;
310
+ border-radius: 10px;
311
+ overflow: hidden;
312
+ }
313
+
314
+ .aimd-markdown-note-field--preview,
315
+ .aimd-markdown-note-field--empty {
316
+ background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
317
+ }
318
+
319
+ .aimd-markdown-note-field__preview-shell {
320
+ min-width: 0;
321
+ }
322
+
323
+ .aimd-markdown-note-field__preview-actions {
324
+ display: flex;
325
+ justify-content: flex-end;
326
+ padding: 8px 8px 0;
327
+ }
328
+
329
+ .aimd-markdown-note-field__preview-edit {
330
+ border: 1px solid #d1d9e6;
331
+ border-radius: 999px;
332
+ min-height: 26px;
333
+ padding: 0 10px;
334
+ background: #fff;
335
+ color: #475569;
336
+ font-size: 12px;
337
+ font-weight: 600;
338
+ cursor: pointer;
339
+ transition: border-color 0.2s, background-color 0.2s, color 0.2s;
340
+ }
341
+
342
+ .aimd-markdown-note-field__preview-edit:hover {
343
+ border-color: #9db1cc;
344
+ background: #f7faff;
345
+ color: #1f4f8f;
346
+ }
347
+
348
+ .aimd-markdown-note-field__editor-shell {
349
+ min-width: 0;
350
+ }
351
+
352
+ .aimd-markdown-note-field__editor-actions {
353
+ display: flex;
354
+ justify-content: flex-end;
355
+ padding: 8px 8px 0;
356
+ background: #fff;
357
+ }
358
+
359
+ .aimd-markdown-note-field__editor-close {
360
+ border: 1px solid #d1d9e6;
361
+ border-radius: 999px;
362
+ min-height: 26px;
363
+ padding: 0 10px;
364
+ background: #fff;
365
+ color: #64748b;
366
+ font-size: 12px;
367
+ font-weight: 600;
368
+ cursor: pointer;
369
+ transition: border-color 0.2s, background-color 0.2s, color 0.2s;
370
+ }
371
+
372
+ .aimd-markdown-note-field__editor-close:hover {
373
+ border-color: #9db1cc;
374
+ background: #f8fbff;
375
+ color: #334155;
376
+ }
377
+
378
+ .aimd-markdown-note-field__preview {
379
+ min-width: 0;
380
+ padding: 6px 14px 14px;
381
+ color: #334155;
382
+ line-height: 1.65;
383
+ }
384
+
385
+ .aimd-markdown-note-field__preview--interactive {
386
+ cursor: text;
387
+ }
388
+
389
+ .aimd-markdown-note-field__preview--interactive:hover {
390
+ background: rgba(247, 250, 255, 0.7);
391
+ }
392
+
393
+ .aimd-markdown-note-field__preview--interactive:focus-visible {
394
+ outline: none;
395
+ box-shadow: inset 0 0 0 2px rgba(47, 111, 237, 0.12);
396
+ }
397
+
398
+ .aimd-markdown-note-field__preview-fallback {
399
+ margin: 0;
400
+ white-space: pre-wrap;
401
+ word-break: break-word;
402
+ font: inherit;
403
+ color: inherit;
404
+ }
405
+
406
+ .aimd-markdown-note-field__empty {
407
+ padding: 12px 14px;
408
+ color: #94a3b8;
409
+ font-size: 13px;
410
+ }
411
+
412
+ .aimd-markdown-note-field :deep(.aimd-editor) {
413
+ border: 0 none;
414
+ border-radius: 0;
415
+ overflow: visible;
416
+ background: transparent;
417
+ }
418
+
419
+ .aimd-markdown-note-field :deep(.aimd-editor-toolbar) {
420
+ border-bottom-color: #d9e6fb;
421
+ background: #fff;
422
+ }
423
+
424
+ .aimd-markdown-note-field :deep(.aimd-editor-panel) {
425
+ min-width: 0;
426
+ }
427
+
428
+ .aimd-markdown-note-field :deep(.aimd-editor-source-mode) {
429
+ background: #fff;
430
+ }
431
+
432
+ .aimd-markdown-note-field :deep(.aimd-editor-wysiwyg-mode) {
433
+ height: auto !important;
434
+ overflow-y: visible !important;
435
+ background: #fff;
436
+ }
437
+
438
+ .aimd-markdown-note-field :deep(p:first-child),
439
+ .aimd-markdown-note-field :deep(ul:first-child),
440
+ .aimd-markdown-note-field :deep(ol:first-child),
441
+ .aimd-markdown-note-field :deep(blockquote:first-child),
442
+ .aimd-markdown-note-field :deep(pre:first-child) {
443
+ margin-top: 0;
444
+ }
445
+
446
+ .aimd-markdown-note-field :deep(p:last-child),
447
+ .aimd-markdown-note-field :deep(ul:last-child),
448
+ .aimd-markdown-note-field :deep(ol:last-child),
449
+ .aimd-markdown-note-field :deep(blockquote:last-child),
450
+ .aimd-markdown-note-field :deep(pre:last-child) {
451
+ margin-bottom: 0;
452
+ }
453
+
454
+ .aimd-markdown-note-field--disabled {
455
+ opacity: 0.92;
456
+ }
457
+ </style>