mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-03 02:20:49 +08:00
feat: add new post creation view
This commit is contained in:
@@ -14,6 +14,10 @@
|
||||
<i class="menu-item-icon fas fa-info-circle"></i>
|
||||
<span class="menu-item-text">关于</span>
|
||||
</router-link>
|
||||
<router-link class="menu-item" exact-active-class="selected" to="/new-post">
|
||||
<i class="menu-item-icon fas fa-edit"></i>
|
||||
<span class="menu-item-text">发帖</span>
|
||||
</router-link>
|
||||
</div>
|
||||
</nav>
|
||||
</transition>
|
||||
|
||||
75
open-isle-cli/src/components/PostEditor.vue
Normal file
75
open-isle-cli/src/components/PostEditor.vue
Normal file
@@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<div class="post-editor-container">
|
||||
<div :id="editorId" ref="vditorElement"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted } from 'vue'
|
||||
import Vditor from 'vditor'
|
||||
import 'vditor/dist/index.css'
|
||||
|
||||
export default {
|
||||
name: 'PostEditor',
|
||||
emits: ['update:modelValue'],
|
||||
props: {
|
||||
modelValue: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
editorId: {
|
||||
type: String,
|
||||
default: () => 'post-editor-' + Math.random().toString(36).slice(2)
|
||||
}
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
const vditorInstance = ref(null)
|
||||
|
||||
onMounted(() => {
|
||||
vditorInstance.value = new Vditor(props.editorId, {
|
||||
placeholder: '请输入正文...',
|
||||
height: 400,
|
||||
theme: 'classic',
|
||||
preview: {
|
||||
theme: { current: 'light' },
|
||||
actions: [],
|
||||
markdown: { toc: false }
|
||||
},
|
||||
toolbar: [
|
||||
'emoji',
|
||||
'bold',
|
||||
'italic',
|
||||
'strike',
|
||||
'|',
|
||||
'list',
|
||||
'line',
|
||||
'quote',
|
||||
'code',
|
||||
'inline-code',
|
||||
'|',
|
||||
'undo',
|
||||
'redo',
|
||||
'|',
|
||||
'link',
|
||||
'image'
|
||||
],
|
||||
toolbarConfig: { pin: true },
|
||||
cache: { enable: false },
|
||||
input(value) {
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
})
|
||||
vditorInstance.value.setValue(props.modelValue)
|
||||
})
|
||||
|
||||
return {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.post-editor-container {
|
||||
border: 1px solid #e2e2e2;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user