|
733 | 733 | },{ |
734 | 734 | name: 'cmdHeading', |
735 | 735 | title: 'Heading', |
736 | | - icon: 'glyphicon glyphicon-font', |
| 736 | + icon: 'glyphicon glyphicon-header', |
737 | 737 | callback: function(e){ |
738 | 738 | // Append/remove ### surround the selection |
739 | 739 | var chunk, cursor, selected = e.getSelection(), content = e.getContent(), pointer, prevChar |
|
742 | 742 | // Give extra word |
743 | 743 | chunk = 'heading text' |
744 | 744 | } else { |
745 | | - chunk = selected.text |
| 745 | + chunk = selected.text + '\n'; |
746 | 746 | } |
747 | 747 |
|
748 | 748 | // transform selection and set the cursor into chunked text |
|
751 | 751 | e.setSelection(selected.start-pointer,selected.end) |
752 | 752 | e.replaceSelection(chunk) |
753 | 753 | 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) |
756 | 756 | cursor = selected.start+6 |
757 | 757 | } else { |
758 | 758 | // Empty string before element |
759 | | - e.replaceSelection('### '+chunk+'\n') |
| 759 | + e.replaceSelection('### '+chunk) |
760 | 760 | cursor = selected.start+4 |
761 | 761 | } |
762 | 762 |
|
|
783 | 783 |
|
784 | 784 | link = prompt('Insert Hyperlink','http://') |
785 | 785 |
|
786 | | - if (link != null) { |
| 786 | + if (link != null && link != '' && link != 'http://') { |
787 | 787 | // transform selection and set the cursor into chunked text |
788 | 788 | e.replaceSelection('['+chunk+']('+link+')') |
789 | 789 | cursor = selected.start+1 |
|
0 commit comments