إذا أدى إصلاح ذلك إلى عنصر نائب لكل من الردود والإنشاء، فسيمكننا تقديم إرشادات محسّنة في الوقت المناسب لجميع المستخدمين (وهو ما سيكون رائعًا لمجتمعات الدعم مثل مجتمعنا).
هذا اكتشاف رائع. جربته بسرعة ويبدو أنه يفصل الرد بشكل جيد جدًا وينشئ عناصر نائبة. أحب أن أرى هذا التغيير يتم إجراؤه في النواة، ولكني سعيد جدًا باستخدام التغييرات التي قدمها جو. شكرًا على ربط هذا @Moin
متابعةً، لم تعمل مقتطفات التعليمات البرمجية التي نشرها جو كما هو متوقع مع زر الموضوع الجديد الخاص بنا: عندما ينشئ المستخدم موضوعًا جديدًا أثناء قراءته لموضوع ما، فإنه يحصل على نص الرد.
فيما يلي نهج بديل:
يعرض عنصراً نائباً للمواضيع الجديدة سواء بدأت في صفحة الفئات أو من داخل موضوع
يعرض عنصراً نائباً مختلفاً للردود
<script type="text/discourse-plugin" version="0.8">
// Custom placeholders
const placeHolderForReplies = `When helping someone else:
1. Describe what you think the problem is
2. Tell them what you think they should do
3. Show them how to do it (code snippets, images, etc)
4. Include links and references `;
const placeHolderForNewTopics = `Type here.
1. Tell us what you're trying to do.
2. Tell us what you already tried.
3. Post error logs as code snippets.`;
// Import required modules
const discourseComputed = require("discourse-common/utils/decorators").default;
const currentLocale = I18n.currentLocale();
I18n.translations[currentLocale].js.composer.custom_reply_placeholder = placeHolderForReplies;
I18n.translations[currentLocale].js.composer.custom_topic_placeholder = placeHolderForNewTopics;
api.modifyClass("component:composer-editor", {
@discourseComputed("composer.replyingToTopic", "composer.creatingTopic")
replyPlaceholder(replyingToTopic, creatingTopic) {
// Determine if the composer is for replying or creating a new topic
if (creatingTopic) {
return "composer.custom_topic_placeholder"; // New topic placeholder
} else if (replyingToTopic) {
return "composer.custom_reply_placeholder"; // Reply placeholder
}
return this._super(...arguments); // Fallback to default behavior
}
});
</script>