mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2026-01-07 23:47:00 +08:00
fix(markdown): use latest version of markdown comp, update api usage
This commit is contained in:
parent
6858a9ad67
commit
beb8f0bb67
@ -34,7 +34,7 @@
|
||||
"screenfull": "4.2.0",
|
||||
"script-loader": "0.7.2",
|
||||
"sortablejs": "1.8.4",
|
||||
"tui-editor": "1.3.3",
|
||||
"@toast-ui/editor": "3.1.3",
|
||||
"vue": "2.6.10",
|
||||
"vue-count-to": "1.0.13",
|
||||
"vue-router": "3.0.2",
|
||||
|
||||
@ -5,10 +5,9 @@
|
||||
<script>
|
||||
// deps for editor
|
||||
import 'codemirror/lib/codemirror.css' // codemirror
|
||||
import 'tui-editor/dist/tui-editor.css' // editor ui
|
||||
import 'tui-editor/dist/tui-editor-contents.css' // editor content
|
||||
import '@toast-ui/editor/dist/toastui-editor.css' // Editor's Style
|
||||
|
||||
import Editor from 'tui-editor'
|
||||
import Editor from '@toast-ui/editor'
|
||||
import defaultOptions from './default-options'
|
||||
|
||||
export default {
|
||||
@ -62,8 +61,8 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
value(newValue, preValue) {
|
||||
if (newValue !== preValue && newValue !== this.editor.getValue()) {
|
||||
this.editor.setValue(newValue)
|
||||
if (newValue !== preValue && newValue !== this.editor.getMarkdown()) {
|
||||
this.editor.setMarkdown(newValue)
|
||||
}
|
||||
},
|
||||
language(val) {
|
||||
@ -85,27 +84,29 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
initEditor() {
|
||||
console.log(this.editorOptions)
|
||||
this.editor = new Editor({
|
||||
el: document.getElementById(this.id),
|
||||
...this.editorOptions
|
||||
})
|
||||
if (this.value) {
|
||||
this.editor.setValue(this.value)
|
||||
this.editor.setMarkdown(this.value)
|
||||
}
|
||||
this.editor.on('change', () => {
|
||||
this.$emit('input', this.editor.getValue())
|
||||
this.$emit('input', this.editor.getMarkdown())
|
||||
})
|
||||
this.editor.getMarkdown()
|
||||
},
|
||||
destroyEditor() {
|
||||
if (!this.editor) return
|
||||
this.editor.off('change')
|
||||
this.editor.remove()
|
||||
this.editor.destroy()
|
||||
},
|
||||
setValue(value) {
|
||||
this.editor.setValue(value)
|
||||
this.editor.setMarkdown(value)
|
||||
},
|
||||
getValue() {
|
||||
return this.editor.getValue()
|
||||
return this.editor.getMarkdown()
|
||||
},
|
||||
setHtml(value) {
|
||||
this.editor.setHtml(value)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user