Liferay内容页面富文本编辑器AlloyEditor工具栏按钮不显示,求@Component配置
解决AlloyEditor插件在内容页面富文本片段中不显示的问题
你的问题核心是内容页面富文本片段使用的EditorConfig Key和博客编辑等后台场景不同,导致自定义的EditorConfigContributor未被触发。以下是正确的@Component属性配置方案:
正确的@Component配置示例
@Component( immediate = true, property = { "editor.config.key=com.liferay.fragment.entry.processor.freemarker.FreeMarkerFragmentEntryProcessor", "editor.config.key=com.liferay.fragment.entry.processor.velocity.VelocityFragmentEntryProcessor", "editor.config.key=com.liferay.portlet.journal.content.editor.configuration.JournalContentEditorConfiguration" }, service = EditorConfigContributor.class ) public class CustomAlloyEditorConfigContributor extends BaseEditorConfigContributor { @Override public void populateConfigJSONObject( JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes, ThemeDisplay themeDisplay) { // 在此添加自定义工具栏按钮的配置逻辑 JSONObject toolbars = jsonObject.getJSONObject("toolbars"); if (toolbars != null) { JSONObject mainToolbar = toolbars.getJSONObject("main"); if (mainToolbar != null) { JSONArray buttons = mainToolbar.getJSONArray("buttons"); buttons.put("你的自定义按钮ID"); } } } }
关键配置说明
- 内容页面的富文本片段编辑器关联两个核心Key:
com.liferay.fragment.entry.processor.freemarker.FreeMarkerFragmentEntryProcessor(FreeMarker类型片段)com.liferay.fragment.entry.processor.velocity.VelocityFragmentEntryProcessor(Velocity类型片段)
必须将这两个Key添加到editor.config.key属性中,多个Key通过重复property声明实现。
- 若需要同时兼容博客编辑等原有场景,保留
com.liferay.portlet.journal.content.editor.configuration.JournalContentEditorConfiguration这类原有Key即可。 - 确保自定义Contributor继承自
BaseEditorConfigContributor,并正确实现populateConfigJSONObject方法。
内容的提问来源于stack exchange,提问作者Andre Albert
相关产品推荐
相关产品推荐

