A platform for community discussion. Free, open, simple.
FEATURE: Add buildQuoteMarkdown for post toolbar (#24326)
Martin Brennand128dc0e6141
diff --git a/app/assets/javascripts/discourse/app/components/post-text-selection-toolbar.gjs b/app/assets/javascripts/discourse/app/components/post-text-selection-toolbar.gjsindex 09b3cd2daff..2734ea4c3d4 100644--- a/app/assets/javascripts/discourse/app/components/post-text-selection-toolbar.gjs+++ b/app/assets/javascripts/discourse/app/components/post-text-selection-toolbar.gjs@@ -235,6 +235,7 @@ export default class PostTextSelectionToolbar extends Component {<PluginOutlet@name="quote-share-buttons-after"@connectorTagName="span"+ @outletArgs={{hash data=@data}}/></span></span>diff --git a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs b/app/assets/javascripts/discourse/app/components/post-text-selection.gjsindex 66667b22096..92a7689c00b 100644--- a/app/assets/javascripts/discourse/app/components/post-text-selection.gjs+++ b/app/assets/javascripts/discourse/app/components/post-text-selection.gjs@@ -209,6 +209,7 @@ export default class PostTextSelection extends Component {topic: this.args.topic,quoteState,insertQuote: this.insertQuote,+ buildQuote: this.buildQuote,hideToolbar: this.hideToolbar,},};@@ -271,6 +272,11 @@ export default class PostTextSelection extends Component {await this.hideToolbar();}+ @action+ async buildQuote() {+ return await this.args.buildQuoteMarkdown();+ }+<template><div{{this.documentListeners}}diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.jsindex 57d20fee556..2f7f582220d 100644--- a/app/assets/javascripts/discourse/app/controllers/topic.js+++ b/app/assets/javascripts/discourse/app/controllers/topic.js@@ -457,6 +457,18 @@ export default Controller.extend(bufferedProperty("model"), {});},+ buildQuoteMarkdown() {+ const { postId, buffer, opts } = this.quoteState;+ const loadedPost = this.get("model.postStream").findLoadedPost(postId);+ const promise = loadedPost+ ? Promise.resolve(loadedPost)+ : this.get("model.postStream").loadPost(postId);++ return promise.then((post) => {+ return buildQuote(post, buffer, opts);+ });+ },+fillGapBefore(args) {return this.get("model.postStream").fillGapBefore(args.post, args.gap);},diff --git a/app/assets/javascripts/discourse/app/templates/topic.hbs b/app/assets/javascripts/discourse/app/templates/topic.hbsindex 9877a4e99ef..58c1b9ae294 100644--- a/app/assets/javascripts/discourse/app/templates/topic.hbs+++ b/app/assets/javascripts/discourse/app/templates/topic.hbs@@ -596,6 +596,7 @@<PostTextSelection@quoteState={{this.quoteState}}@selectText={{action "selectText"}}+ @buildQuoteMarkdown={{this.buildQuoteMarkdown}}@editPost={{action "editPost"}}@topic={{this.model}}/>