New Topic + Reply: Distinquish Ephemeral Text

Both New Topic and Reply display the same text “Type here. Use Markdown, BBCode, or HTML to format. Drag or paste images.” We added custom text and the same text shows up for new topics and replies. We want different instructions to our users for new topics than replies. Specifically we want to alert the users about tagging a new topic and those instructions are not revelant to a topic reply. How can we accomplish our goal? If we change js.composer.reply_placeholder, the same text applies to both.

Thanks,

Correct, the placeholder for both new topics and replies share the same translation key as you mentioned js.composer.reply_placeholder

As far as I know, there haven’t been any requests for separate keys so far.

Still, you can customize this on your site for now.

If you add the following to your theme in the common > header tab, it should give you the desired result.

<script type="text/discourse-plugin" version="0.8">
// options you can change
const placeHolderForReplies = "CHANGE_THIS_TEXT_BUT_KEEP_THE_QUOTES";

// no need to change anything below this line.
const discourseComputed = require("discourse-common/utils/decorators").default;

const currentLocale = I18n.currentLocale();
I18n.translations[currentLocale].js.composer.custom_reply_placeholder =
  placeHolderForReplies;

api.modifyClass("component:composer-editor", {
  @discourseComputed
  replyPlaceholder() {
    return this.topic ? "composer.custom_reply_placeholder" : this._super(...arguments);
  }
});
</script>

You can change the text for the reply placeholder in the second line. If it’s a reply, your site will show that text… otherwise, Discourse will fall back to the default you set for the js.composer.reply_placeholder translation key.

4 Likes

Thanks for detailed instructions, we likely would not have figured this out without your help. We are working on implementing your suggestion now.

3 Likes