diff --git a/app/assets/javascripts/discourse/lib/Markdown.Editor.js b/app/assets/javascripts/discourse/lib/Markdown.Editor.js index 58e3929f8c5..7c6ef13587b 100644 --- a/app/assets/javascripts/discourse/lib/Markdown.Editor.js +++ b/app/assets/javascripts/discourse/lib/Markdown.Editor.js @@ -1550,13 +1550,13 @@ // Don't show the fallback text if more than one line is selected, // it's probably a break between paragraphs. - if(lines.length > 1) { - fallbackText = "" + if (lines.length > 1) { + fallbackText = ""; } for(var i=0; i 1) { + lines[i] = newChunk.before + newChunk.selection + newChunk.after; + } else { + realChunk.startTag = newChunk.before; + realChunk.endTag = newChunk.after; + lines[i] = newChunk.selection; + } } + realChunk.selection = lines.join("\n"); }; @@ -1591,11 +1599,11 @@ } // Only operate if it's not a blank line - if(chunk.selection) { - // Add the true markup. - var markup = nStars === 1 ? "*" : "**"; - chunk.before = chunk.before + markup; - chunk.after = markup + chunk.after; + if (chunk.selection) { + // Add the true markup. + var markup = nStars === 1 ? "*" : "**"; + chunk.before = chunk.before + markup; + chunk.after = markup + chunk.after; } } };