@airalogy/aimd-editor 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -0
- package/README.zh-CN.md +43 -0
- package/dist/AimdEditorTopBar.vue_vue_type_script_setup_true_lang-gbfMDZSh.js +1131 -0
- package/dist/AimdSourceEditor.vue_vue_type_script_setup_true_lang-t_sUoXky.js +274 -0
- package/dist/AimdWysiwygEditor.vue_vue_type_script_setup_true_lang-B8o1VbUH.js +25012 -0
- package/dist/aimd-editor.css +1 -0
- package/dist/embedded.js +11 -0
- package/dist/index.js +44 -0
- package/dist/monaco.js +16 -0
- package/dist/theme-B8dCnOx-.js +583 -0
- package/dist/vue.js +30 -0
- package/dist/wysiwyg.js +9 -0
- package/package.json +90 -0
- package/src/__tests__/editor.test.ts +296 -0
- package/src/embedded.ts +18 -0
- package/src/index.ts +10 -0
- package/src/language-config.ts +152 -0
- package/src/monaco.ts +19 -0
- package/src/theme.ts +166 -0
- package/src/tokens.ts +120 -0
- package/src/vue/AimdEditor.vue +715 -0
- package/src/vue/AimdEditorToolbar.vue +83 -0
- package/src/vue/AimdEditorTopBar.vue +39 -0
- package/src/vue/AimdFieldDialog.vue +1102 -0
- package/src/vue/AimdSourceEditor.vue +330 -0
- package/src/vue/AimdWysiwygEditor.vue +569 -0
- package/src/vue/aimdInlineMarkdownNormalization.ts +10 -0
- package/src/vue/comparableAimdMarkdown.ts +6 -0
- package/src/vue/env.d.ts +7 -0
- package/src/vue/index.ts +45 -0
- package/src/vue/locales.ts +667 -0
- package/src/vue/milkdown-aimd-plugin.ts +378 -0
- package/src/vue/programmaticMarkdownSyncGuard.ts +66 -0
- package/src/vue/types.ts +449 -0
- package/src/vue/useEditorContent.ts +252 -0
- package/src/wysiwyg.ts +17 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AimdFieldType, MdToolbarItem } from './types'
|
|
3
|
+
import type { AimdEditorMessages } from './locales'
|
|
4
|
+
|
|
5
|
+
defineProps<{
|
|
6
|
+
showTopBar: boolean
|
|
7
|
+
showMdToolbar: boolean
|
|
8
|
+
showAimdToolbar: boolean
|
|
9
|
+
editorMode: 'source' | 'wysiwyg'
|
|
10
|
+
resolvedMessages: AimdEditorMessages
|
|
11
|
+
localizedFieldTypes: AimdFieldType[]
|
|
12
|
+
localizedMdToolbarItems: MdToolbarItem[]
|
|
13
|
+
}>()
|
|
14
|
+
|
|
15
|
+
const emit = defineEmits<{
|
|
16
|
+
(e: 'switch-mode', mode: 'source' | 'wysiwyg'): void
|
|
17
|
+
(e: 'md-action', action: string): void
|
|
18
|
+
(e: 'open-aimd-dialog', type: string): void
|
|
19
|
+
(e: 'quick-insert-aimd', type: string): void
|
|
20
|
+
}>()
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<div class="aimd-editor-toolbar">
|
|
25
|
+
<!-- Mode switch (inside toolbar) -->
|
|
26
|
+
<div v-if="showTopBar" class="aimd-editor-mode-switch">
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
:class="['aimd-editor-mode-btn', { active: editorMode === 'source' }]"
|
|
30
|
+
@click="emit('switch-mode', 'source')"
|
|
31
|
+
:title="resolvedMessages.mode.sourceTitle"
|
|
32
|
+
>
|
|
33
|
+
<span class="aimd-editor-mode-icon" v-html="'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>'" />
|
|
34
|
+
<span>{{ resolvedMessages.mode.source }}</span>
|
|
35
|
+
</button>
|
|
36
|
+
<button
|
|
37
|
+
type="button"
|
|
38
|
+
:class="['aimd-editor-mode-btn', { active: editorMode === 'wysiwyg' }]"
|
|
39
|
+
@click="emit('switch-mode', 'wysiwyg')"
|
|
40
|
+
:title="resolvedMessages.mode.wysiwygTitle"
|
|
41
|
+
>
|
|
42
|
+
<span class="aimd-editor-mode-icon" v-html="'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'" />
|
|
43
|
+
<span>{{ resolvedMessages.mode.wysiwyg }}</span>
|
|
44
|
+
</button>
|
|
45
|
+
</div>
|
|
46
|
+
|
|
47
|
+
<div v-if="showTopBar && showMdToolbar" class="aimd-editor-toolbar-sep" />
|
|
48
|
+
|
|
49
|
+
<!-- Markdown buttons -->
|
|
50
|
+
<template v-if="showMdToolbar">
|
|
51
|
+
<template v-for="item in localizedMdToolbarItems" :key="item.action">
|
|
52
|
+
<div v-if="item.action.startsWith('sep')" class="aimd-editor-toolbar-sep" />
|
|
53
|
+
<button
|
|
54
|
+
v-else
|
|
55
|
+
type="button"
|
|
56
|
+
class="aimd-editor-fmt-btn"
|
|
57
|
+
:title="item.title"
|
|
58
|
+
@click="emit('md-action', item.action)"
|
|
59
|
+
v-html="item.svgIcon"
|
|
60
|
+
/>
|
|
61
|
+
</template>
|
|
62
|
+
</template>
|
|
63
|
+
|
|
64
|
+
<div v-if="showMdToolbar && showAimdToolbar" class="aimd-editor-toolbar-divider" />
|
|
65
|
+
|
|
66
|
+
<!-- AIMD buttons -->
|
|
67
|
+
<template v-if="showAimdToolbar">
|
|
68
|
+
<button
|
|
69
|
+
v-for="ft in localizedFieldTypes"
|
|
70
|
+
:key="ft.type"
|
|
71
|
+
type="button"
|
|
72
|
+
class="aimd-editor-fmt-btn aimd-editor-aimd-btn"
|
|
73
|
+
:title="ft.desc"
|
|
74
|
+
:style="{ '--aimd-color': ft.color }"
|
|
75
|
+
@click="emit('open-aimd-dialog', ft.type)"
|
|
76
|
+
@click.middle.prevent="emit('quick-insert-aimd', ft.type)"
|
|
77
|
+
>
|
|
78
|
+
<span class="aimd-editor-aimd-btn-icon" v-html="ft.svgIcon" />
|
|
79
|
+
<span class="aimd-editor-aimd-btn-label">{{ ft.label }}</span>
|
|
80
|
+
</button>
|
|
81
|
+
</template>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { AimdEditorMessages } from './locales'
|
|
3
|
+
|
|
4
|
+
defineProps<{
|
|
5
|
+
editorMode: 'source' | 'wysiwyg'
|
|
6
|
+
resolvedMessages: AimdEditorMessages
|
|
7
|
+
}>()
|
|
8
|
+
|
|
9
|
+
const emit = defineEmits<{
|
|
10
|
+
(e: 'switch-mode', mode: 'source' | 'wysiwyg'): void
|
|
11
|
+
}>()
|
|
12
|
+
|
|
13
|
+
// Mode switch SVG icons
|
|
14
|
+
const modeSvgIcons = {
|
|
15
|
+
source: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>`,
|
|
16
|
+
wysiwyg: `<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>`,
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div class="aimd-editor-mode-switch">
|
|
22
|
+
<button
|
|
23
|
+
:class="['aimd-editor-mode-btn', { active: editorMode === 'source' }]"
|
|
24
|
+
@click="emit('switch-mode', 'source')"
|
|
25
|
+
:title="resolvedMessages.mode.sourceTitle"
|
|
26
|
+
>
|
|
27
|
+
<span class="aimd-editor-mode-icon" v-html="modeSvgIcons.source" />
|
|
28
|
+
<span>{{ resolvedMessages.mode.source }}</span>
|
|
29
|
+
</button>
|
|
30
|
+
<button
|
|
31
|
+
:class="['aimd-editor-mode-btn', { active: editorMode === 'wysiwyg' }]"
|
|
32
|
+
@click="emit('switch-mode', 'wysiwyg')"
|
|
33
|
+
:title="resolvedMessages.mode.wysiwygTitle"
|
|
34
|
+
>
|
|
35
|
+
<span class="aimd-editor-mode-icon" v-html="modeSvgIcons.wysiwyg" />
|
|
36
|
+
<span>{{ resolvedMessages.mode.wysiwyg }}</span>
|
|
37
|
+
</button>
|
|
38
|
+
</div>
|
|
39
|
+
</template>
|