Expand my Community achievements bar.

SOLVED

CQ5 enabling selective plugin features via API

Avatar

Level 1

Hi,

I'm enabling the RTE plugins using the API. So I enabled the EditToolsPlugin as below:

JSONObject editPlugin = new JSONObject(); editPlugin.put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED); editPlugin.put("features", "*"); rtePlugins.put("edit", editPlugin);

When I access the dialog I have all the edit functions/icons displayed. However I need to set the features to paste-plaintext as thats the only option I require from the plugin. I've tried change the feature code line to a number of combinations from String to String Arrays.

  1. editPlugin.put("features", "paste-plaintext");
  2. editPlugin.put("features", editPlugin.put("features", new String[]{"paste-plaintext"});
  3. private String[] features = {"paste-plaintext"};
    editPlugin.put("features", features);

None of these appear to work. The API for the plugin does say "You may provide a String value of "*" to enable all features of the respective plugin, or provide a String[] that contains the IDs of active features" .... so what does it mean for "active features" and is this relevant?

I've probably missed or not done something but any assistance to resolve this is appreciated

Thanks....Gary

1 Accepted Solution

Avatar

Correct answer by
Level 1

I have read that page on "Configuring the Rich Text Editor" and while more focuses on the non-API method does have the following section

Configuring the features Property

  • For this "plugin" node (i.e. named after the plugin) add the property features.

    There are two methods of configuring the property:

    • To activate all features for that plugin:
      • Name features
      • Type String 
      • Value * (asterisk)
    • To activate specific features (any not explicitly defined will be deactivated):
      • Name features
      • Type String[] (multi-string; set Type to String and click Multi in CRXDE Lite)
      • Value(s) set to one, or more, feature values

    CAUTION

     

     

    Even if you are only setting one specific value of features you do have to use String[].

    String is only valid when defining features as *.

    So I know that having a string with "*" works fine, but that when if you want to define one or more features it must be a String Array must be defining/coding that incorrectly. The question is how do I do that programmatically ?

    View solution in original post

    5 Replies

    Avatar

    Level 10

    If 5.6 please file daycare & ask for fix for CUI-438

    Avatar

    Correct answer by
    Level 1

    I have read that page on "Configuring the Rich Text Editor" and while more focuses on the non-API method does have the following section

    Configuring the features Property

    • For this "plugin" node (i.e. named after the plugin) add the property features.

      There are two methods of configuring the property:

      • To activate all features for that plugin:
        • Name features
        • Type String 
        • Value * (asterisk)
      • To activate specific features (any not explicitly defined will be deactivated):
        • Name features
        • Type String[] (multi-string; set Type to String and click Multi in CRXDE Lite)
        • Value(s) set to one, or more, feature values

      CAUTION

       

       

      Even if you are only setting one specific value of features you do have to use String[].

      String is only valid when defining features as *.

      So I know that having a string with "*" works fine, but that when if you want to define one or more features it must be a String Array must be defining/coding that incorrectly. The question is how do I do that programmatically ?

      Avatar

      Level 1

      I'm using CQ 5.3 unfortunately

      Avatar

      Level 1

      Finally!!.. I have it working now . I had to replace the line

      editPlugin.put("features", "*");

      with a JSONArray object for the features that I wanted (I tested with the "copy" and "paste" features as an example)
       

      JSONArray editPluginFeatures = new JSONArray(); editPluginFeatures.put("copy"); editPluginFeatures.put("cut"); editPlugin.put("features", editPluginFeatures);

      so the full example code for the "copy" & "paste" features is..

      JSONObject editPlugin = new JSONObject(); editPlugin.put(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED); editPlugin.put("defaultPasteMode", "plaintext"); JSONArray editPluginFeatures = new JSONArray(); editPluginFeatures.put("copy"); editPluginFeatures.put("cut"); editPlugin.put("features", editPluginFeatures); rtePlugins.put("edit", editPlugin);

       

      I can now start to apply all the features and others options as I need. Thanks to everyone for their feedback smiley