<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Not able to add new button on ckeditor</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112404300" />
  <subtitle>Not able to add new button on ckeditor</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112404300</id>
  <updated>2026-04-04T12:03:42Z</updated>
  <dc:date>2026-04-04T12:03:42Z</dc:date>
  <entry>
    <title>RE: Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119827602" />
    <author>
      <name>Geert van der Ploeg</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119827602</id>
    <updated>2020-08-24T08:02:54Z</updated>
    <published>2020-08-24T08:02:54Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Vipul,&lt;br&gt;Adding a button to the toolbar works a bit different because of the structure of the JSON object. There is no such thing (anymore, or only in Liferay's CK Editor config) as different *named* sets of buttons. It's just a multi dimensional array of button names. If you output the JSONObject before trying to add the button, you'll that it looks something like:&lt;br&gt;&lt;pre&gt;&lt;code&gt;[
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;["Bold","Italic","Underline","Strike","-","Subscript","Superscript","-","RemoveFormat"],
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;["TextColor","BGColor"],
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;["JustifyLeft","JustifyCenter","JustifyRight","JustifyBlock"],
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;["NumberedList","BulletedList","-","Outdent","Indent"],
&amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;"/",
&amp;amp;nbsp; &amp;amp;nbsp; ["Styles","FontSize"],
&amp;amp;nbsp; &amp;amp;nbsp; ["Link","Unlink","Anchor"],
&amp;amp;nbsp; &amp;amp;nbsp; ["Table","-","ImageSelector","Flash","-","Smiley","SpecialChar"],
&amp;amp;nbsp; &amp;amp;nbsp; "/",
&amp;amp;nbsp; &amp;amp;nbsp; ["Cut","Copy","Paste","-","PasteText","PasteFromWord","-","SelectAll","-","Undo","Redo"],
&amp;amp;nbsp; &amp;amp;nbsp; ["Find","Replace","-","SpellChecker","Scayt"],
&amp;amp;nbsp; &amp;amp;nbsp; ["Source"],["A11YBtn"]
]&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;So the way to add a button here (without checking array boundaries etc.) is:&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; JSONArray toolbars = jsonObject.getJSONArray("toolbar_liferay");
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; JSONArray buttons = toolbars.getJSONArray(9);
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; buttons.put("-");
&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; buttons.put("Timestamp");&lt;/code&gt;&lt;/pre&gt;&lt;span style="color: #e83e8c"&gt;&lt;span style="font-family: SFMono-Regular, Menlo, Monaco, Consolas, &amp;quot;Liberation Mono&amp;quot;, &amp;quot;Courier New&amp;quot;, monospace"&gt;&lt;span style="font-size: 14px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Geert van der Ploeg</dc:creator>
    <dc:date>2020-08-24T08:02:54Z</dc:date>
  </entry>
  <entry>
    <title>RE: Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118590620" />
    <author>
      <name>Lee Jordan</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118590620</id>
    <updated>2020-02-25T20:08:49Z</updated>
    <published>2020-02-25T20:08:49Z</published>
    <summary type="html">Liferay should be taking and implementing feature requests for the editor development. I guarantee what you&amp;#39;re trying to do someone else is trying to do also and we should not have to customize such a core feature.</summary>
    <dc:creator>Lee Jordan</dc:creator>
    <dc:date>2020-02-25T20:08:49Z</dc:date>
  </entry>
  <entry>
    <title>RE: Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118588679" />
    <author>
      <name>Marcin Pawluk</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118588679</id>
    <updated>2020-02-25T19:10:47Z</updated>
    <published>2020-02-25T19:10:47Z</published>
    <summary type="html">@&lt;strong&gt;Vipul Khatavkar some time has passed, did you solve your problem? I have the same issue with Language plugin for CKEditor. It doesn&amp;#39;t want to work in Liferay 7.2.1 (button doesn&amp;#39;t appear), but when I do exactly same things in CKEditor out of Liferay it works perfectly.&lt;/strong&gt;</summary>
    <dc:creator>Marcin Pawluk</dc:creator>
    <dc:date>2020-02-25T19:10:47Z</dc:date>
  </entry>
  <entry>
    <title>RE: Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112749484" />
    <author>
      <name>Nader Jafari</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112749484</id>
    <updated>2019-03-14T10:49:37Z</updated>
    <published>2019-03-14T10:49:37Z</published>
    <summary type="html">Hi Vipul &lt;br /&gt;if you share a repository of this project in github, anyone can help you better.&lt;br /&gt;i was added some buttons in jira editor and i hope this could help you.</summary>
    <dc:creator>Nader Jafari</dc:creator>
    <dc:date>2019-03-14T10:49:37Z</dc:date>
  </entry>
  <entry>
    <title>RE: Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112744751" />
    <author>
      <name>Vipul Khatavkar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112744751</id>
    <updated>2019-03-14T09:55:27Z</updated>
    <published>2019-03-14T09:55:27Z</published>
    <summary type="html">No reply yet. Has anybody tried this?</summary>
    <dc:creator>Vipul Khatavkar</dc:creator>
    <dc:date>2019-03-14T09:55:27Z</dc:date>
  </entry>
  <entry>
    <title>Not able to add new button on ckeditor</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112404299" />
    <author>
      <name>Vipul Khatavkar</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112404299</id>
    <updated>2019-02-20T03:38:59Z</updated>
    <published>2019-02-20T03:38:59Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi,&lt;br&gt;&lt;br&gt;I am trying to add a new button on ckeditor in Liferay 7.1. I am following the &lt;a href="https://dev.liferay.com/en/develop/tutorials/-/knowledge_base/7-0/modifying-an-editors-configuration"&gt;article&lt;/a&gt;.&amp;nbsp; I am not getting any error, however the button is also not visible in toolbar.&lt;br&gt;&lt;br&gt;Attaching code snippet.&lt;br&gt;&lt;br&gt;If someone has implemented similar functionality in 7.1, please provide the steps that was followed in order to get it working.&lt;br&gt;&lt;br&gt;Thanks.&lt;br&gt;&lt;br&gt;Added&amp;nbsp;LiferaySnippetbrowser&amp;nbsp; class to extend&amp;nbsp;BaseEditorConfigContributor&amp;nbsp; and override&amp;nbsp;populateConfigJSONObject method as below:&lt;pre&gt;&lt;code&gt;@Component(
        property = {"editor.name=alloyeditor", "editor.name=ckeditor", 
                     "service.ranking:Integer=100"},
        service = EditorConfigContributor.class
)
public class LiferaySnippetbrowser extends BaseEditorConfigContributor {
    
