@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,93 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import AimdRecorder from './AimdRecorder.vue'
4
+ import type { RecorderMilkdownSurfaceState } from './recorderMilkdownPlugin'
5
+
6
+ const props = defineProps<{
7
+ surfaceState: RecorderMilkdownSurfaceState
8
+ rawContent: string
9
+ displayMode: 'inline' | 'block'
10
+ }>()
11
+
12
+ const renderedContent = computed(() => (
13
+ props.displayMode === 'inline'
14
+ ? `<span class="aimd-recorder-wysiwyg-field-host__anchor" aria-hidden="true"></span>${props.rawContent}`
15
+ : props.rawContent
16
+ ))
17
+ </script>
18
+
19
+ <template>
20
+ <div
21
+ class="aimd-recorder-wysiwyg-field-host"
22
+ :class="`aimd-recorder-wysiwyg-field-host--${displayMode}`"
23
+ >
24
+ <AimdRecorder
25
+ :content="renderedContent"
26
+ :model-value="surfaceState.record"
27
+ :readonly="surfaceState.readonly"
28
+ :current-user-name="surfaceState.currentUserName"
29
+ :now="surfaceState.now"
30
+ :locale="surfaceState.locale"
31
+ :messages="surfaceState.messages"
32
+ :step-detail-display="surfaceState.stepDetailDisplay"
33
+ :field-meta="surfaceState.fieldMeta"
34
+ :field-state="surfaceState.fieldState"
35
+ :wrap-field="surfaceState.wrapField"
36
+ :custom-renderers="surfaceState.customRenderers"
37
+ :field-adapters="surfaceState.fieldAdapters"
38
+ :resolve-file="surfaceState.resolveFile"
39
+ :type-plugins="surfaceState.typePlugins"
40
+ @update:model-value="surfaceState.onUpdateRecord"
41
+ @fields-change="surfaceState.onFieldsChange?.($event)"
42
+ @error="surfaceState.onError?.($event)"
43
+ @field-change="surfaceState.onFieldChange?.($event)"
44
+ @field-blur="surfaceState.onFieldBlur?.($event)"
45
+ @assigner-request="surfaceState.onAssignerRequest?.($event)"
46
+ @assigner-cancel="surfaceState.onAssignerCancel?.($event)"
47
+ @table-add-row="surfaceState.onTableAddRow?.($event)"
48
+ @table-remove-row="surfaceState.onTableRemoveRow?.($event)"
49
+ />
50
+ </div>
51
+ </template>
52
+
53
+ <style scoped>
54
+ .aimd-recorder-wysiwyg-field-host {
55
+ min-width: 0;
56
+ }
57
+
58
+ .aimd-recorder-wysiwyg-field-host--inline {
59
+ display: inline-flex;
60
+ align-items: stretch;
61
+ max-width: min(100%, 760px);
62
+ vertical-align: middle;
63
+ }
64
+
65
+ .aimd-recorder-wysiwyg-field-host--block {
66
+ display: block;
67
+ width: 100%;
68
+ }
69
+
70
+ .aimd-recorder-wysiwyg-field-host :deep(.aimd-protocol-recorder__timing) {
71
+ display: none;
72
+ }
73
+
74
+ .aimd-recorder-wysiwyg-field-host :deep(.aimd-protocol-recorder__content) {
75
+ padding: 0;
76
+ border: 0;
77
+ border-radius: 0;
78
+ background: transparent;
79
+ box-shadow: none;
80
+ }
81
+
82
+ .aimd-recorder-wysiwyg-field-host :deep(.aimd-protocol-recorder__empty) {
83
+ display: none;
84
+ }
85
+
86
+ .aimd-recorder-wysiwyg-field-host :deep(.aimd-recorder-wysiwyg-field-host__anchor) {
87
+ display: none;
88
+ }
89
+
90
+ .aimd-recorder-wysiwyg-field-host--inline :deep(.aimd-protocol-recorder) {
91
+ width: auto;
92
+ }
93
+ </style>
@@ -0,0 +1,487 @@
1
+ <script setup lang="ts">
2
+ import { computed, getCurrentInstance, reactive, ref, watch, watchEffect } from 'vue'
3
+ import { parseAndExtract } from '@airalogy/aimd-renderer'
4
+ import {
5
+ AimdEditorToolbar,
6
+ AimdFieldDialog,
7
+ AimdWysiwygEditor,
8
+ createAimdEditorMessages,
9
+ createAimdFieldTypes,
10
+ createMdToolbarItems,
11
+ getQuickAimdSyntax,
12
+ useEditorContent,
13
+ } from '@airalogy/aimd-editor/vue'
14
+ import type { AimdVarTypePresetOption } from '@airalogy/aimd-editor/vue'
15
+ import type { ExtractedAimdFields } from '@airalogy/aimd-core/types'
16
+ import type { AimdComponentRenderer } from '@airalogy/aimd-renderer'
17
+ import type { AimdRecorderMessagesInput } from '../locales'
18
+ import type {
19
+ AimdFieldMeta,
20
+ AimdFieldState,
21
+ AimdProtocolRecordData,
22
+ AimdRecorderFieldAdapters,
23
+ AimdStepDetailDisplay,
24
+ AimdTypePlugin,
25
+ FieldEventPayload,
26
+ TableEventPayload,
27
+ } from '../types'
28
+ import {
29
+ cloneRecordData,
30
+ getRecordDataSignature,
31
+ normalizeIncomingRecord,
32
+ applyIncomingRecord,
33
+ } from '../composables/useRecordState'
34
+ import { createEmptyProtocolRecordData } from '../types'
35
+ import {
36
+ createRecorderMilkdownPlugins,
37
+ type RecorderMilkdownFieldIdentity,
38
+ type RecorderMilkdownSurfaceState,
39
+ } from './recorderMilkdownPlugin'
40
+
41
+ const RECORDER_EDITABLE_FIELD_TYPES = ['var', 'var_table', 'quiz', 'step', 'check'] as const
42
+ const RECORDER_EDITABLE_FIELD_SET = new Set<string>(RECORDER_EDITABLE_FIELD_TYPES)
43
+ const recorderEditableFieldTypesList = [...RECORDER_EDITABLE_FIELD_TYPES]
44
+
45
+ const props = withDefaults(defineProps<{
46
+ content: string
47
+ modelValue?: Partial<AimdProtocolRecordData>
48
+ minHeight?: number
49
+ locale?: string
50
+ readonly?: boolean
51
+ currentUserName?: string
52
+ now?: Date | string | number
53
+ messages?: AimdRecorderMessagesInput
54
+ stepDetailDisplay?: AimdStepDetailDisplay
55
+ fieldMeta?: Record<string, AimdFieldMeta>
56
+ fieldState?: Record<string, AimdFieldState>
57
+ wrapField?: (fieldKey: string, fieldType: string, defaultVNode: any) => any
58
+ customRenderers?: Partial<Record<string, AimdComponentRenderer>>
59
+ fieldAdapters?: AimdRecorderFieldAdapters
60
+ resolveFile?: (src: string) => string | null
61
+ typePlugins?: AimdTypePlugin[]
62
+ enableBlockHandle?: boolean
63
+ }>(), {
64
+ modelValue: undefined,
65
+ minHeight: 560,
66
+ locale: undefined,
67
+ readonly: false,
68
+ currentUserName: undefined,
69
+ now: undefined,
70
+ messages: undefined,
71
+ stepDetailDisplay: 'auto',
72
+ fieldMeta: undefined,
73
+ fieldState: undefined,
74
+ wrapField: undefined,
75
+ customRenderers: undefined,
76
+ fieldAdapters: undefined,
77
+ resolveFile: undefined,
78
+ typePlugins: undefined,
79
+ enableBlockHandle: true,
80
+ })
81
+
82
+ const emit = defineEmits<{
83
+ (e: 'update:content', value: string): void
84
+ (e: 'update:modelValue', value: AimdProtocolRecordData): void
85
+ (e: 'ready', editor: { milkdown?: any }): void
86
+ (e: 'fields-change', fields: ExtractedAimdFields): void
87
+ (e: 'error', message: string): void
88
+ (e: 'field-change', payload: FieldEventPayload): void
89
+ (e: 'field-blur', payload: FieldEventPayload): void
90
+ (e: 'assigner-request', payload: FieldEventPayload): void
91
+ (e: 'assigner-cancel', payload: FieldEventPayload): void
92
+ (e: 'table-add-row', payload: TableEventPayload): void
93
+ (e: 'table-remove-row', payload: TableEventPayload): void
94
+ (e: 'edit-field', field: RecorderMilkdownFieldIdentity): void
95
+ (e: 'delete-field', field: RecorderMilkdownFieldIdentity): void
96
+ }>()
97
+
98
+ const resolvedEditorMessages = computed(() => createAimdEditorMessages(props.locale))
99
+ const localizedFieldTypes = computed(() => (
100
+ createAimdFieldTypes(resolvedEditorMessages.value)
101
+ .filter(fieldType => RECORDER_EDITABLE_FIELD_SET.has(fieldType.type))
102
+ ))
103
+ const localizedMdToolbarItems = computed(() => createMdToolbarItems(resolvedEditorMessages.value))
104
+ const dropCursorLabel = computed(() => ((props.locale || '').toLowerCase().startsWith('zh') ? '拖到这里' : 'Drop here'))
105
+ const surfaceCssVars = computed(() => ({
106
+ '--aimd-recorder-drop-label': JSON.stringify(dropCursorLabel.value),
107
+ }))
108
+ const dialogVarTypePlugins = computed<AimdVarTypePresetOption[]>(() => (
109
+ (props.typePlugins ?? []).map(plugin => ({
110
+ key: plugin.type,
111
+ value: plugin.type,
112
+ label: plugin.type,
113
+ desc: '',
114
+ }))
115
+ ))
116
+
117
+ const {
118
+ content,
119
+ syncFromProp,
120
+ insertTextIntoActiveEditor,
121
+ handleMdAction,
122
+ onMilkdownMarkdownUpdated,
123
+ onMilkdownReady,
124
+ } = useEditorContent({
125
+ initialContent: props.content,
126
+ initialMode: 'wysiwyg',
127
+ resolvedMessages: resolvedEditorMessages,
128
+ emitModelValue: value => emit('update:content', value),
129
+ emitMode: () => {},
130
+ })
131
+
132
+ watch(() => props.content, (value) => {
133
+ syncFromProp(value)
134
+ })
135
+
136
+ watch(content, (value) => {
137
+ try {
138
+ emit('fields-change', parseAndExtract(value))
139
+ } catch (error) {
140
+ emit('error', error instanceof Error ? error.message : String(error))
141
+ }
142
+ }, { immediate: true })
143
+
144
+ const recordState = reactive(createEmptyProtocolRecordData())
145
+
146
+ watch(() => props.modelValue, (value) => {
147
+ const normalized = normalizeIncomingRecord(value)
148
+ if (getRecordDataSignature(normalized) === getRecordDataSignature(recordState)) {
149
+ return
150
+ }
151
+
152
+ applyIncomingRecord(recordState, normalized)
153
+ }, { deep: true, immediate: true })
154
+
155
+ function handleRecordUpdate(value: AimdProtocolRecordData) {
156
+ applyIncomingRecord(recordState, value)
157
+ emit('update:modelValue', cloneRecordData(recordState))
158
+ }
159
+
160
+ const surfaceState = reactive<RecorderMilkdownSurfaceState>({
161
+ record: recordState,
162
+ readonly: props.readonly,
163
+ currentUserName: props.currentUserName,
164
+ now: props.now,
165
+ locale: props.locale,
166
+ messages: props.messages,
167
+ stepDetailDisplay: props.stepDetailDisplay,
168
+ fieldMeta: props.fieldMeta,
169
+ fieldState: props.fieldState,
170
+ wrapField: props.wrapField,
171
+ customRenderers: props.customRenderers,
172
+ fieldAdapters: props.fieldAdapters,
173
+ resolveFile: props.resolveFile,
174
+ typePlugins: props.typePlugins,
175
+ onUpdateRecord: handleRecordUpdate,
176
+ onError: (message) => emit('error', message),
177
+ onFieldChange: (payload) => emit('field-change', payload),
178
+ onFieldBlur: (payload) => emit('field-blur', payload),
179
+ onAssignerRequest: (payload) => emit('assigner-request', payload),
180
+ onAssignerCancel: (payload) => emit('assigner-cancel', payload),
181
+ onTableAddRow: (payload) => emit('table-add-row', payload),
182
+ onTableRemoveRow: (payload) => emit('table-remove-row', payload),
183
+ })
184
+
185
+ watchEffect(() => {
186
+ surfaceState.readonly = props.readonly
187
+ surfaceState.currentUserName = props.currentUserName
188
+ surfaceState.now = props.now
189
+ surfaceState.locale = props.locale
190
+ surfaceState.messages = props.messages
191
+ surfaceState.stepDetailDisplay = props.stepDetailDisplay
192
+ surfaceState.fieldMeta = props.fieldMeta
193
+ surfaceState.fieldState = props.fieldState
194
+ surfaceState.wrapField = props.wrapField
195
+ surfaceState.customRenderers = props.customRenderers
196
+ surfaceState.fieldAdapters = props.fieldAdapters
197
+ surfaceState.resolveFile = props.resolveFile
198
+ surfaceState.typePlugins = props.typePlugins
199
+ })
200
+
201
+ const instance = getCurrentInstance()
202
+ const recorderMilkdownPlugins = [
203
+ ...createRecorderMilkdownPlugins({
204
+ appContext: instance?.appContext ?? null,
205
+ surfaceState,
206
+ onEditField: field => emit('edit-field', field),
207
+ onDeleteField: field => emit('delete-field', field),
208
+ }),
209
+ ]
210
+
211
+ const refSuggestions = computed(() => {
212
+ try {
213
+ const fields = parseAndExtract(content.value)
214
+ return [...(fields.step || []), ...(fields.var || [])]
215
+ } catch {
216
+ return []
217
+ }
218
+ })
219
+
220
+ const showAimdDialog = ref(false)
221
+ const aimdDialogType = ref<string>('var')
222
+
223
+ function openAimdDialog(type: string) {
224
+ aimdDialogType.value = RECORDER_EDITABLE_FIELD_SET.has(type) ? type : 'var'
225
+ showAimdDialog.value = true
226
+ }
227
+
228
+ function quickInsertAimd(type: string) {
229
+ if (!RECORDER_EDITABLE_FIELD_SET.has(type)) {
230
+ return
231
+ }
232
+
233
+ insertTextIntoActiveEditor(getQuickAimdSyntax(type, resolvedEditorMessages.value))
234
+ }
235
+
236
+ function onDialogInsert(syntax: string) {
237
+ insertTextIntoActiveEditor(syntax)
238
+ }
239
+
240
+ function handleWysiwygReady(editor: any) {
241
+ onMilkdownReady(editor)
242
+ emit('ready', { milkdown: editor })
243
+ }
244
+
245
+ const wysiwygEditorRef = ref<InstanceType<typeof AimdWysiwygEditor> | null>(null)
246
+
247
+ defineExpose({
248
+ getEditor: () => wysiwygEditorRef.value?.getEditor?.(),
249
+ })
250
+ </script>
251
+
252
+ <template>
253
+ <div class="aimd-recorder-wysiwyg-surface" :style="surfaceCssVars">
254
+ <AimdEditorToolbar
255
+ :show-top-bar="false"
256
+ :show-md-toolbar="true"
257
+ :show-aimd-toolbar="true"
258
+ editor-mode="wysiwyg"
259
+ :resolved-messages="resolvedEditorMessages"
260
+ :localized-field-types="localizedFieldTypes"
261
+ :localized-md-toolbar-items="localizedMdToolbarItems"
262
+ @md-action="handleMdAction"
263
+ @open-aimd-dialog="openAimdDialog"
264
+ @quick-insert-aimd="quickInsertAimd"
265
+ />
266
+
267
+ <AimdWysiwygEditor
268
+ ref="wysiwygEditorRef"
269
+ :content="content"
270
+ :min-height="minHeight"
271
+ :enable-block-handle="enableBlockHandle"
272
+ :active="true"
273
+ :readonly="readonly"
274
+ :resolved-messages="resolvedEditorMessages"
275
+ :localized-field-types="localizedFieldTypes"
276
+ :milkdown-plugins="recorderMilkdownPlugins"
277
+ @markdown-updated="onMilkdownMarkdownUpdated"
278
+ @ready="handleWysiwygReady"
279
+ @open-aimd-dialog="openAimdDialog"
280
+ />
281
+
282
+ <AimdFieldDialog
283
+ :visible="showAimdDialog"
284
+ :initial-type="aimdDialogType"
285
+ :messages="resolvedEditorMessages"
286
+ :ref-suggestions="refSuggestions"
287
+ :var-type-plugins="dialogVarTypePlugins"
288
+ :allowed-types="recorderEditableFieldTypesList"
289
+ @update:visible="showAimdDialog = $event"
290
+ @insert="onDialogInsert"
291
+ />
292
+ </div>
293
+ </template>
294
+
295
+ <style scoped>
296
+ .aimd-recorder-wysiwyg-surface {
297
+ display: flex;
298
+ min-height: 0;
299
+ flex-direction: column;
300
+ }
301
+
302
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-editor-wysiwyg-mode) {
303
+ position: relative;
304
+ border: 1px solid #e0e7f1;
305
+ border-top: 0;
306
+ border-radius: 0 0 8px 8px;
307
+ }
308
+
309
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node) {
310
+ position: relative;
311
+ display: inline-flex;
312
+ max-width: 100%;
313
+ flex-direction: column;
314
+ gap: 0;
315
+ margin: 6px 2px;
316
+ vertical-align: middle;
317
+ }
318
+
319
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node--block) {
320
+ display: flex;
321
+ width: 100%;
322
+ }
323
+
324
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__chrome) {
325
+ position: absolute;
326
+ top: -12px;
327
+ right: -2px;
328
+ z-index: 3;
329
+ display: inline-flex;
330
+ align-items: center;
331
+ justify-content: space-between;
332
+ gap: 6px;
333
+ padding: 4px 6px;
334
+ border: 1px solid rgba(148, 163, 184, 0.35);
335
+ border-radius: 999px;
336
+ background: rgba(255, 255, 255, 0.96);
337
+ box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
338
+ color: #58708d;
339
+ font-size: 11px;
340
+ line-height: 1.2;
341
+ opacity: 0;
342
+ pointer-events: none;
343
+ transform: translateY(-4px);
344
+ transition:
345
+ opacity 0.16s ease,
346
+ transform 0.16s ease,
347
+ border-color 0.16s ease,
348
+ box-shadow 0.16s ease,
349
+ background 0.16s ease;
350
+ }
351
+
352
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__chrome--inline) {
353
+ padding: 3px 5px;
354
+ }
355
+
356
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__chrome--block) {
357
+ top: 10px;
358
+ right: 10px;
359
+ }
360
+
361
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__summary) {
362
+ max-width: 180px;
363
+ min-width: 0;
364
+ overflow: hidden;
365
+ text-overflow: ellipsis;
366
+ white-space: nowrap;
367
+ font-weight: 700;
368
+ }
369
+
370
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__chrome--inline .aimd-recorder-wysiwyg-node__summary) {
371
+ display: none;
372
+ }
373
+
374
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__actions) {
375
+ display: inline-flex;
376
+ align-items: center;
377
+ gap: 4px;
378
+ }
379
+
380
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__action) {
381
+ display: inline-flex;
382
+ align-items: center;
383
+ justify-content: center;
384
+ min-height: 24px;
385
+ padding: 0 8px;
386
+ border: 1px solid rgba(148, 163, 184, 0.28);
387
+ border-radius: 999px;
388
+ background: rgba(248, 250, 252, 0.96);
389
+ color: #36506a;
390
+ font-size: 10px;
391
+ font-weight: 600;
392
+ cursor: pointer;
393
+ }
394
+
395
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__action:hover:not([disabled])) {
396
+ border-color: rgba(59, 130, 246, 0.35);
397
+ background: #fff;
398
+ color: #17375a;
399
+ }
400
+
401
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__action[disabled]) {
402
+ cursor: not-allowed;
403
+ opacity: 0.45;
404
+ }
405
+
406
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__action--danger) {
407
+ color: #b93855;
408
+ }
409
+
410
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__drag) {
411
+ display: inline-flex;
412
+ align-items: center;
413
+ justify-content: center;
414
+ min-width: 26px;
415
+ min-height: 24px;
416
+ padding: 0 7px;
417
+ border: 1px solid rgba(148, 163, 184, 0.28);
418
+ border-radius: 999px;
419
+ background: rgba(248, 250, 252, 0.96);
420
+ color: #7b8ea3;
421
+ cursor: grab;
422
+ user-select: none;
423
+ }
424
+
425
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__drag:hover) {
426
+ border-color: rgba(59, 130, 246, 0.35);
427
+ background: #fff;
428
+ color: #36506a;
429
+ }
430
+
431
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node__body) {
432
+ min-width: 0;
433
+ max-width: 100%;
434
+ }
435
+
436
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node:hover .aimd-recorder-wysiwyg-node__chrome),
437
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node--selected .aimd-recorder-wysiwyg-node__chrome),
438
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node:focus-within .aimd-recorder-wysiwyg-node__chrome) {
439
+ opacity: 1;
440
+ pointer-events: auto;
441
+ transform: translateY(0);
442
+ }
443
+
444
+ .aimd-recorder-wysiwyg-surface :deep(.aimd-recorder-wysiwyg-node--selected .aimd-recorder-wysiwyg-node__chrome) {
445
+ border-color: rgba(122, 167, 255, 0.75);
446
+ background: rgba(238, 245, 255, 0.98);
447
+ box-shadow: 0 14px 28px rgba(47, 111, 237, 0.14);
448
+ }
449
+
450
+ :global(.aimd-recorder-dropcursor) {
451
+ position: absolute;
452
+ z-index: 70;
453
+ pointer-events: none;
454
+ border-radius: 999px;
455
+ background: linear-gradient(180deg, #60a5fa 0%, #2563eb 100%);
456
+ box-shadow:
457
+ 0 0 0 1px rgba(255, 255, 255, 0.95),
458
+ 0 0 0 5px rgba(37, 99, 235, 0.14),
459
+ 0 10px 22px rgba(37, 99, 235, 0.2);
460
+ }
461
+
462
+ :global(.aimd-recorder-dropcursor.prosemirror-dropcursor-block) {
463
+ min-height: 4px;
464
+ }
465
+
466
+ :global(.aimd-recorder-dropcursor.prosemirror-dropcursor-block::after) {
467
+ content: var(--aimd-recorder-drop-label, "Drop here");
468
+ position: absolute;
469
+ top: 50%;
470
+ right: 10px;
471
+ transform: translateY(-50%);
472
+ padding: 2px 8px;
473
+ border: 1px solid rgba(37, 99, 235, 0.18);
474
+ border-radius: 999px;
475
+ background: rgba(239, 246, 255, 0.96);
476
+ color: #1d4ed8;
477
+ font-size: 11px;
478
+ font-weight: 700;
479
+ letter-spacing: 0.01em;
480
+ white-space: nowrap;
481
+ }
482
+
483
+ :global(.aimd-recorder-dropcursor.prosemirror-dropcursor-inline) {
484
+ min-width: 4px;
485
+ border-radius: 999px;
486
+ }
487
+ </style>
@@ -0,0 +1,122 @@
1
+ <script setup lang="ts">
2
+ import { createElement } from "react"
3
+ import { createRoot, type Root } from "react-dom/client"
4
+ import SeqViz, { type SeqVizProps } from "seqviz"
5
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue"
6
+
7
+ export interface AimdSeqVizAnnotation {
8
+ id: string
9
+ name: string
10
+ start: number
11
+ end: number
12
+ direction?: 1 | -1
13
+ color?: string
14
+ }
15
+
16
+ export interface AimdSeqVizSelection {
17
+ clockwise?: boolean
18
+ color?: string
19
+ direction?: number
20
+ end?: number
21
+ id?: string
22
+ length?: number
23
+ name?: string
24
+ start?: number
25
+ type: string
26
+ viewer?: "LINEAR" | "CIRCULAR"
27
+ }
28
+
29
+ export interface AimdSeqVizExternalSelection {
30
+ clockwise?: boolean
31
+ end: number
32
+ start: number
33
+ }
34
+
35
+ const props = withDefaults(defineProps<{
36
+ name?: string
37
+ sequence: string
38
+ topology: "linear" | "circular"
39
+ annotations: AimdSeqVizAnnotation[]
40
+ selection?: AimdSeqVizExternalSelection | null
41
+ }>(), {
42
+ name: "",
43
+ selection: null,
44
+ })
45
+
46
+ const emit = defineEmits<{
47
+ (e: "selection", value: AimdSeqVizSelection): void
48
+ }>()
49
+
50
+ const containerRef = ref<HTMLDivElement | null>(null)
51
+ let root: Root | null = null
52
+
53
+ const viewerProps = computed<SeqVizProps>(() => ({
54
+ name: props.name,
55
+ seq: props.sequence,
56
+ seqType: "dna",
57
+ annotations: props.annotations as unknown as SeqVizProps["annotations"],
58
+ primers: [],
59
+ viewer: props.topology === "circular" ? "both" : "linear",
60
+ selection: props.selection ?? undefined,
61
+ disableExternalFonts: true,
62
+ rotateOnScroll: props.topology === "circular",
63
+ showComplement: true,
64
+ showIndex: true,
65
+ zoom: {
66
+ linear: props.topology === "circular" ? 36 : 52,
67
+ },
68
+ style: {
69
+ width: "100%",
70
+ minHeight: props.topology === "circular" ? "420px" : "280px",
71
+ height: props.topology === "circular" ? "420px" : "280px",
72
+ },
73
+ onSelection: selection => emit("selection", selection as unknown as AimdSeqVizSelection),
74
+ }))
75
+
76
+ function renderViewer() {
77
+ if (!containerRef.value) {
78
+ return
79
+ }
80
+
81
+ if (!root) {
82
+ root = createRoot(containerRef.value)
83
+ }
84
+
85
+ root.render(createElement(SeqViz, viewerProps.value))
86
+ }
87
+
88
+ let renderDebounceTimer: ReturnType<typeof setTimeout> | null = null
89
+
90
+ watch(viewerProps, () => {
91
+ if (renderDebounceTimer !== null) {
92
+ clearTimeout(renderDebounceTimer)
93
+ }
94
+ renderDebounceTimer = setTimeout(() => {
95
+ renderDebounceTimer = null
96
+ renderViewer()
97
+ }, 16)
98
+ }, { deep: true })
99
+
100
+ onMounted(() => {
101
+ renderViewer()
102
+ })
103
+
104
+ onBeforeUnmount(() => {
105
+ if (renderDebounceTimer !== null) {
106
+ clearTimeout(renderDebounceTimer)
107
+ }
108
+ root?.unmount()
109
+ root = null
110
+ })
111
+ </script>
112
+
113
+ <template>
114
+ <div ref="containerRef" class="aimd-seqviz-viewer" />
115
+ </template>
116
+
117
+ <style scoped>
118
+ .aimd-seqviz-viewer {
119
+ width: 100%;
120
+ min-height: 280px;
121
+ }
122
+ </style>