@@ -12871,6 +12871,7 @@ function createIcon(options, enableTooltips) {
12871
12871
}
12872
12872
}
12873
12873
12874
+ el . tabIndex = - 1 ;
12874
12875
el . className = options . className ;
12875
12876
return el ;
12876
12877
}
@@ -13468,19 +13469,20 @@ function wordCount(data) {
13468
13469
return count ;
13469
13470
}
13470
13471
13471
-
13472
13472
var toolbarBuiltInButtons = {
13473
13473
"bold" : {
13474
13474
name : "bold" ,
13475
13475
action : toggleBold ,
13476
13476
className : "fa fa-bold" ,
13477
- title : "Bold (Ctrl+B)"
13477
+ title : "Bold (Ctrl+B)" ,
13478
+ default : true
13478
13479
} ,
13479
13480
"italic" : {
13480
13481
name : "italic" ,
13481
13482
action : toggleItalic ,
13482
13483
className : "fa fa-italic" ,
13483
- title : "Italic (Ctrl+I)"
13484
+ title : "Italic (Ctrl+I)" ,
13485
+ default : true
13484
13486
} ,
13485
13487
"strikethrough" : {
13486
13488
name : "strikethrough" ,
@@ -13492,7 +13494,8 @@ var toolbarBuiltInButtons = {
13492
13494
name : "heading" ,
13493
13495
action : toggleHeadingSmaller ,
13494
13496
className : "fa fa-header" ,
13495
- title : "Heading (Ctrl+H)"
13497
+ title : "Heading (Ctrl+H)" ,
13498
+ default : true
13496
13499
} ,
13497
13500
"heading-smaller" : {
13498
13501
name : "heading-smaller" ,
@@ -13524,6 +13527,9 @@ var toolbarBuiltInButtons = {
13524
13527
className : "fa fa-header fa-header-x fa-header-3" ,
13525
13528
title : "Small Heading"
13526
13529
} ,
13530
+ "separator-1" : {
13531
+ name : "separator-1"
13532
+ } ,
13527
13533
"code" : {
13528
13534
name : "code" ,
13529
13535
action : toggleCodeBlock ,
@@ -13534,31 +13540,39 @@ var toolbarBuiltInButtons = {
13534
13540
name : "quote" ,
13535
13541
action : toggleBlockquote ,
13536
13542
className : "fa fa-quote-left" ,
13537
- title : "Quote (Ctrl+')"
13543
+ title : "Quote (Ctrl+')" ,
13544
+ default : true
13538
13545
} ,
13539
13546
"unordered-list" : {
13540
13547
name : "unordered-list" ,
13541
13548
action : toggleUnorderedList ,
13542
13549
className : "fa fa-list-ul" ,
13543
- title : "Generic List (Ctrl+L)"
13550
+ title : "Generic List (Ctrl+L)" ,
13551
+ default : true
13544
13552
} ,
13545
13553
"ordered-list" : {
13546
13554
name : "ordered-list" ,
13547
13555
action : toggleOrderedList ,
13548
13556
className : "fa fa-list-ol" ,
13549
- title : "Numbered List (Ctrl+Alt+L)"
13557
+ title : "Numbered List (Ctrl+Alt+L)" ,
13558
+ default : true
13559
+ } ,
13560
+ "separator-2" : {
13561
+ name : "separator-2"
13550
13562
} ,
13551
13563
"link" : {
13552
13564
name : "link" ,
13553
13565
action : drawLink ,
13554
13566
className : "fa fa-link" ,
13555
- title : "Create Link (Ctrl+K)"
13567
+ title : "Create Link (Ctrl+K)" ,
13568
+ default : true
13556
13569
} ,
13557
13570
"image" : {
13558
13571
name : "image" ,
13559
13572
action : drawImage ,
13560
13573
className : "fa fa-picture-o" ,
13561
- title : "Insert Image (Ctrl+Alt+I)"
13574
+ title : "Insert Image (Ctrl+Alt+I)" ,
13575
+ default : true
13562
13576
} ,
13563
13577
"table" : {
13564
13578
name : "table" ,
@@ -13572,29 +13586,36 @@ var toolbarBuiltInButtons = {
13572
13586
className : "fa fa-minus" ,
13573
13587
title : "Insert Horizontal Line"
13574
13588
} ,
13589
+ "separator-3" : {
13590
+ name : "separator-3"
13591
+ } ,
13575
13592
"preview" : {
13576
13593
name : "preview" ,
13577
13594
action : togglePreview ,
13578
13595
className : "fa fa-eye no-disable" ,
13579
- title : "Toggle Preview (Ctrl+P)"
13596
+ title : "Toggle Preview (Ctrl+P)" ,
13597
+ default : true
13580
13598
} ,
13581
13599
"side-by-side" : {
13582
13600
name : "side-by-side" ,
13583
13601
action : toggleSideBySide ,
13584
13602
className : "fa fa-columns no-disable no-mobile" ,
13585
- title : "Toggle Side by Side (F9)"
13603
+ title : "Toggle Side by Side (F9)" ,
13604
+ default : true
13586
13605
} ,
13587
13606
"fullscreen" : {
13588
13607
name : "fullscreen" ,
13589
13608
action : toggleFullScreen ,
13590
13609
className : "fa fa-arrows-alt no-disable no-mobile" ,
13591
- title : "Toggle Fullscreen (F11)"
13610
+ title : "Toggle Fullscreen (F11)" ,
13611
+ default : true
13592
13612
} ,
13593
13613
"guide" : {
13594
13614
name : "guide" ,
13595
13615
action : "http://nextstepwebs.github.io/simplemde-markdown-editor/markdown-guide" ,
13596
13616
className : "fa fa-question-circle" ,
13597
- title : "Markdown Guide"
13617
+ title : "Markdown Guide" ,
13618
+ default : true
13598
13619
}
13599
13620
} ;
13600
13621
@@ -13659,10 +13680,28 @@ function SimpleMDE(options) {
13659
13680
}
13660
13681
13661
13682
13662
- // Handle toolbar and status bar
13663
- if ( options . toolbar !== false )
13664
- options . toolbar = options . toolbar || SimpleMDE . toolbar ;
13683
+ // Handle toolbar
13684
+ if ( options . toolbar === undefined ) {
13685
+ // Initialize
13686
+ options . toolbar = [ ] ;
13687
+
13688
+
13689
+ // Loop over the built in buttons, to get the preferred order
13690
+ for ( var key in toolbarBuiltInButtons ) {
13691
+ if ( toolbarBuiltInButtons . hasOwnProperty ( key ) ) {
13692
+ if ( key . indexOf ( "separator-" ) != - 1 ) {
13693
+ options . toolbar . push ( "|" ) ;
13694
+ }
13695
+
13696
+ if ( toolbarBuiltInButtons [ key ] . default === true || ( options . showIcons && options . showIcons . constructor === Array && options . showIcons . indexOf ( key ) != - 1 ) ) {
13697
+ options . toolbar . push ( key ) ;
13698
+ }
13699
+ }
13700
+ }
13701
+ }
13702
+
13665
13703
13704
+ // Handle status bar
13666
13705
if ( ! options . hasOwnProperty ( "status" ) ) {
13667
13706
options . status = [ "autosave" , "lines" , "words" , "cursor" ] ;
13668
13707
}
@@ -13705,16 +13744,11 @@ function SimpleMDE(options) {
13705
13744
// The codemirror component is only available after rendering
13706
13745
// so, the setter for the initialValue can only run after
13707
13746
// the element has been rendered
13708
- if ( options . initialValue ) {
13747
+ if ( options . initialValue && ( ! this . options . autosave || this . options . autosave . foundSavedValue !== true ) ) {
13709
13748
this . value ( options . initialValue ) ;
13710
13749
}
13711
13750
}
13712
13751
13713
- /**
13714
- * Default toolbar elements.
13715
- */
13716
- SimpleMDE . toolbar = [ "bold" , "italic" , "heading" , "|" , "quote" , "unordered-list" , "ordered-list" , "|" , "link" , "image" , "|" , "preview" , "side-by-side" , "fullscreen" , "guide" ] ;
13717
-
13718
13752
/**
13719
13753
* Default markdown render.
13720
13754
*/
@@ -13850,8 +13884,10 @@ SimpleMDE.prototype.autosave = function() {
13850
13884
}
13851
13885
13852
13886
if ( this . options . autosave . loaded !== true ) {
13853
- if ( typeof localStorage . getItem ( "smde_" + this . options . autosave . uniqueId ) == "string" && localStorage . getItem ( "smde_" + this . options . autosave . uniqueId ) != "" )
13887
+ if ( typeof localStorage . getItem ( "smde_" + this . options . autosave . uniqueId ) == "string" && localStorage . getItem ( "smde_" + this . options . autosave . uniqueId ) != "" ) {
13854
13888
this . codemirror . setValue ( localStorage . getItem ( "smde_" + this . options . autosave . uniqueId ) ) ;
13889
+ this . options . autosave . foundSavedValue = true ;
13890
+ }
13855
13891
13856
13892
this . options . autosave . loaded = true ;
13857
13893
}
0 commit comments