File tree Expand file tree Collapse file tree 3 files changed +21
-11
lines changed
Expand file tree Collapse file tree 3 files changed +21
-11
lines changed Original file line number Diff line number Diff line change 11import KatexParser from './plugin/KatexParser'
2- import { toolbarBtn } from './toolbar-button/toolbarBtn'
2+ import { defaultBtns , getBtns } from './toolbar-button/toolbarBtn'
33import _ from 'lodash'
44
55function set ( obj , config ) {
@@ -17,7 +17,7 @@ export let defaultConfig = {
1717 parsers : [
1818 KatexParser
1919 ] ,
20- toolbarConfig : toolbarBtn ,
20+ toolbarConfig : defaultBtns ,
2121 editorOption : {
2222 mode : 'markdown' ,
2323 lineNumbers : true ,
@@ -26,5 +26,6 @@ export let defaultConfig = {
2626}
2727
2828export function getConfig ( config ) {
29+ if ( config . toolbarConfig !== undefined ) { config . toolbarConfig = getBtns ( config . toolbarConfig ) }
2930 return set ( _ . cloneDeep ( defaultConfig ) , config )
3031}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import BtnUl from './btn-ul'
1010import BtnOl from './btn-ol'
1111import BtnHr from './btn-hr'
1212
13- export let toolbarBtn = [
13+ export let defaultBtns = [
1414 BtnBold ,
1515 BtnStrikeThrough ,
1616 BtnItalic ,
@@ -30,3 +30,20 @@ export let toolbarBtn = [
3030 BtnLink ,
3131 BtnTable
3232]
33+
34+ function getDefaultBtnsMap ( ) {
35+ let btnsMap = { }
36+ defaultBtns . forEach ( function ( btn ) {
37+ btnsMap [ btn . name ] = btn
38+ } )
39+ return btnsMap
40+ }
41+
42+ export function getBtns ( toolbarConfig ) {
43+ let btnsMap = getDefaultBtnsMap ( )
44+ let btns = [ ]
45+ toolbarConfig . forEach ( function ( btn ) {
46+ if ( typeof btn === 'object' ) { btns . push ( btn ) } else { btns . push ( btnsMap [ btn ] ) }
47+ } )
48+ return btns
49+ }
You can’t perform that action at this time.
0 commit comments