@airalogy/aimd-recorder 1.17.0 → 1.18.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/README.md +11 -10
- package/README.zh-CN.md +11 -10
- package/dist/AimdCodeField-BQUuM-EF.js +182 -0
- package/dist/{AimdDnaSequenceField-D6ZgCDpp.js → AimdDnaSequenceField-KZU2Zj3E.js} +2 -2
- package/dist/{AimdEditor.vue_vue_type_style_index_0_lang-B5Tq4zPV.js → AimdEditor.vue_vue_type_style_index_0_lang-CzfYPp5r.js} +3922 -3829
- package/dist/AimdMarkdownField-t2d8uOeU.js +254 -0
- package/dist/AimdMarkdownNoteField-_h1oZSwH.js +259 -0
- package/dist/{_commonjsHelpers-CZXJ37nu.js → _commonjsHelpers-B5RozER-.js} +2 -2
- package/dist/aimd-recorder.css +1 -1
- package/dist/arc-DS_ocYoe.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-Dq2W8_tb.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-B4hnSAF_.js +2425 -0
- package/dist/c4Diagram-AAUBKEIU-CbffqNLY.js +1577 -0
- package/dist/channel-CtXnYrAk.js +5 -0
- package/dist/chunk-2J33WTMH-CROScrt5.js +19 -0
- package/dist/chunk-4BX2VUAB-DTmsQu5_.js +8 -0
- package/dist/chunk-55IACEB6-B5wDJzeX.js +8 -0
- package/dist/chunk-727SXJPM-CfyltY6o.js +1528 -0
- package/dist/chunk-AQP2D5EJ-B8274EYy.js +1387 -0
- package/dist/chunk-FMBD7UC4-CT_FK-SH.js +19 -0
- package/dist/chunk-ND2GUHAM-g9GulPi-.js +68 -0
- package/dist/chunk-QZHKN3VN-Di5HEktz.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-BVUr246k.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-BVUr246k.js +16 -0
- package/dist/components.js +3279 -2216
- package/dist/composables.js +92 -68
- package/dist/cose-bilkent-S5V4N54A-GJ4IOO6v.js +2609 -0
- package/dist/cytoscape.esm-r59gEWFs.js +18710 -0
- package/dist/dagre-BM42HDAG-oL7Br44o.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-DtoCG_N4.js +217 -0
- package/dist/diagram-5GNKFQAL-f8QNdS7L.js +123 -0
- package/dist/diagram-KO2AKTUF-CsJOW_AX.js +461 -0
- package/dist/diagram-LMA3HP47-xmEKNZ7y.js +142 -0
- package/dist/diagram-OG6HWLK6-unpC7vo8.js +528 -0
- package/dist/erDiagram-TEJ5UH35-BGzFnCJD.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-LBFhDnOs.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-CFBc-jPD.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-BLduh-Rb.js +815 -0
- package/dist/graph-DdlKE625.js +1510 -0
- package/dist/index.js +104 -80
- package/dist/infoDiagram-5YYISTIA-CLQQI6zM.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-CStdYBmW.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-B6mRTzoE.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-C-vnN5v4.js +724 -0
- package/dist/katex-DNob3HGn.js +11690 -0
- package/dist/layout-DDt0fz-M.js +1703 -0
- package/dist/linear-C-IAFdOt.js +259 -0
- package/dist/mermaid.core-CuZ3nINf.js +15940 -0
- package/dist/mindmap-definition-RKZ34NQL-TSZ1Vb3z.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-DYok-1-k.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-Cg856sbH.js +1024 -0
- package/dist/requirementDiagram-4Y6WPE33-BN9fGdlJ.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-CDqTgonY.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-Chjrc0-W.js +2891 -0
- package/dist/stateDiagram-AJRCARHV-DRyLHrdr.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-CZTIDHid.js +16 -0
- package/dist/timeline-definition-PNZ67QCA-Bc3D9AAG.js +1055 -0
- package/dist/{useFieldRendering-xLajJhyA.js → useCodeBlockRendering-qA6gj4vz.js} +3035 -2254
- package/dist/useMonacoAutoHeight-D4T-El3J.js +66 -0
- package/dist/vennDiagram-CIIHVFJN-CYAul48m.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-B7Tg0MG9.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-xWYVEqth.js +1342 -0
- package/package.json +9 -8
- package/src/__tests__/assigner-runner-dependent-data.test.ts +32 -0
- package/src/__tests__/markdown-field.test.ts +150 -1
- package/src/__tests__/markdown-note-field.test.ts +86 -3
- package/src/__tests__/recorder-assigner-control.test.ts +844 -0
- package/src/__tests__/recorder-editor.test.ts +17 -0
- package/src/__tests__/recorder-markdown-assigner-integration.test.ts +49 -0
- package/src/__tests__/step-field.test.ts +47 -1
- package/src/__tests__/type-plugins.test.ts +1 -0
- package/src/__tests__/var-field-render.test.ts +741 -1
- package/src/components/AimdCodeField.vue +24 -5
- package/src/components/AimdMarkdownField.vue +548 -11
- package/src/components/AimdMarkdownNoteField.vue +241 -30
- package/src/components/AimdRecorder.vue +1521 -95
- package/src/components/AimdRecorderEditor.vue +276 -8
- package/src/components/AimdRecorderWysiwygFieldHost.vue +6 -0
- package/src/components/AimdRecorderWysiwygSurface.vue +32 -0
- package/src/components/AimdStepCheckField.vue +82 -18
- package/src/components/AimdVarField.vue +694 -25
- package/src/components/AimdVarTableField.vue +283 -110
- package/src/components/icons/AimdAssignerCalculatorIcon.vue +18 -0
- package/src/components/icons/AimdAssignerCloudStatusIcon.vue +22 -0
- package/src/components/recorderMilkdownPlugin.ts +14 -0
- package/src/composables/__tests__/useRecordState.test.ts +86 -0
- package/src/composables/__tests__/useVarHelpers.test.ts +133 -0
- package/src/composables/index.ts +27 -1
- package/src/composables/useAssignerRunner.ts +376 -0
- package/src/composables/useCodeBlockRendering.ts +51 -0
- package/src/composables/useFieldRendering.ts +32 -4
- package/src/composables/useMonacoAutoHeight.ts +127 -0
- package/src/composables/useRecordState.ts +22 -3
- package/src/composables/useVarHelpers.ts +377 -9
- package/src/index.ts +13 -0
- package/src/locales.ts +45 -0
- package/src/styles/aimd.css +151 -1
- package/src/type-plugins.ts +7 -0
- package/src/types.ts +93 -2
- package/dist/AimdCodeField-DC3DPvgc.js +0 -172
- package/dist/AimdMarkdownField-BJ20QtO8.js +0 -67
- package/dist/AimdMarkdownNoteField-DwAQhoyk.js +0 -186
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airalogy/aimd-recorder",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.18.0",
|
|
5
5
|
"description": "AIMD (Airalogy Markdown) recorder Vue components and UI",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/airalogy/
|
|
10
|
-
"directory": "packages/aimd-recorder"
|
|
9
|
+
"url": "https://github.com/airalogy/airalogy.git",
|
|
10
|
+
"directory": "packages/npm/aimd-recorder"
|
|
11
11
|
},
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/airalogy/
|
|
13
|
+
"url": "https://github.com/airalogy/airalogy/issues"
|
|
14
14
|
},
|
|
15
|
-
"homepage": "https://github.com/airalogy/
|
|
15
|
+
"homepage": "https://github.com/airalogy/airalogy/tree/main/packages/npm/aimd-recorder#readme",
|
|
16
16
|
"keywords": [
|
|
17
17
|
"aimd",
|
|
18
18
|
"markdown",
|
|
@@ -54,13 +54,14 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@milkdown/kit": "^7.18.0",
|
|
57
|
+
"mermaid": "^11.15.0",
|
|
57
58
|
"monaco-editor": "^0.52.2",
|
|
58
59
|
"react": "^19.2.4",
|
|
59
60
|
"react-dom": "^19.2.4",
|
|
60
61
|
"seqviz": "^3.10.18",
|
|
61
|
-
"@airalogy/aimd-
|
|
62
|
-
"@airalogy/aimd-core": "^2.
|
|
63
|
-
"@airalogy/aimd-
|
|
62
|
+
"@airalogy/aimd-renderer": "^2.6.0",
|
|
63
|
+
"@airalogy/aimd-core": "^2.8.0",
|
|
64
|
+
"@airalogy/aimd-editor": "^1.9.0"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@types/node": "^24.3.0",
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { buildAimdAssignerDependentData } from '../composables/useAssignerRunner'
|
|
3
|
+
|
|
4
|
+
describe('assigner dependent data normalization', () => {
|
|
5
|
+
it('drops empty placeholder rows from dependent var tables', () => {
|
|
6
|
+
const dependentData = buildAimdAssignerDependentData(
|
|
7
|
+
{
|
|
8
|
+
var: {
|
|
9
|
+
manual_edges: [
|
|
10
|
+
{},
|
|
11
|
+
{ from_site_id: '', to_site_id: '', note: '' },
|
|
12
|
+
{ from_site_id: 'S01', to_site_id: 'S02', note: '' },
|
|
13
|
+
],
|
|
14
|
+
blocked_edges: [{}],
|
|
15
|
+
},
|
|
16
|
+
step: {},
|
|
17
|
+
check: {},
|
|
18
|
+
quiz: {},
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
dependentFields: ['manual_edges', 'blocked_edges'],
|
|
22
|
+
},
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
expect(dependentData).toEqual({
|
|
26
|
+
manual_edges: [
|
|
27
|
+
{ from_site_id: 'S01', to_site_id: 'S02' },
|
|
28
|
+
],
|
|
29
|
+
blocked_edges: [],
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
@@ -1,13 +1,82 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs'
|
|
2
2
|
import { dirname, resolve } from 'node:path'
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
|
-
import {
|
|
4
|
+
import { flushPromises, mount } from '@vue/test-utils'
|
|
5
|
+
import { defineComponent, h, nextTick } from 'vue'
|
|
6
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
7
|
+
|
|
8
|
+
const { codePreRendererMock, createCodeBlockRendererMock, createMermaidRendererMock, loadShikiHighlighterMock, mermaidPreRendererMock, renderToVueMock } = vi.hoisted(() => {
|
|
9
|
+
const mermaidPreRendererMock = vi.fn()
|
|
10
|
+
const codePreRendererMock = vi.fn()
|
|
11
|
+
return {
|
|
12
|
+
codePreRendererMock,
|
|
13
|
+
createCodeBlockRendererMock: vi.fn(() => codePreRendererMock),
|
|
14
|
+
createMermaidRendererMock: vi.fn(() => mermaidPreRendererMock),
|
|
15
|
+
loadShikiHighlighterMock: vi.fn(() => new Promise(() => {})),
|
|
16
|
+
mermaidPreRendererMock,
|
|
17
|
+
renderToVueMock: vi.fn(),
|
|
18
|
+
}
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
vi.mock('@airalogy/aimd-editor/vue', () => ({
|
|
22
|
+
AimdEditor: defineComponent({
|
|
23
|
+
name: 'AimdEditorMock',
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: '',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
emits: ['update:modelValue'],
|
|
31
|
+
setup(props, { emit }) {
|
|
32
|
+
return () => h('textarea', {
|
|
33
|
+
class: 'aimd-editor-mock',
|
|
34
|
+
value: props.modelValue,
|
|
35
|
+
onInput: (event: Event) => emit('update:modelValue', (event.target as HTMLTextAreaElement).value),
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
}))
|
|
40
|
+
|
|
41
|
+
vi.mock('@airalogy/aimd-renderer', () => ({
|
|
42
|
+
createCodeBlockRenderer: createCodeBlockRendererMock,
|
|
43
|
+
createMermaidRenderer: createMermaidRendererMock,
|
|
44
|
+
loadShikiHighlighter: loadShikiHighlighterMock,
|
|
45
|
+
renderToVue: renderToVueMock,
|
|
46
|
+
}))
|
|
47
|
+
|
|
48
|
+
import AimdMarkdownField from '../components/AimdMarkdownField.vue'
|
|
5
49
|
|
|
6
50
|
const __filename = fileURLToPath(import.meta.url)
|
|
7
51
|
const __dirname = dirname(__filename)
|
|
8
52
|
const source = readFileSync(resolve(__dirname, '../components/AimdMarkdownField.vue'), 'utf8')
|
|
9
53
|
|
|
54
|
+
const recorderMessages = {
|
|
55
|
+
scope: {
|
|
56
|
+
var: '变量',
|
|
57
|
+
quiz: '题目',
|
|
58
|
+
step: '步骤',
|
|
59
|
+
check: '检查点',
|
|
60
|
+
table: '表格',
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function flushUi() {
|
|
65
|
+
await flushPromises()
|
|
66
|
+
await new Promise(resolve => setTimeout(resolve, 0))
|
|
67
|
+
await nextTick()
|
|
68
|
+
}
|
|
69
|
+
|
|
10
70
|
describe('AimdMarkdownField', () => {
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
createMermaidRendererMock.mockClear()
|
|
73
|
+
createCodeBlockRendererMock.mockClear()
|
|
74
|
+
loadShikiHighlighterMock.mockClear()
|
|
75
|
+
mermaidPreRendererMock.mockClear()
|
|
76
|
+
codePreRendererMock.mockClear()
|
|
77
|
+
renderToVueMock.mockReset()
|
|
78
|
+
})
|
|
79
|
+
|
|
11
80
|
it('embeds the full AimdEditor so toolbar controls remain available', () => {
|
|
12
81
|
expect(source).toMatch(/import \{ AimdEditor \} from '@airalogy\/aimd-editor\/vue'/)
|
|
13
82
|
expect(source).toMatch(/<AimdEditor/)
|
|
@@ -25,10 +94,90 @@ describe('AimdMarkdownField', () => {
|
|
|
25
94
|
expect(source).toMatch(/aimd-markdown-field__editor/)
|
|
26
95
|
})
|
|
27
96
|
|
|
97
|
+
it('fills the available recorder width as a block field', () => {
|
|
98
|
+
expect(source).toMatch(/\.aimd-markdown-field \{[\s\S]*?width: 100%;[\s\S]*?box-sizing: border-box;/)
|
|
99
|
+
expect(source).not.toContain('width: min(100%, 1040px);')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
it('starts the embedded AiralogyMarkdown editor at a compact content-driven height', () => {
|
|
103
|
+
expect(source).toContain('createMonacoAutoHeight')
|
|
104
|
+
expect(source).toMatch(/const markdownEditorHeight = markdownAutoHeight\.editorHeight/)
|
|
105
|
+
expect(source).toMatch(/markdownAutoHeight\.attachEditor\(editor\.monaco\)/)
|
|
106
|
+
expect(source).toMatch(/:min-height="markdownEditorHeight"/)
|
|
107
|
+
expect(source).toMatch(/@ready="handleMarkdownEditorReady"/)
|
|
108
|
+
expect(source).toContain('--aimd-markdown-field-editor-height')
|
|
109
|
+
expect(source).not.toMatch(/:min-height="360"/)
|
|
110
|
+
expect(source).not.toContain('min-height: 360px;')
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('can switch AiralogyMarkdown output into rendered preview mode', () => {
|
|
114
|
+
expect(source).toMatch(/renderToVue/)
|
|
115
|
+
expect(source).toMatch(/createMermaidRenderer/)
|
|
116
|
+
expect(source).toMatch(/aimd-markdown-field__view-switch/)
|
|
117
|
+
expect(source).toMatch(/aimd-markdown-field__preview/)
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('can host assigner controls inside the markdown field shell', () => {
|
|
121
|
+
expect(source).toMatch(/assignerControl/)
|
|
122
|
+
expect(source).toMatch(/assignerStatus/)
|
|
123
|
+
expect(source).toMatch(/aimd-markdown-field__assigner-actions/)
|
|
124
|
+
})
|
|
125
|
+
|
|
28
126
|
it('keeps a local draft so parent v-model echoes do not reset the editor session', () => {
|
|
29
127
|
expect(source).toMatch(/const draftValue = ref\(normalizeMarkdownModelValue\(props\.modelValue\)\)/)
|
|
30
128
|
expect(source).toMatch(/watch\(\(\) => props\.modelValue, \(value\) => \{/)
|
|
31
129
|
expect(source).toMatch(/if \(nextValue === draftValue\.value\)/)
|
|
32
130
|
expect(source).toMatch(/emitDraftValue/)
|
|
33
131
|
})
|
|
132
|
+
|
|
133
|
+
it('renders markdown previews through the renderer and wires Mermaid code fences', async () => {
|
|
134
|
+
renderToVueMock.mockImplementation(async (content: string) => ({
|
|
135
|
+
nodes: [h('div', { class: 'aimd-rendered-markdown' }, `rendered:${content}`)],
|
|
136
|
+
fields: {},
|
|
137
|
+
}))
|
|
138
|
+
|
|
139
|
+
const wrapper = mount(AimdMarkdownField, {
|
|
140
|
+
props: {
|
|
141
|
+
modelValue: '```mermaid\nflowchart TD\nA-->B\n```',
|
|
142
|
+
varId: 'graph_mermaid_preview',
|
|
143
|
+
locale: 'zh-CN',
|
|
144
|
+
messages: recorderMessages,
|
|
145
|
+
},
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
await flushUi()
|
|
149
|
+
|
|
150
|
+
expect(createMermaidRendererMock).toHaveBeenCalled()
|
|
151
|
+
expect(renderToVueMock).toHaveBeenCalledWith('```mermaid\nflowchart TD\nA-->B\n```', expect.objectContaining({
|
|
152
|
+
locale: 'zh-CN',
|
|
153
|
+
mode: 'preview',
|
|
154
|
+
elementRenderers: { pre: expect.any(Function) },
|
|
155
|
+
}))
|
|
156
|
+
expect(wrapper.find('.aimd-markdown-field__preview').exists()).toBe(true)
|
|
157
|
+
expect(wrapper.find('.aimd-rendered-markdown').text()).toContain('flowchart TD')
|
|
158
|
+
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(false)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
it('lets users switch from preview back to source editing', async () => {
|
|
162
|
+
renderToVueMock.mockImplementation(async (content: string) => ({
|
|
163
|
+
nodes: [h('div', { class: 'aimd-rendered-markdown' }, `rendered:${content}`)],
|
|
164
|
+
fields: {},
|
|
165
|
+
}))
|
|
166
|
+
|
|
167
|
+
const wrapper = mount(AimdMarkdownField, {
|
|
168
|
+
props: {
|
|
169
|
+
modelValue: '# Summary',
|
|
170
|
+
varId: 'graph_summary',
|
|
171
|
+
locale: 'en-US',
|
|
172
|
+
messages: recorderMessages,
|
|
173
|
+
},
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
await flushUi()
|
|
177
|
+
await wrapper.findAll('.aimd-markdown-field__view-btn')[1].trigger('click')
|
|
178
|
+
await nextTick()
|
|
179
|
+
|
|
180
|
+
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(true)
|
|
181
|
+
expect(wrapper.find('.aimd-markdown-field__preview').exists()).toBe(false)
|
|
182
|
+
})
|
|
34
183
|
})
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { dirname, resolve } from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
1
4
|
import { mount } from '@vue/test-utils'
|
|
2
5
|
import { defineComponent, h, nextTick } from 'vue'
|
|
3
6
|
import { describe, expect, it, vi } from 'vitest'
|
|
4
7
|
|
|
5
|
-
const { renderToVueMock } = vi.hoisted(() => ({
|
|
8
|
+
const { createCodeBlockRendererMock, loadShikiHighlighterMock, renderToVueMock } = vi.hoisted(() => ({
|
|
9
|
+
createCodeBlockRendererMock: vi.fn(() => vi.fn()),
|
|
10
|
+
loadShikiHighlighterMock: vi.fn(() => new Promise(() => {})),
|
|
6
11
|
renderToVueMock: vi.fn(),
|
|
7
12
|
}))
|
|
8
13
|
|
|
@@ -27,11 +32,17 @@ vi.mock('@airalogy/aimd-editor/vue', () => ({
|
|
|
27
32
|
}))
|
|
28
33
|
|
|
29
34
|
vi.mock('@airalogy/aimd-renderer', () => ({
|
|
35
|
+
createCodeBlockRenderer: createCodeBlockRendererMock,
|
|
36
|
+
loadShikiHighlighter: loadShikiHighlighterMock,
|
|
30
37
|
renderToVue: renderToVueMock,
|
|
31
38
|
}))
|
|
32
39
|
|
|
33
40
|
import AimdMarkdownNoteField from '../components/AimdMarkdownNoteField.vue'
|
|
34
41
|
|
|
42
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
43
|
+
const __dirname = dirname(__filename)
|
|
44
|
+
const source = readFileSync(resolve(__dirname, '../components/AimdMarkdownNoteField.vue'), 'utf8')
|
|
45
|
+
|
|
35
46
|
async function flushUi() {
|
|
36
47
|
await Promise.resolve()
|
|
37
48
|
await new Promise(resolve => setTimeout(resolve, 0))
|
|
@@ -39,6 +50,23 @@ async function flushUi() {
|
|
|
39
50
|
}
|
|
40
51
|
|
|
41
52
|
describe('AimdMarkdownNoteField', () => {
|
|
53
|
+
it('uses the shared compact Monaco editor height behavior', () => {
|
|
54
|
+
expect(source).toContain('createMonacoAutoHeight')
|
|
55
|
+
expect(source).toContain('--aimd-markdown-note-editor-height')
|
|
56
|
+
expect(source).toMatch(/const noteEditorHeight = noteAutoHeight\.editorHeight/)
|
|
57
|
+
expect(source).toMatch(/noteAutoHeight\.attachEditor\(editor\.monaco\)/)
|
|
58
|
+
expect(source).toMatch(/:min-height="noteEditorHeight"/)
|
|
59
|
+
expect(source).not.toContain('minHeight: 220')
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('offers an explicit preview/source switch for note markdown', () => {
|
|
63
|
+
expect(source).toContain('aimd-markdown-note-field__view-switch')
|
|
64
|
+
expect(source).toContain('aimd-markdown-note-field__view-btn--preview')
|
|
65
|
+
expect(source).toContain('aimd-markdown-note-field__view-btn--source')
|
|
66
|
+
expect(source).toContain('switchToPreview')
|
|
67
|
+
expect(source).toContain('guardModeSwitchFocus')
|
|
68
|
+
})
|
|
69
|
+
|
|
42
70
|
it('renders saved notes as compact markdown preview by default', async () => {
|
|
43
71
|
renderToVueMock.mockImplementation(async (content: string) => ({
|
|
44
72
|
nodes: [h('div', { class: 'aimd-rendered-note' }, `rendered:${content}`)],
|
|
@@ -54,7 +82,10 @@ describe('AimdMarkdownNoteField', () => {
|
|
|
54
82
|
|
|
55
83
|
await flushUi()
|
|
56
84
|
|
|
57
|
-
expect(renderToVueMock).toHaveBeenCalledWith('**keep cold**', {
|
|
85
|
+
expect(renderToVueMock).toHaveBeenCalledWith('**keep cold**', expect.objectContaining({
|
|
86
|
+
locale: 'en-US',
|
|
87
|
+
elementRenderers: { pre: expect.any(Function) },
|
|
88
|
+
}))
|
|
58
89
|
expect(wrapper.find('.aimd-markdown-note-field__preview').exists()).toBe(true)
|
|
59
90
|
expect(wrapper.find('.aimd-rendered-note').text()).toContain('rendered:**keep cold**')
|
|
60
91
|
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(false)
|
|
@@ -74,13 +105,39 @@ describe('AimdMarkdownNoteField', () => {
|
|
|
74
105
|
})
|
|
75
106
|
|
|
76
107
|
await flushUi()
|
|
77
|
-
await wrapper.find('.aimd-markdown-note-
|
|
108
|
+
await wrapper.find('.aimd-markdown-note-field__view-btn--source').trigger('click')
|
|
78
109
|
await nextTick()
|
|
79
110
|
|
|
80
111
|
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(true)
|
|
81
112
|
expect(wrapper.find('.aimd-markdown-note-field__preview').exists()).toBe(false)
|
|
82
113
|
})
|
|
83
114
|
|
|
115
|
+
it('keeps source mode open when the preview/source toggle briefly loses focus', async () => {
|
|
116
|
+
renderToVueMock.mockImplementation(async (content: string) => ({
|
|
117
|
+
nodes: [h('div', { class: 'aimd-rendered-note' }, `rendered:${content}`)],
|
|
118
|
+
fields: {},
|
|
119
|
+
}))
|
|
120
|
+
|
|
121
|
+
const wrapper = mount(AimdMarkdownNoteField, {
|
|
122
|
+
props: {
|
|
123
|
+
modelValue: 'Existing **note**',
|
|
124
|
+
locale: 'en-US',
|
|
125
|
+
},
|
|
126
|
+
attachTo: document.body,
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
await flushUi()
|
|
130
|
+
await wrapper.find('.aimd-markdown-note-field__view-btn--source').trigger('click')
|
|
131
|
+
await wrapper.trigger('focusout', { relatedTarget: null })
|
|
132
|
+
await flushUi()
|
|
133
|
+
|
|
134
|
+
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(true)
|
|
135
|
+
expect(wrapper.find('.aimd-markdown-note-field__preview').exists()).toBe(false)
|
|
136
|
+
expect(wrapper.emitted('blur')).toBeFalsy()
|
|
137
|
+
|
|
138
|
+
wrapper.unmount()
|
|
139
|
+
})
|
|
140
|
+
|
|
84
141
|
it('opens empty notes directly in editor mode', () => {
|
|
85
142
|
const wrapper = mount(AimdMarkdownNoteField, {
|
|
86
143
|
props: {
|
|
@@ -119,6 +176,32 @@ describe('AimdMarkdownNoteField', () => {
|
|
|
119
176
|
wrapper.unmount()
|
|
120
177
|
})
|
|
121
178
|
|
|
179
|
+
it('switches edited notes into rendered preview on demand', async () => {
|
|
180
|
+
renderToVueMock.mockImplementation(async (content: string) => ({
|
|
181
|
+
nodes: [h('div', { class: 'aimd-rendered-note' }, `rendered:${content}`)],
|
|
182
|
+
fields: {},
|
|
183
|
+
}))
|
|
184
|
+
|
|
185
|
+
const wrapper = mount(AimdMarkdownNoteField, {
|
|
186
|
+
props: {
|
|
187
|
+
modelValue: '',
|
|
188
|
+
locale: 'en-US',
|
|
189
|
+
},
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
await wrapper.find('.aimd-editor-mock').setValue('Preview **this** note')
|
|
193
|
+
await nextTick()
|
|
194
|
+
await wrapper.find('.aimd-markdown-note-field__view-btn--preview').trigger('click')
|
|
195
|
+
await flushUi()
|
|
196
|
+
|
|
197
|
+
expect(renderToVueMock).toHaveBeenCalledWith('Preview **this** note', expect.objectContaining({
|
|
198
|
+
locale: 'en-US',
|
|
199
|
+
}))
|
|
200
|
+
expect(wrapper.find('.aimd-markdown-note-field__preview').exists()).toBe(true)
|
|
201
|
+
expect(wrapper.find('.aimd-rendered-note').text()).toContain('rendered:Preview **this** note')
|
|
202
|
+
expect(wrapper.find('.aimd-editor-mock').exists()).toBe(false)
|
|
203
|
+
})
|
|
204
|
+
|
|
122
205
|
it('offers an explicit close action while editing notes', async () => {
|
|
123
206
|
const wrapper = mount(AimdMarkdownNoteField, {
|
|
124
207
|
props: {
|