feat: add MarkdownEditor component and integrate it into news add/edit forms

This commit is contained in:
2026-01-09 00:05:41 +07:00
parent be085db45b
commit 28d93217a3
7 changed files with 727 additions and 17 deletions

View File

@@ -0,0 +1,48 @@
<script lang="ts" setup>
import type { ComponentInstance } from 'vue';
import { getCurrentInstance } from 'vue';
import { storeToRefs } from 'pinia';
import type { ToolbarNames } from 'md-editor-v3';
import { MdEditor } from 'md-editor-v3';
import { useThemeStore } from '@/store/modules/theme';
import 'md-editor-v3/lib/style.css';
const modelValue = defineModel('value', { type: String, default: '' });
const themeStore = useThemeStore();
const { darkMode } = storeToRefs(themeStore);
const toolbarsExclude: ToolbarNames[] = [
'github',
'catalog',
'previewOnly',
'fullscreen',
'image',
'code',
'codeRow',
'save',
'htmlPreview',
'next',
'revoke',
'mermaid'
];
const vm = getCurrentInstance()!;
function changeRef(expose: any) {
vm.exposed = expose;
}
defineExpose({} as ComponentInstance<typeof MdEditor>);
</script>
<template>
<MdEditor
:ref="changeRef"
v-model="modelValue"
v-bind="{ ...$attrs }"
:toolbars-exclude="toolbarsExclude"
:theme="darkMode ? 'dark' : 'light'"
/>
</template>
<style lang="css" scoped></style>