FEATURE: Add buildQuoteMarkdown for post toolbar (#24326)
This allows outlets for the post-text-selection-toolbar to get just the raw markdown of the selected text for a quote, rather than opening the composer.
This commit is contained in:
parent
9919046c1c
commit
d128dc0e61
|
@ -235,6 +235,7 @@ export default class PostTextSelectionToolbar extends Component {
|
|||
<PluginOutlet
|
||||
@name="quote-share-buttons-after"
|
||||
@connectorTagName="span"
|
||||
@outletArgs={{hash data=@data}}
|
||||
/>
|
||||
</span>
|
||||
</span>
|
||||
|
|
|
@ -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}}
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
|
@ -596,6 +596,7 @@
|
|||
<PostTextSelection
|
||||
@quoteState={{this.quoteState}}
|
||||
@selectText={{action "selectText"}}
|
||||
@buildQuoteMarkdown={{this.buildQuoteMarkdown}}
|
||||
@editPost={{action "editPost"}}
|
||||
@topic={{this.model}}
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue