新しい「投稿タイプ」コンポーザーアクションドロップダウンの紹介

好消息は、現時点でテーマコンポーネント内でこれを許可するためのフックが用意されていることです。これは、イデアカテゴリでのみトグルを表示するためのイニシャライザーで機能します。

import { withPluginApi } from "discourse/lib/plugin-api";

export default {
    name: "hide-post-voting-toggle",
    after: "extend-composer-actions", 

    initialize() {
      withPluginApi((api) => {
        api.registerValueTransformer(
          "composer-actions-content",
          ({ value, context }) => {
            const category = context.composerModel?.category;
    
            if (!category?.isType("ideas")) {
              return value.filter((item) => item.id !== "togglePostVoting");
            }
    
            return value;
          }
        );
      });
    }
};

「いいね!」 5