# 书写描述时的字符数

**URL:** https://meta.discourse.org/t/character-count-when-writing-description/190698
**Category:** Feature
**Tags:** composer, characters-required
**Created:** [2021年五月17日 17:14 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698 "2021-05-17T17:14:48Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![jayrajm97](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jayrajm97/32/161546_2.png) [@jayrajm97](https://meta.discourse.org/u/jayrajm97)
#### Post date: [2021年五月17日 17:14 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/1 "2021-05-17T17:14:48Z")

</div>

是否有方法在编写描述时显示字符数？  
我找到了这个插件，但其缺点是它设定了最小字符数，而我想要显示已使用的字符数。

> [@Discourse Characters Required](https://meta.discourse.org/t/characters-required/77195):
>
> discourse2Summary Discourse Characters Required adds a count of characters required in the composer.hammer_and_wrenchRepository Link [https://github.com/discourse/discourse-characters-required](https://github.com/discourse/discourse-characters-required)open_bookInstall Guide [How to install plugins in Discourse](https://meta.discourse.org/t/install-plugins-in-discourse/19157)Features If installed, users will see an indicator of how many characters are required before their post can be made: Last edited by @JammyDodger 2024-06-03T22:00:39Z (UTC) play_button Check document

在下方的截图中，显示的是“需要 20 个字符”，我希望它显示为“字符数：300”。

 ![Screenshot 2021-05-17 at 10.42.58 PM](https://global.discourse-cdn.com/meta/original/3X/4/1/41ddf1287c84292bfbce212672b9d9076373a550.png)

如果有人能帮助调整代码，请与我联系。

---

<div class="post-metadata">

### Author: ![spamless](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spamless/32/255876_2.png) [@spamless](https://meta.discourse.org/u/spamless)
#### Post date: [2022年四月10日 12:21 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/2 "2022-04-10T12:21:44Z")

</div>

此建议正是我打算发布的内容，也是我找到此现有主题的原因。我花了一整周的时间设置我的网站，添加类别和描述。UI 建议将初始描述保持在 200 个字符以内是很好的建议。我希望在编辑模式下能看到字符计数！

我一直以来都将描述写在可以显示字符计数的编辑器中，然后将最终确定的文本粘贴回 Discourse 描述中。

---

<div class="post-metadata">

### Author: ![Aizada\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aizada_m/32/352050_2.png) [@Aizada\_M](https://meta.discourse.org/u/Aizada_M)
#### Post date: [2023年九月29日 07:09 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/3 "2023-09-29T07:09:44Z")

</div>

您好，我也对这个问题感兴趣。  
本身 Discourse 的核心就有一个通知功能；如果一个人输入的字符数少于网站管理员设定的数量，就会显示需要遵守最小字符数的通知。因此，我认为如果这个插件不仅能显示最小字符数，还能显示最大字符数，并且能显示已输入的字符数，那它会更有用。希望我能表达清楚我的想法（我使用谷歌翻译）。

---

<div class="post-metadata">

### Author: ![Aizada\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aizada_m/32/352050_2.png) [@Aizada\_M](https://meta.discourse.org/u/Aizada_M)
#### Post date: [2023年九月29日 07:28 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/4 "2023-09-29T07:28:21Z")

</div>

我想添加我的想法。如上所示显示字符，在使用将人工智能集成到 Discourse 的插件时效果会很好，例如 [Chatbot](https://meta.discourse.org/t/discourse-chatbot-now-smarter-than-chatgpt/256652)(@merefield) 和 [Discourse AI](https://meta.discourse.org/t/discourse-ai/259214)(@Falco)。那些与人工智能工具互动过的人会理解这种控制字符数的功能的必要性，因为在向人工智能撰写请求时，每个字符都要花钱 😅

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2023年九月29日 16:26 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/5 "2023-09-29T16:26:38Z")

</div>

这两种都适用：

> **[GitHub - merefield/discourse-tc-character-count: A Theme Component to simultaneously count the...](https://github.com/merefield/discourse-tc-character-count)**
>
> A Theme Component to simultaneously count the number of characters typed in the composer as well as the required number to post!

（并且大致基于原始的 discourse 插件）。

---

<div class="post-metadata">

### Author: ![Heliosurge](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/heliosurge/32/571810_2.png) [@Heliosurge](https://meta.discourse.org/u/Heliosurge)
#### Post date: [2023年九月29日 22:23 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/6 "2023-09-29T22:23:55Z")

</div>

这是一个很棒的补充！消除了对插件的需求，并使其能够被更广泛的受众使用！

---

<div class="post-metadata">

### Author: ![Aizada\_M](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aizada_m/32/352050_2.png) [@Aizada\_M](https://meta.discourse.org/u/Aizada_M)
#### Post date: [2023年十月3日 09:03 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/7 "2023-10-03T09:03:29Z")

</div>

问候，确实是该主题的一个关键要素，简直太棒了！

---

<div class="post-metadata">

### Author: ![spamless](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spamless/32/255876_2.png) [@spamless](https://meta.discourse.org/u/spamless)
#### Post date: [2023年十一月9日 21:37 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/8 "2023-11-09T21:37:40Z")

</div>

看起来不错。我需要一些关于如何实现它的帮助。

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [2023年十一月9日 21:55 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/9 "2023-11-09T21:55:01Z")

</div>

请查看有关主题组件的指南  
[Beginner's guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966#add-theme-components-to-a-theme-9)  
[Installing a theme or theme component](https://meta.discourse.org/t/install-a-theme-or-theme-component/63682)

---

<div class="post-metadata">

### Author: ![spamless](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/spamless/32/255876_2.png) [@spamless](https://meta.discourse.org/u/spamless)
#### Post date: [2023年十一月9日 22:14 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/10 "2023-11-09T22:14:30Z")

</div>

谢谢。我自己也进展到这一步了。而且我以前也安装过主题和组件。但我不知道该把哪个 URL 填进去。我试了

`https://github.com/merefield/discourse-tc-character-count/tree/main`

我还从那里找到了另一个 URL，这是我的第二次尝试。

两者都不奏效后，我决定来问一下。你看，我只是在胡乱猜测。

[编辑：我现在弄明白了。要添加的是：  
`https://github.com/merefield/discourse-tc-character-count.git`  
这个奏效了。谢谢！]

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年十一月9日 22:20 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/11 "2023-11-09T22:20:23Z")

</div>

您可以使用此 URL 进行安装：`https://github.com/merefield/discourse-tc-character-count` 👍

---

<div class="post-metadata">

### Author: ![Farhan\_Hossen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/farhan_hossen/32/344620_2.png) [@Farhan\_Hossen](https://meta.discourse.org/u/Farhan_Hossen)
#### Post date: [2023年十一月30日 13:02 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/12 "2023-11-30T13:02:49Z")

</div>

好的。有什么方法可以使其与主题标题配合使用吗？

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2023年十一月30日 13:05 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/13 "2023-11-30T13:05:33Z")

</div>

这真是个绝妙的主意 💡 🌟 … 欢迎提交拉取请求！

---

<div class="post-metadata">

### Author: ![merefield](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/merefield/32/176214_2.png) [@merefield](https://meta.discourse.org/u/merefield)
#### Post date: [2025年二月18日 23:34 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/14 "2025-02-18T23:34:12Z")

</div>

完成！

> <https://github.com/merefield/discourse-tc-character-count/pull/2>
>
> \* FEATURE: adds title count with minimum display
> \* COMPATIBILITY: converts ever…ything to gjs.
> \* SWANSONG: Discourse is redesigning the Composer so this might be the last hurrah for this Component.

如果你觉得这很棒并且我做得很好，你可以[买我一杯咖啡](https://github.com/sponsors/merefield/sponsorships?sponsor=merefield&tier_id=464896&preview=false) ☕

 ![图片显示了一个用户界面中的文本框，其中有一个不完整的句子，读作“this is a nice helpful...” (由AI配字幕)](https://global.discourse-cdn.com/meta/original/4X/8/8/7/887780fee32312d6f4345d51d568b0b6289dfca9.png)

@fokx 😉

---

<div class="post-metadata">

### Author: ![alltiagocom](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/alltiagocom/32/492709_2.png) [@alltiagocom](https://meta.discourse.org/u/alltiagocom)
#### Post date: [2025年三月24日 20:57 UTC](https://meta.discourse.org/t/character-count-when-writing-description/190698/15 "2025-03-24T20:57:14Z")

</div>

我为自己对组件做了一些小的改动，因为我对 GitHub、fork 等没有经验。  
我最终得到了这个：  
[![](https://global.discourse-cdn.com/meta/original/4X/f/5/2/f52c0ab28bff3cbee7ab94767fc010db63a6e104.png) ](https://global.discourse-cdn.com/meta/original/4X/f/5/2/f52c0ab28bff3cbee7ab94767fc010db63a6e104.png)

你可以在这里阅读更多关于它的信息，看看你是否同意我的建议：

> [@Suggestion for the "Characters Required" plugin](https://meta.discourse.org/t/suggestion-for-the-characters-required-plugin/358621/7?u=alltiagocom):
>
> Where were you a few hours go to prevent me from having to go through the painful process of installing the plugin? wink That is indeed what I wanted. A few suggestions, if you think they are worth implementing: 1 - Ability to change the color of the text. In my particular case, I like it in the original color. On my non-professional UI expertise, I like to see red only when something is over the limit, for example, too many characters that will throw an error if I try to save, or if it do…

非常感谢 @merefield 提出这个组件！🙌
