FEATURE: keep formatting when quoting
This commit is contained in:
parent
bb377e2021
commit
71f5215711
|
@ -9,6 +9,8 @@
|
||||||
//= require ./deprecated
|
//= require ./deprecated
|
||||||
|
|
||||||
// Stuff we need to load first
|
// Stuff we need to load first
|
||||||
|
//= require ./discourse/helpers/parse-html
|
||||||
|
//= require ./discourse/lib/to-markdown
|
||||||
//= require ./discourse/lib/utilities
|
//= require ./discourse/lib/utilities
|
||||||
//= require ./discourse/lib/page-visible
|
//= require ./discourse/lib/page-visible
|
||||||
//= require ./discourse/lib/logout
|
//= require ./discourse/lib/logout
|
||||||
|
|
|
@ -131,7 +131,6 @@ export default Ember.Controller.extend(BufferedContent, {
|
||||||
return this.get('model.postStream').loadPost(postId).then(post => {
|
return this.get('model.postStream').loadPost(postId).then(post => {
|
||||||
const composer = this.get('composer');
|
const composer = this.get('composer');
|
||||||
const viewOpen = composer.get('model.viewOpen');
|
const viewOpen = composer.get('model.viewOpen');
|
||||||
|
|
||||||
const quotedText = Quote.build(post, buffer);
|
const quotedText = Quote.build(post, buffer);
|
||||||
|
|
||||||
// If we can't create a post, delegate to reply as new topic
|
// If we can't create a post, delegate to reply as new topic
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { escape } from 'pretty-text/sanitizer';
|
import { escape } from 'pretty-text/sanitizer';
|
||||||
|
import toMarkdown from 'discourse/lib/to-markdown';
|
||||||
|
|
||||||
const homepageSelector = 'meta[name=discourse_current_homepage]';
|
const homepageSelector = 'meta[name=discourse_current_homepage]';
|
||||||
|
|
||||||
|
@ -113,12 +114,8 @@ export function selectedText() {
|
||||||
$div.find(".clicks").remove();
|
$div.find(".clicks").remove();
|
||||||
// replace emojis
|
// replace emojis
|
||||||
$div.find("img.emoji").replaceWith(function() { return this.title; });
|
$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
|
// Determine the row and col of the caret in an element
|
||||||
|
|
Loading…
Reference in New Issue