11import Component from " @glimmer/component" ;
22import { tracked } from " @glimmer/tracking" ;
33import { array } from " @ember/helper" ;
4+ import { on } from " @ember/modifier" ;
45import { action } from " @ember/object" ;
56import didInsert from " @ember/render-modifiers/modifiers/did-insert" ;
67import didUpdate from " @ember/render-modifiers/modifiers/did-update" ;
@@ -29,6 +30,7 @@ export default class AiSummaryModal extends Component {
2930 @service currentUser;
3031 @service site;
3132 @service modal;
33+ @service appEvents;
3234
3335 @tracked text = " " ;
3436 @tracked summarizedOn = null ;
@@ -208,6 +210,18 @@ export default class AiSummaryModal extends Component {
208210 this .args .closeModal ();
209211 }
210212
213+ @action
214+ onSummaryTextClick (event ) {
215+ // Check if the clicked element is an anchor tag
216+ if (event .target .tagName === " A" && event .target .href ) {
217+ this .appEvents .trigger (" ai_summary_link_clicked" , {
218+ topic_id: this .args .model .topic .id ,
219+ user_id: this .currentUser .id ,
220+ link: event .target .href ,
221+ });
222+ }
223+ }
224+
211225 <template >
212226 <DModal
213227 @ title ={{i18n " discourse_ai.summarization.topic.title" }}
@@ -221,7 +235,11 @@ export default class AiSummaryModal extends Component {
221235 >
222236 <: body >
223237 {{htmlClass " scrollable-modal" }}
224- <div class =" ai-summary-container" {{didInsert this . generateSummary}} >
238+ <div
239+ class =" ai-summary-container"
240+ {{didInsert this . generateSummary}}
241+ {{on " click" this . onSummaryTextClick}}
242+ >
225243 <article
226244 class ={{concatClass
227245 " ai-summary-box"
0 commit comments