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 {
4343class MarkdownHeaderButtonElement extends MarkdownButtonElement {
4444 constructor ( ) {
4545 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+ } )
4752 }
4853}
4954
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ describe('markdown-toolbbar-element', function() {
7070 <markdown-toolbar for="textarea_id">
7171 <md-bold>bold</md-bold>
7272 <md-header>header</md-header>
73+ <md-header level="1">h1</md-header>
7374 <md-italic>italic</md-italic>
7475 <md-quote>quote</md-quote>
7576 <md-code>code</md-code>
@@ -516,5 +517,18 @@ describe('markdown-toolbbar-element', function() {
516517 assert . equal ( "GitHub's " , visualValue ( ) )
517518 } )
518519 } )
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+ } )
519533 } )
520534} )
You can’t perform that action at this time.
0 commit comments