File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,12 @@ class MarkdownButtonElement extends HTMLElement {
43
43
class MarkdownHeaderButtonElement extends MarkdownButtonElement {
44
44
constructor ( ) {
45
45
super ( )
46
- styles . set ( this , { prefix : '### ' } )
46
+
47
+ const level = parseInt ( this . getAttribute ( 'level' ) || 3 , 10 )
48
+ const prefix = `${ '#' . repeat ( level ) } `
49
+ styles . set ( this , {
50
+ prefix
51
+ } )
47
52
}
48
53
}
49
54
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ describe('markdown-toolbbar-element', function() {
70
70
<markdown-toolbar for="textarea_id">
71
71
<md-bold>bold</md-bold>
72
72
<md-header>header</md-header>
73
+ <md-header level="1">h1</md-header>
73
74
<md-italic>italic</md-italic>
74
75
<md-quote>quote</md-quote>
75
76
<md-code>code</md-code>
@@ -516,5 +517,18 @@ describe('markdown-toolbbar-element', function() {
516
517
assert . equal ( "GitHub's " , visualValue ( ) )
517
518
} )
518
519
} )
520
+
521
+ describe ( 'header' , function ( ) {
522
+ it ( 'inserts header syntax with cursor in description' , function ( ) {
523
+ setVisualValue ( '|title|' )
524
+ clickToolbar ( 'md-header' )
525
+ assert . equal ( '### |title|' , visualValue ( ) )
526
+ } )
527
+ it ( 'inserts header 1 syntax with cursor in description' , function ( ) {
528
+ setVisualValue ( '|title|' )
529
+ clickToolbar ( 'md-header[level="1"]' )
530
+ assert . equal ( '# |title|' , visualValue ( ) )
531
+ } )
532
+ } )
519
533
} )
520
534
} )
You can’t perform that action at this time.
0 commit comments