FEATURE: keep formatting when quoting

This commit is contained in:
Régis Hanol 2018-05-05 10:51:54 +02:00
parent bb377e2021
commit 71f5215711
3 changed files with 4 additions and 6 deletions

View File

@ -9,6 +9,8 @@
//= require ./deprecated
// Stuff we need to load first
//= require ./discourse/helpers/parse-html
//= require ./discourse/lib/to-markdown
//= require ./discourse/lib/utilities
//= require ./discourse/lib/page-visible
//= require ./discourse/lib/logout

View File

@ -131,7 +131,6 @@ export default Ember.Controller.extend(BufferedContent, {
return this.get('model.postStream').loadPost(postId).then(post => {
const composer = this.get('composer');
const viewOpen = composer.get('model.viewOpen');
const quotedText = Quote.build(post, buffer);
// If we can't create a post, delegate to reply as new topic

View File

@ -1,4 +1,5 @@
import { escape } from 'pretty-text/sanitizer';
import toMarkdown from 'discourse/lib/to-markdown';
const homepageSelector = 'meta[name=discourse_current_homepage]';
@ -113,12 +114,8 @@ export function selectedText() {
$div.find(".clicks").remove();
// replace emojis
$div.find("img.emoji").replaceWith(function() { return this.title; });
// replace br with newlines
$div.find("br").replaceWith(() => "\n");
// enforce newline at the end of paragraphs
$div.find("p").append(() => "\n");
return String($div.text()).trim().replace(/(^\s*\n)+/gm, "\n");
return toMarkdown($div.html());
}
// Determine the row and col of the caret in an element