legacy-knowledge-base
公開されました Jul. 2, 2025

AlloyEditorのハイパーリンクドロップダウンリストをカスタマイズするには?

written-by

Alfonso Crisci

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

legacy-article

learn-legacy-article-disclaimer-text

問題

  • ビジネスのニーズは、AlloyEditorツールバーのAlloyEditorハイパーリンクドロップダウンリストをカスタマイズする必要がある場合があります。

    _blank.png

環境への配慮

  • Liferay DXP 7.2

決議

リンク ドロップダウン リストに追加の設定を提供することができます。 最良の方法は、 buttonCfgを渡すEditorConfigContributorを作成することです。

  buttonCfg: {
'linkEdit': {
allowedTargets: [
{
label: AlloyEditor.Strings.linkTargetDefault,
value: ''
}, {
label: AlloyEditor.Strings.linkTargetBlank,
value: '_blank'
}
]
}

これは AlloyEditorCreoleEditorConfigContributor.java. なので、最終的には、以下のコードを populateConfigJSONObject メソッドに追加するだけで、最もクリーンな解決策となります。

JSONArray allowedTargetsJSONObject = JSONUtil.putAll(
JSONUtil.put("label","_self (same tab)").put("value","_self"),
JSONUtil.put("label","_blank (new tab)").put("value","_blank")
);

JSONObject linkEditJSONObject = JSONUtil.put(
"allowedTargets", allowedTargetsJSONObject
);

JSONObject buttonCfgJSONObject = JSONUtil.put(
"linkEdit", linkEditJSONObject);
jsonObject.put(
"buttonCfg", buttonCfgJSONObject
);

新しい動作を示す小さなプラグインが添付されています。

did-this-article-resolve-your-issue

legacy-knowledge-base