@@ -666,19 +666,20 @@ function wordCount(data) {
666
666
return count ;
667
667
}
668
668
669
-
670
669
var toolbarBuiltInButtons = {
671
670
"bold" : {
672
671
name : "bold" ,
673
672
action : toggleBold ,
674
673
className : "fa fa-bold" ,
675
- title : "Bold (Ctrl+B)"
674
+ title : "Bold (Ctrl+B)" ,
675
+ default : true
676
676
} ,
677
677
"italic" : {
678
678
name : "italic" ,
679
679
action : toggleItalic ,
680
680
className : "fa fa-italic" ,
681
- title : "Italic (Ctrl+I)"
681
+ title : "Italic (Ctrl+I)" ,
682
+ default : true
682
683
} ,
683
684
"strikethrough" : {
684
685
name : "strikethrough" ,
@@ -690,7 +691,8 @@ var toolbarBuiltInButtons = {
690
691
name : "heading" ,
691
692
action : toggleHeadingSmaller ,
692
693
className : "fa fa-header" ,
693
- title : "Heading (Ctrl+H)"
694
+ title : "Heading (Ctrl+H)" ,
695
+ default : true
694
696
} ,
695
697
"heading-smaller" : {
696
698
name : "heading-smaller" ,
@@ -722,6 +724,9 @@ var toolbarBuiltInButtons = {
722
724
className : "fa fa-header fa-header-x fa-header-3" ,
723
725
title : "Small Heading"
724
726
} ,
727
+ "separator-1" : {
728
+ name : "separator-1"
729
+ } ,
725
730
"code" : {
726
731
name : "code" ,
727
732
action : toggleCodeBlock ,
@@ -732,31 +737,39 @@ var toolbarBuiltInButtons = {
732
737
name : "quote" ,
733
738
action : toggleBlockquote ,
734
739
className : "fa fa-quote-left" ,
735
- title : "Quote (Ctrl+')"
740
+ title : "Quote (Ctrl+')" ,
741
+ default : true
736
742
} ,
737
743
"unordered-list" : {
738
744
name : "unordered-list" ,
739
745
action : toggleUnorderedList ,
740
746
className : "fa fa-list-ul" ,
741
- title : "Generic List (Ctrl+L)"
747
+ title : "Generic List (Ctrl+L)" ,
748
+ default : true
742
749
} ,
743
750
"ordered-list" : {
744
751
name : "ordered-list" ,
745
752
action : toggleOrderedList ,
746
753
className : "fa fa-list-ol" ,
747
- title : "Numbered List (Ctrl+Alt+L)"
754
+ title : "Numbered List (Ctrl+Alt+L)" ,
755
+ default : true
756
+ } ,
757
+ "separator-2" : {
758
+ name : "separator-2"
748
759
} ,
749
760
"link" : {
750
761
name : "link" ,
751
762
action : drawLink ,
752
763
className : "fa fa-link" ,
753
- title : "Create Link (Ctrl+K)"
764
+ title : "Create Link (Ctrl+K)" ,
765
+ default : true
754
766
} ,
755
767
"image" : {
756
768
name : "image" ,
757
769
action : drawImage ,
758
770
className : "fa fa-picture-o" ,
759
- title : "Insert Image (Ctrl+Alt+I)"
771
+ title : "Insert Image (Ctrl+Alt+I)" ,
772
+ default : true
760
773
} ,
761
774
"table" : {
762
775
name : "table" ,
@@ -770,29 +783,36 @@ var toolbarBuiltInButtons = {
770
783
className : "fa fa-minus" ,
771
784
title : "Insert Horizontal Line"
772
785
} ,
786
+ "separator-3" : {
787
+ name : "separator-3"
788
+ } ,
773
789
"preview" : {
774
790
name : "preview" ,
775
791
action : togglePreview ,
776
792
className : "fa fa-eye no-disable" ,
777
- title : "Toggle Preview (Ctrl+P)"
793
+ title : "Toggle Preview (Ctrl+P)" ,
794
+ default : true
778
795
} ,
779
796
"side-by-side" : {
780
797
name : "side-by-side" ,
781
798
action : toggleSideBySide ,
782
799
className : "fa fa-columns no-disable no-mobile" ,
783
- title : "Toggle Side by Side (F9)"
800
+ title : "Toggle Side by Side (F9)" ,
801
+ default : true
784
802
} ,
785
803
"fullscreen" : {
786
804
name : "fullscreen" ,
787
805
action : toggleFullScreen ,
788
806
className : "fa fa-arrows-alt no-disable no-mobile" ,
789
- title : "Toggle Fullscreen (F11)"
807
+ title : "Toggle Fullscreen (F11)" ,
808
+ default : true
790
809
} ,
791
810
"guide" : {
792
811
name : "guide" ,
793
812
action : "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide" ,
794
813
className : "fa fa-question-circle" ,
795
- title : "Markdown Guide"
814
+ title : "Markdown Guide" ,
815
+ default : true
796
816
}
797
817
} ;
798
818
@@ -857,10 +877,28 @@ function SimpleMDE(options) {
857
877
}
858
878
859
879
860
- // Handle toolbar and status bar
861
- if ( options . toolbar !== false )
862
- options . toolbar = options . toolbar || SimpleMDE . toolbar ;
880
+ // Handle toolbar
881
+ if ( options . toolbar === undefined ) {
882
+ // Initialize
883
+ options . toolbar = [ ] ;
863
884
885
+
886
+ // Loop over the built in buttons, to get the preferred order
887
+ for ( var key in toolbarBuiltInButtons ) {
888
+ if ( toolbarBuiltInButtons . hasOwnProperty ( key ) ) {
889
+ if ( key . indexOf ( "separator-" ) != - 1 ) {
890
+ options . toolbar . push ( "|" ) ;
891
+ }
892
+
893
+ if ( toolbarBuiltInButtons [ key ] . default === true || ( options . showIcons && options . showIcons . constructor === Array && options . showIcons . indexOf ( key ) != - 1 ) ) {
894
+ options . toolbar . push ( key ) ;
895
+ }
896
+ }
897
+ }
898
+ }
899
+
900
+
901
+ // Handle status bar
864
902
if ( ! options . hasOwnProperty ( "status" ) ) {
865
903
options . status = [ "autosave" , "lines" , "words" , "cursor" ] ;
866
904
}
@@ -908,11 +946,6 @@ function SimpleMDE(options) {
908
946
}
909
947
}
910
948
911
- /**
912
- * Default toolbar elements.
913
- */
914
- SimpleMDE . toolbar = [ "bold" , "italic" , "heading" , "|" , "quote" , "unordered-list" , "ordered-list" , "|" , "link" , "image" , "|" , "preview" , "side-by-side" , "fullscreen" , "guide" ] ;
915
-
916
949
/**
917
950
* Default markdown render.
918
951
*/
0 commit comments