Skip to content

A platform for community discussion. Free, open, simple.

DEV: Add outlet and API for adding/controlling post selection buttons (#23782)

Keegan George5f5fe912a583
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.gjs
index d36e8630a89..635dc72d65b 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
@@ -8,7 +8,7 @@ import FastEditModal from "discourse/components/modal/fast-edit";
import Component from "@glimmer/component";
import concatClass from "discourse/helpers/concat-class";
import DButton from "discourse/components/d-button";
-import { fn } from "@ember/helper";
+import { fn, hash } from "@ember/helper";
import PluginOutlet from "discourse/components/plugin-outlet";
import FastEdit from "discourse/components/fast-edit";
import { on } from "@ember/modifier";
@@ -33,53 +33,59 @@ export default class PostTextSelectionToolbar extends Component {
{{this.appEventsListeners}}
>
<div class="buttons">
- {{#if this.embedQuoteButton}}
- <DButton
- @icon="quote-left"
- @label="post.quote_reply"
- @title="post.quote_reply_shortcut"
- class="btn-flat insert-quote"
- @action={{@data.insertQuote}}
- />
- {{/if}}
-
- {{#if @data.canEditPost}}
- <DButton
- @icon="pencil-alt"
- @label="post.quote_edit"
- @title="post.quote_edit_shortcut"
- class="btn-flat quote-edit-label"
- {{on "click" this.toggleFastEdit}}
- />
- {{/if}}
-
- {{#if this.quoteSharingEnabled}}
- <span class="quote-sharing">
- {{#if this.quoteSharingShowLabel}}
- <DButton
- @icon="share"
- @label="post.quote_share"
- class="btn-flat quote-share-label"
- />
- {{/if}}
-
- <span class="quote-share-buttons">
- {{#each this.quoteSharingSources as |source|}}
+ <PluginOutlet
+ @name="post-text-buttons"
+ @defaultGlimmer={{true}}
+ @outletArgs={{hash data=@data}}
+ >
+ {{#if this.embedQuoteButton}}
+ <DButton
+ @icon="quote-left"
+ @label="post.quote_reply"
+ @title="post.quote_reply_shortcut"
+ class="btn-flat insert-quote"
+ @action={{@data.insertQuote}}
+ />
+ {{/if}}
+
+ {{#if @data.canEditPost}}
+ <DButton
+ @icon="pencil-alt"
+ @label="post.quote_edit"
+ @title="post.quote_edit_shortcut"
+ class="btn-flat quote-edit-label"
+ {{on "click" this.toggleFastEdit}}
+ />
+ {{/if}}
+
+ {{#if this.quoteSharingEnabled}}
+ <span class="quote-sharing">
+ {{#if this.quoteSharingShowLabel}}
<DButton
- @action={{fn this.share source}}
- @translatedTitle={{source.title}}
- @icon={{source.icon}}
- class="btn-flat"
+ @icon="share"
+ @label="post.quote_share"
+ class="btn-flat quote-share-label"
/>
- {{/each}}
-
- <PluginOutlet
- @name="quote-share-buttons-after"
- @connectorTagName="span"
- />
+ {{/if}}
+
+ <span class="quote-share-buttons">
+ {{#each this.quoteSharingSources as |source|}}
+ <DButton
+ @action={{fn this.share source}}
+ @translatedTitle={{source.title}}
+ @icon={{source.icon}}
+ class="btn-flat"
+ />
+ {{/each}}
+
+ <PluginOutlet
+ @name="quote-share-buttons-after"
+ @connectorTagName="span"
+ />
+ </span>
</span>
- </span>
- {{/if}}
+ {{/if}}
+ </PluginOutlet>
</div>
<div class="extra">