    @Override
    public void populateConfigJSONObject(JSONObject jsonObject, Map&amp;lt;string, object&amp;gt; inputEditorTaglibAttributes,
            ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {
        
        JSONArray toolbars = jsonObject.getJSONArray("toolbar_tablet");
        if (toolbars != null) {
          
               JSONArray addButtons = JSONFactoryUtil.createJSONArray();
          
               addButtons.put("camera");
                          
                toolbars.put(addButtons);
                
                jsonObject.put("toolbar_tablet", toolbars);
        }else if(jsonObject.getJSONObject("toolbars") != null){
            JSONObject toolbar1 = jsonObject.getJSONObject("toolbars");
            if (toolbar1 != null) {
                JSONObject toolbarAdd = toolbar1.getJSONObject("add");

                if (toolbarAdd != null) {
                    JSONArray addButtons = toolbarAdd.getJSONArray("buttons");

                    addButtons.put("camera");
                   
                }
            }
        }
        else{
        
          JSONArray addButtons = JSONFactoryUtil.createJSONArray();
           addButtons.put("camera");
           
        jsonObject.put("liferay_add", addButtons);
        
        }
    }

}&amp;lt;/string,&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;And&amp;nbsp;&lt;br&gt;&lt;pre&gt;&lt;code&gt;@Component(immediate = true, service = DynamicInclude.class)
public class AlloyEditorMyButtonDynamicInclude extends BaseDynamicInclude {

        @Override
        public void include(
                        HttpServletRequest request, HttpServletResponse response,
                        String key)
                throws IOException {

                ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
                        WebKeys.THEME_DISPLAY);

                PrintWriter printWriter = response.getWriter();

                StringBundler sb = new StringBundler(7);

                sb.append("&amp;lt;script src="\&amp;amp;quot;&amp;amp;quot;);" sb.append(themedisplay.getportalurl()); sb.append(portalutil.getpathproxy()); sb.append(_servletcontext.getcontextpath()); sb.append(" js buttons.js"); sb.append("\" "); sb.append("type="\&amp;amp;quot;text/javascript\&amp;amp;quot;"&amp;gt;&amp;lt;/script&amp;gt;");

                printWriter.println(sb.toString());
        }

        @Override
        public void register(DynamicIncludeRegistry dynamicIncludeRegistry) {
                dynamicIncludeRegistry.register(
                        "com.liferay.frontend.editor.alloyeditor.web#ckeditor#" +
                                "additionalResources");
        }

        @Reference(
                target = "(osgi.web.symbolicname=com.liferay.frontend.editor.ckeditor.my.button.web)"
        )
        private ServletContext _servletContext;
}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;The same code works if I configure default WYSIWYG editor as alloyeditor.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Vipul Khatavkar</dc:creator>
    <dc:date>2019-02-20T03:38:59Z</dc:date>
  </entry>
</feed>
