# Discourse GIFs TC 添加 GIF 时为何不使用 toolbarEvent？

**URL:** https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629
**Category:** Development
**Tags:** gifs
**Created:** [2025 年11 月 5 日 03:34 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629 "2025-11-05T03:34:28Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### 作者： ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### 发布日期： [2025 年11 月 5 日 03:34 UTC](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629/1 "2025-11-05T03:34:28Z")

</div>

我昨天在看 #gifs TC 时，注意到这段代码：

> <https://github.com/discourse/discourse-gifs/blob/910bd8b73f1939ef046516d231791ab5d27e5ebf/javascripts/discourse/components/modal/gif.gjs#L28-L38>

它使用了 `appEvents` 服务。问题是，为什么不能在 action 中传递 `toolbarEvent`？

> <https://github.com/discourse/discourse-gifs/blob/910bd8b73f1939ef046516d231791ab5d27e5ebf/javascripts/discourse/initializers/gif-integration.js#L11-L21>

[我试过了](https://github.com/NateDhaliwal/discourse-post-image-carousel/blob/cce808a44bf70f907eb13750b57618c241e2b289/javascripts/discourse/api-initializers/add-image-carousel.js#L23-L28)，似乎可行。是否有不使用它的原因？

考虑到它在底层使用了 [TextManipulation](https://github.com/discourse/discourse/blob/c7ba17369645e66593a246f577005da5cce23ff1/frontend/discourse/app/lib/composer/text-manipulation.js)，似乎有一个 [`insertText`](https://github.com/discourse/discourse/blob/c7ba17369645e66593a246f577005da5cce23ff1/frontend/discourse/app/lib/composer/text-manipulation.js#L177) 方法。

只是好奇。

谢谢。

---

_[View the full topic](https://meta.discourse.org/t/why-doesnt-discourse-gifs-tc-use-toolbarevent-instead-of-app-event-when-adding-the-gif/387629)._
