5.1. エレメント・アクションアイテムを無効化する¶
この章では、任意のエレメントやアクションアイテムを無効化し、利用できなくする方法を説明します。
注意
5.1.1. 作業の手順¶
5.1.2. エレメントを無効化する処理の実装¶
エレメントを無効化する処理を {VSCODE_HOME}/src/index.ts に実装します。
// エレメントのリポジトリを取得します。
const elementRepository = window.imHichee.UIElementRepository;
// 無効化したいエレメントのクラス名を配列に列挙してください。
const excludesElementClassNames = ['MySampleElement'];
// IUIElementRepository.classes で登録済みのエレメントの一覧を取得し、filter を使って無効化するエレメントを絞り込みます。
const disableElements = elementRepository.classes.filter((clazz) => {
return excludesElementClassNames.find((excludeClazz) => excludeClazz === clazz.name);
});
// エレメントを無効化する場合は、IUIElementRepository.setClassOptions() の第二引数の hiddenInPalette に true を指定します。
disableElements.forEach((item) => elementRepository.setClassOptions(item, {hiddenInPalette: true}));
IM-BloomMaker が提供する標準のエレメントを無効化したい場合は、「IM-BloomMakerが提供する標準のエレメントのクラス名と提供開始バージョン一覧」を参照して、無効化したいエレメントのクラス名を excludesElementClassNames の配列に列挙してください。
5.1.3. アクションアイテムを無効化する処理の実装¶
アクションアイテムを無効化する処理を {VSCODE_HOME}/src/index.ts に実装します。
// アクションアイテムのリポジトリを取得します。
const actionItemRepository = window.imHichee.UIContainerActionItemRepository;
// 無効化したいアクションアイテムのクラス名を配列に列挙してください。
const excludesActionItemClassNames = ['MySampleActionItem'];
// IUIContainerActionItemRepository.classes で登録済みのアクションアイテムの一覧を取得し、filter を使って無効化するアクションアイテムを絞り込みます。
const disableActionItems = actionItemRepository.classes.filter((clazz) => {
return excludesActionItemClassNames.find((excludeClazz) => excludeClazz === clazz.name);
});
// アクションアイテムを無効化する場合は、IUIContainerActionItemRepository.setClassOptions() の第二引数の hiddenInPalette に true を指定します。
disableActionItems.forEach((item) => actionItemRepository.setClassOptions(item, {hiddenInPalette: true}));
IM-BloomMaker が提供する標準のアクションアイテムを無効化したい場合は、「IM-BloomMakerが提供する標準のアクションアイテムのクラス名と提供開始バージョン一覧」を参照して、無効化したいアクションアイテムのクラス名を excludesActionItemClassNames の配列に列挙してください。