Skip to content

Commit 052c6f6

Browse files
committed
Merge pull request #25 from FokkeZB/patch-1
Some optimalisations
2 parents 9dbc048 + 11839a3 commit 052c6f6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

js/bootstrap-markdown.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@
733733
},{
734734
name: 'cmdHeading',
735735
title: 'Heading',
736-
icon: 'glyphicon glyphicon-font',
736+
icon: 'glyphicon glyphicon-header',
737737
callback: function(e){
738738
// Append/remove ### surround the selection
739739
var chunk, cursor, selected = e.getSelection(), content = e.getContent(), pointer, prevChar
@@ -742,7 +742,7 @@
742742
// Give extra word
743743
chunk = 'heading text'
744744
} else {
745-
chunk = selected.text
745+
chunk = selected.text + '\n';
746746
}
747747

748748
// transform selection and set the cursor into chunked text
@@ -751,12 +751,12 @@
751751
e.setSelection(selected.start-pointer,selected.end)
752752
e.replaceSelection(chunk)
753753
cursor = selected.start-pointer
754-
} else if (prevChar = content.substr(selected.start-1,1), !!prevChar && prevChar != '\n') {
755-
e.replaceSelection('\n\n### '+chunk+'\n')
754+
} else if (selected.start > 0 && (prevChar = content.substr(selected.start-1,1), !!prevChar && prevChar != '\n')) {
755+
e.replaceSelection('\n\n### '+chunk)
756756
cursor = selected.start+6
757757
} else {
758758
// Empty string before element
759-
e.replaceSelection('### '+chunk+'\n')
759+
e.replaceSelection('### '+chunk)
760760
cursor = selected.start+4
761761
}
762762

@@ -783,7 +783,7 @@
783783

784784
link = prompt('Insert Hyperlink','http://')
785785

786-
if (link != null) {
786+
if (link != null && link != '' && link != 'http://') {
787787
// transform selection and set the cursor into chunked text
788788
e.replaceSelection('['+chunk+']('+link+')')
789789
cursor = selected.start+1

0 commit comments

Comments
 (0)