From f7b4fbfda567deb463afb2d3363763bb7bfbdc3b Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 12 Aug 2022 12:15:42 +0200 Subject: [PATCH] Add support for Header size 4, 5, 6 --- src/js/easymde.js | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/js/easymde.js b/src/js/easymde.js index 70ad27c..2d9c784 100644 --- a/src/js/easymde.js +++ b/src/js/easymde.js @@ -1143,30 +1143,12 @@ function _toggleHeading(cm, direction, size) { } } } else { - if (size == 1) { - if (currHeadingLevel <= 0) { - text = '# ' + text; - } else if (currHeadingLevel == size) { - text = text.substr(currHeadingLevel + 1); - } else { - text = '# ' + text.substr(currHeadingLevel + 1); - } - } else if (size == 2) { - if (currHeadingLevel <= 0) { - text = '## ' + text; - } else if (currHeadingLevel == size) { - text = text.substr(currHeadingLevel + 1); - } else { - text = '## ' + text.substr(currHeadingLevel + 1); - } + if (currHeadingLevel <= 0) { + text = '#'.repeat(size) + ' ' + text; + } else if (currHeadingLevel == size) { + text = text.substr(currHeadingLevel + 1); } else { - if (currHeadingLevel <= 0) { - text = '### ' + text; - } else if (currHeadingLevel == size) { - text = text.substr(currHeadingLevel + 1); - } else { - text = '### ' + text.substr(currHeadingLevel + 1); - } + text = '#'.repeat(size) + ' ' + text.substr(currHeadingLevel + 1); } }