11<template >
22 <div id =" luogu-markdown-editor" class =" editor-container" >
33 <div id =" editor-toolbar" class =" editor-toolbar" >
4- <toolbar @change =" insert" @click =" clickToolbar" :toolbarConfig =" this.config .toolbarConfig" ></toolbar >
4+ <toolbar @change =" insert" @click =" clickToolbar" :toolbarConfig =" editorConfig .toolbarConfig" ></toolbar >
55 </div >
66 <div id =" editor-area" >
77 <div id =" editor-input-area" class =" editor-area input-area" >
88 <input-area v-model =" code"
99 @input =" updateCode"
1010 @finish =" insertCode = null"
11- :height =" this.config .height"
11+ :height =" editorConfig .height"
1212 :insertCode =" insertCode"
13- :editorOption =" this.config .editorOption" ></input-area >
13+ :editorOption =" editorConfig .editorOption" ></input-area >
1414 </div >
1515 <div id =" editor-preview-area" class =" editor-area preview-area" >
16- <preview-area v-model =" code" :height =" this.config. height" :parsers =" this.config .parsers" ></preview-area >
16+ <preview-area v-model =" code" :height =" editorConfig. height" :parsers =" editorConfig .parsers" ></preview-area >
1717 </div >
1818 </div >
1919 <div id =" editor-dialog" >
@@ -53,8 +53,7 @@ import PreviewArea from './PreviewArea.vue'
5353import Toolbar from ' ./Toolbar.vue'
5454import EditorDialog from ' ./Dialog.vue'
5555
56- import KatexParser from ' ./plugin/KatexParser'
57- import {toolbarBtn } from ' ./toolbar-button/toolbarBtn'
56+ import { defaultConfig , getConfig } from ' ./DefaultConfig'
5857
5958export default {
6059 name: ' luogu-markdown-editor' ,
@@ -64,28 +63,18 @@ export default {
6463 },
6564 config: {
6665 type: Object ,
67- default () {
68- return {
69- height: ' 500px' ,
70- parsers: [
71- KatexParser
72- ],
73- toolbarConfig: toolbarBtn,
74- editorOption: {
75- mode: ' markdown' ,
76- lineNumbers: true ,
77- lineWrapping: true
78- }
66+ default : function () {
67+ return defaultConfig
7968 }
80- }
8169 }
8270 },
8371 data () {
8472 return {
8573 code: ' ' ,
8674 showDialog: false ,
8775 dialogRequest: {},
88- insertCode: null
76+ insertCode: null ,
77+ editorConfig: getConfig (this .config )
8978 }
9079 },
9180 mounted () {
0 commit comments