Add Alloy Editor buttons for fragments with text
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
You are viewing an article from our legacy "FastTrack"
publication program, made available for informational purposes. Articles
in this program were published without a requirement for independent
editing or verification and are provided"as is" without
guarantee.
Before using any information from this article, independently verify its
suitability for your situation and project.
Issue
- Trying to new buttons to Alloy Editor in fragments with text is not working.
- What should be the appropriate editor's configuration?
Resolution
- The documentation articles Adding a Button to the Add Toolbar and Adding a Button to a Styles Toolbar explain how to add particular buttons for the Add and Styles Toolbars.
- The documentation article Modifying an Editor's Configuration explains how to target particular portlets and editors.
- To make sure that the changes affect fragments with text it's necessary to specify the appropriate
editor.config.key and javax.portlet.name:
@Component(
immediate = true,
property = {
"editor.config.key=fragmenEntryLinkRichTextEditor",
"javax.portlet.name=" + ContentPageEditorPortletKeys.CONTENT_PAGE_EDITOR_PORTLET,
"service.ranking:Integer=100"
},
service = EditorConfigContributor.class
)
- Note that the Add Toolbar "+" button will appear by default on the left of the text box, so it might be hidden if the fragment stretches all the way to the left. It's possible to change the button position, for example to the right, with:
JSONObject toolbarsJSONObject = jsonObject.getJSONObject("toolbars");
JSONObject addToolbar = toolbarsJSONObject.getJSONObject("add");
addToolbar.put("position", "right");
Did this article resolve your issue ?