1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2026-01-09 00:28:27 +08:00

Merge 943d2419ca139905116ffd3ddb3d41f5ecf97803 into 6858a9ad67483025f6a9432a926beb9327037be3

This commit is contained in:
itsimddc 2025-09-14 00:38:21 +08:00 committed by GitHub
commit c779857e22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 35 deletions

View File

@ -34,7 +34,7 @@
"screenfull": "4.2.0", "screenfull": "4.2.0",
"script-loader": "0.7.2", "script-loader": "0.7.2",
"sortablejs": "1.8.4", "sortablejs": "1.8.4",
"tui-editor": "1.3.3", "@toast-ui/editor": "3.1.3",
"vue": "2.6.10", "vue": "2.6.10",
"vue-count-to": "1.0.13", "vue-count-to": "1.0.13",
"vue-router": "3.0.2", "vue-router": "3.0.2",

View File

@ -7,25 +7,31 @@ export default {
usageStatistics: false, usageStatistics: false,
hideModeSwitch: false, hideModeSwitch: false,
toolbarItems: [ toolbarItems: [
[
'heading', 'heading',
'bold', 'bold',
'italic', 'italic',
'strike', 'strike'
'divider', ],
[
'hr', 'hr',
'quote', 'quote'
'divider', ],
[
'ul', 'ul',
'ol', 'ol',
'task', 'task',
'indent', 'indent'
],
[
'outdent', 'outdent',
'divider',
'table', 'table',
'image', 'image',
'link', 'link'
'divider', ],
[
'code', 'code',
'codeblock' 'codeblock'
] ]
]
} }

View File

@ -5,10 +5,9 @@
<script> <script>
// deps for editor // deps for editor
import 'codemirror/lib/codemirror.css' // codemirror import 'codemirror/lib/codemirror.css' // codemirror
import 'tui-editor/dist/tui-editor.css' // editor ui import '@toast-ui/editor/dist/toastui-editor.css' // Editor's Style
import 'tui-editor/dist/tui-editor-contents.css' // editor content
import Editor from 'tui-editor' import Editor from '@toast-ui/editor'
import defaultOptions from './default-options' import defaultOptions from './default-options'
export default { export default {
@ -62,8 +61,8 @@ export default {
}, },
watch: { watch: {
value(newValue, preValue) { value(newValue, preValue) {
if (newValue !== preValue && newValue !== this.editor.getValue()) { if (newValue !== preValue && newValue !== this.editor.getMarkdown()) {
this.editor.setValue(newValue) this.editor.setMarkdown(newValue)
} }
}, },
language(val) { language(val) {
@ -85,27 +84,29 @@ export default {
}, },
methods: { methods: {
initEditor() { initEditor() {
console.log(this.editorOptions)
this.editor = new Editor({ this.editor = new Editor({
el: document.getElementById(this.id), el: document.getElementById(this.id),
...this.editorOptions ...this.editorOptions
}) })
if (this.value) { if (this.value) {
this.editor.setValue(this.value) this.editor.setMarkdown(this.value)
} }
this.editor.on('change', () => { this.editor.on('change', () => {
this.$emit('input', this.editor.getValue()) this.$emit('input', this.editor.getMarkdown())
}) })
this.editor.getMarkdown()
}, },
destroyEditor() { destroyEditor() {
if (!this.editor) return if (!this.editor) return
this.editor.off('change') this.editor.off('change')
this.editor.remove() this.editor.destroy()
}, },
setValue(value) { setValue(value) {
this.editor.setValue(value) this.editor.setMarkdown(value)
}, },
getValue() { getValue() {
return this.editor.getValue() return this.editor.getMarkdown()
}, },
setHtml(value) { setHtml(value) {
this.editor.setHtml(value) this.editor.setHtml(value)

View File

@ -20,14 +20,19 @@
<el-tag class="tag-title"> <el-tag class="tag-title">
Markdown Mode: Markdown Mode:
</el-tag> </el-tag>
<markdown-editor ref="markdownEditor" v-model="content2" :options="{hideModeSwitch:true,previewStyle:'tab'}" height="200px" /> <markdown-editor
ref="markdownEditor"
v-model="content2"
:options="{ hideModeSwitch: true, previewStyle: 'tab' }"
height="200px"
/>
</div> </div>
<div class="editor-container"> <div class="editor-container">
<el-tag class="tag-title"> <el-tag class="tag-title">
Customize Toolbar: Customize Toolbar:
</el-tag> </el-tag>
<markdown-editor v-model="content3" :options="{ toolbarItems: ['heading','bold','italic']}" /> <markdown-editor v-model="content3" :options="{ toolbarItems: [['heading', 'bold', 'italic']] }" />
</div> </div>
<div class="editor-container"> <div class="editor-container">
@ -92,10 +97,11 @@ export default {
</script> </script>
<style scoped> <style scoped>
.editor-container{ .editor-container {
margin-bottom: 30px; margin-bottom: 30px;
} }
.tag-title{
.tag-title {
margin-bottom: 5px; margin-bottom: 5px;
} }
</style> </style>